[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-7-1+backports' - 2 commits - android/source
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Fri Mar 19 06:55:06 UTC 2021
android/source/src/java/org/libreoffice/LOKitShell.java | 2 -
android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java | 11 ++++++----
android/source/src/java/org/libreoffice/ToolbarController.java | 4 ++-
3 files changed, 11 insertions(+), 6 deletions(-)
New commits:
commit 4dc452895e1814c070778d07bdb5193a8acf3aeb
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu Mar 18 15:57:40 2021 +0100
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Fri Mar 19 07:54:22 2021 +0100
android: Don't allow editing for read-only docs
Previously when experimental mode was enabled in Android
Viewer, a "This file is read-only, saving is disabled."
info was shown to the user when opening a file read-only,
e.g. when the file was passed from a third-party app.
However, editing the document was still possible, a
dialog asking whether or not to save the modified doc
was shown when existing and only then saving would fail.
Disable editing completely for this case, rather than
having the user lose changes in the end.
Change-Id: Ie523971949d11909223aeac4f99023ecf28cb56c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112693
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
(cherry picked from commit bf6efbb808929bfba42f88c894be93d1aa6f4210)
diff --git a/android/source/src/java/org/libreoffice/LOKitShell.java b/android/source/src/java/org/libreoffice/LOKitShell.java
index c69e02669619..46ca256c7993 100644
--- a/android/source/src/java/org/libreoffice/LOKitShell.java
+++ b/android/source/src/java/org/libreoffice/LOKitShell.java
@@ -61,7 +61,7 @@ public class LOKitShell {
}
public static boolean isEditingEnabled() {
- return LibreOfficeMainActivity.isExperimentalMode();
+ return !LibreOfficeMainActivity.isReadOnlyMode();
}
// EVENTS
commit 5fa9abfc4bfeb8f100db583289ea40d3fa4e82e0
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:54:15 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>
(cherry picked from commit 878cbe229fdb61501bf7889408a19fca14d1afdd)
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