summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2021-03-18 14:36:33 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2021-03-19 07:54:15 +0100
commit5fa9abfc4bfeb8f100db583289ea40d3fa4e82e0 (patch)
tree9b333f8bc965a9c08cc1e0c8f775b11098be5ddf
parent6b15b6d5e80f15a15838cdbde979f5b8319e090a (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> (cherry picked from commit 878cbe229fdb61501bf7889408a19fca14d1afdd)
-rw-r--r--android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java11
-rw-r--r--android/source/src/java/org/libreoffice/ToolbarController.java4
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();
}