Loading core/java/android/inputmethodservice/InkWindow.java +0 −1 Original line number Diff line number Diff line Loading @@ -99,7 +99,6 @@ final class InkWindow extends PhoneWindow { if (getDecorView() != null) { getDecorView().setVisibility(remove ? View.GONE : View.INVISIBLE); } //TODO(b/210039666): remove window from WM after a delay. Delay amount TBD. } void setToken(@NonNull IBinder token) { Loading core/java/android/inputmethodservice/InputMethodService.java +39 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,14 @@ public class InputMethodService extends AbstractInputMethodService { */ private static final int MAX_EVENTS_BUFFER = 500; /** * When IME doesn't receive stylus input for these many milliseconds, Handwriting session * will be finished by calling {@link #finishStylusHandwriting()}. * @see #onStartStylusHandwriting() * @see #onFinishStylusHandwriting() */ private static final int STYLUS_HANDWRITING_IDLE_TIMEOUT_MS = 10000; /** * A circular buffer of size MAX_EVENTS_BUFFER in case IME is taking too long to add ink view. **/ Loading @@ -353,6 +361,7 @@ public class InputMethodService extends AbstractInputMethodService { private Boolean mBackCallbackRegistered = false; private final OnBackInvokedCallback mCompatBackCallback = this::compatHandleBack; private Runnable mImeSurfaceRemoverRunnable; private Runnable mFinishHwRunnable; /** * Returns whether {@link InputMethodService} is responsible for rendering the back button and Loading Loading @@ -996,8 +1005,10 @@ public class InputMethodService extends AbstractInputMethodService { return false; } onStylusHandwritingMotionEvent((MotionEvent) event); scheduleHandwritingSessionTimeout(); return true; }); scheduleHandwritingSessionTimeout(); } /** Loading Loading @@ -2475,6 +2486,10 @@ public class InputMethodService extends AbstractInputMethodService { if (!mHandwritingRequestId.isPresent()) { return; } if (mHandler != null && mFinishHwRunnable != null) { mHandler.removeCallbacks(mFinishHwRunnable); } mFinishHwRunnable = null; final int requestId = mHandwritingRequestId.getAsInt(); mHandwritingRequestId = OptionalInt.empty(); Loading @@ -2488,6 +2503,30 @@ public class InputMethodService extends AbstractInputMethodService { onFinishStylusHandwriting(); } private Runnable getFinishHandwritingRunnable() { if (mFinishHwRunnable != null) { return mFinishHwRunnable; } return mFinishHwRunnable = () -> { if (mHandler != null) { mHandler.removeCallbacks(mFinishHwRunnable); } Log.d(TAG, "Stylus handwriting idle timed-out. calling finishStylusHandwriting()"); mFinishHwRunnable = null; finishStylusHandwriting(); }; } private void scheduleHandwritingSessionTimeout() { if (mHandler == null) { mHandler = new Handler(getMainLooper()); } if (mFinishHwRunnable != null) { mHandler.removeCallbacks(mFinishHwRunnable); } mHandler.postDelayed(getFinishHandwritingRunnable(), STYLUS_HANDWRITING_IDLE_TIMEOUT_MS); } /** * The system has decided that it may be time to show your input method. * This is called due to a corresponding call to your Loading Loading
core/java/android/inputmethodservice/InkWindow.java +0 −1 Original line number Diff line number Diff line Loading @@ -99,7 +99,6 @@ final class InkWindow extends PhoneWindow { if (getDecorView() != null) { getDecorView().setVisibility(remove ? View.GONE : View.INVISIBLE); } //TODO(b/210039666): remove window from WM after a delay. Delay amount TBD. } void setToken(@NonNull IBinder token) { Loading
core/java/android/inputmethodservice/InputMethodService.java +39 −0 Original line number Diff line number Diff line Loading @@ -345,6 +345,14 @@ public class InputMethodService extends AbstractInputMethodService { */ private static final int MAX_EVENTS_BUFFER = 500; /** * When IME doesn't receive stylus input for these many milliseconds, Handwriting session * will be finished by calling {@link #finishStylusHandwriting()}. * @see #onStartStylusHandwriting() * @see #onFinishStylusHandwriting() */ private static final int STYLUS_HANDWRITING_IDLE_TIMEOUT_MS = 10000; /** * A circular buffer of size MAX_EVENTS_BUFFER in case IME is taking too long to add ink view. **/ Loading @@ -353,6 +361,7 @@ public class InputMethodService extends AbstractInputMethodService { private Boolean mBackCallbackRegistered = false; private final OnBackInvokedCallback mCompatBackCallback = this::compatHandleBack; private Runnable mImeSurfaceRemoverRunnable; private Runnable mFinishHwRunnable; /** * Returns whether {@link InputMethodService} is responsible for rendering the back button and Loading Loading @@ -996,8 +1005,10 @@ public class InputMethodService extends AbstractInputMethodService { return false; } onStylusHandwritingMotionEvent((MotionEvent) event); scheduleHandwritingSessionTimeout(); return true; }); scheduleHandwritingSessionTimeout(); } /** Loading Loading @@ -2475,6 +2486,10 @@ public class InputMethodService extends AbstractInputMethodService { if (!mHandwritingRequestId.isPresent()) { return; } if (mHandler != null && mFinishHwRunnable != null) { mHandler.removeCallbacks(mFinishHwRunnable); } mFinishHwRunnable = null; final int requestId = mHandwritingRequestId.getAsInt(); mHandwritingRequestId = OptionalInt.empty(); Loading @@ -2488,6 +2503,30 @@ public class InputMethodService extends AbstractInputMethodService { onFinishStylusHandwriting(); } private Runnable getFinishHandwritingRunnable() { if (mFinishHwRunnable != null) { return mFinishHwRunnable; } return mFinishHwRunnable = () -> { if (mHandler != null) { mHandler.removeCallbacks(mFinishHwRunnable); } Log.d(TAG, "Stylus handwriting idle timed-out. calling finishStylusHandwriting()"); mFinishHwRunnable = null; finishStylusHandwriting(); }; } private void scheduleHandwritingSessionTimeout() { if (mHandler == null) { mHandler = new Handler(getMainLooper()); } if (mFinishHwRunnable != null) { mHandler.removeCallbacks(mFinishHwRunnable); } mHandler.postDelayed(getFinishHandwritingRunnable(), STYLUS_HANDWRITING_IDLE_TIMEOUT_MS); } /** * The system has decided that it may be time to show your input method. * This is called due to a corresponding call to your Loading