From 5facce3c212387054d2da05672445556f5bca14d Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sun, 3 Mar 2013 12:51:38 +0200 Subject: Add scroll and fling gesture recognition Not yet passed on down. Also fix a misleading comment. Change-Id: I1e6f79c84b1e13f48e4b2620e44b326fb6fc4ee9 --- .../libreoffice/experimental/desktop/Desktop.java | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'android') 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) -- cgit