diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-03-12 18:16:51 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-03-16 09:38:10 +0100 |
commit | 5df6cd16a2604163ee8e19edadba48de65ba205e (patch) | |
tree | f343572b2513c10f05a41f9455ac78e351a7472f /android | |
parent | e6f7b8823af239a69bc108cce82629c03e41039a (diff) |
android: Make the Bold button actually work - switches to typing in bold.
Change-Id: I48da0f3cc918bda1cdb396b4ea72a82eddafb9a8
Diffstat (limited to 'android')
7 files changed, 31 insertions, 11 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java index 0e0dd594cf58..5d97656879cf 100644 --- a/android/Bootstrap/src/org/libreoffice/kit/Document.java +++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java @@ -133,6 +133,12 @@ public class Document { public native void postMouseEvent(int type, int x, int y, int count); /** + * Post a .uno: command to LOK + * @param command - the command, like ".uno:Bold" + */ + public native void postUnoCommand(String command); + + /** * Change text selection. * @param type - text selection type * @param x - x coordinate diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java index c162c22ceaeb..4413a63e80dd 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOEvent.java @@ -24,14 +24,15 @@ public class LOEvent implements Comparable<LOEvent> { public static final int SWIPE_RIGHT = 11; public static final int SWIPE_LEFT = 12; public static final int NAVIGATION_CLICK = 13; + public static final int UNO_COMMAND = 14; public final int mType; public int mPriority = 0; - public String mTypeString; + private String mTypeString; public ThumbnailCreator.ThumbnailCreationTask mTask; public int mPartIndex; - public String mFilename; + public String mString; public ComposedTileLayer mComposedTileLayer; public String mTouchType; public PointF mDocumentCoordinate; @@ -51,8 +52,8 @@ public class LOEvent implements Comparable<LOEvent> { public LOEvent(int type, String filename) { mType = type; - mTypeString = "Filename"; - mFilename = filename; + mTypeString = "String"; + mString = filename; } public LOEvent(int type, int partIndex) { diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java index ea7cc31b183a..12e48999e1b1 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java @@ -178,7 +178,7 @@ public class LOKitThread extends Thread { private void processEvent(LOEvent event) { switch (event.mType) { case LOEvent.LOAD: - loadDocument(event.mFilename); + loadDocument(event.mString); break; case LOEvent.CLOSE: closeDocument(); @@ -216,6 +216,9 @@ public class LOKitThread extends Thread { case LOEvent.NAVIGATION_CLICK: mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.NONE); break; + case LOEvent.UNO_COMMAND: + mTileProvider.postUnoCommand(event.mString); + break; } } diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java index eb8522cfcb8d..9bab22bd3a39 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java @@ -359,6 +359,11 @@ public class LOKitTileProvider implements TileProvider { mouseButton(Document.MOUSE_BUTTON_UP, documentCoordinate, numberOfClicks); } + @Override + public void postUnoCommand(String command) { + mDocument.postUnoCommand(command); + } + private void setTextSelection(int type, PointF documentCoordinate) { int x = (int) pixelToTwip(documentCoordinate.x, mDPI); int y = (int) pixelToTwip(documentCoordinate.y, mDPI); diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java index c0e481071ac0..e1af1e293e7a 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java @@ -77,7 +77,7 @@ public class LibreOfficeMainActivity extends ActionBarActivity { int id = item.getItemId(); switch (id) { case R.id.action_bold: - Toast.makeText(this,"set text to bold", Toast.LENGTH_LONG).show(); + LOKitShell.sendEvent(new LOEvent(LOEvent.UNO_COMMAND, ".uno:Bold")); return true; case R.id.action_about: mAbout.showAbout(); diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java index 9ec55ad0b24c..c30c1bb21629 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java @@ -91,32 +91,30 @@ public class MockTileProvider implements TileProvider { @Override public void sendKeyEvent(KeyEvent keyEvent) { - } @Override public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks) { - } @Override public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks) { + } + @Override + public void postUnoCommand(String command) { } @Override public void setTextSelectionStart(PointF documentCoordinate) { - } @Override public void setTextSelectionEnd(PointF documentCoordinate) { - } @Override public void setTextSelectionReset(PointF documentCoordinate) { - } @Override diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java index 128344f5fe64..1b34be0bd9f3 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/TileProvider.java @@ -99,6 +99,13 @@ public interface TileProvider { */ void mouseButtonUp(PointF documentCoordinate, int numberOfClicks); + /** + * Post a UNO command to LOK. + * + * @param command - the .uno: command, like ".uno:Bold" + */ + void postUnoCommand(String command); + void setTextSelectionStart(PointF documentCoordinate); void setTextSelectionEnd(PointF documentCoordinate); |