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

Commit b51f07d7 authored by Justin Ghan's avatar Justin Ghan
Browse files

Improve HandwritingInitiator handling of disabled views

Disabled views should still be tracked and considered for the purpose of
finding the best candidate view. However if the best candidate view is
disabled, then the handwriting initiator shouldn't take any further
action. Before this change, the handwriting initiator would try to
request focus which would fail, or try to start handwriting which would
fail.

Test: atest HandwritingInitiatorTest
Change-Id: I69a66dcf702bed54714bb09314fad8700ec510f2
parent 4055e248
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ public class HandwritingInitiator {
                    mState.mExceedHandwritingSlop = true;
                    View candidateView = findBestCandidateView(mState.mStylusDownX,
                            mState.mStylusDownY, /* isHover */ false);
                    if (candidateView != null) {
                    if (candidateView != null && candidateView.isEnabled()) {
                        if (candidateView == getConnectedOrFocusedView()) {
                            if (!mInitiateWithoutConnection && !candidateView.hasFocus()) {
                                requestFocusWithoutReveal(candidateView);
+20 −0
Original line number Diff line number Diff line
@@ -471,6 +471,26 @@ public class HandwritingInitiatorTest {
        verify(mTestView1, times(1)).requestFocus();
    }

    @Test
    public void onTouchEvent_doesNothing_viewDisabled() {
        mTestView1.setEnabled(false);

        final int x1 = (sHwArea1.left + sHwArea1.right) / 2;
        final int y1 = (sHwArea1.top + sHwArea1.bottom) / 2;
        MotionEvent stylusEvent1 = createStylusEvent(ACTION_DOWN, x1, y1, 0);
        mHandwritingInitiator.onTouchEvent(stylusEvent1);

        final int x2 = x1 + mHandwritingSlop * 2;
        final int y2 = y1;

        MotionEvent stylusEvent2 = createStylusEvent(ACTION_MOVE, x2, y2, 0);
        mHandwritingInitiator.onTouchEvent(stylusEvent2);

        // HandwritingInitiator will not request focus if it is disabled.
        verify(mTestView1, never()).requestFocus();
        verify(mHandwritingInitiator, never()).startHandwriting(mTestView1);
    }

    @Test
    public void onTouchEvent_focusView_inputConnectionAlreadyBuilt_stylusMoveOnce_withinHWArea() {
        if (!mInitiateWithoutConnection) {