Loading core/java/android/inputmethodservice/KeyboardView.java +10 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.inputmethodservice; import android.companion.virtualdevice.flags.Flags; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; Loading Loading @@ -220,6 +221,7 @@ public class KeyboardView extends View implements View.OnClickListener { private SwipeTracker mSwipeTracker = new SwipeTracker(); private int mSwipeThreshold; private boolean mDisambiguateSwipe; private final int mLongPressTimeoutMillis; // Variables for dealing with multiple pointers private int mOldPointerCount = 1; Loading @@ -231,7 +233,6 @@ public class KeyboardView extends View implements View.OnClickListener { private static final int REPEAT_INTERVAL = 50; // ~20 keys per second private static final int REPEAT_START_DELAY = 400; private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout(); private static int MAX_NEARBY_KEYS = 12; private int[] mDistances = new int[MAX_NEARBY_KEYS]; Loading Loading @@ -368,6 +369,12 @@ public class KeyboardView extends View implements View.OnClickListener { mAccessibilityManager = AccessibilityManager.getInstance(context); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (Flags.viewconfigurationApis()) { mLongPressTimeoutMillis = ViewConfiguration.get(context).getLongPressTimeoutMillis(); } else { mLongPressTimeoutMillis = ViewConfiguration.getLongPressTimeout(); } resetMultiTap(); } Loading Loading @@ -1292,7 +1299,7 @@ public class KeyboardView extends View implements View.OnClickListener { } if (mCurrentKey != NOT_A_KEY) { Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me); mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT); mHandler.sendMessageDelayed(msg, mLongPressTimeoutMillis); } showPreview(keyIndex); break; Loading Loading @@ -1325,7 +1332,7 @@ public class KeyboardView extends View implements View.OnClickListener { // Start new longpress if key has changed if (keyIndex != NOT_A_KEY) { Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me); mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT); mHandler.sendMessageDelayed(msg, mLongPressTimeoutMillis); } } showPreview(mCurrentKey); Loading core/java/android/inputmethodservice/navigationbar/KeyButtonView.java +7 −1 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface { private final Paint mOvalBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); private float mDarkIntensity; private boolean mHasOvalBg = false; private final int mLongPressTimeoutMillis; /** Runnable for checking whether the long click action should be performed. */ private final Runnable mCheckLongPress = new Runnable() { Loading Loading @@ -107,6 +108,11 @@ public class KeyButtonView extends ImageView implements ButtonInterface { setBackground(mRipple); setWillNotDraw(false); forceHasOverlappingRendering(false); mLongPressTimeoutMillis = android.companion.virtualdevice.flags.Flags.viewconfigurationApis() ? ViewConfiguration.get(context).getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } @Override Loading Loading @@ -210,7 +216,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface { } if (Flags.imeSwitcherRevamp() && isLongClickable()) { removeCallbacks(mCheckLongPress); postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout()); postDelayed(mCheckLongPress, mLongPressTimeoutMillis); } break; case MotionEvent.ACTION_MOVE: Loading core/java/android/view/GestureDetector.java +6 −3 Original line number Diff line number Diff line Loading @@ -250,6 +250,7 @@ public class GestureDetector { private int mTapTimeout; private int mDoubleTapTimeout; private int mDoubleTapMinTime; private int mLongPressTimeoutMillis; // constants for Message.what used by GestureHandler below private static final int SHOW_PRESS = 1; Loading Loading @@ -514,10 +515,12 @@ public class GestureDetector { mTapTimeout = configuration.getTapTimeoutMillis(); mDoubleTapTimeout = configuration.getDoubleTapTimeoutMillis(); mDoubleTapMinTime = configuration.getDoubleTapMinTimeMillis(); mLongPressTimeoutMillis = configuration.getLongPressTimeoutMillis(); } else { mTapTimeout = ViewConfiguration.getTapTimeout(); mDoubleTapTimeout = ViewConfiguration.getDoubleTapTimeout(); mDoubleTapMinTime = ViewConfiguration.getDoubleTapMinTime(); mLongPressTimeoutMillis = ViewConfiguration.getLongPressTimeout(); } } mTouchSlopSquare = touchSlop * touchSlop; Loading Loading @@ -687,7 +690,7 @@ public class GestureDetector { TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), mCurrentDownEvent.getDownTime() + ViewConfiguration.getLongPressTimeout()); + mLongPressTimeoutMillis); } mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + mTapTimeout); Loading Loading @@ -728,14 +731,14 @@ public class GestureDetector { // will happen in response to user input. To prevent this, // reschedule long press with a modified timeout. mHandler.removeMessages(LONG_PRESS); final long longPressTimeout = ViewConfiguration.getLongPressTimeout(); mHandler.sendMessageAtTime( mHandler.obtainMessage( LONG_PRESS, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), ev.getDownTime() + (long) (longPressTimeout * mAmbiguousGestureMultiplier)); + (long) (mLongPressTimeoutMillis * mAmbiguousGestureMultiplier)); } // Inhibit default scroll. If a gesture is ambiguous, we prevent scroll // until the gesture is resolved. Loading core/java/android/view/HandwritingInitiator.java +4 −1 Original line number Diff line number Diff line Loading @@ -149,7 +149,10 @@ public class HandwritingInitiator { public HandwritingInitiator(@NonNull ViewConfiguration viewConfiguration, @NonNull InputMethodManager inputMethodManager) { mHandwritingSlop = viewConfiguration.getScaledHandwritingSlop(); mHandwritingTimeoutInMillis = ViewConfiguration.getLongPressTimeout(); mHandwritingTimeoutInMillis = android.companion.virtualdevice.flags.Flags.viewconfigurationApis() ? viewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); mImm = inputMethodManager; } Loading core/java/android/view/View.java +12 −8 Original line number Diff line number Diff line Loading @@ -6012,8 +6012,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mTapTimeoutMillis = Flags.viewconfigurationApis() ? configuration.getTapTimeoutMillis() : ViewConfiguration.getTapTimeout(); mAmbiguousGestureMultiplier = configuration.getScaledAmbiguousGestureMultiplier(); setOverScrollMode(OVER_SCROLL_IF_CONTENT_SCROLLS); Loading Loading @@ -17573,7 +17572,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, setPressed(true, x, y); } checkForLongClick( ViewConfiguration.getLongPressTimeout(), getLongPressTimeoutMillis(), x, y, // This is not a touch gesture -- do not classify it as one. Loading Loading @@ -18381,7 +18380,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!clickable) { checkForLongClick( ViewConfiguration.getLongPressTimeout(), getLongPressTimeoutMillis(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading Loading @@ -18409,7 +18408,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // Not inside a scrolling container, so show the feedback right away setPressed(true, x, y); checkForLongClick( ViewConfiguration.getLongPressTimeout(), getLongPressTimeoutMillis(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading Loading @@ -18443,7 +18442,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // just extend the timeout here, in case the classification // stays ambiguous. removeLongPressCallback(); long delay = (long) (ViewConfiguration.getLongPressTimeout() long delay = (long) (getLongPressTimeoutMillis() * mAmbiguousGestureMultiplier); // Subtract the time already spent delay -= event.getEventTime() - event.getDownTime(); Loading Loading @@ -18531,6 +18530,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } private int getLongPressTimeoutMillis() { return Flags.viewconfigurationApis() ? ViewConfiguration.get(getContext()).getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } /** * Return true if the long press callback is scheduled to run sometime in the future. * Return false if there is no scheduled long press callback at the moment. Loading Loading @@ -31769,8 +31774,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public void run() { mPrivateFlags &= ~PFLAG_PREPRESSED; setPressed(true, x, y); final long delay = (long) ViewConfiguration.getLongPressTimeout() - mTapTimeoutMillis; final int delay = getLongPressTimeoutMillis() - mTapTimeoutMillis; checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } } Loading
core/java/android/inputmethodservice/KeyboardView.java +10 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.inputmethodservice; import android.companion.virtualdevice.flags.Flags; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.res.TypedArray; Loading Loading @@ -220,6 +221,7 @@ public class KeyboardView extends View implements View.OnClickListener { private SwipeTracker mSwipeTracker = new SwipeTracker(); private int mSwipeThreshold; private boolean mDisambiguateSwipe; private final int mLongPressTimeoutMillis; // Variables for dealing with multiple pointers private int mOldPointerCount = 1; Loading @@ -231,7 +233,6 @@ public class KeyboardView extends View implements View.OnClickListener { private static final int REPEAT_INTERVAL = 50; // ~20 keys per second private static final int REPEAT_START_DELAY = 400; private static final int LONGPRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout(); private static int MAX_NEARBY_KEYS = 12; private int[] mDistances = new int[MAX_NEARBY_KEYS]; Loading Loading @@ -368,6 +369,12 @@ public class KeyboardView extends View implements View.OnClickListener { mAccessibilityManager = AccessibilityManager.getInstance(context); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); if (Flags.viewconfigurationApis()) { mLongPressTimeoutMillis = ViewConfiguration.get(context).getLongPressTimeoutMillis(); } else { mLongPressTimeoutMillis = ViewConfiguration.getLongPressTimeout(); } resetMultiTap(); } Loading Loading @@ -1292,7 +1299,7 @@ public class KeyboardView extends View implements View.OnClickListener { } if (mCurrentKey != NOT_A_KEY) { Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me); mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT); mHandler.sendMessageDelayed(msg, mLongPressTimeoutMillis); } showPreview(keyIndex); break; Loading Loading @@ -1325,7 +1332,7 @@ public class KeyboardView extends View implements View.OnClickListener { // Start new longpress if key has changed if (keyIndex != NOT_A_KEY) { Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me); mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT); mHandler.sendMessageDelayed(msg, mLongPressTimeoutMillis); } } showPreview(mCurrentKey); Loading
core/java/android/inputmethodservice/navigationbar/KeyButtonView.java +7 −1 Original line number Diff line number Diff line Loading @@ -74,6 +74,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface { private final Paint mOvalBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); private float mDarkIntensity; private boolean mHasOvalBg = false; private final int mLongPressTimeoutMillis; /** Runnable for checking whether the long click action should be performed. */ private final Runnable mCheckLongPress = new Runnable() { Loading Loading @@ -107,6 +108,11 @@ public class KeyButtonView extends ImageView implements ButtonInterface { setBackground(mRipple); setWillNotDraw(false); forceHasOverlappingRendering(false); mLongPressTimeoutMillis = android.companion.virtualdevice.flags.Flags.viewconfigurationApis() ? ViewConfiguration.get(context).getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } @Override Loading Loading @@ -210,7 +216,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface { } if (Flags.imeSwitcherRevamp() && isLongClickable()) { removeCallbacks(mCheckLongPress); postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout()); postDelayed(mCheckLongPress, mLongPressTimeoutMillis); } break; case MotionEvent.ACTION_MOVE: Loading
core/java/android/view/GestureDetector.java +6 −3 Original line number Diff line number Diff line Loading @@ -250,6 +250,7 @@ public class GestureDetector { private int mTapTimeout; private int mDoubleTapTimeout; private int mDoubleTapMinTime; private int mLongPressTimeoutMillis; // constants for Message.what used by GestureHandler below private static final int SHOW_PRESS = 1; Loading Loading @@ -514,10 +515,12 @@ public class GestureDetector { mTapTimeout = configuration.getTapTimeoutMillis(); mDoubleTapTimeout = configuration.getDoubleTapTimeoutMillis(); mDoubleTapMinTime = configuration.getDoubleTapMinTimeMillis(); mLongPressTimeoutMillis = configuration.getLongPressTimeoutMillis(); } else { mTapTimeout = ViewConfiguration.getTapTimeout(); mDoubleTapTimeout = ViewConfiguration.getDoubleTapTimeout(); mDoubleTapMinTime = ViewConfiguration.getDoubleTapMinTime(); mLongPressTimeoutMillis = ViewConfiguration.getLongPressTimeout(); } } mTouchSlopSquare = touchSlop * touchSlop; Loading Loading @@ -687,7 +690,7 @@ public class GestureDetector { TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), mCurrentDownEvent.getDownTime() + ViewConfiguration.getLongPressTimeout()); + mLongPressTimeoutMillis); } mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + mTapTimeout); Loading Loading @@ -728,14 +731,14 @@ public class GestureDetector { // will happen in response to user input. To prevent this, // reschedule long press with a modified timeout. mHandler.removeMessages(LONG_PRESS); final long longPressTimeout = ViewConfiguration.getLongPressTimeout(); mHandler.sendMessageAtTime( mHandler.obtainMessage( LONG_PRESS, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), ev.getDownTime() + (long) (longPressTimeout * mAmbiguousGestureMultiplier)); + (long) (mLongPressTimeoutMillis * mAmbiguousGestureMultiplier)); } // Inhibit default scroll. If a gesture is ambiguous, we prevent scroll // until the gesture is resolved. Loading
core/java/android/view/HandwritingInitiator.java +4 −1 Original line number Diff line number Diff line Loading @@ -149,7 +149,10 @@ public class HandwritingInitiator { public HandwritingInitiator(@NonNull ViewConfiguration viewConfiguration, @NonNull InputMethodManager inputMethodManager) { mHandwritingSlop = viewConfiguration.getScaledHandwritingSlop(); mHandwritingTimeoutInMillis = ViewConfiguration.getLongPressTimeout(); mHandwritingTimeoutInMillis = android.companion.virtualdevice.flags.Flags.viewconfigurationApis() ? viewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); mImm = inputMethodManager; } Loading
core/java/android/view/View.java +12 −8 Original line number Diff line number Diff line Loading @@ -6012,8 +6012,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mTapTimeoutMillis = Flags.viewconfigurationApis() ? configuration.getTapTimeoutMillis() : ViewConfiguration.getTapTimeout(); mAmbiguousGestureMultiplier = configuration.getScaledAmbiguousGestureMultiplier(); setOverScrollMode(OVER_SCROLL_IF_CONTENT_SCROLLS); Loading Loading @@ -17573,7 +17572,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, setPressed(true, x, y); } checkForLongClick( ViewConfiguration.getLongPressTimeout(), getLongPressTimeoutMillis(), x, y, // This is not a touch gesture -- do not classify it as one. Loading Loading @@ -18381,7 +18380,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!clickable) { checkForLongClick( ViewConfiguration.getLongPressTimeout(), getLongPressTimeoutMillis(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading Loading @@ -18409,7 +18408,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // Not inside a scrolling container, so show the feedback right away setPressed(true, x, y); checkForLongClick( ViewConfiguration.getLongPressTimeout(), getLongPressTimeoutMillis(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading Loading @@ -18443,7 +18442,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // just extend the timeout here, in case the classification // stays ambiguous. removeLongPressCallback(); long delay = (long) (ViewConfiguration.getLongPressTimeout() long delay = (long) (getLongPressTimeoutMillis() * mAmbiguousGestureMultiplier); // Subtract the time already spent delay -= event.getEventTime() - event.getDownTime(); Loading Loading @@ -18531,6 +18530,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } private int getLongPressTimeoutMillis() { return Flags.viewconfigurationApis() ? ViewConfiguration.get(getContext()).getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } /** * Return true if the long press callback is scheduled to run sometime in the future. * Return false if there is no scheduled long press callback at the moment. Loading Loading @@ -31769,8 +31774,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public void run() { mPrivateFlags &= ~PFLAG_PREPRESSED; setPressed(true, x, y); final long delay = (long) ViewConfiguration.getLongPressTimeout() - mTapTimeoutMillis; final int delay = getLongPressTimeoutMillis() - mTapTimeoutMillis; checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } }