diff options
| author | 2022-09-23 18:23:23 +0000 | |
|---|---|---|
| committer | 2022-09-23 18:23:23 +0000 | |
| commit | fd032bc0fa4ef050d99dcaa38a876e4d0532537a (patch) | |
| tree | 0058d81e574a246d3f401cf15e88bf50562d3cc2 | |
| parent | 98bd21bdd326a49ed9bfd75a607b24a5da2c5903 (diff) | |
| parent | 9915c4ba8840c0560bed8d4bc76a89f816717dbf (diff) | |
Merge "Revert "Handle non-initalized InkWindow""
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 9ed55ffef11f..7436601f5352 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -967,7 +967,7 @@ public class InputMethodService extends AbstractInputMethodService { Log.d(TAG, "Input should have started before starting Stylus handwriting."); return; } - maybeCreateAndInitInkWindow(); + maybeCreateInkWindow(); if (!mOnPreparedStylusHwCalled) { // prepare hasn't been called by Stylus HOVER. onPrepareStylusHandwriting(); @@ -1027,7 +1027,8 @@ public class InputMethodService extends AbstractInputMethodService { */ @Override public void initInkWindow() { - maybeCreateAndInitInkWindow(); + maybeCreateInkWindow(); + mInkWindow.initOnly(); onPrepareStylusHandwriting(); mOnPreparedStylusHwCalled = true; } @@ -1035,13 +1036,11 @@ public class InputMethodService extends AbstractInputMethodService { /** * Create and attach token to Ink window if it wasn't already created. */ - private void maybeCreateAndInitInkWindow() { + private void maybeCreateInkWindow() { if (mInkWindow == null) { mInkWindow = new InkWindow(mWindow.getContext()); mInkWindow.setToken(mToken); } - mInkWindow.initOnly(); - setInkViewVisibilityListener(); // TODO(b/243571274): set an idle-timeout after which InkWindow is removed. } @@ -2470,19 +2469,13 @@ public class InputMethodService extends AbstractInputMethodService { * @param motionEvent {@link MotionEvent} from stylus. */ public void onStylusHandwritingMotionEvent(@NonNull MotionEvent motionEvent) { - if (mInkWindow != null && mInkWindow.isInkViewVisible()) { + if (mInkWindow.isInkViewVisible()) { mInkWindow.getDecorView().dispatchTouchEvent(motionEvent); } else { if (mPendingEvents == null) { mPendingEvents = new RingBuffer(MotionEvent.class, MAX_EVENTS_BUFFER); } mPendingEvents.append(motionEvent); - setInkViewVisibilityListener(); - } - } - - private void setInkViewVisibilityListener() { - if (mInkWindow != null) { mInkWindow.setInkViewVisibilityListener(() -> { if (mPendingEvents != null && !mPendingEvents.isEmpty()) { for (MotionEvent event : mPendingEvents.toArray()) { @@ -2546,7 +2539,6 @@ public class InputMethodService extends AbstractInputMethodService { mHandler.removeCallbacks(mFinishHwRunnable); } mFinishHwRunnable = null; - mPendingEvents.clear(); final int requestId = mHandwritingRequestId.getAsInt(); mHandwritingRequestId = OptionalInt.empty(); |