Implement "lift-to-type" interaction. Fix event text.
Bug: 6456970 Change-Id: Idd6b84fc7a730a1e78d9c1157e3b5f22e5d49fc4
This commit is contained in:
parent
7c23ad92fc
commit
6662e2a40d
4 changed files with 34 additions and 5 deletions
|
@ -90,6 +90,7 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat
|
||||||
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
|
final AccessibilityEvent event = AccessibilityEvent.obtain(eventType);
|
||||||
event.setPackageName(mKeyboardView.getContext().getPackageName());
|
event.setPackageName(mKeyboardView.getContext().getPackageName());
|
||||||
event.setClassName(key.getClass().getName());
|
event.setClassName(key.getClass().getName());
|
||||||
|
event.setContentDescription(keyDescription);
|
||||||
event.setEnabled(true);
|
event.setEnabled(true);
|
||||||
|
|
||||||
final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
|
final AccessibilityRecordCompat record = new AccessibilityRecordCompat(event);
|
||||||
|
@ -158,12 +159,12 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat
|
||||||
info = AccessibilityNodeInfoCompat.obtain();
|
info = AccessibilityNodeInfoCompat.obtain();
|
||||||
info.setPackageName(mKeyboardView.getContext().getPackageName());
|
info.setPackageName(mKeyboardView.getContext().getPackageName());
|
||||||
info.setClassName(key.getClass().getName());
|
info.setClassName(key.getClass().getName());
|
||||||
|
info.setContentDescription(keyDescription);
|
||||||
info.setBoundsInParent(boundsInParent);
|
info.setBoundsInParent(boundsInParent);
|
||||||
info.setBoundsInScreen(boundsInScreen);
|
info.setBoundsInScreen(boundsInScreen);
|
||||||
info.setParent(mKeyboardView);
|
info.setParent(mKeyboardView);
|
||||||
info.setSource(mKeyboardView, virtualViewId);
|
info.setSource(mKeyboardView, virtualViewId);
|
||||||
info.setBoundsInScreen(boundsInScreen);
|
info.setBoundsInScreen(boundsInScreen);
|
||||||
info.setText(keyDescription);
|
|
||||||
info.setEnabled(true);
|
info.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v4.view.accessibility.AccessibilityEventCompat;
|
import android.support.v4.view.accessibility.AccessibilityEventCompat;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewConfiguration;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
|
@ -41,6 +42,12 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
|
||||||
|
|
||||||
private Key mLastHoverKey = null;
|
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) {
|
public static void init(InputMethodService inputMethod) {
|
||||||
sInstance.initInternal(inputMethod);
|
sInstance.initInternal(inputMethod);
|
||||||
}
|
}
|
||||||
|
@ -55,6 +62,7 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
|
||||||
|
|
||||||
private void initInternal(InputMethodService inputMethod) {
|
private void initInternal(InputMethodService inputMethod) {
|
||||||
mInputMethod = inputMethod;
|
mInputMethod = inputMethod;
|
||||||
|
mEdgeSlop = ViewConfiguration.get(inputMethod).getScaledEdgeSlop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,8 +116,14 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
|
||||||
mLastHoverKey = key;
|
mLastHoverKey = key;
|
||||||
|
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case MotionEvent.ACTION_HOVER_ENTER:
|
|
||||||
case MotionEvent.ACTION_HOVER_EXIT:
|
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);
|
return onHoverKey(key, event);
|
||||||
case MotionEvent.ACTION_HOVER_MOVE:
|
case MotionEvent.ACTION_HOVER_MOVE:
|
||||||
if (key != previousKey) {
|
if (key != previousKey) {
|
||||||
|
@ -122,6 +136,20 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* 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 previous key, a HOVER_ENTER on the current key, and a HOVER_MOVE
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
final PointerTracker tracker = (PointerTracker) msg.obj;
|
final PointerTracker tracker = (PointerTracker) msg.obj;
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_REPEAT_KEY:
|
case MSG_REPEAT_KEY:
|
||||||
tracker.onRepeatKey(tracker.getKey());
|
tracker.onRegisterKey(tracker.getKey());
|
||||||
startKeyRepeatTimer(tracker, mParams.mKeyRepeatInterval);
|
startKeyRepeatTimer(tracker, mParams.mKeyRepeatInterval);
|
||||||
break;
|
break;
|
||||||
case MSG_LONGPRESS_KEY:
|
case MSG_LONGPRESS_KEY:
|
||||||
|
|
|
@ -714,7 +714,7 @@ public class PointerTracker {
|
||||||
|
|
||||||
private void startRepeatKey(Key key) {
|
private void startRepeatKey(Key key) {
|
||||||
if (key != null && key.isRepeatable()) {
|
if (key != null && key.isRepeatable()) {
|
||||||
onRepeatKey(key);
|
onRegisterKey(key);
|
||||||
mTimerProxy.startKeyRepeatTimer(this);
|
mTimerProxy.startKeyRepeatTimer(this);
|
||||||
mIsRepeatableKey = true;
|
mIsRepeatableKey = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -722,7 +722,7 @@ public class PointerTracker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRepeatKey(Key key) {
|
public void onRegisterKey(Key key) {
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
detectAndSendKey(key, key.mX, key.mY);
|
detectAndSendKey(key, key.mX, key.mY);
|
||||||
if (!key.altCodeWhileTyping() && !key.isModifier()) {
|
if (!key.altCodeWhileTyping() && !key.isModifier()) {
|
||||||
|
|
Loading…
Reference in a new issue