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();
}
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();
}
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();
}
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();
}
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);
}
}
Aggregations