summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorMert Tumer <merttumer@outlook.com>2016-12-07 13:45:28 +0200
committerjan iversen <jani@documentfoundation.org>2017-01-13 09:59:54 +0000
commit2e582ed403c41a07265ef090c5891eab04978117 (patch)
tree119559c50539bd4a0cd53cd636a4341f5f2b26c2 /android
parent978ff8f55cfa47b6ced80a6adc3d92327e0303f4 (diff)
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@libreoffice.org> Reviewed-by: jan iversen <jani@documentfoundation.org>
Diffstat (limited to 'android')
-rw-r--r--android/source/src/java/org/libreoffice/LOEvent.java8
-rw-r--r--android/source/src/java/org/libreoffice/LOKitShell.java4
-rw-r--r--android/source/src/java/org/libreoffice/LOKitThread.java33
-rwxr-xr-xandroid/source/src/java/org/libreoffice/LibreOfficeMainActivity.java7
4 files changed, 51 insertions, 1 deletions
diff --git a/android/source/src/java/org/libreoffice/LOEvent.java b/android/source/src/java/org/libreoffice/LOEvent.java
index 215512136167..23109e8d7f6a 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 aff04720b2c0..6e32b056dc01 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 7b2e9b27f04a..5927f5fd6e60 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 0eb326bef925..8325d5deb258 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);
}