[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - android/Bootstrap android/experimental include/LibreOfficeKit

Siqi Liu me at siqi.fr
Fri Mar 6 04:36:36 PST 2015


 android/Bootstrap/src/org/libreoffice/kit/Document.java                         |    2 +
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java |   18 +++++++++-
 include/LibreOfficeKit/LibreOfficeKitEnums.h                                    |    8 +++-
 3 files changed, 26 insertions(+), 2 deletions(-)

New commits:
commit ab934a73748a6f8b393f386968b6ce94e4f6a884
Author: Siqi Liu <me at siqi.fr>
Date:   Fri Mar 6 13:35:34 2015 +0100

    tdf#89705: provides callback for url handling on android.
    
    Change-Id: Ie28cd768519fbdc305f98e1d764d05bd209951ca

diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 8c20f70..56d92b0 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -40,6 +40,8 @@ public class Document {
     public static final int CALLBACK_TEXT_SELECTION_START = 3;
     public static final int CALLBACK_TEXT_SELECTION_END = 4;
     public static final int CALLBACK_CURSOR_VISIBLE = 5;
+    // LOK_CALLBACK_GRAPHIC_SELECTION = 6
+    public static final int CALLBACK_HYPERLINK_CLICKED = 7;
 
     /**
      * Text selection types
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 0ef12c6..179c6ff 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -5,6 +5,8 @@ import android.graphics.PointF;
 import android.graphics.RectF;
 import android.util.Log;
 import android.view.KeyEvent;
+import android.net.Uri;
+import android.content.Intent;
 
 import org.libreoffice.kit.DirectBufferAllocator;
 import org.libreoffice.kit.Document;
@@ -411,10 +413,24 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
      */
     @Override
     public void messageRetrieved(int messageID, String payload) {
+        /**
+         * Handles messages that do not require entering editing mode.
+         */
+        switch (messageID) {
+            case Document.CALLBACK_HYPERLINK_CLICKED:
+                if (!payload.startsWith("http://") &&
+                        !payload.startsWith("https://"))
+                    payload = "http://" + payload;
+
+                Intent url_intent = new Intent(Intent.ACTION_VIEW);
+                url_intent.setData(Uri.parse(payload));
+                LibreOfficeMainActivity.mAppContext.startActivity(url_intent);
+                return;
+        }
+
         if (!LOKitShell.isEditingEnabled()) {
             return;
         }
-
         mInvalidationHandler.processMessage(messageID, payload);
     }
 }
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index cc5a32b..b8ab5f6 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -94,7 +94,13 @@ typedef enum
      *
      * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES.
      */
-    LOK_CALLBACK_GRAPHIC_SELECTION
+    LOK_CALLBACK_GRAPHIC_SELECTION,
+
+    /**
+     * User clicked on an hyperlink that should be handled by other
+     * applications accordingly.
+     */
+    LOK_CALLBACK_HYPERLINK_CLICKED
 }
 LibreOfficeKitCallbackType;
 


More information about the Libreoffice-commits mailing list