diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-04-08 18:24:48 +0900 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-04-13 09:07:02 +0200 |
commit | 5d7a203bdae1940e4846c4c42f5d733e4ffa4160 (patch) | |
tree | e5a7166c37ee4e4412ff5bedd081975c044a04c7 /android | |
parent | e585b1206905ba57e98483b8295f78a384291b01 (diff) |
android: reposition the viewport to the cursor at key event
Change-Id: I9b18001d0629e203bee41ebbf4a3bd57adfea88e
Diffstat (limited to 'android')
-rw-r--r-- | android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java | 12 | ||||
-rw-r--r-- | android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java index 7aeb573015f7..9f83006bc785 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java @@ -1,6 +1,7 @@ package org.libreoffice; import android.content.Intent; +import android.graphics.PointF; import android.graphics.RectF; import android.net.Uri; @@ -19,6 +20,7 @@ public class InvalidationHandler implements Document.MessageCallback { private static String LOGTAG = InvalidationHandler.class.getSimpleName(); private final DocumentOverlay mDocumentOverlay; private OverlayState mState; + private boolean mKeyEvent = false; public InvalidationHandler(LibreOfficeMainActivity mainActivity) { mDocumentOverlay = mainActivity.getDocumentOverlay(); @@ -150,6 +152,12 @@ public class InvalidationHandler implements Document.MessageCallback { mDocumentOverlay.positionCursor(cursorRectangle); mDocumentOverlay.positionHandle(SelectionHandle.HandleType.MIDDLE, cursorRectangle); + if (mKeyEvent) { + PointF point = new PointF(cursorRectangle.centerX(), cursorRectangle.centerY()); + LOKitShell.moveViewportTo(point, null); + mKeyEvent = false; + } + if (mState == OverlayState.TRANSITION || mState == OverlayState.CURSOR) { changeStateTo(OverlayState.CURSOR); } @@ -352,6 +360,10 @@ public class InvalidationHandler implements Document.MessageCallback { return mState; } + public void keyEvent() { + mKeyEvent = true; + } + public enum OverlayState { /** * State where the overlay is empty diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java index 1da85f34be5c..cc21840b41ea 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java @@ -271,6 +271,7 @@ public class LOKitThread extends Thread { if (mTileProvider == null) { return; } + mInvalidationHandler.keyEvent(); mTileProvider.sendKeyEvent(keyEvent); } |