summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2012-10-21 17:16:11 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-10-21 17:16:11 -0700
commit05fbb32555ddbca8e09f32e29964329d946591e9 (patch)
treefb5c493f10faa0a89ec320afddcbbc94dc6990dd
parent7a515913449e89f7028898125e22c0aa1a676413 (diff)
parent08999d276db9b07c2fdd28d11ea6a20ca05aaa2e (diff)
downloadandroid_packages_apps_Snap-05fbb32555ddbca8e09f32e29964329d946591e9.tar.gz
android_packages_apps_Snap-05fbb32555ddbca8e09f32e29964329d946591e9.tar.bz2
android_packages_apps_Snap-05fbb32555ddbca8e09f32e29964329d946591e9.zip
am c778aab1: Prevent unveil direction to change as long as no touch up
* commit 'c778aab129fb001fdff1ccf167867fc40fbf7523': Prevent unveil direction to change as long as no touch up
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index 40da5725b..c009b99dd 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -86,6 +86,10 @@ public class ImageShow extends View implements OnGestureListener,
private long mTouchShowOriginalDate = 0;
private final long mTouchShowOriginalDelayMin = 200; // 200ms
private final long mTouchShowOriginalDelayMax = 300; // 300ms
+ private int mShowOriginalDirection = 0;
+ private static int UNVEIL_HORIZONTAL = 1;
+ private static int UNVEIL_VERTICAL = 2;
+
private int mTouchDownX = 0;
private int mTouchDownY = 0;
protected float mTouchX = 0;
@@ -425,29 +429,39 @@ public class ImageShow extends View implements OnGestureListener,
return;
canvas.save();
if (image != null) {
- boolean goingDown = false;
- if ((mTouchY - mTouchDownY) > (mTouchX - mTouchDownX)) {
- goingDown = true;
+ if (mShowOriginalDirection == 0) {
+ if ((mTouchY - mTouchDownY) > (mTouchX - mTouchDownX)) {
+ mShowOriginalDirection = UNVEIL_VERTICAL;
+ } else {
+ mShowOriginalDirection = UNVEIL_HORIZONTAL;
+ }
}
- int px = (int) (mTouchX - mImageBounds.left);
- int py = mImageBounds.height();
- if (goingDown) {
+
+ int px = 0;
+ int py = 0;
+ if (mShowOriginalDirection == UNVEIL_VERTICAL) {
px = mImageBounds.width();
py = (int) (mTouchY - mImageBounds.top);
+ } else {
+ px = (int) (mTouchX - mImageBounds.left);
+ py = mImageBounds.height();
}
+
Rect d = new Rect(mImageBounds.left, mImageBounds.top,
mImageBounds.left + px, mImageBounds.top + py);
canvas.clipRect(d);
drawImage(canvas, image);
Paint paint = new Paint();
paint.setColor(Color.BLACK);
- if (goingDown) {
+
+ if (mShowOriginalDirection == UNVEIL_VERTICAL) {
canvas.drawLine(mImageBounds.left, mTouchY - 1,
mImageBounds.right, mTouchY - 1, paint);
} else {
canvas.drawLine(mTouchX - 1, mImageBounds.top,
mTouchX - 1, mImageBounds.bottom, paint);
}
+
Rect bounds = new Rect();
paint.setTextSize(mOriginalTextSize);
paint.getTextBounds(mOriginalText, 0, mOriginalText.length(), bounds);
@@ -588,6 +602,7 @@ public class ImageShow extends View implements OnGestureListener,
mTouchDownX = ex;
mTouchDownY = ey;
mTouchShowOriginalDate = System.currentTimeMillis();
+ mShowOriginalDirection = 0;
}
if (event.getAction() == MotionEvent.ACTION_MOVE) {
mTouchX = ex;