summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorXimeng Zu <uznomis@yahoo.com>2017-03-16 23:24:27 -0500
committerTomaž Vajngerl <quikee@gmail.com>2017-04-18 13:02:34 +0200
commited900113d091431f89ccc312b55a6955ca341b9e (patch)
treec7b006190a64ac7382f959a24877f6df0afe2ece /android
parentd52d230fc204b7b2b0d9b27445b496b0113a8dd5 (diff)
tdf#106368 android: restrict zoom to page width
Created an overloaded constructor for ZoomConstraints class that takes in minZoom and maxZoom. Added calculation of minZoom according to page width and screen width and assigned the minZoom to ZoomConstraints in LOKitThread class. Deleted minZoom checking in the onScale method in JavaPanZoomController class because the checking prevented zoom-in from functioning. (Update: I also removed the old constructor because it is not used any more.) Change-Id: I89e80761efc093b3738970d4482dd735532c0397 Reviewed-on: https://gerrit.libreoffice.org/35308 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'android')
-rw-r--r--android/source/src/java/org/libreoffice/LOKitThread.java6
-rwxr-xr-xandroid/source/src/java/org/libreoffice/LibreOfficeMainActivity.java2
-rw-r--r--android/source/src/java/org/mozilla/gecko/ZoomConstraints.java8
-rw-r--r--android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java1
-rw-r--r--android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java4
5 files changed, 11 insertions, 10 deletions
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index 31d3b96440ed..4dd403dd2d0c 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -8,6 +8,7 @@ import android.view.KeyEvent;
import org.libreoffice.canvas.SelectionHandle;
import org.libreoffice.ui.LibreOfficeUIActivity;
+import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.gfx.CairoImage;
import org.mozilla.gecko.gfx.ComposedTileLayer;
import org.mozilla.gecko.gfx.GeckoLayerClient;
@@ -197,6 +198,11 @@ class LOKitThread extends Thread {
mInvalidationHandler = new InvalidationHandler(mContext);
mTileProvider = TileProviderFactory.create(mContext, mInvalidationHandler, filePath);
+ // Set min zoom to the page width so that you cannot zoom below page width
+ // applies to all types of document; in the future spreadsheets may be singled out
+ float minZoom = mLayerClient.getViewportMetrics().getWidth()/mTileProvider.getPageWidth();
+ mLayerClient.setZoomConstraints(new ZoomConstraints(true, 0.0f, minZoom, 0.0f));
+
if (mTileProvider.isReady()) {
LOKitShell.showProgressSpinner(mContext);
refresh();
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 53e956a7de69..3e41a7dda98f 100755
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -33,7 +33,6 @@ import org.libreoffice.storage.DocumentProviderFactory;
import org.libreoffice.storage.IFile;
import org.libreoffice.ui.FileUtilities;
import org.libreoffice.ui.LibreOfficeUIActivity;
-import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.LayerView;
@@ -191,7 +190,6 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
loKitThread.start();
mLayerClient = new GeckoLayerClient(this);
- mLayerClient.setZoomConstraints(new ZoomConstraints(true));
LayerView layerView = (LayerView) findViewById(R.id.layer_view);
mLayerClient.setView(layerView);
layerView.setInputConnectionHandler(new LOKitInputConnectionHandler());
diff --git a/android/source/src/java/org/mozilla/gecko/ZoomConstraints.java b/android/source/src/java/org/mozilla/gecko/ZoomConstraints.java
index eba0dfe54aff..f1672ba3dd76 100644
--- a/android/source/src/java/org/mozilla/gecko/ZoomConstraints.java
+++ b/android/source/src/java/org/mozilla/gecko/ZoomConstraints.java
@@ -12,12 +12,12 @@ public final class ZoomConstraints {
private final float mMinZoom;
private final float mMaxZoom;
- public ZoomConstraints(boolean allowZoom) {
+ public ZoomConstraints(boolean allowZoom, float defaultZoom, float minZoom, float maxZoom) {
mAllowZoom = allowZoom;
mAllowDoubleTapZoom = allowZoom;
- mDefaultZoom = 0.0f;
- mMinZoom = 0.0f;
- mMaxZoom = 0.0f;
+ mDefaultZoom = defaultZoom;
+ mMinZoom = minZoom;
+ mMaxZoom = maxZoom;
}
public final boolean getAllowZoom() {
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java b/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
index 93ab1dd26d7f..386b1638ebaf 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/GeckoLayerClient.java
@@ -62,7 +62,6 @@ public class GeckoLayerClient implements PanZoomTarget {
mForceRedraw = true;
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
mViewportMetrics = new ImmutableViewportMetrics(displayMetrics);
- mZoomConstraints = new ZoomConstraints(false);
}
public void setView(LayerView view) {
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 020b403a9879..7d7474eae0b4 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java
@@ -845,13 +845,11 @@ class JavaPanZoomController
synchronized (mTarget.getLock()) {
float newZoomFactor = getMetrics().zoomFactor * spanRatio;
- float minZoomFactor = 0.0f;
+ float minZoomFactor = 0.0f; // deliberately set to zero to allow big zoom out effect
float maxZoomFactor = MAX_ZOOM;
ZoomConstraints constraints = mTarget.getZoomConstraints();
- if (constraints.getMinZoom() > 0)
- minZoomFactor = constraints.getMinZoom();
if (constraints.getMaxZoom() > 0)
maxZoomFactor = constraints.getMaxZoom();