diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2021-03-18 14:36:33 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2021-03-19 07:35:09 +0100 |
commit | 878cbe229fdb61501bf7889408a19fca14d1afdd (patch) | |
tree | c2346edd70b50279572b29b29f44eacdc1b3ac8f /android | |
parent | 370984c385dbc52c8ee7e6e71f4c0cc085fee422 (diff) |
android: Don't show message for readonly files in non-experimental mode
Since editing is disabled in Android Viewer for non-experimental
mode anyway, there's no need to tell the user it's not possible
to edit a specific document if it's readonly.
Replace the 'usesTemporaryFile' method with a more explicit
'isReadOnlyMode' method since ToolbarController shouldn't
have to worry about implementation details like whether
temporary files are used and the new method will be reused in other
places in a follow-up commit as well.
Change-Id: Iaccf5b40bd19887b9e76b982ce7252368871c716
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112692
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java | 11 | ||||
-rw-r--r-- | android/source/src/java/org/libreoffice/ToolbarController.java | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java index a9a192099008..b640fa404973 100644 --- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java +++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java @@ -75,6 +75,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin private static boolean mIsExperimentalMode; private static boolean mIsDeveloperMode; + private static boolean mbISReadOnlyMode; private int providerId; private URI documentUri; @@ -120,10 +121,6 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin return mIsDeveloperMode; } - public boolean usesTemporaryFile() { - return mTempFile != null; - } - private boolean isKeyboardOpen = false; private boolean isFormattingToolbarOpen = false; private boolean isSearchToolbarOpen = false; @@ -189,10 +186,12 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin loadNewDocument(newFilePath, newDocumentType); } + mbISReadOnlyMode = !isExperimentalMode(); if (getIntent().getData() != null) { if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT)) { if (copyFileToTemp() && mTempFile != null) { mInputFile = mTempFile; + mbISReadOnlyMode = true; Log.d(LOGTAG, "SCHEME_CONTENT: getPath(): " + getIntent().getData().getPath()); String displayName = extractDisplayNameFromIntent(); @@ -882,6 +881,10 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin return mIsSpreadsheet; } + public static boolean isReadOnlyMode() { + return mbISReadOnlyMode; + } + public static void setDocumentChanged (boolean changed) { isDocumentChanged = changed; } diff --git a/android/source/src/java/org/libreoffice/ToolbarController.java b/android/source/src/java/org/libreoffice/ToolbarController.java index d21396cf4615..76c67a06375f 100644 --- a/android/source/src/java/org/libreoffice/ToolbarController.java +++ b/android/source/src/java/org/libreoffice/ToolbarController.java @@ -246,7 +246,9 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener { } void setupToolbars() { - if (mContext.usesTemporaryFile()) { + // show message in case experimental mode is enabled (i.e. editing is supported in general), + // but current document is readonly + if (LibreOfficeMainActivity.isExperimentalMode() && LibreOfficeMainActivity.isReadOnlyMode()) { disableMenuItem(R.id.action_save, true); Toast.makeText(mContext, mContext.getString(R.string.temp_file_saving_disabled), Toast.LENGTH_LONG).show(); } |