Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38b5e423 authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "Implement "lift-to-type" interaction. Fix event text." into jb-dev

parents 59e6ad38 6662e2a4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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);
        }

+29 −1
Original line number Diff line number Diff line
@@ -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) {
@@ -122,6 +136,20 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat {
        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
     * on the previous key, a HOVER_ENTER on the current key, and a HOVER_MOVE
+1 −1
Original line number Diff line number Diff line
@@ -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:
+2 −2
Original line number Diff line number Diff line
@@ -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()) {