Send text input to the LO code
Change-Id: I28070fb1a8b85c9737d2a78a8a713243ce47dde9
This commit is contained in:
@@ -45,6 +45,7 @@ public class Desktop
|
|||||||
/* implementend by vcl */
|
/* implementend by vcl */
|
||||||
public static native void renderVCL(Bitmap bitmap);
|
public static native void renderVCL(Bitmap bitmap);
|
||||||
public static native void setViewSize(int width, int height);
|
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
|
* 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) {
|
@Override public boolean commitText(CharSequence text, int newCursorPosition) {
|
||||||
Log.i(TAG, "commitText(" + text + ", " + 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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#define LOGTAG "LibreOffice/androidinst"
|
#define LOGTAG "LibreOffice/androidinst"
|
||||||
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
|
#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__))
|
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOGTAG, __VA_ARGS__))
|
||||||
|
|
||||||
static bool bHitIdle = false;
|
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
|
* 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;
|
return pFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
int32_t AndroidSalInstance::onInputEvent (struct android_app* app, AInputEvent* event)
|
int32_t AndroidSalInstance::onInputEvent (struct android_app* app, AInputEvent* event)
|
||||||
{
|
{
|
||||||
bool bHandled = false;
|
bool bHandled = false;
|
||||||
@@ -960,7 +965,7 @@ typedef struct ANativeWindow_Buffer {
|
|||||||
|
|
||||||
extern "C" SAL_JNI_EXPORT void JNICALL
|
extern "C" SAL_JNI_EXPORT void JNICALL
|
||||||
Java_org_libreoffice_experimental_desktop_Desktop_setViewSize(JNIEnv * /* env */,
|
Java_org_libreoffice_experimental_desktop_Desktop_setViewSize(JNIEnv * /* env */,
|
||||||
jobject /* object */,
|
jobject /* clazz */,
|
||||||
jint width,
|
jint width,
|
||||||
jint height)
|
jint height)
|
||||||
{
|
{
|
||||||
@@ -969,4 +974,26 @@ Java_org_libreoffice_experimental_desktop_Desktop_setViewSize(JNIEnv * /* env */
|
|||||||
viewHeight = height;
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Reference in New Issue
Block a user