[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-0' - android/app android/lib

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 10 13:52:15 UTC 2020


 android/app/src/main/AndroidManifest.xml                             |    4 -
 android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java |   34 +++++++++-
 2 files changed, 34 insertions(+), 4 deletions(-)

New commits:
commit 2e32f1b9dc422edddba796b3d892068f782a867f
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Mon Mar 2 09:32:15 2020 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Mar 10 14:51:54 2020 +0100

    android: reuse an already open activity when starting a new one
    
    This sets the "launchMode" of the LOActivity to "singleTask" and
    implements "onNewIntent". This is necessary so that we don't
    duplicate LOActivity instances, as that isn't handled correctly
    and can cause a freeze or in some cases that text input from one
    instance is sent to the other. The back button stack isn't ideal
    as it still can return us to LibreOfficeUIActivity even when the
    activity is started from some other app, but this at least is
    consistent with how some other apps work.
    
    Change-Id: Idd11214578ec124661e2612bb49ba7e4bc4f3cea
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89811
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89912
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 5d1f2b091..79cea3f49 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -35,7 +35,6 @@
             android:label="@string/app_name">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
-
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
             <intent-filter>
@@ -50,7 +49,8 @@
         <!-- The main document editing Activity -->
         <activity
             android:name="org.libreoffice.androidlib.LOActivity"
-            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden">
+            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
+            android:launchMode="singleTask">
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
                 <action android:name="android.intent.action.EDIT" />
diff --git a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
index 4a7c23151..e1fbc6717 100644
--- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
+++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
@@ -395,6 +395,36 @@ public class LOActivity extends AppCompatActivity {
         }
     }
 
+    @Override
+    protected void onNewIntent(Intent intent) {
+
+        Log.i(TAG, "onNewIntent");
+
+        if (documentLoaded) {
+            postMobileMessageNative("save dontTerminateEdit=true dontSaveIfUnmodified=true");
+        }
+
+        final Intent finalIntent = intent;
+        mProgressDialog.indeterminate(R.string.saving);
+        mainHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                documentLoaded = false;
+                postMobileMessageNative("BYE");
+                copyTempBackToIntent();
+                runOnUiThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        mProgressDialog.dismiss();
+                        setIntent(finalIntent);
+                        init();
+                    }
+                });
+            }
+        });
+        super.onNewIntent(intent);
+    }
+
     @Override
     protected void onSaveInstanceState(@NonNull Bundle outState) {
         super.onSaveInstanceState(outState);
@@ -415,7 +445,7 @@ public class LOActivity extends AppCompatActivity {
                     loadDocument();
                 } else {
                     Toast.makeText(this, getString(R.string.storage_permission_required), Toast.LENGTH_SHORT).show();
-                    finish();
+                    finishAndRemoveTask();
                     break;
                 }
                 break;
@@ -636,7 +666,7 @@ public class LOActivity extends AppCompatActivity {
                     }
                 });
 
-                finish();
+                finishAndRemoveTask();
             }
         });
     }


More information about the Libreoffice-commits mailing list