[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - 2 commits - android/lib
Jan Holesovsky (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jul 6 04:38:18 UTC 2020
android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java | 22 +++++++++-
1 file changed, 20 insertions(+), 2 deletions(-)
New commits:
commit c2c1e9dddb8965db9bdb9dbe27f3f52c957b5b4e
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Jul 3 22:38:23 2020 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Jul 6 06:38:13 2020 +0200
android: Fallback to "w" mode, "wt" is not supported by Google Drive.
Would be cool to consolidate these two places actually to a common
method at some stage...
Change-Id: I5ff3aed134066f26bb058223b972ef11600fa887
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97911
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Andras Timar <andras.timar at 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 ddb8a220e..855fa63b0 100644
--- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
+++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
@@ -489,7 +489,13 @@ public class LOActivity extends AppCompatActivity {
inputStream = new FileInputStream(mTempFile);
Uri uri = getIntent().getData();
- outputStream = contentResolver.openOutputStream(uri, "wt");
+ try {
+ outputStream = contentResolver.openOutputStream(uri, "wt");
+ }
+ catch (FileNotFoundException e) {
+ Log.i(TAG, "failed with the 'wt' mode, trying without: " + e.getMessage());
+ outputStream = contentResolver.openOutputStream(uri);
+ }
byte[] buffer = new byte[1024];
int length;
@@ -588,7 +594,13 @@ public class LOActivity extends AppCompatActivity {
LOActivity.this.saveAs(tempFile.toURI().toString(), format);
inputStream = new FileInputStream(tempFile);
- outputStream = getContentResolver().openOutputStream(intent.getData(), "wt");
+ try {
+ outputStream = getContentResolver().openOutputStream(intent.getData(), "wt");
+ }
+ catch (FileNotFoundException e) {
+ Log.i(TAG, "failed with the 'wt' mode, trying without: " + e.getMessage());
+ outputStream = getContentResolver().openOutputStream(intent.getData());
+ }
byte[] buffer = new byte[4096];
int len;
commit 911d445fb21f13195898fd1db84ed9ea3b173f18
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Jul 3 23:07:47 2020 +0200
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Jul 6 06:37:59 2020 +0200
android: On ChromeOS, load files from Google Drive read-only.
Apparently it is not possible to save to Google Drive yet.
Unfortunately I don't have a proof in the documentation or anywhere on
the net, but the good indication of this is that the
Intent.ACTION_CREATE_DOCUMENT does not offer Google Drive (while it does
on a "normal" Android).
Change-Id: I521b866fd783b81a2bb9eace84354b5564ebabee
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97913
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Andras Timar <andras.timar at 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 8465ff5e1..ddb8a220e 100644
--- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
+++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
@@ -262,6 +262,12 @@ public class LOActivity extends AppCompatActivity {
if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
isDocEditable = (getIntent().getFlags() & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0;
+
+ // turns out that on ChromeOS, it is not possible to save back
+ // to Google Drive; detect it already here to avoid disappointment
+ if (getIntent().getData().toString().startsWith("content://org.chromium.arc.chromecontentprovider/externalfile"))
+ isDocEditable = false;
+
if (!isDocEditable)
Toast.makeText(this, getResources().getString(R.string.temp_file_saving_disabled), Toast.LENGTH_SHORT).show();
More information about the Libreoffice-commits
mailing list