android/source/src/java/org/libreoffice/LOEvent.java         |    3 +
 android/source/src/java/org/libreoffice/LOKitThread.java     |   20 ++++++++---
 android/source/src/java/org/mozilla/gecko/gfx/LayerView.java |    4 ++
 3 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit f45cfc6569d2a5a81784284f294eb35e98211b19
Author: Ximeng Zu <[email protected]>
Date:   Fri May 19 23:15:28 2017 -0500

    Update zoom constraints with device rotate
    
    Added function of updating zoom constraints
    whenever device rotates. This is achieved by
    calculating min zoom factor every time the
    size change function is called.
    
    Change-Id: I6d795c1eb79faa36b4f5dabedd2d4b8c87dcf7d7
    Reviewed-on: https://gerrit.libreoffice.org/37847
    Tested-by: Jenkins <[email protected]>
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/android/source/src/java/org/libreoffice/LOEvent.java 
b/android/source/src/java/org/libreoffice/LOEvent.java
index f5579aea087a..14980dca0ec4 100644
--- a/android/source/src/java/org/libreoffice/LOEvent.java
+++ b/android/source/src/java/org/libreoffice/LOEvent.java
@@ -36,7 +36,8 @@ public class LOEvent implements Comparable<LOEvent> {
     public static final int RESUME = 15;
     public static final int LOAD_NEW = 16;
     public static final int SAVE_AS = 17;
-    public static final int UPDATE_PART_PAGE_RECT= 18;
+    public static final int UPDATE_PART_PAGE_RECT = 18;
+    public static final int UPDATE_ZOOM_CONSTRAINTS = 19;
 
     public final int mType;
     public int mPriority = 0;
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java 
b/android/source/src/java/org/libreoffice/LOKitThread.java
index 52a7c6c2f43a..dac8cc43109c 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -168,6 +168,15 @@ class LOKitThread extends Thread {
         
mContext.getDocumentOverlay().setPartPageRectangles(partPageRectangles);
     }
 
+    private void updateZoomConstraints() {
+        mLayerClient = mContext.getLayerClient();
+
+        // 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));
+    }
+
 
     /**
      * Resume the document with the current part
@@ -181,6 +190,7 @@ class LOKitThread extends Thread {
         mTileProvider = TileProviderFactory.create(mContext, 
mInvalidationHandler, filename);
 
         if (mTileProvider.isReady()) {
+            updateZoomConstraints();
             changePart(partIndex);
         } else {
             closeDocument();
@@ -209,13 +219,9 @@ 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);
+            updateZoomConstraints();
             refresh();
             LOKitShell.hideProgressSpinner(mContext);
         } else {
@@ -236,6 +242,7 @@ class LOKitThread extends Thread {
 
         if (mTileProvider.isReady()) {
             LOKitShell.showProgressSpinner(mContext);
+            updateZoomConstraints();
             refresh();
             LOKitShell.hideProgressSpinner(mContext);
 
@@ -333,6 +340,9 @@ class LOKitThread extends Thread {
             case LOEvent.UPDATE_PART_PAGE_RECT:
                 updatePartPageRectangles();
                 break;
+            case LOEvent.UPDATE_ZOOM_CONSTRAINTS:
+                updateZoomConstraints();
+                break;
         }
     }
 
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java 
b/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java
index 0aa19ddf93e2..41fafd46a3db 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/LayerView.java
@@ -25,6 +25,8 @@ import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputConnection;
 import android.widget.FrameLayout;
 
+import org.libreoffice.LOEvent;
+import org.libreoffice.LOKitShell;
 import org.libreoffice.LibreOfficeMainActivity;
 import org.libreoffice.R;
 import org.mozilla.gecko.OnInterceptTouchListener;
@@ -319,6 +321,8 @@ public class LayerView extends FrameLayout {
         if (mListener != null) {
             mListener.surfaceChanged(width, height);
         }
+
+        LOKitShell.sendEvent(new LOEvent(LOEvent.UPDATE_ZOOM_CONSTRAINTS));
     }
 
     private void onDestroyed() {
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to