Search in sources :

Example 1 with TemplateRemoveModifier

use of fr.free.nrw.commons.modifications.TemplateRemoveModifier in project apps-android-commons by commons-app.

the class MultipleShareActivity method onCategoriesSave.

@Override
public void onCategoriesSave(ArrayList<String> categories) {
    if (categories.size() > 0) {
        ContentProviderClient client = getContentResolver().acquireContentProviderClient(ModificationsContentProvider.AUTHORITY);
        for (Contribution contribution : photosList) {
            ModifierSequence categoriesSequence = new ModifierSequence(contribution.getContentUri());
            categoriesSequence.queueModifier(new CategoryModifier(categories.toArray(new String[] {})));
            categoriesSequence.queueModifier(new TemplateRemoveModifier("Uncategorized"));
            categoriesSequence.setContentProviderClient(client);
            categoriesSequence.save();
        }
    }
    // FIXME: Make sure that the content provider is up
    // This is the wrong place for it, but bleh - better than not having it turned on by default for people who don't go throughl ogin
    // Enable sync by default!
    ContentResolver.setSyncAutomatically(app.getCurrentAccount(), ModificationsContentProvider.AUTHORITY, true);
    EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT).param("username", app.getCurrentAccount().name).param("categories-count", categories.size()).param("files-count", photosList.size()).param("source", Contribution.SOURCE_EXTERNAL).param("result", "queued").log();
    finish();
}
Also used : TemplateRemoveModifier(fr.free.nrw.commons.modifications.TemplateRemoveModifier) ContentProviderClient(android.content.ContentProviderClient) Contribution(fr.free.nrw.commons.contributions.Contribution) ModifierSequence(fr.free.nrw.commons.modifications.ModifierSequence) CategoryModifier(fr.free.nrw.commons.modifications.CategoryModifier)

Example 2 with TemplateRemoveModifier

use of fr.free.nrw.commons.modifications.TemplateRemoveModifier in project apps-android-commons by commons-app.

the class ShareActivity method onCategoriesSave.

@Override
public void onCategoriesSave(ArrayList<String> categories) {
    if (categories.size() > 0) {
        ModifierSequence categoriesSequence = new ModifierSequence(contribution.getContentUri());
        categoriesSequence.queueModifier(new CategoryModifier(categories.toArray(new String[] {})));
        categoriesSequence.queueModifier(new TemplateRemoveModifier("Uncategorized"));
        categoriesSequence.setContentProviderClient(getContentResolver().acquireContentProviderClient(ModificationsContentProvider.AUTHORITY));
        categoriesSequence.save();
    }
    // FIXME: Make sure that the content provider is up
    // This is the wrong place for it, but bleh - better than not having it turned on by default for people who don't go throughl ogin
    // Enable sync by default!
    ContentResolver.setSyncAutomatically(app.getCurrentAccount(), ModificationsContentProvider.AUTHORITY, true);
    EventLog.schema(CommonsApplication.EVENT_CATEGORIZATION_ATTEMPT).param("username", app.getCurrentAccount().name).param("categories-count", categories.size()).param("files-count", 1).param("source", contribution.getSource()).param("result", "queued").log();
    finish();
}
Also used : TemplateRemoveModifier(fr.free.nrw.commons.modifications.TemplateRemoveModifier) ModifierSequence(fr.free.nrw.commons.modifications.ModifierSequence) CategoryModifier(fr.free.nrw.commons.modifications.CategoryModifier)

Aggregations

CategoryModifier (fr.free.nrw.commons.modifications.CategoryModifier)2 ModifierSequence (fr.free.nrw.commons.modifications.ModifierSequence)2 TemplateRemoveModifier (fr.free.nrw.commons.modifications.TemplateRemoveModifier)2 ContentProviderClient (android.content.ContentProviderClient)1 Contribution (fr.free.nrw.commons.contributions.Contribution)1