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

Michael Weghorn (via logerrit) logerrit at kemper.freedesktop.org
Fri May 21 20:00:18 UTC 2021


 android/source/src/java/org/libreoffice/LOKitThread.java |   22 ++++++++-------
 1 file changed, 12 insertions(+), 10 deletions(-)

New commits:
commit 1cfc6c545cd979eff04e38b2998c40e25106faf2
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Fri May 21 17:47:13 2021 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Fri May 21 21:59:31 2021 +0200

    android: Don't reset zoom and position on refresh event
    
    Don't call 'zoomAndRepositionTheDocument' for a REFRESH
    event. The only two places sending such an event are in
    'LibreOfficeMainActivity#onStart' and in
    'FormattingControler#sendInsertGraphic'.
    
    I don't see any need to reset the zoom and position in
    any of those two cases. Doing so had the effect that any
    manual zoom changes would be lost when e.g. switching
    between the LibreOffice Viewer app and another one,
    after a "Save As" or when inserting a picture.
    
    In my opinion, it's desirable to keep the view
    the user had before doing any of those actions and
    just rendering the document anew.
    
    To do so, add an extra bool parameter
    'resetZoomAndPosition' to the relevant methods
    in 'LOKitThread' that says whether a reset
    should take place.
    
    Change-Id: I8ba6a7cd8d984ad99654e188e00144e1edf407ed
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115950
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index fb076389f0f4..547cb4acc6d2 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -111,7 +111,7 @@ class LOKitThread extends Thread {
     /**
      * Handle the geometry change + draw.
      */
-    private void redraw() {
+    private void redraw(boolean resetZoomAndPosition) {
         if (mLayerClient == null || mTileProvider == null) {
             // called too early...
             return;
@@ -121,7 +121,9 @@ class LOKitThread extends Thread {
         mViewportMetrics = mLayerClient.getViewportMetrics();
         mLayerClient.setViewportMetrics(mViewportMetrics);
 
-        zoomAndRepositionTheDocument();
+        if (resetZoomAndPosition) {
+            zoomAndRepositionTheDocument();
+        }
 
         mLayerClient.forceRedraw();
         mLayerClient.forceRender();
@@ -151,9 +153,9 @@ class LOKitThread extends Thread {
     /**
      * Invalidate everything + handle the geometry change
      */
-    private void refresh() {
+    private void refresh(boolean resetZoomAndPosition) {
         mLayerClient.clearAndResetlayers();
-        redraw();
+        redraw(resetZoomAndPosition);
         updatePartPageRectangles();
         if (mTileProvider != null && mTileProvider.isSpreadsheet()) {
             updateCalcHeaders();
@@ -176,7 +178,7 @@ class LOKitThread extends Thread {
 
     private void updatePageSize(int pageWidth, int pageHeight){
         mTileProvider.setDocumentSize(pageWidth, pageHeight);
-        redraw();
+        redraw(true);
     }
 
     private void updateZoomConstraints() {
@@ -195,7 +197,7 @@ class LOKitThread extends Thread {
         mTileProvider.changePart(partIndex);
         mViewportMetrics = mLayerClient.getViewportMetrics();
         // mLayerClient.setViewportMetrics(mViewportMetrics.scaleTo(0.9f, new PointF()));
-        refresh();
+        refresh(true);
         LOKitShell.hideProgressSpinner(mContext);
     }
 
@@ -217,7 +219,7 @@ class LOKitThread extends Thread {
                 public void run() {
                     // synchronize to avoid deletion while loading
                     synchronized (LOKitThread.this) {
-                        refresh();
+                        refresh(true);
                     }
                 }
             });
@@ -241,7 +243,7 @@ class LOKitThread extends Thread {
         if (mTileProvider.isReady()) {
             LOKitShell.showProgressSpinner(mContext);
             updateZoomConstraints();
-            refresh();
+            refresh(true);
             LOKitShell.hideProgressSpinner(mContext);
 
             mTileProvider.saveDocumentAs(filePath, true);
@@ -293,7 +295,7 @@ class LOKitThread extends Thread {
                 closeDocument();
                 break;
             case LOEvent.SIZE_CHANGED:
-                redraw();
+                redraw(true);
                 break;
             case LOEvent.CHANGE_PART:
                 changePart(event.mPartIndex);
@@ -347,7 +349,7 @@ class LOKitThread extends Thread {
                     mTileProvider.postUnoCommand(event.mString, event.mValue, event.mNotify);
                 break;
             case LOEvent.REFRESH:
-                refresh();
+                refresh(false);
                 break;
             case LOEvent.PAGE_SIZE_CHANGED:
                 updatePageSize(event.mPageWidth, event.mPageHeight);


More information about the Libreoffice-commits mailing list