diff options
| author | Haoyu Zhang <haoyuchang@google.com> | 2022-01-20 09:54:54 -0800 |
|---|---|---|
| committer | Haoyu Zhang <haoyuchang@google.com> | 2022-01-20 16:31:04 -0800 |
| commit | 57620822d372f3b5cce69ea6bc89c8e147b6657b (patch) | |
| tree | 9b9146dd204cb53e0e509cad44f03d6a271a095f /core/java/android | |
| parent | 8b22e7b706b7abe16e36a7293cfc407a65b82837 (diff) | |
Scribe in View: enable Handwriting
Bug: 209854913
Test: atest FrameworksCoreTests:HandwritingInitiatorTest
Change-Id: I8449b3d9e713e226a2cd2b772103e79bf65b88c9
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/HandwritingInitiator.java | 36 | ||||
| -rw-r--r-- | core/java/android/view/inputmethod/InputMethodManager.java | 2 |
2 files changed, 7 insertions, 31 deletions
diff --git a/core/java/android/view/HandwritingInitiator.java b/core/java/android/view/HandwritingInitiator.java index 8524ac846d1a..097d1d0df51b 100644 --- a/core/java/android/view/HandwritingInitiator.java +++ b/core/java/android/view/HandwritingInitiator.java @@ -19,7 +19,6 @@ package android.view; import android.annotation.NonNull; import android.annotation.Nullable; import android.graphics.Rect; -import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import com.android.internal.annotations.VisibleForTesting; @@ -75,11 +74,6 @@ public class HandwritingInitiator { @VisibleForTesting public WeakReference<View> mConnectedView = null; - /** The editor bound reported by the connected View. */ - @Nullable - @VisibleForTesting - public Rect mEditorBound = null; - /** * When InputConnection restarts for a View, View#onInputConnectionCreatedInternal * might be called before View#onInputConnectionClosedInternal, so we need to count the input @@ -174,9 +168,8 @@ public class HandwritingInitiator { * @param view the view that created the current InputConnection. * @see #onInputConnectionClosed(View) */ - public void onInputConnectionCreated(@NonNull View view, @NonNull EditorInfo editorInfo) { + public void onInputConnectionCreated(@NonNull View view) { final View connectedView = getConnectedView(); -// updateEditorBound(editorInfo.getInitialEditorBound()); if (connectedView == view) { ++mConnectionCount; } else { @@ -198,33 +191,15 @@ public class HandwritingInitiator { --mConnectionCount; if (mConnectionCount == 0) { mConnectedView = null; - mEditorBound = null; } } else { // Unexpected branch, set mConnectedView to null to avoid further problem. mConnectedView = null; - mEditorBound = null; mConnectionCount = 0; } } /** - * Notify the HandwritingInitiator that editor bound of the connected view(the view with - * active InputConnection) has be updated. - * @param editorBound new the editor bounds of the connected view. - */ - public void updateEditorBound(@NonNull Rect editorBound) { - if (mEditorBound == null) { - mEditorBound = new Rect(editorBound); - } else { - mEditorBound.left = editorBound.left; - mEditorBound.top = editorBound.top; - mEditorBound.right = editorBound.right; - mEditorBound.bottom = editorBound.bottom; - } - } - - /** * Try to initiate handwriting. For this method to successfully send startHandwriting signal, * the following 3 conditions should meet: * a) The stylus movement exceeds the touchSlop. @@ -240,18 +215,19 @@ public class HandwritingInitiator { return; } final View connectedView = getConnectedView(); - if (connectedView == null || mEditorBound == null) { + if (connectedView == null) { return; } final ViewParent viewParent = connectedView.getParent(); // Do a final check before startHandwriting. if (viewParent != null && connectedView.isAttachedToWindow()) { - final Rect editorBounds = new Rect(mEditorBound); + final Rect editorBounds = + new Rect(0, 0, connectedView.getWidth(), connectedView.getHeight()); if (viewParent.getChildVisibleRect(connectedView, editorBounds, null)) { final int roundedInitX = Math.round(mState.mStylusDownX); final int roundedInitY = Math.round(mState.mStylusDownY); if (editorBounds.contains(roundedInitX, roundedInitY)) { - startHandwriting(mConnectedView.get()); + startHandwriting(connectedView); } } } @@ -261,7 +237,7 @@ public class HandwritingInitiator { /** For test only. */ @VisibleForTesting public void startHandwriting(View view) { - // mImm.startHandwriting(view); + mImm.startStylusHandwriting(view); } private boolean largerThanTouchSlop(float x1, float y1, float x2, float y2) { diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 6fc246eb2514..6a22023dc9da 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -2139,7 +2139,7 @@ public final class InputMethodManager { view.onInputConnectionOpenedInternal(ic, tba, icHandler); final ViewRootImpl viewRoot = view.getViewRootImpl(); if (viewRoot != null) { - viewRoot.getHandwritingInitiator().onInputConnectionCreated(view, tba); + viewRoot.getHandwritingInitiator().onInputConnectionCreated(view); } } |
