tdf#89705: provides callback for url handling on android.

Change-Id: Ie28cd768519fbdc305f98e1d764d05bd209951ca
This commit is contained in:
Siqi Liu
2015-03-06 13:35:34 +01:00
committed by Miklos Vajna
parent 5aa19be38f
commit 619f033d39
3 changed files with 26 additions and 2 deletions

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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;