diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-02-26 18:48:47 +0900 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-03-02 08:50:58 +0100 |
commit | bb0892de8f54e8f6f2b6427c4d839fef217b03f4 (patch) | |
tree | f873201c5c11b8674af82762c814ac0e9ef1f030 /android | |
parent | cb08fbbd2ac8816c48c8439895ee809a4359278c (diff) |
android: add LOEvent to report handle position changes
With LOEvent CHANGE_HANDLE_POSITION we can report handle (start
and end selelection change and cursor change) to the LOKitThread.
Change-Id: Ia247acc147e54a1f05999a5e55786367c4377091
Diffstat (limited to 'android')
3 files changed, 24 insertions, 7 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java index e5afe1684203..a0469883f04d 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java @@ -5,6 +5,7 @@ import android.graphics.RectF; import android.view.KeyEvent; import android.view.MotionEvent; +import org.mozilla.gecko.TextSelectionHandle; import org.mozilla.gecko.gfx.ComposedTileLayer; import org.mozilla.gecko.gfx.IntSize; import org.mozilla.gecko.gfx.SubTile; @@ -19,6 +20,7 @@ public class LOEvent implements Comparable<LOEvent> { public static final int TILE_INVALIDATION = 7; public static final int TOUCH = 8; public static final int KEY_EVENT = 9; + public static final int CHANGE_HANDLE_POSITION = 10; public final int mType; public int mPriority = 0; @@ -29,9 +31,10 @@ public class LOEvent implements Comparable<LOEvent> { public String mFilename; public ComposedTileLayer mComposedTileLayer; public String mTouchType; - public PointF mDocumentTouchCoordinate; + public PointF mDocumentCoordinate; public KeyEvent mKeyEvent; public RectF mInvalidationRect; + public TextSelectionHandle.HandleType mHandleType; public LOEvent(int type) { mType = type; @@ -65,7 +68,7 @@ public class LOEvent implements Comparable<LOEvent> { mType = type; mTypeString = "Touch"; mTouchType = touchType; - mDocumentTouchCoordinate = documentTouchCoordinate; + mDocumentCoordinate = documentTouchCoordinate; } public LOEvent(int type, KeyEvent keyEvent) { @@ -80,6 +83,12 @@ public class LOEvent implements Comparable<LOEvent> { mInvalidationRect = rect; } + public LOEvent(int type, TextSelectionHandle.HandleType handleType, PointF documentCoordinate) { + mType = type; + mHandleType = handleType; + mDocumentCoordinate = documentCoordinate; + } + public String getTypeString() { if (mTypeString == null) { return "Event type: " + mType; diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java index 809b4c1a62a3..68ab523e8e31 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java @@ -10,6 +10,7 @@ import android.util.DisplayMetrics; import android.view.KeyEvent; import android.view.MotionEvent; +import org.mozilla.gecko.TextSelectionHandle; import org.mozilla.gecko.gfx.ComposedTileLayer; import org.mozilla.gecko.gfx.LayerView; import org.mozilla.gecko.gfx.SubTile; @@ -126,4 +127,11 @@ public class LOKitShell { public static void sendTileInvalidationRequest(RectF rect) { LOKitShell.sendEvent(new LOEvent(LOEvent.TILE_INVALIDATION, rect)); } + + /** + * Send change handle position event to LOKitThread. + */ + public static void sendChangeHandlePositionEvent(TextSelectionHandle.HandleType handleType, PointF documentCoordinate) { + LOKitShell.sendEvent(new LOEvent(LOEvent.CHANGE_HANDLE_POSITION, handleType, documentCoordinate)); + } } diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java index 6fb6f3ae9347..295d982139af 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java @@ -196,7 +196,7 @@ public class LOKitThread extends Thread { createThumbnail(event.mTask); break; case LOEvent.TOUCH: - touch(event.mTouchType, event.mDocumentTouchCoordinate); + touch(event.mTouchType, event.mDocumentCoordinate); break; case LOEvent.KEY_EVENT: keyEvent(event.mKeyEvent); @@ -223,7 +223,7 @@ public class LOKitThread extends Thread { /** * Processes touch events. */ - private void touch(String touchType, PointF mDocumentTouchCoordinate) { + private void touch(String touchType, PointF documentCoordinate) { if (!LOKitShell.isEditingEnabled()) { return; } @@ -233,12 +233,12 @@ public class LOKitThread extends Thread { if (touchType.equals("LongPress")) { LibreOfficeMainActivity.mAppContext.hideSoftKeyboard(); mInvalidationHandler.setOverlayState(InvalidationHandler.OverlayState.SELECTION); - mTileProvider.mouseButtonDown(mDocumentTouchCoordinate, 2); + mTileProvider.mouseButtonDown(documentCoordinate, 2); } else { // "SingleTap" LibreOfficeMainActivity.mAppContext.showSoftKeyboard(); mInvalidationHandler.setOverlayState(InvalidationHandler.OverlayState.CURSOR); - mTileProvider.mouseButtonDown(mDocumentTouchCoordinate, 1); - mTileProvider.mouseButtonUp(mDocumentTouchCoordinate, 1); + mTileProvider.mouseButtonDown(documentCoordinate, 1); + mTileProvider.mouseButtonUp(documentCoordinate, 1); } } |