aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorCharles Chen <clchen@google.com>2012-05-11 10:16:05 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-05-11 10:16:05 -0700
commit38b5e4239d5f31f04eaf38951442476eb378c80f (patch)
tree80d9e4d822a08c33d848a8c4ddb4355d87d2327f /java/src
parent59e6ad38748b0d3c2ed63738d6ab5e6f123466d0 (diff)
parent6662e2a40dc764d5b6a55c0e30ce650fd834afb6 (diff)
downloadlatinime-38b5e4239d5f31f04eaf38951442476eb378c80f.tar.gz
latinime-38b5e4239d5f31f04eaf38951442476eb378c80f.tar.xz
latinime-38b5e4239d5f31f04eaf38951442476eb378c80f.zip
Merge "Implement "lift-to-type" interaction. Fix event text." into jb-dev
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java3
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java30
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/PointerTracker.java4
4 files changed, 34 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
index d7cd8e23a..955cb4c42 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
@@ -90,6 +90,7 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
event.setPackageName(mKeyboardView.getContext().getPackageName());
event.setClassName(key.getClass().getName());
+ event.setContentDescription(keyDescription);
event.setEnabled(true);
final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
@@ -158,12 +159,12 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat
info = AccessibilityNodeInfoCompat.obtain();
info.setPackageName(mKeyboardView.getContext().getPackageName());
info.setClassName(key.getClass().getName());
+ info.setContentDescription(keyDescription);
info.setBoundsInParent(boundsInParent);
info.setBoundsInScreen(boundsInScreen);
info.setParent(mKeyboardView);
info.setSource(mKeyboardView, virtualViewId);
info.setBoundsInScreen(boundsInScreen);
- info.setText(keyDescription);
info.setEnabled(true);
}
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index ba814e390..34817ba4e 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -23,6 +23,7 @@ import android.support.v4.view.ViewCompat;
import android.support.v4.view.accessibility.AccessibilityEventCompat;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import com.android.inputmethod.keyboard.Key;
@@ -41,6 +42,12 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
private Key mLastHoverKey = null;
+ /**
+ * Inset in pixels to look for keys when the user's finger exits the
+ * keyboard area. See {@link ViewConfiguration#getScaledEdgeSlop()}.
+ */
+ private int mEdgeSlop;
+
public static void init(InputMethodService inputMethod) {
sInstance.initInternal(inputMethod);
}
@@ -55,6 +62,7 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
private void initInternal(InputMethodService inputMethod) {
mInputMethod = inputMethod;
+ mEdgeSlop = ViewConfiguration.get(inputMethod).getScaledEdgeSlop();
}
/**
@@ -108,8 +116,14 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
mLastHoverKey = key;
switch (event.getAction()) {
- case MotionEvent.ACTION_HOVER_ENTER:
case MotionEvent.ACTION_HOVER_EXIT:
+ // Make sure we're not getting an EXIT event because the user slid
+ // off the keyboard area, then force a key press.
+ if (pointInView(x, y)) {
+ tracker.onRegisterKey(key);
+ }
+ //$FALL-THROUGH$
+ case MotionEvent.ACTION_HOVER_ENTER:
return onHoverKey(key, event);
case MotionEvent.ACTION_HOVER_MOVE:
if (key != previousKey) {
@@ -123,6 +137,20 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
}
/**
+ * Utility method to determine whether the given point, in local
+ * coordinates, is inside the view, where the area of the view is contracted
+ * by the edge slop factor.
+ *
+ * @param localX The local x-coordinate.
+ * @param localY The local y-coordinate.
+ */
+ private boolean pointInView(int localX, int localY) {
+ return (localX >= mEdgeSlop) && (localY >= mEdgeSlop)
+ && (localX < (mView.getWidth() - mEdgeSlop))
+ && (localY < (mView.getHeight() - mEdgeSlop));
+ }
+
+ /**
* Simulates a transition between two {@link Key}s by sending a HOVER_EXIT
* on the previous key, a HOVER_ENTER on the current key, and a HOVER_MOVE
* on the current key.
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index aeca839f1..337ae9c17 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -140,7 +140,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
final PointerTracker tracker = (PointerTracker) msg.obj;
switch (msg.what) {
case MSG_REPEAT_KEY:
- tracker.onRepeatKey(tracker.getKey());
+ tracker.onRegisterKey(tracker.getKey());
startKeyRepeatTimer(tracker, mParams.mKeyRepeatInterval);
break;
case MSG_LONGPRESS_KEY:
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index c62c3ddbc..6ad854d1b 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -714,7 +714,7 @@ public class PointerTracker {
private void startRepeatKey(Key key) {
if (key != null && key.isRepeatable()) {
- onRepeatKey(key);
+ onRegisterKey(key);
mTimerProxy.startKeyRepeatTimer(this);
mIsRepeatableKey = true;
} else {
@@ -722,7 +722,7 @@ public class PointerTracker {
}
}
- public void onRepeatKey(Key key) {
+ public void onRegisterKey(Key key) {
if (key != null) {
detectAndSendKey(key, key.mX, key.mY);
if (!key.altCodeWhileTyping() && !key.isModifier()) {