android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java | 49 ++++++++-- android/lib/src/main/res/layout/lolib_dialog_loading.xml | 3 android/lib/src/main/res/values/strings.xml | 1 3 files changed, 46 insertions(+), 7 deletions(-)
New commits: commit 475c7cd42e37efab6c8e48e03efc32a3cf315171 Author: mert <mert.tu...@collabora.com> AuthorDate: Thu Feb 6 16:27:01 2020 +0300 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Tue Feb 11 23:29:27 2020 +0100 android: Notify the user about saving the document on close Change-Id: Ie96bd1918d2d166df096bec5e2c6489f819b6f13 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88102 Tested-by: Jan Holesovsky <ke...@collabora.com> Reviewed-by: Jan Holesovsky <ke...@collabora.com> 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 e3e479a4c..a964ad392 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -33,12 +33,15 @@ import android.print.PrintDocumentAdapter; import android.print.PrintManager; import android.provider.DocumentsContract; import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; import android.view.WindowManager; import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; +import android.widget.TextView; import android.widget.Toast; import java.io.File; @@ -458,6 +461,10 @@ public class LOActivity extends AppCompatActivity { Log.i(TAG, "onDestroy() - we know we are leaving the document"); nativeLooper.quit(); mWebView.destroy(); + + // Most probably the native part has already got a 'BYE' from + // finishWithProgress(), but it is actually better to send it twice + // than never, so let's call it from here too anyway postMobileMessageNative("BYE"); } @@ -528,6 +535,38 @@ public class LOActivity extends AppCompatActivity { return null; } + /** Show the Saving progress and finish the app. */ + private void finishWithProgress() { + LayoutInflater inflater = this.getLayoutInflater(); + View loadingView = inflater.inflate(R.layout.lolib_dialog_loading, null); + TextView loadingText = loadingView.findViewById(R.id.lolib_loading_dialog_text); + loadingText.setText(getText(R.string.saving)); + final AlertDialog savingProgress = new AlertDialog.Builder(LOActivity.this) + .setView(loadingView) + .setCancelable(true) + .create(); + + savingProgress.show(); + + // The 'BYE' takes a considerable amount of time, we need to post it + // so that it starts after the saving progress is actually shown + mainHandler.post(new Runnable() { + @Override + public void run() { + postMobileMessageNative("BYE"); + + runOnUiThread(new Runnable() { + @Override + public void run() { + savingProgress.dismiss(); + } + }); + + finish(); + } + }); + } + @Override public void onBackPressed() { if (mMobileWizardVisible) @@ -537,8 +576,7 @@ public class LOActivity extends AppCompatActivity { return; } - postMobileMessageNative("BYE"); - super.onBackPressed(); + finishWithProgress(); } private void loadDocument() { @@ -600,10 +638,6 @@ public class LOActivity extends AppCompatActivity { postMobileMessageNative(message); afterMessageFromWebView(messageAndParameterArray); } - - // Going back to document browser on BYE (called when pressing the top left exit button) - if (message.equals("BYE")) - finish(); } /** @@ -647,6 +681,9 @@ public class LOActivity extends AppCompatActivity { */ private boolean beforeMessageFromWebView(String[] messageAndParam) { switch (messageAndParam[0]) { + case "BYE": + finishWithProgress(); + return false; case "PRINT": mainHandler.post(new Runnable() { @Override diff --git a/android/lib/src/main/res/layout/lolib_dialog_loading.xml b/android/lib/src/main/res/layout/lolib_dialog_loading.xml index f4dc98443..db4825bb7 100644 --- a/android/lib/src/main/res/layout/lolib_dialog_loading.xml +++ b/android/lib/src/main/res/layout/lolib_dialog_loading.xml @@ -10,9 +10,10 @@ android:layout_weight="1" /> <TextView + android:id="@+id/lolib_loading_dialog_text" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="4" android:gravity="center" android:text="@string/loading" /> -</LinearLayout> \ No newline at end of file +</LinearLayout> diff --git a/android/lib/src/main/res/values/strings.xml b/android/lib/src/main/res/values/strings.xml index a283939e6..f5ad4ee4c 100644 --- a/android/lib/src/main/res/values/strings.xml +++ b/android/lib/src/main/res/values/strings.xml @@ -4,6 +4,7 @@ <string name="failed_to_load_file">Failed to determine the file to load</string> <string name="failed_to_insert_image">Failed to insert image</string> <string name="cannot_open_file_chooser">Cannot open file chooser</string> + <string name="saving">Saving...</string> <!-- Loading SlideShow Dialog Strings --> <string name="loading">Loading...</string> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits