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

Commit 67578618 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Update KeyBoardView to reflect the interaction model in Latin IME

A new patch checked in Latin IME makes it behave like any other Views. Touch
explore announces the letter under the finger and subsequent tap types in the
letter. Making KeyBoardView consistent with that.

bug:5552217

Change-Id: Ifeb6c3f071a5d64d0a16de584bf04ea40fff62fc
parent a9656df5
Loading
Loading
Loading
Loading
+10 −25
Original line number Diff line number Diff line
@@ -1145,44 +1145,29 @@ public class KeyboardView extends View implements View.OnClickListener {

    @Override
    public boolean onHoverEvent(MotionEvent event) {
        // If touch exploring is enabled we ignore touch events and transform
        // the stream of hover events as touch events. This allows one consistent
        // event stream to drive the keyboard since during touch exploring the
        // first touch generates only hover events and tapping on the same
        // location generates hover and touch events.
        if (mAccessibilityManager.isTouchExplorationEnabled() && event.getPointerCount() == 1) {
            final int action = event.getAction();
            switch (action) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    event.setAction(MotionEvent.ACTION_DOWN);
                    break;
                case MotionEvent.ACTION_HOVER_MOVE:
                    event.setAction(MotionEvent.ACTION_MOVE);
                    final int touchX = (int) event.getX() - mPaddingLeft;
                    int touchY = (int) event.getY() - mPaddingTop;
                    if (touchY >= -mVerticalCorrection) {
                        touchY += mVerticalCorrection;
                    }
                    final int keyIndex = getKeyIndices(touchX, touchY, null);
                    showPreview(keyIndex);
                    break;
                case MotionEvent.ACTION_HOVER_EXIT:
                    event.setAction(MotionEvent.ACTION_UP);
                    showPreview(NOT_A_KEY);
                    break;
            }
            onTouchEventInternal(event);
            event.setAction(action);
        }
        return super.onHoverEvent(event);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // If touch exploring is enabled we ignore touch events and transform
        // the stream of hover events as touch events. This allows one consistent
        // event stream to drive the keyboard since during touch exploring the
        // first touch generates only hover events and tapping on the same
        // location generates hover and touch events.
        if (mAccessibilityManager.isTouchExplorationEnabled()) {
        return true;
    }
        return onTouchEventInternal(event);
    }

    private boolean onTouchEventInternal(MotionEvent me) {
    @Override
    public boolean onTouchEvent(MotionEvent me) {
        // Convert multi-pointer up/down events to single up/down events to 
        // deal with the typical multi-pointer behavior of two-thumb typing
        final int pointerCount = me.getPointerCount();