summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2012-09-28 15:49:27 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-28 15:49:28 -0700
commit66b4e60be3cb2d5e6f0770f2d3690fc7ad7527e5 (patch)
treefb9e26ae7f75cfb478f703f024286aa57514bf26
parent9055cd7d1fecd9b73d1907cac9bc234cb8021894 (diff)
parentc6d34735efceb8d4fa041d46fe13f63c8e3223e5 (diff)
downloadandroid_packages_apps_Snap-66b4e60be3cb2d5e6f0770f2d3690fc7ad7527e5.tar.gz
android_packages_apps_Snap-66b4e60be3cb2d5e6f0770f2d3690fc7ad7527e5.tar.bz2
android_packages_apps_Snap-66b4e60be3cb2d5e6f0770f2d3690fc7ad7527e5.zip
Merge "Debounce after quick fling towards camera but zoom if slow" into gb-ub-photos-arches
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java57
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java18
-rw-r--r--src/com/android/gallery3d/ui/PositionController.java12
3 files changed, 70 insertions, 17 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index ec1f8142e..3caa8689e 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -30,6 +30,7 @@ import android.nfc.NfcEvent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.os.SystemClock;
import android.view.animation.AccelerateInterpolator;
import android.widget.RelativeLayout;
import android.widget.Toast;
@@ -89,6 +90,7 @@ public class PhotoPage extends ActivityState implements
private static final int MSG_WANT_BARS = 7;
private static final int MSG_REFRESH_GRID_BUTTON = 8;
private static final int MSG_REFRESH_BOTTOM_CONTROLS = 9;
+ private static final int MSG_ON_CAMERA_CENTER = 10;
private static final int HIDE_BARS_TIMEOUT = 3500;
private static final int UNFREEZE_GLROOT_TIMEOUT = 250;
@@ -156,6 +158,10 @@ public class PhotoPage extends ActivityState implements
private boolean mStartInFilmstrip;
private boolean mStartedFromAlbumPage;
+ private long mCameraSwitchCutoff = 0;
+ private boolean mSkipUpdateCurrentPhoto = false;
+ private static final long CAMERA_SWITCH_CUTOFF_THRESHOLD_MS = 300;
+
private RawTexture mFadeOutTexture;
private Rect mOpenAnimationRect;
public static final int ANIM_TIME_OPENING = 300;
@@ -286,6 +292,26 @@ public class PhotoPage extends ActivityState implements
mActivity.getGLRoot().unfreeze();
break;
}
+ case MSG_ON_CAMERA_CENTER: {
+ mSkipUpdateCurrentPhoto = false;
+ boolean updateNeeded = false;
+ if (!mPhotoView.getFilmMode()) {
+ lockOrientation();
+ updateNeeded = true;
+ } else if (SystemClock.uptimeMillis() < mCameraSwitchCutoff &&
+ mMediaSet.getMediaItemCount() > 1) {
+ mPhotoView.switchToImage(1);
+ } else {
+ mPhotoView.setFilmMode(false);
+ updateNeeded = true;
+ }
+
+ if (updateNeeded) {
+ updateBars();
+ updateCurrentPhoto(mModel.getMediaItem(0));
+ }
+ break;
+ }
default: throw new AssertionError(message.what);
}
}
@@ -382,18 +408,32 @@ public class PhotoPage extends ActivityState implements
public void onPhotoChanged(int index, Path item) {
int oldIndex = mCurrentIndex;
mCurrentIndex = index;
- if (item != null) {
- MediaItem photo = mModel.getMediaItem(0);
- if (photo != null) updateCurrentPhoto(photo);
- }
+
if (mAppBridge != null) {
+ mPhotoView.setWantCameraCenterCallbacks(true);
+ if (mCurrentIndex > 0) {
+ mHandler.removeMessages(MSG_ON_CAMERA_CENTER);
+ mSkipUpdateCurrentPhoto = false;
+ }
+
if (oldIndex == 0 && mCurrentIndex > 0
&& !mPhotoView.getFilmMode()) {
mPhotoView.setFilmMode(true);
+ } else if (oldIndex == 2 && mCurrentIndex == 1) {
+ mCameraSwitchCutoff = SystemClock.uptimeMillis() +
+ CAMERA_SWITCH_CUTOFF_THRESHOLD_MS;
+ mPhotoView.stopScrolling();
+ } else if (oldIndex == 1 && mCurrentIndex == 0) {
+ mSkipUpdateCurrentPhoto = true;
}
}
- updateBars();
-
+ if (!mSkipUpdateCurrentPhoto) {
+ if (item != null) {
+ MediaItem photo = mModel.getMediaItem(0);
+ if (photo != null) updateCurrentPhoto(photo);
+ }
+ updateBars();
+ }
// Reset the timeout for the bars after a swipe
refreshHidingMessage();
}
@@ -436,6 +476,11 @@ public class PhotoPage extends ActivityState implements
}
}
+ public void onCameraCenter() {
+ mPhotoView.setWantCameraCenterCallbacks(false);
+ mHandler.sendEmptyMessage(MSG_ON_CAMERA_CENTER);
+ }
+
public boolean canDisplayBottomControls() {
return mShowBars && !mPhotoView.getFilmMode();
}
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index df7ab4c58..54ee07f24 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -128,6 +128,7 @@ public class PhotoView extends GLView {
public void onUndoDeleteImage();
public void onCommitDeleteImage();
public void onFilmModeChanged(boolean enabled);
+ public void onCameraCenter();
}
// The rules about orientation locking:
@@ -201,6 +202,7 @@ public class PhotoView extends GLView {
private boolean mCancelExtraScalingPending;
private boolean mFilmMode = false;
+ private boolean mWantCameraCenterCallbacks = false;
private int mDisplayRotation = 0;
private int mCompensation = 0;
private boolean mFullScreenCamera;
@@ -304,6 +306,10 @@ public class PhotoView extends GLView {
}
}
+ public void stopScrolling() {
+ mPositionController.stopScrolling();
+ }
+
public void setModel(Model model) {
mModel = model;
mTileView.setModel(mModel);
@@ -380,6 +386,10 @@ public class PhotoView extends GLView {
}
}
+ public void setWantCameraCenterCallbacks(boolean wanted) {
+ mWantCameraCenterCallbacks = wanted;
+ }
+
////////////////////////////////////////////////////////////////////////////
// Data/Image change notifications
////////////////////////////////////////////////////////////////////////////
@@ -624,12 +634,10 @@ public class PhotoView extends GLView {
// Holdings except touch-down prevent the transitions.
if ((mHolding & ~HOLD_TOUCH_DOWN) != 0) return;
- boolean isCenter = mPositionController.isCenter();
- boolean isCameraCenter = mIsCamera && isCenter && !canUndoLastPicture();
+ boolean isCameraCenter = mIsCamera && mPositionController.isCenter() && !canUndoLastPicture();
- if (isCameraCenter && !mFilmMode) {
- // Move into camera in page mode, lock
- mListener.lockOrientation();
+ if (isCameraCenter && mWantCameraCenterCallbacks) {
+ mListener.onCameraCenter();
}
}
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
index 15211bda7..45b5ec6b3 100644
--- a/src/com/android/gallery3d/ui/PositionController.java
+++ b/src/com/android/gallery3d/ui/PositionController.java
@@ -19,9 +19,9 @@ package com.android.gallery3d.ui;
import android.content.Context;
import android.graphics.Rect;
import android.util.Log;
+import android.widget.Scroller;
import com.android.gallery3d.app.PhotoPage;
-import com.android.gallery3d.common.OverScroller;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.ui.PhotoView.Size;
import com.android.gallery3d.util.GalleryUtils;
@@ -128,7 +128,7 @@ class PositionController {
private FlingScroller mPageScroller;
// This is used by the fling animation (film mode).
- private OverScroller mFilmScroller;
+ private Scroller mFilmScroller;
// The bound of the stable region that the focused box can stay, see the
// comments above calculateStableBound() for details.
@@ -211,8 +211,7 @@ class PositionController {
public PositionController(Context context, Listener listener) {
mListener = listener;
mPageScroller = new FlingScroller();
- mFilmScroller = new OverScroller(context,
- null /* default interpolator */, 0, 0, false /* no flywheel */);
+ mFilmScroller = new Scroller(context, null, false);
// Initialize the areas.
initPlatform();
@@ -1540,8 +1539,9 @@ class PositionController {
}
}
if (dir != EdgeView.INVALID_DIRECTION) {
- int v = (int) (mFilmScroller.getCurrVelocity() + 0.5f);
- mListener.onAbsorb(v, dir);
+ // TODO: restore this onAbsorb call
+ //int v = (int) (mFilmScroller.getCurrVelocity() + 0.5f);
+ //mListener.onAbsorb(v, dir);
mFilmScroller.forceFinished(true);
mCurrentX = mDefaultX;
}