From 6d9124de6fac2dea39427978993e68155291cc9c Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sun, 1 Nov 2015 22:52:24 +0100 Subject: android: update JNI facade, rename mouse/keyboard event flags Change-Id: Ia2b9a812717d05c7d98d47bf0fe5fd293029d045 --- .../src/java/org/libreoffice/InvalidationHandler.java | 4 +++- android/source/src/java/org/libreoffice/LOEvent.java | 13 +++++++++++-- android/source/src/java/org/libreoffice/LOKitThread.java | 4 ++-- .../src/java/org/libreoffice/LOKitTileProvider.java | 16 ++++++++-------- .../source/src/java/org/libreoffice/TileProvider.java | 2 +- 5 files changed, 25 insertions(+), 14 deletions(-) (limited to 'android/source') diff --git a/android/source/src/java/org/libreoffice/InvalidationHandler.java b/android/source/src/java/org/libreoffice/InvalidationHandler.java index 32fe8530671f..8aec88ca3c42 100644 --- a/android/source/src/java/org/libreoffice/InvalidationHandler.java +++ b/android/source/src/java/org/libreoffice/InvalidationHandler.java @@ -208,7 +208,7 @@ public class InvalidationHandler implements Document.MessageCallback { float newTop = moveToRect.top; if (cursorRectangle.right < moveToRect.left || cursorRectangle.left < moveToRect.left) { - newLeft = cursorRectangle.left - (moveToRect.width() * 0.1f); + newLeft = cursorRectangle.left - (moveToRect.width() * 0.1f); } else if (cursorRectangle.right > moveToRect.right || cursorRectangle.left > moveToRect.right) { newLeft = cursorRectangle.right - (moveToRect.width() * 0.9f); } @@ -306,6 +306,7 @@ public class InvalidationHandler implements Document.MessageCallback { /** * Trigger a transition to a new overlay state. + * * @param next - new state to transition to */ public synchronized void changeStateTo(OverlayState next) { @@ -314,6 +315,7 @@ public class InvalidationHandler implements Document.MessageCallback { /** * Executes a transition from old overlay state to a new overlay state. + * * @param previous - old state * @param next - new state */ diff --git a/android/source/src/java/org/libreoffice/LOEvent.java b/android/source/src/java/org/libreoffice/LOEvent.java index 7067714fd1f6..215512136167 100644 --- a/android/source/src/java/org/libreoffice/LOEvent.java +++ b/android/source/src/java/org/libreoffice/LOEvent.java @@ -47,6 +47,7 @@ public class LOEvent implements Comparable { public KeyEvent mKeyEvent; public RectF mInvalidationRect; public SelectionHandle.HandleType mHandleType; + public String mValue; public LOEvent(int type) { mType = type; @@ -58,10 +59,18 @@ public class LOEvent implements Comparable { mComposedTileLayer = composedTileLayer; } - public LOEvent(int type, String filename) { + public LOEvent(int type, String someString) { mType = type; mTypeString = "String"; - mString = filename; + mString = someString; + mValue = null; + } + + public LOEvent(int type, String key, String value) { + mType = type; + mTypeString = "key / value"; + mString = key; + mValue = value; } public LOEvent(int type, int partIndex) { diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java index d87a152a74bf..a8f4d303293c 100644 --- a/android/source/src/java/org/libreoffice/LOKitThread.java +++ b/android/source/src/java/org/libreoffice/LOKitThread.java @@ -16,7 +16,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.LinkedBlockingQueue; -/* +/** * Thread that communicates with LibreOffice through LibreOfficeKit JNI interface. The thread * consumes events from other threads (mainly the UI thread) and acts accordingly. */ @@ -243,7 +243,7 @@ public class LOKitThread extends Thread { mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.NONE); break; case LOEvent.UNO_COMMAND: - mTileProvider.postUnoCommand(event.mString); + mTileProvider.postUnoCommand(event.mString, event.mValue); break; } } diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java index 6b7759d4a90e..f859b7a1bc62 100644 --- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java @@ -388,12 +388,12 @@ public class LOKitTileProvider implements TileProvider { String keyString = keyEvent.getCharacters(); for (int i = 0; i < keyString.length(); i++) { int codePoint = keyString.codePointAt(i); - mDocument.postKeyEvent(Office.KEY_PRESS, codePoint, getKeyCode(keyEvent)); + mDocument.postKeyEvent(Document.KEY_EVENT_PRESS, codePoint, getKeyCode(keyEvent)); } } else if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) { - mDocument.postKeyEvent(Office.KEY_PRESS, getCharCode(keyEvent), getKeyCode(keyEvent)); + mDocument.postKeyEvent(Document.KEY_EVENT_PRESS, getCharCode(keyEvent), getKeyCode(keyEvent)); } else if (keyEvent.getAction() == KeyEvent.ACTION_UP) { - mDocument.postKeyEvent(Office.KEY_RELEASE, getCharCode(keyEvent), getKeyCode(keyEvent)); + mDocument.postKeyEvent(Document.KEY_EVENT_RELEASE, getCharCode(keyEvent), getKeyCode(keyEvent)); } } @@ -401,7 +401,7 @@ public class LOKitTileProvider implements TileProvider { int x = (int) pixelToTwip(inDocument.x, mDPI); int y = (int) pixelToTwip(inDocument.y, mDPI); - mDocument.postMouseEvent(type, x, y, numberOfClicks); + mDocument.postMouseEvent(type, x, y, numberOfClicks, Document.MOUSE_BUTTON_LEFT, Document.KEYBOARD_MODIFIER_NONE); } /** @@ -409,7 +409,7 @@ public class LOKitTileProvider implements TileProvider { */ @Override public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks) { - mouseButton(Document.MOUSE_BUTTON_DOWN, documentCoordinate, numberOfClicks); + mouseButton(Document.MOUSE_EVENT_BUTTON_DOWN, documentCoordinate, numberOfClicks); } /** @@ -417,12 +417,12 @@ public class LOKitTileProvider implements TileProvider { */ @Override public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks) { - mouseButton(Document.MOUSE_BUTTON_UP, documentCoordinate, numberOfClicks); + mouseButton(Document.MOUSE_EVENT_BUTTON_UP, documentCoordinate, numberOfClicks); } @Override - public void postUnoCommand(String command) { - mDocument.postUnoCommand(command); + public void postUnoCommand(String command, String arguments) { + mDocument.postUnoCommand(command, arguments); } private void setTextSelection(int type, PointF documentCoordinate) { diff --git a/android/source/src/java/org/libreoffice/TileProvider.java b/android/source/src/java/org/libreoffice/TileProvider.java index cf9173a8d1bd..3104172ef5cf 100644 --- a/android/source/src/java/org/libreoffice/TileProvider.java +++ b/android/source/src/java/org/libreoffice/TileProvider.java @@ -114,7 +114,7 @@ public interface TileProvider { * * @param command - the .uno: command, like ".uno:Bold" */ - void postUnoCommand(String command); + void postUnoCommand(String command, String arguments); /** * Send text selection start coordinate. -- cgit