summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToma┼ż Vajngerl <tomaz.vajngerl@collabora.co.uk>2015-04-08 18:24:48 +0900
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-04-13 09:07:02 +0200
commit5d7a203bdae1940e4846c4c42f5d733e4ffa4160 (patch)
treee5a7166c37ee4e4412ff5bedd081975c044a04c7
parente585b1206905ba57e98483b8295f78a384291b01 (diff)
android: reposition the viewport to the cursor at key event
Change-Id: I9b18001d0629e203bee41ebbf4a3bd57adfea88e
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/InvalidationHandler.java12
-rw-r--r--android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java1
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);
}