summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-02-28 00:24:33 +0200
committerTor Lillqvist <tml@iki.fi>2013-02-28 00:25:01 +0200
commit3cf4f1a13b61592b1af8040692029216d9c90d4c (patch)
tree5d755fc646a0e4109402732da7396684a8347d43 /android
parente2e68b5c65911fa75ed5b3935e0cf1ca0fabc2d8 (diff)
Handle touch events
Change-Id: I9c9d200731df9ba48ee61f7c97692ed9b9f06648
Diffstat (limited to 'android')
-rw-r--r--android/experimental/desktop/src/org/libreoffice/android/experimental/desktop/Desktop.java35
1 files changed, 33 insertions, 2 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 5c5433062db1..ba3d6da05b0e 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
@@ -23,6 +23,7 @@ import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
import android.view.MotionEvent;
+import android.view.ScaleGestureDetector;
import android.view.View;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
@@ -46,6 +47,7 @@ public class Desktop
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);
+ public static native void touch(int action, int x, int y, short timestamp);
/**
* This class contains the state that is initialized once and never changes
@@ -152,11 +154,21 @@ public class Desktop
{
Bitmap mBitmap;
boolean renderedOnce;
+ ScaleGestureDetector gestureDetector;
public BitmapView()
{
super(Desktop.this);
setFocusableInTouchMode(true);
+ gestureDetector =
+ new ScaleGestureDetector(Desktop.this,
+ new ScaleGestureDetector.SimpleOnScaleGestureListener() {
+ @Override public boolean onScale(ScaleGestureDetector detector)
+ {
+ Log.i(TAG, "onScale: " + detector.getScaleFactor());
+ return true;
+ }
+ });
}
@Override protected void onDraw(Canvas canvas)
@@ -182,13 +194,32 @@ public class Desktop
return super.onTouchEvent(event);
super.onTouchEvent(event);
- Log.d(TAG, "onTOUCH");
- if (event.getAction() == MotionEvent.ACTION_UP) {
+ Log.d(TAG, "onTouch (" + event.getX() + "," + event.getY() + ")");
+
+ // Just temporary hack. We should not show the keyboard
+ // unconditionally on a ACTION_UP event here. The LO level
+ // should callback to us requesting showing the keyboard
+ // if the user taps in a text area. Also, if the device
+ // has a hardware keyboard, we probably should not show
+ // the soft one unconditionally? But what if the user
+ // wants to input in another script than what the hardware
+ // keyboard covers?
+ if (event.getActionMasked() == MotionEvent.ACTION_UP) {
// show the keyboard so we can enter text
InputMethodManager imm = (InputMethodManager) getContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(this, InputMethodManager.SHOW_FORCED);
}
+
+ switch (event.getActionMasked()) {
+ case MotionEvent.ACTION_DOWN:
+ case MotionEvent.ACTION_UP:
+ case MotionEvent.ACTION_MOVE:
+ short timestamp = (short) (System.currentTimeMillis() % Short.MAX_VALUE);
+ Desktop.touch(event.getActionMasked(), (int) event.getX(), (int) event.getY(), timestamp);
+ break;
+ }
+
return true;
}