diff options
author | Jan Holesovsky <kendy@collabora.com> | 2019-08-10 00:21:50 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-08-10 00:21:50 +0200 |
commit | f1f9b5af886ee866c33455a1f0ae487ddf5eba04 (patch) | |
tree | 18fade15a93ef0abf89ccdb768d1cb582be1afe0 | |
parent | 483440f848eb827c7d116fa0f268414b3c0a185a (diff) |
android: Framework to be able to broadcast to another activity.coas-0.3.0
Change-Id: I24634c5e06223bd1c5cdb8da511159b03ce35719
-rw-r--r-- | android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java | 9 | ||||
-rw-r--r-- | loleaflet/js/toolbar.js | 7 |
2 files changed, 14 insertions, 2 deletions
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 8c8ae52b8..81d9536bb 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -533,7 +533,8 @@ public class LOActivity extends AppCompatActivity { * return true to pass the message to the native part or false to block the message */ boolean interceptMsgFromWebView(String message) { - switch (message) { + String[] messageAndParam = message.split(" ", 2); // the command and the rest (that can potentially contain spaces too) + switch (messageAndParam[0]) { case "PRINT": mainHandler.post(new Runnable() { @Override @@ -545,6 +546,9 @@ public class LOActivity extends AppCompatActivity { case "SLIDESHOW": initiateSlideShow(); return false; + case "SAVE": + sendBroadcast(messageAndParam[0], messageAndParam[1]); + return false; case "uno .uno:Paste": clipData = clipboardManager.getPrimaryClip(); if (clipData != null) { @@ -627,6 +631,9 @@ public class LOActivity extends AppCompatActivity { }); } + /** Could be overridden if it's necessary to forward some callbacks elsewhere. */ + public void sendBroadcast(String event, String data) {} + public native void saveAs(String fileUri, String format); public native String getTextSelection(); diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js index bfc40b7eb..ac87170b0 100644 --- a/loleaflet/js/toolbar.js +++ b/loleaflet/js/toolbar.js @@ -2134,7 +2134,12 @@ function onCommandResult(e) { // add the result reason string if failed postMessageObj['result'] = e.result && e.result.value; } - map.fire('postMessage', {msgId: 'Action_Save_Resp', args: postMessageObj}); + + if (window.ThisIsAMobileApp) { + window.postMobileMessage('SAVE ' + JSON.stringify(postMessageObj)); + } else { + map.fire('postMessage', {msgId: 'Action_Save_Resp', args: postMessageObj}); + } } else if ((commandName === '.uno:Undo' || commandName === '.uno:Redo') && e.success === true && e.result.value && !isNaN(e.result.value)) { /*UNDO_CONFLICT*/ |