Search in sources :

Example 1 with FilterUserPresetRepresentation

use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method updateUserPresetsFromAdapter.

public void updateUserPresetsFromAdapter(UserPresetsAdapter adapter) {
    ArrayList<FilterUserPresetRepresentation> representations = adapter.getDeletedRepresentations();
    for (FilterUserPresetRepresentation representation : representations) {
        deletePreset(representation.getId());
    }
    ArrayList<FilterUserPresetRepresentation> changedRepresentations = adapter.getChangedRepresentations();
    for (FilterUserPresetRepresentation representation : changedRepresentations) {
        updatePreset(representation);
    }
    adapter.clearDeletedRepresentations();
    adapter.clearChangedRepresentations();
    loadUserPresets();
}
Also used : FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 2 with FilterUserPresetRepresentation

use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method removeLook.

public void removeLook(Action action) {
    FilterUserPresetRepresentation rep = (FilterUserPresetRepresentation) action.getRepresentation();
    if (rep == null) {
        return;
    }
    mUserPresetsManager.delete(rep.getId());
    updateUserPresetsFromManager();
}
Also used : FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 3 with FilterUserPresetRepresentation

use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method addCurrentVersion.

public void addCurrentVersion() {
    ImagePreset current = new ImagePreset(MasterImage.getImage().getPreset());
    mVersionsCounter++;
    FilterUserPresetRepresentation rep = new FilterUserPresetRepresentation("" + mVersionsCounter, current, -1);
    mVersions.add(rep);
    updateVersions();
}
Also used : ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 4 with FilterUserPresetRepresentation

use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method updateVersions.

public void updateVersions() {
    mCategoryVersionsAdapter.clear();
    FilterUserPresetRepresentation originalRep = new FilterUserPresetRepresentation(getString(R.string.filtershow_version_original), new ImagePreset(), -1);
    mCategoryVersionsAdapter.add(new Action(this, originalRep, Action.FULL_VIEW));
    ImagePreset current = new ImagePreset(MasterImage.getImage().getPreset());
    FilterUserPresetRepresentation currentRep = new FilterUserPresetRepresentation(getString(R.string.filtershow_version_current), current, -1);
    mCategoryVersionsAdapter.add(new Action(this, currentRep, Action.FULL_VIEW));
    if (mVersions.size() > 0) {
        mCategoryVersionsAdapter.add(new Action(this, Action.SPACER));
    }
    for (FilterUserPresetRepresentation rep : mVersions) {
        mCategoryVersionsAdapter.add(new Action(this, rep, Action.FULL_VIEW, true));
    }
    mCategoryVersionsAdapter.notifyDataSetInvalidated();
}
Also used : Action(com.android.gallery3d.filtershow.category.Action) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Example 5 with FilterUserPresetRepresentation

use of com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation in project android_packages_apps_Gallery2 by LineageOS.

the class ImagePreset method addFilter.

// If the filter is an "None" effect or border, then just don't add this filter.
public void addFilter(FilterRepresentation representation) {
    if (representation instanceof FilterUserPresetRepresentation) {
        ImagePreset preset = ((FilterUserPresetRepresentation) representation).getImagePreset();
        if (preset.nbFilters() == 1 && preset.contains(FilterRepresentation.TYPE_FX)) {
            FilterRepresentation rep = preset.getFilterRepresentationForType(FilterRepresentation.TYPE_FX);
            addFilter(rep);
        } else {
            // user preset replaces everything
            mFilters.clear();
            for (int i = 0; i < preset.nbFilters(); i++) {
                addFilter(preset.getFilterRepresentation(i));
            }
        }
    } else if (representation.getFilterType() == FilterRepresentation.TYPE_GEOMETRY) {
        // Add geometry filter, removing duplicates and do-nothing operations.
        for (int i = 0; i < mFilters.size(); i++) {
            if (sameSerializationName(representation, mFilters.elementAt(i))) {
                mFilters.remove(i);
            }
        }
        int index = 0;
        for (; index < mFilters.size(); index++) {
            FilterRepresentation rep = mFilters.elementAt(index);
            if (rep.getFilterType() != FilterRepresentation.TYPE_GEOMETRY) {
                break;
            }
        }
        if (!representation.isNil()) {
            mFilters.insertElementAt(representation, index);
        }
    } else if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
        removeFilter(representation);
        if (!isNoneBorderFilter(representation)) {
            mFilters.add(representation);
        }
    } else if (representation.getFilterType() == FilterRepresentation.TYPE_DUALCAM) {
        removeFilter(representation);
        if (!isNoneDualCamFilter(representation)) {
            mFilters.add(representation);
        }
    } else if (representation.getFilterType() == FilterRepresentation.TYPE_TRUEPORTRAIT) {
        removeFilter(representation);
        if (!isNoneTruePortraitFilter(representation)) {
            mFilters.add(representation);
        }
    } else if (representation.getFilterType() == FilterRepresentation.TYPE_FX) {
        boolean replaced = false;
        for (int i = 0; i < mFilters.size(); i++) {
            FilterRepresentation current = mFilters.elementAt(i);
            if (current.getFilterType() == FilterRepresentation.TYPE_FX || (current.getFilterType() == FilterRepresentation.TYPE_PRESETFILTER)) {
                mFilters.remove(i);
                replaced = true;
                if (!isNoneFxFilter(representation)) {
                    mFilters.add(i, representation);
                }
                break;
            }
        }
        if (!replaced && !isNoneFxFilter(representation)) {
            mFilters.add(representation);
        }
    } else if (representation.getFilterType() == FilterRepresentation.TYPE_PRESETFILTER) {
        boolean replaced = false;
        for (int i = 0; i < mFilters.size(); i++) {
            FilterRepresentation current = mFilters.elementAt(i);
            if ((current.getFilterType() == FilterRepresentation.TYPE_PRESETFILTER) || (current.getFilterType() == FilterRepresentation.TYPE_FX)) {
                mFilters.remove(i);
                replaced = true;
                if (!isNonePresetFilter(representation)) {
                    mFilters.add(i, representation);
                }
                break;
            }
        }
        if (!replaced && !isNonePresetFilter(representation)) {
            mFilters.add(representation);
        }
    } else if (representation.getFilterType() == FilterRepresentation.TYPE_WATERMARK) {
        boolean replaced = false;
        for (int i = 0; i < mFilters.size(); i++) {
            FilterRepresentation current = mFilters.elementAt(i);
            if (current.getFilterType() == FilterRepresentation.TYPE_WATERMARK) {
                mFilters.remove(i);
                replaced = true;
                mFilters.add(i, representation);
                break;
            }
        }
        if (!replaced) {
            mFilters.add(representation);
        }
    } else {
        mFilters.add(representation);
    }
    // Enforces Filter type ordering for borders and dual cam
    FilterRepresentation border = null;
    FilterRepresentation dualcam = null;
    FilterRepresentation trueportrait = null;
    for (int i = 0; i < mFilters.size(); ) {
        FilterRepresentation rep = mFilters.elementAt(i);
        if (rep.getFilterType() == FilterRepresentation.TYPE_BORDER) {
            border = rep;
            mFilters.remove(i);
            continue;
        } else if (rep.getFilterType() == FilterRepresentation.TYPE_DUALCAM) {
            dualcam = rep;
            mFilters.remove(i);
            continue;
        } else if (rep.getFilterType() == FilterRepresentation.TYPE_TRUEPORTRAIT) {
            trueportrait = rep;
            mFilters.remove(i);
            continue;
        }
        i++;
    }
    if (border != null) {
        mFilters.add(border);
    }
    if (dualcam != null) {
        int i = 0;
        for (; i < mFilters.size(); i++) {
            FilterRepresentation rep = mFilters.elementAt(i);
            if (rep.getFilterType() != FilterRepresentation.TYPE_GEOMETRY) {
                break;
            }
        }
        mFilters.add(i, dualcam);
    }
    if (trueportrait != null) {
        int i = 0;
        for (; i < mFilters.size(); i++) {
            FilterRepresentation rep = mFilters.elementAt(i);
            if (rep.getFilterType() != FilterRepresentation.TYPE_GEOMETRY) {
                break;
            }
        }
        mFilters.add(i, trueportrait);
    }
}
Also used : FilterRepresentation(com.android.gallery3d.filtershow.filters.FilterRepresentation) FilterUserPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)

Aggregations

FilterUserPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation)14 FilterRepresentation (com.android.gallery3d.filtershow.filters.FilterRepresentation)6 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)4 Action (com.android.gallery3d.filtershow.category.Action)2 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 Point (android.graphics.Point)1 Message (android.os.Message)1 FilterMirrorRepresentation (com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation)1 FilterRotateRepresentation (com.android.gallery3d.filtershow.filters.FilterRotateRepresentation)1 ImageFilter (com.android.gallery3d.filtershow.filters.ImageFilter)1 State (com.android.gallery3d.filtershow.state.State)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1