diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-02-20 14:56:29 +0900 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-23 10:10:29 +0100 |
commit | 532e77cd3886b985f6e61363f563cbaa6c1b4b6d (patch) | |
tree | 637b8e11202626c5043f55280c8ba0855aabe030 /android | |
parent | 4d6eb40f9b433f2f95c5025e1fb26be9039612c5 (diff) |
android: support selection invalidation, show selection handles
Change-Id: I82909e6426d4e9fd5dc7b9c9e6e1b21259cf9a57
Diffstat (limited to 'android')
-rw-r--r-- | android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java index eb7cb40701b6..1fd138871d13 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java @@ -398,6 +398,18 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback case Document.CALLBACK_INVALIDATE_VISIBLE_CURSOR: invalidateCursor(payload); break; + case Document.CALLBACK_INVALIDATE_TEXT_SELECTION: + Log.i(LOGTAG, "Selection: " + payload); + invalidateSelection(payload); + break; + case Document.CALLBACK_INVALIDATE_TEXT_SELECTION_START: + Log.i(LOGTAG, "Selection start: " + payload); + invalidateSelectionStart(payload); + break; + case Document.CALLBACK_INVALIDATE_TEXT_SELECTION_END: + Log.i(LOGTAG, "Selection end: " + payload); + invalidateSelectionEnd(payload); + break; } } @@ -421,6 +433,44 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback LOKitShell.sendTileInvalidationRequest(rect); } } + + private void invalidateSelectionStart(String payload) { + RectF rect = convertCallbackMessageStringToRectF(payload); + if (rect != null) { + RectF underSelection = new RectF(rect.centerX(), rect.bottom, rect.centerX(), rect.bottom); + TextSelection textSelection = LibreOfficeMainActivity.mAppContext.getTextSelection(); + textSelection.positionHandle(TextSelectionHandle.HandleType.START, underSelection); + textSelection.showHandle(TextSelectionHandle.HandleType.START); + + textSelection.hideHandle(TextSelectionHandle.HandleType.MIDDLE); + + TextCursorLayer textCursorLayer = LibreOfficeMainActivity.mAppContext.getTextCursorLayer(); + textCursorLayer.hideCursor(); + } + } + + private void invalidateSelectionEnd(String payload) { + RectF rect = convertCallbackMessageStringToRectF(payload); + if (rect != null) { + RectF underSelection = new RectF(rect.centerX(), rect.bottom, rect.centerX(), rect.bottom); + TextSelection textSelection = LibreOfficeMainActivity.mAppContext.getTextSelection(); + textSelection.positionHandle(TextSelectionHandle.HandleType.END, underSelection); + textSelection.showHandle(TextSelectionHandle.HandleType.END); + + textSelection.hideHandle(TextSelectionHandle.HandleType.MIDDLE); + + TextCursorLayer textCursorLayer = LibreOfficeMainActivity.mAppContext.getTextCursorLayer(); + textCursorLayer.hideCursor(); + } + } + + private void invalidateSelection(String payload) { + if (payload.isEmpty()) { + TextSelection textSelection = LibreOfficeMainActivity.mAppContext.getTextSelection(); + textSelection.hideHandle(TextSelectionHandle.HandleType.START); + textSelection.hideHandle(TextSelectionHandle.HandleType.END); + } + } } // vim:set shiftwidth=4 softtabstop=4 expandtab: |