[Libreoffice-commits] core.git: android/source

Ximeng Zu uznomis at yahoo.com
Tue May 9 17:52:26 UTC 2017


 android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java |   22 +++++-----
 1 file changed, 12 insertions(+), 10 deletions(-)

New commits:
commit e0ccc8913598c91a9a76fd6bcca6d397bf79e304
Author: Ximeng Zu <uznomis at yahoo.com>
Date:   Thu Apr 27 22:07:32 2017 -0500

    Fix behavior of double tap zoom in and out
    
    Fix the behavior of double tap zoom. Previously
    double tap zooms to the viewport whose
    top left point is the point of double touch. Now
    double tap behaves such that the point of
    doule touch does not move on the screen, and
    the rest part of the view zooms in or out. This
    behavior is more UX friendly and correct.
    
    Change-Id: Ifccc337631d523be1cd870f892235899d0fc5dfe
    Reviewed-on: https://gerrit.libreoffice.org/37046
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
index 1d109cf426a1..b834fa0798d5 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
@@ -985,16 +985,18 @@ class JavaPanZoomController
     @Override
     public boolean onDoubleTap(MotionEvent motionEvent) {
         // Double tap zooms in or out depending on the current zoom factor
-        PointF viewPoint = getMotionInDocumentCoordinates(motionEvent);
-        ZoomConstraints constraints = mTarget.getZoomConstraints();
-        float zoomFactor = getMetrics().getZoomFactor();
-        if (zoomFactor >= DOUBLE_TAP_THRESHOLD) {
-            animatedMove(viewPoint, constraints.getMinZoom());
-        } else {
-            animatedMove(viewPoint, DOUBLE_TAP_THRESHOLD);
-        }
-
-        LOKitShell.sendTouchEvent("DoubleTap", getMotionInDocumentCoordinates(motionEvent));
+        PointF pointOfTap = getMotionInDocumentCoordinates(motionEvent);
+        ImmutableViewportMetrics metrics = getMetrics();
+        float newZoom = metrics.getZoomFactor() >=
+                DOUBLE_TAP_THRESHOLD ? mTarget.getZoomConstraints().getMinZoom() : DOUBLE_TAP_THRESHOLD;
+        // calculate new top_left point from the point of tap
+        float ratio = newZoom/metrics.getZoomFactor();
+        float newLeft = pointOfTap.x - 1/ratio * (pointOfTap.x - metrics.getOrigin().x / metrics.getZoomFactor());
+        float newTop = pointOfTap.y - 1/ratio * (pointOfTap.y - metrics.getOrigin().y / metrics.getZoomFactor());
+        // animate move to the new view
+        animatedMove(new PointF(newLeft, newTop), newZoom);
+
+        LOKitShell.sendTouchEvent("DoubleTap", pointOfTap);
         return true;
     }
 


More information about the Libreoffice-commits mailing list