summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2013-06-24 13:54:04 -0700
committerztenghui <ztenghui@google.com>2013-06-27 14:49:06 -0700
commitd9347c858cfb20256dababe51806a38e71651103 (patch)
tree19bbd693692e5606fca204a6612425f07e925bec /src
parentc75824ac1422e011cb001abc25560aba97d56254 (diff)
downloadandroid_packages_apps_Snap-d9347c858cfb20256dababe51806a38e71651103.tar.gz
android_packages_apps_Snap-d9347c858cfb20256dababe51806a38e71651103.tar.bz2
android_packages_apps_Snap-d9347c858cfb20256dababe51806a38e71651103.zip
Save button now behaves correctly for filter changes.
Basically, save the original filter from the file's XMP. Compare the current filter against original one to decide whether or not the file has been modified and needed to be saved. At the same time, make sure we don't save "None" filter in the ImagePreset. bug:9468909 Change-Id: I5b86ab95556b6b010367c9577b02c0bb42ffb824
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java4
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java51
2 files changed, 31 insertions, 24 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index 096bedac9..c046a6e7f 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -82,7 +82,9 @@ public class FilterRepresentation implements Cloneable {
if (representation.mFilterClass == mFilterClass
&& representation.mName.equalsIgnoreCase(mName)
&& representation.mPriority == mPriority
- && representation.mSupportsPartialRendering == mSupportsPartialRendering
+ // TODO: After we enable partial rendering, we can switch back
+ // to use member variable here.
+ && representation.supportsPartialRendering() == supportsPartialRendering()
&& representation.mTextId == mTextId
&& representation.mEditorId == mEditorId
&& representation.mButtonId == mButtonId
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index 808288f89..2276ee71c 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -18,20 +18,19 @@ package com.android.gallery3d.filtershow.presets;
import android.graphics.Bitmap;
import android.graphics.Rect;
-import android.net.Uri;
import android.support.v8.renderscript.Allocation;
import android.util.JsonReader;
import android.util.JsonWriter;
import android.util.Log;
-import com.adobe.xmp.XMPException;
-import com.adobe.xmp.XMPMeta;
-import com.adobe.xmp.options.PropertyOptions;
+import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.cache.CachingPipeline;
import com.android.gallery3d.filtershow.cache.ImageLoader;
import com.android.gallery3d.filtershow.filters.BaseFiltersManager;
-import com.android.gallery3d.filtershow.filters.FiltersManager;
+import com.android.gallery3d.filtershow.filters.FilterFxRepresentation;
+import com.android.gallery3d.filtershow.filters.FilterImageBorderRepresentation;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
+import com.android.gallery3d.filtershow.filters.FiltersManager;
import com.android.gallery3d.filtershow.filters.ImageFilter;
import com.android.gallery3d.filtershow.imageshow.GeometryMetadata;
import com.android.gallery3d.filtershow.imageshow.MasterImage;
@@ -53,6 +52,8 @@ public class ImagePreset {
private Vector<FilterRepresentation> mFilters = new Vector<FilterRepresentation>();
+ protected boolean mIsFxPreset = false;
+
private boolean mDoApplyGeometry = true;
private boolean mDoApplyFilters = true;
@@ -185,21 +186,6 @@ public class ImagePreset {
return geo;
}
- public boolean hasModifications() {
- for (int i = 0; i < mFilters.size(); i++) {
- FilterRepresentation filter = mFilters.elementAt(i);
- if (filter instanceof GeometryMetadata) {
- if (((GeometryMetadata) filter).hasModifications()) {
- return true;
- }
- }
- if (!filter.isNil() && !filter.getName().equalsIgnoreCase("none")) {
- return true;
- }
- }
- return false;
- }
-
public boolean isPanoramaSafe() {
for (FilterRepresentation representation : mFilters) {
if (representation instanceof GeometryMetadata) {
@@ -353,14 +339,19 @@ public class ImagePreset {
}
}
+ // If the filter is an "None" effect or border, then just don't add this
+ // filter.
public void addFilter(FilterRepresentation representation) {
if (representation instanceof GeometryMetadata) {
setGeometry((GeometryMetadata) representation);
return;
}
+
if (representation.getFilterType() == FilterRepresentation.TYPE_BORDER) {
removeFilter(representation);
- mFilters.add(representation);
+ if (!isNoneBorderFilter(representation)) {
+ mFilters.add(representation);
+ }
} else if (representation.getFilterType() == FilterRepresentation.TYPE_FX) {
boolean found = false;
for (int i = 0; i < mFilters.size(); i++) {
@@ -373,18 +364,32 @@ public class ImagePreset {
}
if (type == FilterRepresentation.TYPE_FX) {
mFilters.remove(i);
- mFilters.add(i, representation);
+ if (!isNoneFxFilter(representation)) {
+ mFilters.add(i, representation);
+ }
found = true;
}
}
if (!found) {
- mFilters.add(representation);
+ if (!isNoneFxFilter(representation)) {
+ mFilters.add(representation);
+ }
}
} else {
mFilters.add(representation);
}
}
+ private boolean isNoneBorderFilter(FilterRepresentation representation) {
+ return representation instanceof FilterImageBorderRepresentation &&
+ ((FilterImageBorderRepresentation) representation).getDrawableResource() == 0;
+ }
+
+ private boolean isNoneFxFilter(FilterRepresentation representation) {
+ return representation instanceof FilterFxRepresentation &&
+ ((FilterFxRepresentation)representation).getNameResource() == R.string.none;
+ }
+
public FilterRepresentation getRepresentation(FilterRepresentation filterRepresentation) {
for (int i = 0; i < mFilters.size(); i++) {
FilterRepresentation representation = mFilters.elementAt(i);