android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java |   80 
+++++-----
 loleaflet/src/control/Control.Toolbar.js                             |    7 
 2 files changed, 51 insertions(+), 36 deletions(-)

New commits:
commit c6f36965cfc1bd68fdb88b01d493163b5d176bcc
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Sat Aug 10 00:21:50 2019 +0200
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Tue Dec 10 17:10:29 2019 +0100

    android: Framework to be able to broadcast to another activity.
    
    Change-Id: I24634c5e06223bd1c5cdb8da511159b03ce35719
    Reviewed-on: https://gerrit.libreoffice.org/84871
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@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 dbb58d0b0..3fe1c317f 100644
--- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
+++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java
@@ -528,7 +528,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
@@ -540,47 +541,53 @@ public class LOActivity extends AppCompatActivity {
             case "SLIDESHOW":
                 initiateSlideShow();
                 return false;
-            case "uno .uno:Paste":
-                clipData = clipboardManager.getPrimaryClip();
-                if (clipData != null) {
-                    if 
(clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
-                        final ClipData.Item clipItem = clipData.getItemAt(0);
+            case "SAVE":
+                sendBroadcast(messageAndParam[0], messageAndParam[1]);
+                return false;
+            case "uno":
+                switch (messageAndParam[1]) {
+                    case ".uno:Paste":
+                        clipData = clipboardManager.getPrimaryClip();
+                        if (clipData != null) {
+                            if 
(clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
+                                final ClipData.Item clipItem = 
clipData.getItemAt(0);
+                                nativeHandler.post(new Runnable() {
+                                    @Override
+                                    public void run() {
+                                        
LOActivity.this.paste("text/plain;charset=utf-16", 
clipItem.getText().toString());
+                                    }
+                                });
+                            }
+                            return false;
+                        }
+                        break;
+                    case ".uno:Copy": {
                         nativeHandler.post(new Runnable() {
                             @Override
                             public void run() {
-                                
LOActivity.this.paste("text/plain;charset=utf-16", 
clipItem.getText().toString());
+                                String tempSelectedText = 
LOActivity.this.getTextSelection();
+                                if (!tempSelectedText.equals("")) {
+                                    clipData = 
ClipData.newPlainText(ClipDescription.MIMETYPE_TEXT_PLAIN, tempSelectedText);
+                                    clipboardManager.setPrimaryClip(clipData);
+                                }
                             }
                         });
+                        break;
                     }
-                    return false;
-                }
-                break;
-            case "uno .uno:Copy": {
-                nativeHandler.post(new Runnable() {
-                    @Override
-                    public void run() {
-                        String tempSelectedText = 
LOActivity.this.getTextSelection();
-                        if (!tempSelectedText.equals("")) {
-                            clipData = 
ClipData.newPlainText(ClipDescription.MIMETYPE_TEXT_PLAIN, tempSelectedText);
-                            clipboardManager.setPrimaryClip(clipData);
-                        }
-                    }
-                });
-                break;
-            }
-            case "uno .uno:Cut": {
-                nativeHandler.post(new Runnable() {
-                    @Override
-                    public void run() {
-                        String tempSelectedText = 
LOActivity.this.getTextSelection();
-                        if (!tempSelectedText.equals("")) {
-                            clipData = 
ClipData.newPlainText(ClipDescription.MIMETYPE_TEXT_PLAIN, tempSelectedText);
-                            clipboardManager.setPrimaryClip(clipData);
-                        }
+                    case ".uno:Cut": {
+                        nativeHandler.post(new Runnable() {
+                            @Override
+                            public void run() {
+                                String tempSelectedText = 
LOActivity.this.getTextSelection();
+                                if (!tempSelectedText.equals("")) {
+                                    clipData = 
ClipData.newPlainText(ClipDescription.MIMETYPE_TEXT_PLAIN, tempSelectedText);
+                                    clipboardManager.setPrimaryClip(clipData);
+                                }
+                            }
+                        });
+                        break;
                     }
-                });
-                break;
-            }
+                }
             case "DIM_SCREEN": {
                 mainHandler.post(new Runnable() {
                     @Override
@@ -640,6 +647,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/src/control/Control.Toolbar.js 
b/loleaflet/src/control/Control.Toolbar.js
index 5d9de3baf..86474ddce 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -2135,7 +2135,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*/
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to