Loading core/java/android/view/HandwritingInitiator.java +5 −5 Original line number Diff line number Diff line Loading @@ -351,13 +351,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(); } Loading Loading @@ -682,7 +682,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(); } /** Loading core/java/android/view/View.java +13 −4 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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. core/java/android/widget/TextView.java +6 −0 Original line number Diff line number Diff line Loading @@ -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++) { Loading @@ -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(); Loading @@ -1891,6 +1896,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } setClickable(clickable); setLongClickable(longClickable); setAutoHandwritingEnabled(isAutoHandwritingEnabled); if (mEditor != null) mEditor.prepareCursorControllers(); Loading core/tests/coretests/src/android/view/stylus/HandwritingInitiatorTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -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( Loading @@ -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); Loading Loading
core/java/android/view/HandwritingInitiator.java +5 −5 Original line number Diff line number Diff line Loading @@ -351,13 +351,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(); } Loading Loading @@ -682,7 +682,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(); } /** Loading
core/java/android/view/View.java +13 −4 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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.
core/java/android/widget/TextView.java +6 −0 Original line number Diff line number Diff line Loading @@ -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++) { Loading @@ -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(); Loading @@ -1891,6 +1896,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } setClickable(clickable); setLongClickable(longClickable); setAutoHandwritingEnabled(isAutoHandwritingEnabled); if (mEditor != null) mEditor.prepareCursorControllers(); Loading
core/tests/coretests/src/android/view/stylus/HandwritingInitiatorTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -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( Loading @@ -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); Loading