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

Mert Tumer merttumer at outlook.com
Fri Jan 13 10:00:14 UTC 2017


 android/source/src/java/org/libreoffice/LOEvent.java                 |    8 ++
 android/source/src/java/org/libreoffice/LOKitShell.java              |    4 +
 android/source/src/java/org/libreoffice/LOKitThread.java             |   33 ++++++++++
 android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java |    7 +-
 4 files changed, 51 insertions(+), 1 deletion(-)

New commits:
commit 2e582ed403c41a07265ef090c5891eab04978117
Author: Mert Tumer <merttumer at outlook.com>
Date:   Wed Dec 7 13:45:28 2016 +0200

    tdf#101689 - Fix returning to first part of documents when resumed
    
    Change-Id: I6d3a9354c702628e991c69176086efbbc28ddd74
    Reviewed-on: https://gerrit.libreoffice.org/31753
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: jan iversen <jani at documentfoundation.org>

diff --git a/android/source/src/java/org/libreoffice/LOEvent.java b/android/source/src/java/org/libreoffice/LOEvent.java
index 2155121..23109e8 100644
--- a/android/source/src/java/org/libreoffice/LOEvent.java
+++ b/android/source/src/java/org/libreoffice/LOEvent.java
@@ -33,6 +33,7 @@ public class LOEvent implements Comparable<LOEvent> {
     public static final int SWIPE_LEFT = 12;
     public static final int NAVIGATION_CLICK = 13;
     public static final int UNO_COMMAND = 14;
+    public static final int RESUME = 15;
 
     public final int mType;
     public int mPriority = 0;
@@ -73,6 +74,13 @@ public class LOEvent implements Comparable<LOEvent> {
         mValue = value;
     }
 
+    public LOEvent(int type, String key, int value) {
+        mType = type;
+        mTypeString = "Resume partIndex";
+        mString = key;
+        mPartIndex = value;
+    }
+
     public LOEvent(int type, int partIndex) {
         mType = type;
         mPartIndex = partIndex;
diff --git a/android/source/src/java/org/libreoffice/LOKitShell.java b/android/source/src/java/org/libreoffice/LOKitShell.java
index aff0472..6e32b05 100644
--- a/android/source/src/java/org/libreoffice/LOKitShell.java
+++ b/android/source/src/java/org/libreoffice/LOKitShell.java
@@ -138,6 +138,10 @@ public class LOKitShell {
         LOKitShell.sendEvent(new LOEvent(LOEvent.LOAD, inputFile));
     }
 
+    public static void sendResumeEvent(String inputFile, int partIndex) {
+        LOKitShell.sendEvent(new LOEvent(LOEvent.RESUME, inputFile, partIndex));
+    }
+
     public static void sendCloseEvent() {
         LOKitShell.sendEvent(new LOEvent(LOEvent.CLOSE));
     }
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index 7b2e9b2..5927f5f 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -153,10 +153,40 @@ public class LOKitThread extends Thread {
         redraw();
     }
 
+
+    /**
+     * Resume the document with the current part
+     */
+
+    private void resumeDocument(String filename, int partIndex){
+        if (mApplication == null) {
+            mApplication = LibreOfficeMainActivity.mAppContext;
+        }
+
+        mLayerClient = LibreOfficeMainActivity.getLayerClient();
+
+        mInvalidationHandler = new InvalidationHandler(LibreOfficeMainActivity.mAppContext);
+        mTileProvider = TileProviderFactory.create(mLayerClient, mInvalidationHandler, filename);
+
+        if (mTileProvider.isReady()) {
+            LOKitShell.showProgressSpinner();
+            mTileProvider.changePart(partIndex);
+            mViewportMetrics = mLayerClient.getViewportMetrics();
+            mLayerClient.setViewportMetrics(mViewportMetrics.scaleTo(0.9f, new PointF()));
+            refresh();
+            LOKitShell.hideProgressSpinner();
+        } else {
+            closeDocument();
+        }
+
+
+    }
+
     /**
      * Change part of the document.
      */
     private void changePart(int partIndex) {
+
         LOKitShell.showProgressSpinner();
         mTileProvider.changePart(partIndex);
         mViewportMetrics = mLayerClient.getViewportMetrics();
@@ -206,6 +236,9 @@ public class LOKitThread extends Thread {
             case LOEvent.LOAD:
                 loadDocument(event.mString);
                 break;
+            case LOEvent.RESUME:
+                resumeDocument(event.mString, event.mPartIndex);
+                break;
             case LOEvent.CLOSE:
                 closeDocument();
                 break;
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 0eb326b..8325d5d 100755
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -72,6 +72,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
     private ListView mDrawerList;
     private List<DocumentPartView> mDocumentPartView = new ArrayList<DocumentPartView>();
     private DocumentPartViewListAdapter mDocumentPartViewListAdapter;
+    private int partIndex=-1;
     private File mInputFile;
     private DocumentOverlay mDocumentOverlay;
     private File mTempFile = null;
@@ -333,7 +334,10 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
     protected void onStart() {
         Log.i(LOGTAG, "onStart..");
         super.onStart();
-        LOKitShell.sendLoadEvent(mInputFile.getPath());
+        if(partIndex == -1)
+            LOKitShell.sendLoadEvent(mInputFile.getPath());
+        else
+            LOKitShell.sendResumeEvent(mInputFile.getPath(), partIndex);
     }
 
     @Override
@@ -626,6 +630,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity {
         @Override
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
             DocumentPartView partView = mDocumentPartViewListAdapter.getItem(position);
+            partIndex = partView.partIndex;
             LOKitShell.sendChangePartEvent(partView.partIndex);
             mDrawerLayout.closeDrawer(mDrawerList);
         }


More information about the Libreoffice-commits mailing list