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

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

Change autoHandwritingEnabled default to false

Bug: 296586357
Test: atest HandwritingInitiatorTest
Change-Id: I430046e7842ecee5aca2ff22fe95d3b8a8a2fa1e
parent 02bc2a69
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -342,13 +342,13 @@ public class HandwritingInitiator {
    }

    private static boolean shouldTriggerStylusHandwritingForView(@NonNull View view) {
        if (!view.isAutoHandwritingEnabled()) {
        if (!view.shouldInitiateHandwriting()) {
            return false;
        }
        // The view may be a handwriting initiation delegate, in which case it is not the editor
        // The view may be a handwriting initiation delegator, in which case it is not the editor
        // view for which handwriting would be started. However, in almost all cases, the return
        // values of View#isStylusHandwritingAvailable will be the same for the delegate view and
        // the delegator editor view. So the delegate view can be used to decide whether handwriting
        // values of View#isStylusHandwritingAvailable will be the same for the delegator view and
        // the delegate editor view. So the delegator view can be used to decide whether handwriting
        // should be triggered.
        return view.isStylusHandwritingAvailable();
    }
@@ -639,7 +639,7 @@ public class HandwritingInitiator {
    /** The helper method to check if the given view is still active for handwriting. */
    private static boolean isViewActive(@Nullable View view) {
        return view != null && view.isAttachedToWindow() && view.isAggregatedVisible()
                && view.isAutoHandwritingEnabled();
                && view.shouldInitiateHandwriting();
    }

    /**
+13 −4
Original line number Diff line number Diff line
@@ -5488,7 +5488,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                (TEXT_ALIGNMENT_DEFAULT << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT) |
                (PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT) |
                (IMPORTANT_FOR_ACCESSIBILITY_DEFAULT << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT);
        mPrivateFlags4 = PFLAG4_AUTO_HANDWRITING_ENABLED;
        final ViewConfiguration configuration = ViewConfiguration.get(context);
        mTouchSlop = configuration.getScaledTouchSlop();
@@ -6213,7 +6212,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
                    setPreferKeepClear(a.getBoolean(attr, false));
                    break;
                case R.styleable.View_autoHandwritingEnabled:
                    setAutoHandwritingEnabled(a.getBoolean(attr, true));
                    setAutoHandwritingEnabled(a.getBoolean(attr, false));
                    break;
                case R.styleable.View_handwritingBoundsOffsetLeft:
                    mHandwritingBoundsOffsetLeft = a.getDimension(attr, 0);
@@ -12078,7 +12077,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        if (getSystemGestureExclusionRects().isEmpty()
                && collectPreferKeepClearRects().isEmpty()
                && collectUnrestrictedPreferKeepClearRects().isEmpty()
                && (info.mHandwritingArea == null || !isAutoHandwritingEnabled())) {
                && (info.mHandwritingArea == null || !shouldInitiateHandwriting())) {
            if (info.mPositionUpdateListener != null) {
                mRenderNode.removePositionUpdateListener(info.mPositionUpdateListener);
                info.mPositionUpdateListener = null;
@@ -12445,13 +12444,23 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    void updateHandwritingArea() {
        // If autoHandwritingArea is not enabled, do nothing.
        if (!isAutoHandwritingEnabled()) return;
        if (!shouldInitiateHandwriting()) return;
        final AttachInfo ai = mAttachInfo;
        if (ai != null) {
            ai.mViewRootImpl.getHandwritingInitiator().updateHandwritingAreasForView(this);
        }
    }
    /**
     * Returns true if a stylus {@link MotionEvent} within this view's bounds should initiate
     * handwriting mode, either for this view ({@link #isAutoHandwritingEnabled()} is {@code true})
     * or for a handwriting delegate view ({@link #getHandwritingDelegatorCallback()} is not {@code
     * null}).
     */
    boolean shouldInitiateHandwriting() {
        return isAutoHandwritingEnabled() || getHandwritingDelegatorCallback() != null;
    }
    /**
     * Sets a callback which should be called when a stylus {@link MotionEvent} occurs within this
     * view's bounds. The callback will be called from the UI thread.
+6 −0
Original line number Diff line number Diff line
@@ -1856,6 +1856,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        boolean clickable = canInputOrMove || isClickable();
        boolean longClickable = canInputOrMove || isLongClickable();
        int focusable = getFocusable();
        boolean isAutoHandwritingEnabled = true;
        n = a.getIndexCount();
        for (int i = 0; i < n; i++) {
@@ -1878,6 +1879,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                case com.android.internal.R.styleable.View_longClickable:
                    longClickable = a.getBoolean(attr, longClickable);
                    break;
                case com.android.internal.R.styleable.View_autoHandwritingEnabled:
                    isAutoHandwritingEnabled = a.getBoolean(attr, true);
                    break;
            }
        }
        a.recycle();
@@ -1891,6 +1896,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
        setClickable(clickable);
        setLongClickable(longClickable);
        setAutoHandwritingEnabled(isAutoHandwritingEnabled);
        if (mEditor != null) mEditor.prepareCursorControllers();
+2 −2
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ public class HandwritingInitiatorTest {

    @Test
    public void onTouchEvent_tryAcceptDelegation_delegatorCallbackCreatesInputConnection() {
        View delegateView = new View(mContext);
        View delegateView = new EditText(mContext);
        delegateView.setIsHandwritingDelegate(true);

        mTestView1.setHandwritingDelegatorCallback(
@@ -266,7 +266,7 @@ public class HandwritingInitiatorTest {

    @Test
    public void onTouchEvent_tryAcceptDelegation_delegatorCallbackFocusesDelegate() {
        View delegateView = new View(mContext);
        View delegateView = new EditText(mContext);
        delegateView.setIsHandwritingDelegate(true);
        mHandwritingInitiator.onInputConnectionCreated(delegateView);
        reset(mHandwritingInitiator);