summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d
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
commitdfaf4c5b5b901dbbd4904fd86995b71f4acfd47c (patch)
treeb23941db9af10ed2cb7091df68e0e5eaa631bc1b /src/com/android/gallery3d
parent83b16cf2b02773370e00d3659e201efff20d788d (diff)
downloadandroid_packages_apps_Snap-dfaf4c5b5b901dbbd4904fd86995b71f4acfd47c.tar.gz
android_packages_apps_Snap-dfaf4c5b5b901dbbd4904fd86995b71f4acfd47c.tar.bz2
android_packages_apps_Snap-dfaf4c5b5b901dbbd4904fd86995b71f4acfd47c.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/com/android/gallery3d')
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java11
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterRepresentation.java4
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java9
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/MasterImage.java29
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePreset.java51
5 files changed, 65 insertions, 39 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index 89565711f..cab1af360 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -36,8 +36,8 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.util.DisplayMetrics;
-import android.util.TypedValue;
import android.util.Log;
+import android.util.TypedValue;
import android.view.Display;
import android.view.Menu;
import android.view.MenuItem;
@@ -450,10 +450,12 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
copy.addFilter(filterRepresentation);
} else {
if (filterRepresentation.allowsSingleInstanceOnly()) {
- representation.updateTempParametersFrom(filterRepresentation);
- representation.synchronizeRepresentation();
+ // Don't just update the filter representation. Centralize the
+ // logic in the addFilter(), such that we can keep "None" as
+ // null.
+ copy.removeFilter(representation);
+ copy.addFilter(filterRepresentation);
}
- filterRepresentation = representation;
}
MasterImage.getImage().setPreset(copy, filterRepresentation, true);
MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation);
@@ -565,6 +567,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
mLoadBitmapTask = null;
if (mOriginalPreset != null) {
+ MasterImage.getImage().setLoadedPreset(mOriginalPreset);
MasterImage.getImage().setPreset(mOriginalPreset,
mOriginalPreset.getLastRepresentation(), true);
mOriginalPreset = null;
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/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 13f18dc45..63de9ccbd 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -99,10 +99,7 @@ public class ImageShow extends View implements OnGestureListener,
}
public boolean hasModifications() {
- if (getImagePreset() == null) {
- return false;
- }
- return getImagePreset().hasModifications();
+ return MasterImage.getImage().hasModifications();
}
public void resetParameter() {
@@ -321,9 +318,9 @@ public class ImageShow extends View implements OnGestureListener,
int py = 0;
if (mShowOriginalDirection == UNVEIL_VERTICAL) {
px = mImageBounds.width();
- py = (int) (mTouch.y - mImageBounds.top);
+ py = mTouch.y - mImageBounds.top;
} else {
- px = (int) (mTouch.x - mImageBounds.left);
+ px = mTouch.x - mImageBounds.left;
py = mImageBounds.height();
if (showsOriginal) {
px = mImageBounds.width();
diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
index 3dc8302df..53e38f4d9 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java
@@ -16,15 +16,22 @@
package com.android.gallery3d.filtershow.imageshow;
-import android.graphics.*;
+import android.graphics.Bitmap;
+import android.graphics.Matrix;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.graphics.RectF;
import android.os.Handler;
import android.os.Message;
-import android.util.Log;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.history.HistoryAdapter;
import com.android.gallery3d.filtershow.history.HistoryItem;
-import com.android.gallery3d.filtershow.cache.*;
+import com.android.gallery3d.filtershow.cache.FilteringPipeline;
+import com.android.gallery3d.filtershow.cache.ImageLoader;
+import com.android.gallery3d.filtershow.cache.RenderingRequest;
+import com.android.gallery3d.filtershow.cache.RenderingRequestCaller;
+import com.android.gallery3d.filtershow.cache.TripleBufferBitmap;
import com.android.gallery3d.filtershow.filters.FilterRepresentation;
import com.android.gallery3d.filtershow.filters.ImageFilter;
import com.android.gallery3d.filtershow.presets.ImagePreset;
@@ -45,6 +52,7 @@ public class MasterImage implements RenderingRequestCaller {
private ImageFilter mCurrentFilter = null;
private ImagePreset mPreset = null;
+ private ImagePreset mLoadedPreset = null;
private ImagePreset mGeometryOnlyPreset = null;
private ImagePreset mFiltersOnlyPreset = null;
@@ -224,9 +232,12 @@ public class MasterImage implements RenderingRequestCaller {
public synchronized boolean hasModifications() {
if (mPreset == null) {
- return false;
+ return getLoadedPreset() != null;
+ } else {
+ // TODO: same() is quite strict check here. We should be only
+ // checking for functionality parity.
+ return !mPreset.same(getLoadedPreset());
}
- return mPreset.hasModifications();
}
public TripleBufferBitmap getDoubleBuffer() {
@@ -512,4 +523,12 @@ public class MasterImage implements RenderingRequestCaller {
public boolean showsOriginal() {
return mShowsOriginal;
}
+
+ public void setLoadedPreset(ImagePreset preset) {
+ mLoadedPreset = preset;
+ }
+
+ public ImagePreset getLoadedPreset() {
+ return mLoadedPreset;
+ }
}
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);