From 4dbacef51b9aed14cfa34a8a72ec4fe07684dc9e Mon Sep 17 00:00:00 2001 From: Chao Zhang Date: Wed, 20 Apr 2016 11:08:03 +0800 Subject: Gallery2: fix some abnormal of comparison button in photo editor. 1. don't call backToMain() when press comparison button. 2. don't call updateCategories() when press comparison button. 3. fix comparison button disappeared when exit Crop editor. 4. hide comparison button in Straighten editor. Change-Id: Ib5d2a9df59d2e1c5ed0d0764dc7520c1ed518207 CRs-Fixed: 1005753 --- .../android/gallery3d/filtershow/FilterShowActivity.java | 14 +++++++++----- .../gallery3d/filtershow/imageshow/ImageStraighten.java | 1 + .../gallery3d/filtershow/imageshow/MasterImage.java | 16 ++++++++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 39dfbd42e..a5b58f2b1 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -404,9 +404,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL HistoryManager adapter = mMasterImage.getHistory(); int position = adapter.backToOriginal();// adapter.undo(); - mMasterImage.onHistoryItemClick(position); + mMasterImage.onHistoryItemClick(position, false); v.setPressed(true); - backToMain(); invalidateViews(); } if (action == MotionEvent.ACTION_UP @@ -415,7 +414,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL v.setPressed(false); HistoryManager adapter = mMasterImage.getHistory(); int position = adapter.backToCurrent(); - mMasterImage.onHistoryItemClick(position); + mMasterImage.onHistoryItemClick(position, false); invalidateViews(); } @@ -1654,13 +1653,18 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } loadMainPanel(); showDefaultImageView(); + showComparisonButton(); } - @Override - public void onBackPressed() { + private void showComparisonButton() { if (imgComparison != null && imgComparison.getVisibility() == View.GONE) { imgComparison.setVisibility(View.VISIBLE); } + } + + @Override + public void onBackPressed() { + showComparisonButton(); Fragment currentPanel = getSupportFragmentManager().findFragmentByTag( MainPanel.FRAGMENT_TAG); diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java b/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java index 829af18eb..cec45f15f 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageStraighten.java @@ -249,6 +249,7 @@ public class ImageStraighten extends ImageShow { MasterImage.getImage().invalidateFiltersOnly(); return; } + toggleComparisonButtonVisibility(); GeometryMathUtils.initializeHolder(mDrawHolder, mLocalRep); mDrawHolder.straighten = mAngle; int imageWidth = image.getWidth(); diff --git a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java index c1c9d693d..b2aae85a6 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java +++ b/src/com/android/gallery3d/filtershow/imageshow/MasterImage.java @@ -334,6 +334,12 @@ public class MasterImage implements RenderingRequestCaller { public synchronized void setPreset(ImagePreset preset, FilterRepresentation change, boolean addToHistory) { + setPreset(preset, change, addToHistory, true); + } + + public synchronized void setPreset(ImagePreset preset, + FilterRepresentation change, + boolean addToHistory, boolean updateCategory) { if (DEBUG) { preset.showFilters(); } @@ -345,10 +351,16 @@ public class MasterImage implements RenderingRequestCaller { } updatePresets(true); resetGeometryImages(false); - mActivity.updateCategories(); + if (updateCategory) { + mActivity.updateCategories(); + } } public void onHistoryItemClick(int position) { + onHistoryItemClick(position, true); + } + + public void onHistoryItemClick(int position, boolean updateCategory) { HistoryItem historyItem = mHistory.getItem(position); // We need a copy from the history if (historyItem == null) { @@ -356,7 +368,7 @@ public class MasterImage implements RenderingRequestCaller { } ImagePreset newPreset = new ImagePreset(historyItem.getImagePreset()); // don't need to add it to the history - setPreset(newPreset, historyItem.getFilterRepresentation(), false); + setPreset(newPreset, historyItem.getFilterRepresentation(), false, updateCategory); mHistory.setCurrentPreset(position); } -- cgit v1.2.3