[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-5' - android/lib
android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java |2 ++ 1 file changed, 2 insertions(+) New commits: commit edd1b83345169c75bbedb022567f4e2cacd64e5d Author: Jan Holesovsky AuthorDate: Fri Jul 17 16:02:46 2020 +0200 Commit: Jan Holesovsky CommitDate: Fri Jul 17 16:12:02 2020 +0200 android: Log when we disable editing for easier debugging. Change-Id: I358b1a50be7f9f377e9376f8b1772ad92fd059ae Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98976 Tested-by: Jan Holesovsky Reviewed-by: Jan Holesovsky 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 221c83174..24319e215 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -272,6 +272,7 @@ public class LOActivity extends AppCompatActivity { // is it read-only? if ((getIntent().getFlags() & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == 0) { isDocEditable = false; +Log.d(TAG, "Disabled editing: Read-only"); Toast.makeText(this, getResources().getString(R.string.temp_file_saving_disabled), Toast.LENGTH_SHORT).show(); } @@ -282,6 +283,7 @@ public class LOActivity extends AppCompatActivity { if (isDocEditable && (getIntent().getData().toString().startsWith("content://org.chromium.arc.chromecontentprovider/externalfile") || getIntent().getData().toString().startsWith("content://org.chromium.arc.volumeprovider/"))) { isDocEditable = false; +Log.d(TAG, "Disabled editing: Chrome OS unsupported content providers"); Toast.makeText(this, getResources().getString(R.string.file_chromeos_read_only), Toast.LENGTH_LONG).show(); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-5' - android/lib
android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java | 18 +++--- android/lib/src/main/res/values/strings.xml |1 2 files changed, 14 insertions(+), 5 deletions(-) New commits: commit 2c739a852b3b44e8a08967e79d144554cbadbf15 Author: Jan Holesovsky AuthorDate: Fri Jul 17 09:56:25 2020 +0200 Commit: Jan Holesovsky CommitDate: Fri Jul 17 11:07:14 2020 +0200 android: One more location that fails to save on Chrome OS. Turns out that saving directly to "My files" is problematic in some cases too; suggest to use the "Play files" location. Change-Id: Ifb88fc048685596f85e7cf39a57c60864da12d83 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98943 Tested-by: Jan Holesovsky Reviewed-by: Jan Holesovsky 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 e904c6d74..221c83174 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -267,15 +267,23 @@ public class LOActivity extends AppCompatActivity { if (getIntent().getData() != null) { if (getIntent().getData().getScheme().equals(ContentResolver.SCHEME_CONTENT)) { -isDocEditable = (getIntent().getFlags() & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) != 0; +isDocEditable = true; + +// is it read-only? +if ((getIntent().getFlags() & Intent.FLAG_GRANT_WRITE_URI_PERMISSION) == 0) { +isDocEditable = false; +Toast.makeText(this, getResources().getString(R.string.temp_file_saving_disabled), Toast.LENGTH_SHORT).show(); +} // 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")) +// also the volumeprovider does not work for saving back, +// which is much more serious :-( +if (isDocEditable && (getIntent().getData().toString().startsWith("content://org.chromium.arc.chromecontentprovider/externalfile") || + getIntent().getData().toString().startsWith("content://org.chromium.arc.volumeprovider/"))) { isDocEditable = false; - -if (!isDocEditable) -Toast.makeText(this, getResources().getString(R.string.temp_file_saving_disabled), Toast.LENGTH_SHORT).show(); +Toast.makeText(this, getResources().getString(R.string.file_chromeos_read_only), Toast.LENGTH_LONG).show(); +} if (copyFileToTemp() && mTempFile != null) { documentUri = mTempFile.toURI(); diff --git a/android/lib/src/main/res/values/strings.xml b/android/lib/src/main/res/values/strings.xml index dff5fb931..5fcb5e742 100644 --- a/android/lib/src/main/res/values/strings.xml +++ b/android/lib/src/main/res/values/strings.xml @@ -1,5 +1,6 @@ This file is read-only, saving is disabled. +This file cannot be saved in this location, opening it read-only. Move it to the "Play files" for full read/write access. Storage permission is required Failed to determine the file to load Failed to insert image ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-5' - android/lib kit/ChildSession.cpp loleaflet/src
android/lib/src/main/cpp/androidapp.cpp | 54 +-- android/lib/src/main/cpp/androidapp.hpp |3 + kit/ChildSession.cpp | 11 +- loleaflet/src/control/Control.Toolbar.js |6 --- 4 files changed, 52 insertions(+), 22 deletions(-) New commits: commit c543ee26c422563147d5fa006475836af19d1623 Author: Jan Holesovsky AuthorDate: Tue Jul 14 14:27:03 2020 +0200 Commit: Jan Holesovsky CommitDate: Tue Jul 14 17:16:59 2020 +0200 android: Call the SAVE directly from the native code. Until now, for the "local save has completed, upload it back to the content: URI" messages we were relying on the "local save" -> JavaScript -> Java -> "upload to content:/ URI" chain. It turns out though, that the WebView can be dead by the time we need the notification that the save has completed. This was particularly seen on ChromeOS when the document was closed using the [x] in the window decoration. As a solution, we need to pass the info that the "local save" has completed directly to Java. So far this uses the same semantics as the postMobileMessage() and reuse its code; but maybe in the future we'll need to split this. Change-Id: If1b93e4f76cee3abc6aebfc3e9072810ab73bb42 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98724 Tested-by: Jan Holesovsky Reviewed-by: Michael Meeks diff --git a/android/lib/src/main/cpp/androidapp.cpp b/android/lib/src/main/cpp/androidapp.cpp index a3f847135..f3405f374 100644 --- a/android/lib/src/main/cpp/androidapp.cpp +++ b/android/lib/src/main/cpp/androidapp.cpp @@ -35,6 +35,10 @@ static int closeNotificationPipeForForwardingThread[2] = {-1, -1}; static JavaVM* javaVM = nullptr; static bool lokInitialized = false; +// Remember the reference to the LOActivity +jclass g_loActivityClz = nullptr; +jobject g_loActivityObj = nullptr; + extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) { javaVM = vm; @@ -89,7 +93,7 @@ public: JNIEnv *getEnv() const { return _env; } }; -static void send2JS(const JNIThreadContext , jclass loActivityClz, jobject loActivityObj, const std::vector& buffer) +static void send2JS(const JNIThreadContext , const std::vector& buffer) { LOG_DBG("Send to JS: " << LOOLProtocol::getAbbreviatedMessage(buffer.data(), buffer.size())); @@ -149,8 +153,22 @@ static void send2JS(const JNIThreadContext , jclass loActivityClz, jobject JNIEnv *env = jctx.getEnv(); jstring jstr = env->NewStringUTF(js.c_str()); -jmethodID callFakeWebsocket = env->GetMethodID(loActivityClz, "callFakeWebsocketOnMessage", "(Ljava/lang/String;)V"); -env->CallVoidMethod(loActivityObj, callFakeWebsocket, jstr); +jmethodID callFakeWebsocket = env->GetMethodID(g_loActivityClz, "callFakeWebsocketOnMessage", "(Ljava/lang/String;)V"); +env->CallVoidMethod(g_loActivityObj, callFakeWebsocket, jstr); +env->DeleteLocalRef(jstr); + +if (env->ExceptionCheck()) +env->ExceptionDescribe(); +} + +void postDirectMessage(std::string message) +{ +JNIThreadContext ctx; +JNIEnv *env = ctx.getEnv(); + +jstring jstr = env->NewStringUTF(message.c_str()); +jmethodID callPostMobileMessage = env->GetMethodID(g_loActivityClz, "postMobileMessage", "(Ljava/lang/String;)V"); +env->CallVoidMethod(g_loActivityObj, callPostMobileMessage, jstr); env->DeleteLocalRef(jstr); if (env->ExceptionCheck()) @@ -170,7 +188,7 @@ void closeDocument() /// Handle a message from JavaScript. extern "C" JNIEXPORT void JNICALL -Java_org_libreoffice_androidlib_LOActivity_postMobileMessageNative(JNIEnv *env, jobject instance, jstring message) +Java_org_libreoffice_androidlib_LOActivity_postMobileMessageNative(JNIEnv *env, jobject, jstring message) { const char *string_value = env->GetStringUTFChars(message, nullptr); @@ -197,11 +215,7 @@ Java_org_libreoffice_androidlib_LOActivity_postMobileMessageNative(JNIEnv *env, fakeSocketPipe2(closeNotificationPipeForForwardingThread); // Start another thread to read responses and forward them to the JavaScript -jclass clz = env->GetObjectClass(instance); -jclass loActivityClz = (jclass) env->NewGlobalRef(clz); -jobject loActivityObj = env->NewGlobalRef(instance); - -std::thread([loActivityClz, loActivityObj, currentFakeClientFd] +std::thread([currentFakeClientFd] { Util::setThreadName("app2js"); JNIThreadContext ctx; @@ -242,7 +256,7 @@ Java_org_libreoffice_androidlib_LOActivity_postMobileMessageNative(JNIEnv *env, return; std::vector buf(n); n = fakeSocketRead(currentFakeClientFd, buf.data(), n); -
[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-5' - android/lib
android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) New commits: commit fffcc45b46a99c3df9b0e2c386ad697a38257ce2 Author: Jan Holesovsky AuthorDate: Tue Jul 14 17:07:01 2020 +0200 Commit: Jan Holesovsky CommitDate: Tue Jul 14 17:15:26 2020 +0200 android: A small follow-up, the intention was an early return. Change-Id: I3a73cd03c9ec51b7f190092702b4ef860c1f589b Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98748 Tested-by: Jan Holesovsky Reviewed-by: Jan Holesovsky 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 5fb44fa97..3374ff4ca 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -784,8 +784,10 @@ public class LOActivity extends AppCompatActivity { if (mWebView != null) mWebView.post(new Runnable() { public void run() { -if (mWebView != null) +if (mWebView == null) { Log.i(TAG, "Skipped forwarding to the WebView: " + message); +return; +} Log.i(TAG, "Forwarding to the WebView: " + message); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-5' - android/lib
android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java | 31 +- 1 file changed, 18 insertions(+), 13 deletions(-) New commits: commit 1f0a184edd44c611ea93f71e4ccd5db70ba246ce Author: Jan Holesovsky AuthorDate: Mon Jul 13 18:21:28 2020 +0200 Commit: Michael Meeks CommitDate: Tue Jul 14 14:48:52 2020 +0200 android: Avoid calling methods of a destroyed WebView. Avoids exceptions like: 2020-07-13 13:19:49.607 2919-2919/? I/LOActivity: Forwarding to the WebView: 'statusindicatorsetvalue: 86' 2020-07-13 13:19:49.609 2919-2919/? W/cr_AwContents: Application attempted to call on a destroyed WebView java.lang.Throwable at org.chromium.android_webview.AwContents.t(chromium-SystemWebViewGoogle.apk-stable-410410651:2) at com.android.webview.chromium.WebViewChromium.loadUrl(chromium-SystemWebViewGoogle.apk-stable-410410651:11) at android.webkit.WebView.loadUrl(WebView.java:970) at org.libreoffice.androidlib.LOActivity$6.run(LOActivity.java:794) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6971) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:865) Change-Id: Ic853131bac937deec7e68723b956a4ab7cf61872 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98723 Tested-by: Michael Meeks Reviewed-by: Michael Meeks 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 855fa63b0..5fb44fa97 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -101,7 +101,7 @@ public class LOActivity extends AppCompatActivity { private URI documentUri; private String urlToLoad; -private WebView mWebView; +private WebView mWebView = null; private SharedPreferences sPrefs; private Handler mMainHandler = null; private RateAppController rateAppController; @@ -544,6 +544,7 @@ public class LOActivity extends AppCompatActivity { if (viewGroup != null) viewGroup.removeView(mWebView); mWebView.destroy(); +mWebView = null; // Most probably the native part has already got a 'BYE' from // finishWithProgress(), but it is actually better to send it twice @@ -780,20 +781,24 @@ public class LOActivity extends AppCompatActivity { */ void callFakeWebsocketOnMessage(final String message) { // call from the UI thread -mWebView.post(new Runnable() { -public void run() { -Log.i(TAG, "Forwarding to the WebView: " + message); +if (mWebView != null) +mWebView.post(new Runnable() { +public void run() { +if (mWebView != null) +Log.i(TAG, "Skipped forwarding to the WebView: " + message); -/* Debug only: in case the message is too long, truncated in the logcat, and you need to see it. -final int size = 80; -for (int start = 0; start < message.length(); start += size) { -Log.i(TAG, "split: " + message.substring(start, Math.min(message.length(), start + size))); -} -*/ +Log.i(TAG, "Forwarding to the WebView: " + message); - mWebView.loadUrl("javascript:window.TheFakeWebSocket.onmessage({'data':" + message + "});"); -} -}); +/* Debug only: in case the message is too long, truncated in the logcat, and you need to see it. +final int size = 80; +for (int start = 0; start < message.length(); start += size) { +Log.i(TAG, "split: " + message.substring(start, Math.min(message.length(), start + size))); +} +*/ + + mWebView.loadUrl("javascript:window.TheFakeWebSocket.onmessage({'data':" + message + "});"); +} +}); // update progress bar when loading if (message.startsWith("'statusindicator") || message.startsWith("'error:")) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-5' - android/lib
android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java |6 ++ 1 file changed, 6 insertions(+) New commits: commit 359326e4222d516c245f46d30c5ee16949571b45 Author: Jan Holesovsky AuthorDate: Fri Jul 3 23:07:47 2020 +0200 Commit: Jan Holesovsky CommitDate: Fri Jul 3 23:20:24 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/+/97902 Tested-by: Jan Holesovsky Reviewed-by: Jan Holesovsky 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 d6d9f804b..855fa63b0 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(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-5' - android/lib
android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java | 16 -- 1 file changed, 14 insertions(+), 2 deletions(-) New commits: commit 922e043d946c84179008bdac9e4f8683a07f7f37 Author: Jan Holesovsky AuthorDate: Fri Jul 3 22:38:23 2020 +0200 Commit: Jan Holesovsky CommitDate: Fri Jul 3 23:14:46 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/+/97901 Tested-by: Jan Holesovsky Reviewed-by: Jan Holesovsky 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..d6d9f804b 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -483,7 +483,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; @@ -582,7 +588,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; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-5' - android/lib
android/lib/build.gradle |6 ++ 1 file changed, 6 insertions(+) New commits: commit c62447a4e64b289054b8f44b8356ef1ec9b1099b Author: Jan Holesovsky AuthorDate: Fri Jul 3 15:25:43 2020 +0200 Commit: Jan Holesovsky CommitDate: Fri Jul 3 16:35:23 2020 +0200 android: Always re-do the fonts.conf, to update when the filter changed. No idea how to add dependency on the build.gradle itself, so at least this... Change-Id: I7d43064d3a2299929b36a3ed3d5c13ada808c898 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97869 Tested-by: Jan Holesovsky Reviewed-by: Jan Holesovsky diff --git a/android/lib/build.gradle b/android/lib/build.gradle index b4a45fefd..2a6c79f63 100644 --- a/android/lib/build.gradle +++ b/android/lib/build.gradle @@ -113,6 +113,12 @@ task copyUnpackAssets(type: Copy) { into('etc/fonts') { from "${liboSrcRoot}/android/source/" includes = ['fonts.conf'] +doFirst { +// we have changed the filter below; so to always re-generate this +// file, delete it first - no idea how to set a dependency on +// build.gradle changes :-( +file('fonts.conf').delete() +} filter { String line -> line.replaceAll( ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits