diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-03-03 12:51:38 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-03-03 22:29:42 +0200 |
commit | 5facce3c212387054d2da05672445556f5bca14d (patch) | |
tree | 00ca22873525198c6b664d57266d484e47f5a668 /android | |
parent | 779a7015fd25099759bf00cee345a03e0e40e08f (diff) |
Add scroll and fling gesture recognition
Not yet passed on down.
Also fix a misleading comment.
Change-Id: I1e6f79c84b1e13f48e4b2620e44b326fb6fc4ee9
Diffstat (limited to 'android')
-rw-r--r-- | android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java index 6e5627be6e72..d01c323d8f16 100644 --- a/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java +++ b/android/experimental/desktop/src/org/libreoffice/experimental/desktop/Desktop.java @@ -22,6 +22,7 @@ import android.graphics.Rect; import android.os.Bundle; import android.text.InputType; import android.util.Log; +import android.view.GestureDetector; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.ScaleGestureDetector; @@ -163,7 +164,8 @@ public class Desktop Bitmap mBitmap; boolean renderedOnce; boolean scalingInProgress; - ScaleGestureDetector gestureDetector; + GestureDetector gestureDetector; + ScaleGestureDetector scaleDetector; float scale = 1; public BitmapView() @@ -171,6 +173,22 @@ public class Desktop super(Desktop.this); setFocusableInTouchMode(true); + gestureDetector = + new GestureDetector(Desktop.this, + new GestureDetector.SimpleOnGestureListener() { + @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) + { + Log.i(TAG, "onFling: events:" + e1 + ", " + e2 + ", velocity: (" + velocityX + ", " + velocityY + ")"); + return false; + } + + @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) + { + Log.i(TAG, "onScroll: events:" + e1 + ", " + e2 + ", velocity: (" + velocityX + ", " + velocityY + ")"); + return false; + } + }); + // Is this sane? It is rather slow to ask LO to zoom // continuously while the scaling gesture is in progress. @@ -178,7 +196,7 @@ public class Desktop // progress to just scale the bitmap view (UI elements // too, which of course was a bit silly). - gestureDetector = + scaleDetector = new ScaleGestureDetector(Desktop.this, new ScaleGestureDetector.SimpleOnScaleGestureListener() { @Override public boolean onScaleBegin(ScaleGestureDetector detector) @@ -255,12 +273,12 @@ public class Desktop @Override public boolean onTouchEvent(MotionEvent event) { - Log.i(TAG, "onTouchEvent, scalingInProgress=" + scalingInProgress); + if (gestureDetector.onTouchEvent(event)) + return true; - // For now, when during scaling we just scale the bitmap - // view, if a scaling gesture is in progress no other - // touch processing should be done. - if (gestureDetector.onTouchEvent(event) && scalingInProgress) + // If a scaling gesture is in progress no other touch + // processing should be done. + if (scaleDetector.onTouchEvent(event) && scalingInProgress) return true; if (!renderedOnce) |