diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-01-17 08:40:41 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-01-17 11:08:27 +0000 |
commit | 377a8c8ed7dd997d1ac96918b69f805880d208af (patch) | |
tree | 30e15f14e809e4c8060de9ff67b8f303777d460f /android/source/src | |
parent | 7c399767053b1cc6f68beccfbbb084c2891fe05e (diff) |
tdf#153058 android: Use "fit page" for min zoom level
So far, Android Viewer was using "fit page width"
as minimum zoom level, meaning that it was impossible
to zoom out to see the full page, e.g. when opening
a doc with page size A4 portrait and using
the device in landscape mode.
Change the minimum zoom level to take the page
height into account as well, i.e. adapt the minimum
zoom level to be "fit whole page" to allow doing that.
However, keep applying "fit page width" as
zoom level when double-tapping, by using
the "fit page width" zoom level as new
default zoom level and applying the default
instead of the minimum zoom level on
double-tap.
("Fit page width" is probably more desirable
than "fit whole page" at least when used on small
devices, at least in all cases where
writing is in horizontal direction, so the user
can see the current portion of text and scroll
down to continue reading/writing.)
Use on double-tap is currently the only use for the
default zoom level, the only previous occurence
was effectively unused since
commit 9ab43aebad67383057d2cc3f754ce2193fa78b4e
Date: Wed Dec 4 17:18:20 2019 +0100
android: Allow zooming for Calc as well
and finally dropped with
Change-Id I702874f1d9161e5cef660bb4c4a0b7864d6e3c09
("android: Drop superfluous ZoomConstraints#mAllow{,DoubleTap}Zoom").
Change-Id: Ica5d8207bc19a81173143fcb5c3747dc89f9fa81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145658
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android/source/src')
-rw-r--r-- | android/source/src/java/org/libreoffice/LOKitThread.java | 8 | ||||
-rw-r--r-- | android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java index 27568ace5599..fd40c3089102 100644 --- a/android/source/src/java/org/libreoffice/LOKitThread.java +++ b/android/source/src/java/org/libreoffice/LOKitThread.java @@ -184,9 +184,11 @@ class LOKitThread extends Thread { private void updateZoomConstraints() { if (mTileProvider == null) return; mLayerClient = mContext.getLayerClient(); - // Set min zoom to the page width so that you cannot zoom below page width - final float minZoom = mLayerClient.getViewportMetrics().getWidth()/mTileProvider.getPageWidth(); - mLayerClient.setZoomConstraints(new ZoomConstraints(1f, minZoom, 0f)); + // Set default zoom to the page width and min zoom so that the whole page is visible + final float pageHeightZoom = mLayerClient.getViewportMetrics().getHeight() / mTileProvider.getPageHeight(); + final float pageWidthZoom = mLayerClient.getViewportMetrics().getWidth() / mTileProvider.getPageWidth(); + final float minZoom = Math.min(pageWidthZoom, pageHeightZoom); + mLayerClient.setZoomConstraints(new ZoomConstraints(pageWidthZoom, minZoom, 0f)); } /** 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 ef3d28e8ebb3..f1973d980e32 100644 --- a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java +++ b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java @@ -983,7 +983,7 @@ class JavaPanZoomController PointF pointOfTap = getMotionInDocumentCoordinates(motionEvent); ImmutableViewportMetrics metrics = getMetrics(); float newZoom = metrics.getZoomFactor() >= - DOUBLE_TAP_THRESHOLD ? mTarget.getZoomConstraints().getMinZoom() : DOUBLE_TAP_THRESHOLD; + DOUBLE_TAP_THRESHOLD ? mTarget.getZoomConstraints().getDefaultZoom() : 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()); |