summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-05-03 18:22:59 +0800
committerChih-Chung Chang <chihchung@google.com>2012-05-04 12:35:09 +0800
commit1f9d97a22fb095c19cecbb87e08ff5bc7806dfca (patch)
treec23f8941a90fc385d331a7cd66075f2b829c98b6 /src/com/android/gallery3d/ui
parentd6a033d59667a53527d19f1f0e07c950aff6d74a (diff)
downloadandroid_packages_apps_Snap-1f9d97a22fb095c19cecbb87e08ff5bc7806dfca.tar.gz
android_packages_apps_Snap-1f9d97a22fb095c19cecbb87e08ff5bc7806dfca.tar.bz2
android_packages_apps_Snap-1f9d97a22fb095c19cecbb87e08ff5bc7806dfca.zip
Fix 6399813: tapping on a photo that isn't in the middle of the screen doesn't select it.
Also make tapping while flinging stop the scroll instead of opening the item. Change-Id: Iefef4738d7d74b29e4594ea3ae2cb1c91e0e17ab
Diffstat (limited to 'src/com/android/gallery3d/ui')
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java33
-rw-r--r--src/com/android/gallery3d/ui/PositionController.java10
2 files changed, 42 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index adbf791fb..7b97e78eb 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -748,11 +748,15 @@ public class PhotoView extends GLView {
private boolean mModeChanged;
// If this scaling gesture should be ignored.
private boolean mIgnoreScalingGesture;
+ // whether the down action happened while the view is scrolling.
+ private boolean mDownInScrolling;
@Override
public boolean onSingleTapUp(float x, float y) {
- if (mFilmMode) {
+ if (mFilmMode && !mDownInScrolling) {
+ switchToHitPicture((int) (x + 0.5f), (int) (y + 0.5f));
setFilmMode(false);
+ mIgnoreUpEvent = true;
return true;
}
@@ -881,6 +885,13 @@ public class PhotoView extends GLView {
@Override
public void onDown() {
mHolding |= HOLD_TOUCH_DOWN;
+
+ if (mFilmMode && mPositionController.isScrolling()) {
+ mDownInScrolling = true;
+ mPositionController.stopScrolling();
+ } else {
+ mDownInScrolling = false;
+ }
}
@Override
@@ -1020,6 +1031,26 @@ public class PhotoView extends GLView {
return 0;
}
+ // Switch to the previous or next picture if the hit position is inside
+ // one of their boxes. This runs in main thread.
+ private void switchToHitPicture(int x, int y) {
+ if (mPrevBound < 0) {
+ Rect r = mPositionController.getPosition(-1);
+ if (r.right >= x) {
+ slideToPrevPicture();
+ return;
+ }
+ }
+
+ if (mNextBound > 0) {
+ Rect r = mPositionController.getPosition(1);
+ if (r.left <= x) {
+ slideToNextPicture();
+ return;
+ }
+ }
+ }
+
////////////////////////////////////////////////////////////////////////////
// Page mode focus switching
//
diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java
index 03fe65b1c..c09ffea0c 100644
--- a/src/com/android/gallery3d/ui/PositionController.java
+++ b/src/com/android/gallery3d/ui/PositionController.java
@@ -1003,6 +1003,16 @@ class PositionController {
return edges;
}
+ public boolean isScrolling() {
+ return mPlatform.mAnimationStartTime != NO_ANIMATION
+ && mPlatform.mCurrentX != mPlatform.mToX;
+ }
+
+ public void stopScrolling() {
+ if (mPlatform.mAnimationStartTime == NO_ANIMATION) return;
+ mPlatform.mFromX = mPlatform.mToX = mPlatform.mCurrentX;
+ }
+
////////////////////////////////////////////////////////////////////////////
// Private utilities
////////////////////////////////////////////////////////////////////////////