[Libreoffice-commits] core.git: android/source
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Fri Mar 19 06:35:53 UTC 2021
android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java | 11 ++++++----
android/source/src/java/org/libreoffice/ToolbarController.java | 4 ++-
2 files changed, 10 insertions(+), 5 deletions(-)
New commits:
commit 878cbe229fdb61501bf7889408a19fca14d1afdd
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu Mar 18 14:36:33 2021 +0100
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Fri Mar 19 07:35:09 2021 +0100
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 at posteo.de>
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();
}
More information about the Libreoffice-commits
mailing list