diff options
author | Tor Lillqvist <tml@iki.fi> | 2013-02-27 21:00:02 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2013-02-27 21:00:53 +0200 |
commit | 7cf5fea49991cce9198d43d63a5fb403234f6d4c (patch) | |
tree | 99cb6def8167de9c1f90642e5661d3b6d6bcc464 | |
parent | 86d734c03bcb57d11347404e2cbc7586981bc6e4 (diff) |
Send text input to the LO code
Change-Id: I28070fb1a8b85c9737d2a78a8a713243ce47dde9
-rw-r--r-- | android/experimental/desktop/src/org/libreoffice/android/experimental/desktop/Desktop.java | 5 | ||||
-rw-r--r-- | vcl/android/androidinst.cxx | 29 |
2 files changed, 33 insertions, 1 deletions
diff --git a/android/experimental/desktop/src/org/libreoffice/android/experimental/desktop/Desktop.java b/android/experimental/desktop/src/org/libreoffice/android/experimental/desktop/Desktop.java index a3eb4d64dcc9..5c5433062db1 100644 --- a/android/experimental/desktop/src/org/libreoffice/android/experimental/desktop/Desktop.java +++ b/android/experimental/desktop/src/org/libreoffice/android/experimental/desktop/Desktop.java @@ -45,6 +45,7 @@ public class Desktop /* implementend by vcl */ public static native void renderVCL(Bitmap bitmap); public static native void setViewSize(int width, int height); + public static native void key(char c, short timestamp); /** * This class contains the state that is initialized once and never changes @@ -217,6 +218,10 @@ public class Desktop @Override public boolean commitText(CharSequence text, int newCursorPosition) { Log.i(TAG, "commitText(" + text + ", " + newCursorPosition + ")"); + short timestamp = (short) (System.currentTimeMillis() % Short.MAX_VALUE); + for (int i = 0; i < text.length(); i++) { + Desktop.key(text.charAt(i), timestamp); + } return true; } } diff --git a/vcl/android/androidinst.cxx b/vcl/android/androidinst.cxx index 2bdcf8a61508..b94855df1c75 100644 --- a/vcl/android/androidinst.cxx +++ b/vcl/android/androidinst.cxx @@ -39,6 +39,7 @@ #define LOGTAG "LibreOffice/androidinst" #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__)) +#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, LOGTAG, __VA_ARGS__)) #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOGTAG, __VA_ARGS__)) static bool bHitIdle = false; @@ -463,6 +464,8 @@ void AndroidSalInstance::onAppCmd (struct android_app* app, int32_t cmd) } } +#endif + /* * Try too hard to get a frame, in the absence of anything better to do */ @@ -486,6 +489,8 @@ SalFrame *AndroidSalInstance::getFocusFrame() const return pFocus; } +#if 0 + int32_t AndroidSalInstance::onInputEvent (struct android_app* app, AInputEvent* event) { bool bHandled = false; @@ -960,7 +965,7 @@ typedef struct ANativeWindow_Buffer { extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_experimental_desktop_Desktop_setViewSize(JNIEnv * /* env */, - jobject /* object */, + jobject /* clazz */, jint width, jint height) { @@ -969,4 +974,26 @@ Java_org_libreoffice_experimental_desktop_Desktop_setViewSize(JNIEnv * /* env */ viewHeight = height; } +extern "C" SAL_JNI_EXPORT void JNICALL +Java_org_libreoffice_experimental_desktop_Desktop_key(JNIEnv * /* env */, + jobject /* clazz */, + jchar c, + jshort timestamp) +{ + SalKeyEvent aEvent; + + aEvent.mnCharCode = c; + aEvent.mnTime = timestamp; + aEvent.mnCode = c; + aEvent.mnRepeat = 0; + + SalFrame *pFocus = AndroidSalInstance::getInstance()->getFocusFrame(); + if (pFocus) { + pFocus->CallCallback( SALEVENT_KEYINPUT, &aEvent ); + pFocus->CallCallback( SALEVENT_KEYUP, &aEvent ); + } + else + LOGW("No focused frame to emit event on"); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |