Kaydet (Commit) 5d7a203b authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Miklos Vajna

android: reposition the viewport to the cursor at key event

Change-Id: I9b18001d0629e203bee41ebbf4a3bd57adfea88e
üst e585b120
package org.libreoffice; package org.libreoffice;
import android.content.Intent; import android.content.Intent;
import android.graphics.PointF;
import android.graphics.RectF; import android.graphics.RectF;
import android.net.Uri; import android.net.Uri;
...@@ -19,6 +20,7 @@ public class InvalidationHandler implements Document.MessageCallback { ...@@ -19,6 +20,7 @@ public class InvalidationHandler implements Document.MessageCallback {
private static String LOGTAG = InvalidationHandler.class.getSimpleName(); private static String LOGTAG = InvalidationHandler.class.getSimpleName();
private final DocumentOverlay mDocumentOverlay; private final DocumentOverlay mDocumentOverlay;
private OverlayState mState; private OverlayState mState;
private boolean mKeyEvent = false;
public InvalidationHandler(LibreOfficeMainActivity mainActivity) { public InvalidationHandler(LibreOfficeMainActivity mainActivity) {
mDocumentOverlay = mainActivity.getDocumentOverlay(); mDocumentOverlay = mainActivity.getDocumentOverlay();
...@@ -150,6 +152,12 @@ public class InvalidationHandler implements Document.MessageCallback { ...@@ -150,6 +152,12 @@ public class InvalidationHandler implements Document.MessageCallback {
mDocumentOverlay.positionCursor(cursorRectangle); mDocumentOverlay.positionCursor(cursorRectangle);
mDocumentOverlay.positionHandle(SelectionHandle.HandleType.MIDDLE, 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) { if (mState == OverlayState.TRANSITION || mState == OverlayState.CURSOR) {
changeStateTo(OverlayState.CURSOR); changeStateTo(OverlayState.CURSOR);
} }
...@@ -352,6 +360,10 @@ public class InvalidationHandler implements Document.MessageCallback { ...@@ -352,6 +360,10 @@ public class InvalidationHandler implements Document.MessageCallback {
return mState; return mState;
} }
public void keyEvent() {
mKeyEvent = true;
}
public enum OverlayState { public enum OverlayState {
/** /**
* State where the overlay is empty * State where the overlay is empty
......
...@@ -271,6 +271,7 @@ public class LOKitThread extends Thread { ...@@ -271,6 +271,7 @@ public class LOKitThread extends Thread {
if (mTileProvider == null) { if (mTileProvider == null) {
return; return;
} }
mInvalidationHandler.keyEvent();
mTileProvider.sendKeyEvent(keyEvent); mTileProvider.sendKeyEvent(keyEvent);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment