From f4e22eb44bfae0c2a3b6570f19480c8c3535d808 Mon Sep 17 00:00:00 2001 From: Bobby Georgescu Date: Tue, 2 Oct 2012 18:34:08 -0700 Subject: [PATCH] Correct behavior when swiping to placeholder item in PhotoPage Bug: 7261641 Change-Id: I54deed0f20a4673cb5470ffc128c73cddc071772 --- src/com/android/gallery3d/app/PhotoPage.java | 21 +++++++++++++++------ src/com/android/gallery3d/ui/PhotoView.java | 14 ++++++-------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 6d05df167..3c64fa32b 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -92,6 +92,7 @@ public class PhotoPage extends ActivityState implements private static final int MSG_WANT_BARS = 7; private static final int MSG_REFRESH_BOTTOM_CONTROLS = 8; private static final int MSG_ON_CAMERA_CENTER = 9; + private static final int MSG_ON_PICTURE_CENTER = 10; private static final int HIDE_BARS_TIMEOUT = 3500; private static final int UNFREEZE_GLROOT_TIMEOUT = 250; @@ -311,6 +312,13 @@ public class PhotoPage extends ActivityState implements } break; } + case MSG_ON_PICTURE_CENTER: { + if (mCurrentPhoto != null + && (mCurrentPhoto.getSupportedOperations() & MediaObject.SUPPORT_ACTION) != 0) { + mPhotoView.setFilmMode(true); + } + break; + } default: throw new AssertionError(message.what); } } @@ -417,9 +425,7 @@ public class PhotoPage extends ActivityState implements mCurrentIndex = index; if (mAppBridge != null) { - mPhotoView.setWantCameraCenterCallbacks(true); if (mCurrentIndex > 0) { - mHandler.removeMessages(MSG_ON_CAMERA_CENTER); mSkipUpdateCurrentPhoto = false; } @@ -431,6 +437,7 @@ public class PhotoPage extends ActivityState implements CAMERA_SWITCH_CUTOFF_THRESHOLD_MS; mPhotoView.stopScrolling(); } else if (oldIndex == 1 && mCurrentIndex == 0) { + mPhotoView.setWantPictureCenterCallbacks(true); mSkipUpdateCurrentPhoto = true; } } @@ -483,9 +490,11 @@ public class PhotoPage extends ActivityState implements } } - public void onCameraCenter() { - mPhotoView.setWantCameraCenterCallbacks(false); - mHandler.sendEmptyMessage(MSG_ON_CAMERA_CENTER); + public void onPictureCenter(boolean isCamera) { + mPhotoView.setWantPictureCenterCallbacks(false); + mHandler.removeMessages(MSG_ON_CAMERA_CENTER); + mHandler.removeMessages(MSG_ON_PICTURE_CENTER); + mHandler.sendEmptyMessage(isCamera ? MSG_ON_CAMERA_CENTER : MSG_ON_PICTURE_CENTER); } public boolean canDisplayBottomControls() { @@ -598,7 +607,7 @@ public class PhotoPage extends ActivityState implements // more clear if ((photo.getSupportedOperations() & MediaObject.SUPPORT_ACTION) != 0 && !mPhotoView.getFilmMode()) { - mPhotoView.setFilmMode(true); + mPhotoView.setWantPictureCenterCallbacks(true); } updateMenuOperations(); diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java index 303d302d2..8c9c6d757 100644 --- a/src/com/android/gallery3d/ui/PhotoView.java +++ b/src/com/android/gallery3d/ui/PhotoView.java @@ -125,7 +125,7 @@ public class PhotoView extends GLView { public void onUndoDeleteImage(); public void onCommitDeleteImage(); public void onFilmModeChanged(boolean enabled); - public void onCameraCenter(); + public void onPictureCenter(boolean isCamera); } // The rules about orientation locking: @@ -199,7 +199,7 @@ public class PhotoView extends GLView { private boolean mCancelExtraScalingPending; private boolean mFilmMode = false; - private boolean mWantCameraCenterCallbacks = false; + private boolean mWantPictureCenterCallbacks = false; private int mDisplayRotation = 0; private int mCompensation = 0; private boolean mFullScreenCamera; @@ -383,8 +383,8 @@ public class PhotoView extends GLView { } } - public void setWantCameraCenterCallbacks(boolean wanted) { - mWantCameraCenterCallbacks = wanted; + public void setWantPictureCenterCallbacks(boolean wanted) { + mWantPictureCenterCallbacks = wanted; } //////////////////////////////////////////////////////////////////////////// @@ -629,10 +629,8 @@ public class PhotoView extends GLView { // Holdings except touch-down prevent the transitions. if ((mHolding & ~HOLD_TOUCH_DOWN) != 0) return; - boolean isCameraCenter = mIsCamera && mPositionController.isCenter() && !canUndoLastPicture(); - - if (isCameraCenter && mWantCameraCenterCallbacks) { - mListener.onCameraCenter(); + if (mWantPictureCenterCallbacks && mPositionController.isCenter()) { + mListener.onPictureCenter(mIsCamera && !canUndoLastPicture()); } } -- 2.11.0