summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2013-06-28 09:25:23 -0700
committerztenghui <ztenghui@google.com>2013-07-01 15:45:12 -0700
commit2185e9b81380f7e43608419743c983c5afee43c4 (patch)
tree5986f546bfced1a6cca39693b9beffaf82a38865
parent59e60d36233f4acd67c4542bf849a0bcfce54adc (diff)
downloadandroid_packages_apps_Snap-2185e9b81380f7e43608419743c983c5afee43c4.zip
android_packages_apps_Snap-2185e9b81380f7e43608419743c983c5afee43c4.tar.gz
android_packages_apps_Snap-2185e9b81380f7e43608419743c983c5afee43c4.tar.bz2
Fix the save button issue.
When dealing with non Fx filters, the hasModification() really need to go deep to figure out whether things has changed. bug:9468909 Change-Id: I89495f147f7af7c35490def84805aae98e3f917f
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java3
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java3
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java1
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java28
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java14
5 files changed, 42 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index f87df71..8302893 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -812,8 +812,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
public void enableSave(boolean enable) {
- if (mSaveButton != null)
+ if (mSaveButton != null) {
mSaveButton.setEnabled(enable);
+ }
}
private void fillFx() {
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
index c046a6e..a60410d 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java
@@ -174,6 +174,9 @@ public class FilterRepresentation implements Cloneable {
mFilterClass = filterClass;
}
+ // This same() function is different from equals(), basically it checks
+ // whether 2 FilterRepresentations are the same type. It doesn't care about
+ // the values.
public boolean same(FilterRepresentation b) {
if (b == null) {
return false;
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 63de9cc..a95932d 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -108,7 +108,6 @@ public class ImageShow extends View implements OnGestureListener,
public void onNewValue(int parameter) {
invalidate();
- mActivity.enableSave(hasModifications());
}
public ImageShow(Context context, AttributeSet attrs, int defStyle) {
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index 56c4a62..44b9d82 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -231,12 +231,22 @@ public class MasterImage implements RenderingRequestCaller {
}
public synchronized boolean hasModifications() {
+ // TODO: We need to have a better same effects check to see if two
+ // presets are functionally the same. Right now, we are relying on a
+ // stricter check as equals().
+ ImagePreset loadedPreset = getLoadedPreset();
if (mPreset == null) {
- return getLoadedPreset() != null;
+ if (loadedPreset == null) {
+ return false;
+ } else {
+ return loadedPreset.hasModifications();
+ }
} else {
- // TODO: same() is quite strict check here. We should be only
- // checking for functionality parity.
- return !mPreset.same(getLoadedPreset());
+ if (loadedPreset == null) {
+ return mPreset.hasModifications();
+ } else {
+ return !mPreset.equals(getLoadedPreset());
+ }
}
}
@@ -304,7 +314,6 @@ public class MasterImage implements RenderingRequestCaller {
}
}
invalidatePreview();
- mActivity.enableSave(hasModifications());
}
public FilterRepresentation getCurrentFilterRepresentation() {
@@ -404,20 +413,29 @@ public class MasterImage implements RenderingRequestCaller {
if (request.getBitmap() == null) {
return;
}
+
+ boolean needsCheckModification = false;
if (request.getType() == RenderingRequest.GEOMETRY_RENDERING) {
mGeometryOnlyBitmap = request.getBitmap();
+ needsCheckModification = true;
}
if (request.getType() == RenderingRequest.FILTERS_RENDERING) {
mFiltersOnlyBitmap = request.getBitmap();
+ needsCheckModification = true;
}
if (request.getType() == RenderingRequest.PARTIAL_RENDERING
&& request.getScaleFactor() == getScaleFactor()) {
mPartialBitmap = request.getBitmap();
notifyObservers();
+ needsCheckModification = true;
}
if (request.getType() == RenderingRequest.HIGHRES_RENDERING) {
mHighresBitmap = request.getBitmap();
notifyObservers();
+ needsCheckModification = true;
+ }
+ if (needsCheckModification) {
+ mActivity.enableSave(hasModifications());
}
}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
index 2276ee7..5a0100d 100644
--- a/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
+++ b/src/com/android/gallery3d/filtershow/presets/ImagePreset.java
@@ -186,6 +186,20 @@ 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;
+ }
+ } else if (!filter.isNil()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public boolean isPanoramaSafe() {
for (FilterRepresentation representation : mFilters) {
if (representation instanceof GeometryMetadata) {