Kaydet (Commit) b7469087 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Miklos Vajna

android: add key_press event and send them to LOKitThread

Change-Id: I306fbe12e0a91e28bb2308074ded03b768173440
üst 56e7490e
package org.libreoffice; package org.libreoffice;
import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import org.mozilla.gecko.gfx.ComposedTileLayer; import org.mozilla.gecko.gfx.ComposedTileLayer;
...@@ -17,6 +18,7 @@ public class LOEvent implements Comparable<LOEvent> { ...@@ -17,6 +18,7 @@ public class LOEvent implements Comparable<LOEvent> {
public static final int THUMBNAIL = 8; public static final int THUMBNAIL = 8;
public static final int TILE_RERENDER = 9; public static final int TILE_RERENDER = 9;
public static final int TOUCH = 10; public static final int TOUCH = 10;
public static final int KEY_PRESS = 11;
public final int mType; public final int mType;
public int mPriority = 0; public int mPriority = 0;
...@@ -31,6 +33,7 @@ public class LOEvent implements Comparable<LOEvent> { ...@@ -31,6 +33,7 @@ public class LOEvent implements Comparable<LOEvent> {
public SubTile mTile; public SubTile mTile;
public String mTouchType; public String mTouchType;
public MotionEvent mMotionEvent; public MotionEvent mMotionEvent;
public KeyEvent mKeyEvent;
public LOEvent(int type) { public LOEvent(int type) {
mType = type; mType = type;
...@@ -85,6 +88,11 @@ public class LOEvent implements Comparable<LOEvent> { ...@@ -85,6 +88,11 @@ public class LOEvent implements Comparable<LOEvent> {
mMotionEvent = motionEvent; mMotionEvent = motionEvent;
} }
public LOEvent(int type, KeyEvent keyEvent) {
mType = type;
mKeyEvent = keyEvent;
}
public String getTypeString() { public String getTypeString() {
if (mTypeString == null) { if (mTypeString == null) {
return "Event type: " + mType; return "Event type: " + mType;
......
...@@ -3,6 +3,7 @@ package org.libreoffice; ...@@ -3,6 +3,7 @@ package org.libreoffice;
import android.os.Handler; import android.os.Handler;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
...@@ -61,4 +62,8 @@ public class LOKitShell { ...@@ -61,4 +62,8 @@ public class LOKitShell {
public static void sentTouchEvent(String touchType, MotionEvent motionEvent) { public static void sentTouchEvent(String touchType, MotionEvent motionEvent) {
LOKitShell.sendEvent(new LOEvent(LOEvent.TOUCH, "SingleTap", motionEvent)); LOKitShell.sendEvent(new LOEvent(LOEvent.TOUCH, "SingleTap", motionEvent));
} }
public static void sendKeyPressEvent(KeyEvent event) {
LOKitShell.sendEvent(new LOEvent(LOEvent.KEY_PRESS, event));
}
} }
...@@ -9,6 +9,7 @@ import android.os.Handler; ...@@ -9,6 +9,7 @@ import android.os.Handler;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
...@@ -239,6 +240,12 @@ public class LibreOfficeMainActivity extends LOAbout { ...@@ -239,6 +240,12 @@ public class LibreOfficeMainActivity extends LOAbout {
mDrawerLayout.closeDrawer(mDrawerList); mDrawerLayout.closeDrawer(mDrawerList);
} }
} }
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
LOKitShell.sendKeyPressEvent(event);
return super.onKeyDown(keyCode, event);
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment