Loading core/java/android/view/HandwritingInitiator.java +25 −21 Original line number Diff line number Diff line Loading @@ -249,19 +249,19 @@ public class HandwritingInitiator { return; } Rect handwritingArea = getViewHandwritingArea(connectedView); if (handwritingArea != null) { final Rect handwritingArea = getViewHandwritingArea(connectedView); if (contains(handwritingArea, mState.mStylusDownX, mState.mStylusDownY)) { startHandwriting(connectedView); } } } else { reset(); } } /** For test only. */ @VisibleForTesting public void startHandwriting(@NonNull View view) { mImm.startStylusHandwriting(view); reset(); } /** Loading @@ -287,7 +287,7 @@ public class HandwritingInitiator { final View connectedView = getConnectedView(); if (connectedView != null && connectedView.isAutoHandwritingEnabled()) { final Rect handwritingArea = getViewHandwritingArea(connectedView); if (handwritingArea != null && contains(handwritingArea, x, y)) { if (contains(handwritingArea, x, y)) { return connectedView; } } Loading @@ -298,8 +298,7 @@ public class HandwritingInitiator { for (HandwritableViewInfo viewInfo : handwritableViewInfos) { final View view = viewInfo.getView(); if (!view.isAutoHandwritingEnabled()) continue; final Rect rect = viewInfo.getHandwritingArea(); if (rect != null && contains(rect, x, y)) { if (contains(viewInfo.getHandwritingArea(), x, y)) { return viewInfo.getView(); } } Loading @@ -315,12 +314,15 @@ public class HandwritingInitiator { private static Rect getViewHandwritingArea(@NonNull View view) { final ViewParent viewParent = view.getParent(); if (viewParent != null && view.isAttachedToWindow() && view.isAggregatedVisible()) { Rect handwritingArea = view.getHandwritingArea(); if (handwritingArea == null) { handwritingArea = new Rect(0, 0, view.getWidth(), view.getHeight()); final Rect localHandwritingArea = view.getHandwritingArea(); final Rect globalHandwritingArea = new Rect(); if (localHandwritingArea != null) { globalHandwritingArea.set(localHandwritingArea); } else { globalHandwritingArea.set(0, 0, view.getWidth(), view.getHeight()); } if (viewParent.getChildVisibleRect(view, handwritingArea, null)) { return handwritingArea; if (viewParent.getChildVisibleRect(view, globalHandwritingArea, null)) { return globalHandwritingArea; } } return null; Loading @@ -329,7 +331,8 @@ public class HandwritingInitiator { /** * Return true if the (x, y) is inside by the given {@link Rect}. */ private boolean contains(@NonNull Rect rect, float x, float y) { private boolean contains(@Nullable Rect rect, float x, float y) { if (rect == null) return false; return x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom; } Loading Loading @@ -481,17 +484,18 @@ public class HandwritingInitiator { if (!mIsDirty) { return true; } final Rect localRect = view.getHandwritingArea(); if (localRect == null) { final Rect handwritingArea = view.getHandwritingArea(); if (handwritingArea == null) { return false; } ViewParent parent = view.getParent(); if (parent != null) { final Rect newRect = new Rect(localRect); if (parent.getChildVisibleRect(view, newRect, null /* offset */)) { mHandwritingArea = newRect; } else { if (mHandwritingArea == null) { mHandwritingArea = new Rect(); } mHandwritingArea.set(handwritingArea); if (!parent.getChildVisibleRect(view, mHandwritingArea, null /* offset */)) { mHandwritingArea = null; } } Loading core/java/android/view/View.java +1 −2 Original line number Diff line number Diff line Loading @@ -12016,7 +12016,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Return the handwriting areas set on this view, in its local coordinates. * Notice: the caller of this method should not modify the Rect returned. * @see #setHandwritingArea(Rect) * * @hide Loading @@ -12025,7 +12024,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public Rect getHandwritingArea() { final ListenerInfo info = mListenerInfo; if (info != null) { return info.mHandwritingArea; return new Rect(info.mHandwritingArea); } return null; } Loading
core/java/android/view/HandwritingInitiator.java +25 −21 Original line number Diff line number Diff line Loading @@ -249,19 +249,19 @@ public class HandwritingInitiator { return; } Rect handwritingArea = getViewHandwritingArea(connectedView); if (handwritingArea != null) { final Rect handwritingArea = getViewHandwritingArea(connectedView); if (contains(handwritingArea, mState.mStylusDownX, mState.mStylusDownY)) { startHandwriting(connectedView); } } } else { reset(); } } /** For test only. */ @VisibleForTesting public void startHandwriting(@NonNull View view) { mImm.startStylusHandwriting(view); reset(); } /** Loading @@ -287,7 +287,7 @@ public class HandwritingInitiator { final View connectedView = getConnectedView(); if (connectedView != null && connectedView.isAutoHandwritingEnabled()) { final Rect handwritingArea = getViewHandwritingArea(connectedView); if (handwritingArea != null && contains(handwritingArea, x, y)) { if (contains(handwritingArea, x, y)) { return connectedView; } } Loading @@ -298,8 +298,7 @@ public class HandwritingInitiator { for (HandwritableViewInfo viewInfo : handwritableViewInfos) { final View view = viewInfo.getView(); if (!view.isAutoHandwritingEnabled()) continue; final Rect rect = viewInfo.getHandwritingArea(); if (rect != null && contains(rect, x, y)) { if (contains(viewInfo.getHandwritingArea(), x, y)) { return viewInfo.getView(); } } Loading @@ -315,12 +314,15 @@ public class HandwritingInitiator { private static Rect getViewHandwritingArea(@NonNull View view) { final ViewParent viewParent = view.getParent(); if (viewParent != null && view.isAttachedToWindow() && view.isAggregatedVisible()) { Rect handwritingArea = view.getHandwritingArea(); if (handwritingArea == null) { handwritingArea = new Rect(0, 0, view.getWidth(), view.getHeight()); final Rect localHandwritingArea = view.getHandwritingArea(); final Rect globalHandwritingArea = new Rect(); if (localHandwritingArea != null) { globalHandwritingArea.set(localHandwritingArea); } else { globalHandwritingArea.set(0, 0, view.getWidth(), view.getHeight()); } if (viewParent.getChildVisibleRect(view, handwritingArea, null)) { return handwritingArea; if (viewParent.getChildVisibleRect(view, globalHandwritingArea, null)) { return globalHandwritingArea; } } return null; Loading @@ -329,7 +331,8 @@ public class HandwritingInitiator { /** * Return true if the (x, y) is inside by the given {@link Rect}. */ private boolean contains(@NonNull Rect rect, float x, float y) { private boolean contains(@Nullable Rect rect, float x, float y) { if (rect == null) return false; return x >= rect.left && x < rect.right && y >= rect.top && y < rect.bottom; } Loading Loading @@ -481,17 +484,18 @@ public class HandwritingInitiator { if (!mIsDirty) { return true; } final Rect localRect = view.getHandwritingArea(); if (localRect == null) { final Rect handwritingArea = view.getHandwritingArea(); if (handwritingArea == null) { return false; } ViewParent parent = view.getParent(); if (parent != null) { final Rect newRect = new Rect(localRect); if (parent.getChildVisibleRect(view, newRect, null /* offset */)) { mHandwritingArea = newRect; } else { if (mHandwritingArea == null) { mHandwritingArea = new Rect(); } mHandwritingArea.set(handwritingArea); if (!parent.getChildVisibleRect(view, mHandwritingArea, null /* offset */)) { mHandwritingArea = null; } } Loading
core/java/android/view/View.java +1 −2 Original line number Diff line number Diff line Loading @@ -12016,7 +12016,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Return the handwriting areas set on this view, in its local coordinates. * Notice: the caller of this method should not modify the Rect returned. * @see #setHandwritingArea(Rect) * * @hide Loading @@ -12025,7 +12024,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public Rect getHandwritingArea() { final ListenerInfo info = mListenerInfo; if (info != null) { return info.mHandwritingArea; return new Rect(info.mHandwritingArea); } return null; }