Loading core/java/android/inputmethodservice/KeyboardView.java +2 −4 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup.LayoutParams; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; Loading Loading @@ -231,7 +230,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 @@ -1292,7 +1290,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, getLongPressTimeoutMillis()); } showPreview(keyIndex); break; Loading Loading @@ -1325,7 +1323,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, getLongPressTimeoutMillis()); } } showPreview(mCurrentKey); Loading core/java/android/inputmethodservice/navigationbar/KeyButtonView.java +1 −1 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface { } if (Flags.imeSwitcherRevamp() && isLongClickable()) { removeCallbacks(mCheckLongPress); postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout()); postDelayed(mCheckLongPress, getLongPressTimeoutMillis()); } break; case MotionEvent.ACTION_MOVE: Loading core/java/android/view/GestureDetector.java +20 −13 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 ViewConfiguration mViewConfiguration = null; // constants for Message.what used by GestureHandler below private static final int SHOW_PRESS = 1; Loading Loading @@ -503,17 +504,17 @@ public class GestureDetector { mDoubleTapMinTime = ViewConfiguration.getDoubleTapMinTime(); } else { StrictMode.assertConfigurationContext(context, "GestureDetector#init"); final ViewConfiguration configuration = ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); doubleTapTouchSlop = configuration.getScaledDoubleTapTouchSlop(); doubleTapSlop = configuration.getScaledDoubleTapSlop(); mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity(); mAmbiguousGestureMultiplier = configuration.getScaledAmbiguousGestureMultiplier(); mViewConfiguration = ViewConfiguration.get(context); touchSlop = mViewConfiguration.getScaledTouchSlop(); doubleTapTouchSlop = mViewConfiguration.getScaledDoubleTapTouchSlop(); doubleTapSlop = mViewConfiguration.getScaledDoubleTapSlop(); mMinimumFlingVelocity = mViewConfiguration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = mViewConfiguration.getScaledMaximumFlingVelocity(); mAmbiguousGestureMultiplier = mViewConfiguration.getScaledAmbiguousGestureMultiplier(); if (Flags.viewconfigurationApis()) { mTapTimeout = configuration.getTapTimeoutMillis(); mDoubleTapTimeout = configuration.getDoubleTapTimeoutMillis(); mDoubleTapMinTime = configuration.getDoubleTapMinTimeMillis(); mTapTimeout = mViewConfiguration.getTapTimeoutMillis(); mDoubleTapTimeout = mViewConfiguration.getDoubleTapTimeoutMillis(); mDoubleTapMinTime = mViewConfiguration.getDoubleTapMinTimeMillis(); } else { mTapTimeout = ViewConfiguration.getTapTimeout(); mDoubleTapTimeout = ViewConfiguration.getDoubleTapTimeout(); Loading Loading @@ -687,7 +688,7 @@ public class GestureDetector { TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), mCurrentDownEvent.getDownTime() + ViewConfiguration.getLongPressTimeout()); + getLongPressTimeoutMillis()); } mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + mTapTimeout); Loading Loading @@ -728,14 +729,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) (getLongPressTimeoutMillis() * mAmbiguousGestureMultiplier)); } // Inhibit default scroll. If a gesture is ambiguous, we prevent scroll // until the gesture is resolved. Loading Loading @@ -908,6 +909,12 @@ public class GestureDetector { mIgnoreNextUpEvent = false; } private int getLongPressTimeoutMillis() { return mViewConfiguration != null && Flags.viewconfigurationApis() ? mViewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } private boolean isConsideredDoubleTap(@NonNull MotionEvent firstDown, @NonNull MotionEvent firstUp, @NonNull MotionEvent secondDown) { if (!mAlwaysInBiggerTapRegion) { Loading core/java/android/view/HandwritingInitiator.java +4 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,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 +39 −45 Original line number Diff line number Diff line Loading @@ -5519,21 +5519,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private ViewTreeObserver mFloatingTreeObserver; /** * Cache the touch slop from the context that created the view. */ private int mTouchSlop; /** * Cache the tap timeout from the context that created the view. */ private int mTapTimeoutMillis; /** * Cache the ambiguous gesture multiplier from the context that created the view. */ private float mAmbiguousGestureMultiplier; /** * Object that handles automatic animation of view properties. */ Loading Loading @@ -5905,9 +5890,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private float mFrameContentVelocity = -1; @Nullable private ViewTranslationResponse mViewTranslationResponse; private final ViewConfiguration mViewConfiguration; /** * The size in DP that is considered small for VRR purposes, if square. */ Loading Loading @@ -6010,11 +5996,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, (PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT) | (IMPORTANT_FOR_ACCESSIBILITY_DEFAULT << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mTapTimeoutMillis = Flags.viewconfigurationApis() ? configuration.getTapTimeoutMillis() : ViewConfiguration.getTapTimeout(); mAmbiguousGestureMultiplier = configuration.getScaledAmbiguousGestureMultiplier(); mViewConfiguration = ViewConfiguration.get(context); setOverScrollMode(OVER_SCROLL_IF_CONTENT_SCROLLS); mUserPaddingStart = UNDEFINED_PADDING; Loading Loading @@ -7018,6 +7000,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, View() { mResources = null; mRenderNode = RenderNode.create(getClass().getName(), new ViewAnimationHostBridge(this)); mViewConfiguration = new ViewConfiguration(); } /** Loading Loading @@ -7274,7 +7257,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mScrollCache.fadingEdgeLength = a.getDimensionPixelSize( R.styleable.View_fadingEdgeLength, ViewConfiguration.get(mContext).getScaledFadingEdgeLength()); mViewConfiguration.getScaledFadingEdgeLength()); } /** Loading Loading @@ -7517,7 +7500,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, scrollabilityCache.scrollBarSize = a.getDimensionPixelSize( com.android.internal.R.styleable.View_scrollbarSize, ViewConfiguration.get(mContext).getScaledScrollBarSize()); mViewConfiguration.getScaledScrollBarSize()); Drawable track = a.getDrawable(R.styleable.View_scrollbarTrackHorizontal); scrollabilityCache.scrollBar.setHorizontalTrackDrawable(track); Loading Loading @@ -7676,7 +7659,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private void initScrollCache() { if (mScrollCache == null) { mScrollCache = new ScrollabilityCache(ViewConfiguration.get(mContext), this); mScrollCache = new ScrollabilityCache(mViewConfiguration, this); } } Loading Loading @@ -13335,7 +13318,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, List<Rect> collectPreferKeepClearRects() { ListenerInfo info = mListenerInfo; boolean keepClearForFocus = isFocused() && ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled(); && mViewConfiguration.isPreferKeepClearForFocusEnabled(); boolean keepBoundsClear = (info != null && info.mPreferKeepClear) || keepClearForFocus; boolean hasCustomKeepClearRects = info != null && info.mKeepClearRects != null; Loading @@ -13358,7 +13341,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } private void updatePreferKeepClearForFocus() { if (ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled()) { if (mViewConfiguration.isPreferKeepClearForFocusEnabled()) { updatePositionUpdateListener(); post(this::updateKeepClearRects); } Loading Loading @@ -16980,8 +16963,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // 2) Limits latency from the `ViewConfiguration` API, which may be slow due to feature // flag querying. if ((mPrivateFlags4 & PFLAG4_ROTARY_HAPTICS_DETERMINED) == 0) { if (ViewConfiguration.get(mContext) .isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()) { if (mViewConfiguration.isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()) { mPrivateFlags4 |= PFLAG4_ROTARY_HAPTICS_ENABLED; } mPrivateFlags4 |= PFLAG4_ROTARY_HAPTICS_DETERMINED; Loading Loading @@ -17582,7 +17564,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 @@ -18390,7 +18372,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!clickable) { checkForLongClick( ViewConfiguration.getLongPressTimeout(), getLongPressTimeoutMillis(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading @@ -18413,12 +18395,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } mPendingCheckForTap.x = event.getX(); mPendingCheckForTap.y = event.getY(); postDelayed(mPendingCheckForTap, mTapTimeoutMillis); postDelayed(mPendingCheckForTap, getTapTimeoutMillis()); } else { // 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 @@ -18445,15 +18427,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final int motionClassification = event.getClassification(); final boolean ambiguousGesture = motionClassification == MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE; int touchSlop = mTouchSlop; int touchSlop = mViewConfiguration.getScaledTouchSlop(); if (ambiguousGesture && hasPendingLongPressCallback()) { float ambiguousGestureMultiplier = mViewConfiguration.getScaledAmbiguousGestureMultiplier(); if (!pointInView(x, y, touchSlop)) { // The default action here is to cancel long press. But instead, we // just extend the timeout here, in case the classification // stays ambiguous. removeLongPressCallback(); long delay = (long) (ViewConfiguration.getLongPressTimeout() * mAmbiguousGestureMultiplier); long delay = (long) (getLongPressTimeoutMillis() * ambiguousGestureMultiplier); // Subtract the time already spent delay -= event.getEventTime() - event.getDownTime(); checkForLongClick( Loading @@ -18462,7 +18446,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } touchSlop *= mAmbiguousGestureMultiplier; touchSlop *= ambiguousGestureMultiplier; } // Be lenient about moving outside of buttons Loading Loading @@ -18531,6 +18515,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return false; } /** @hide */ protected int getLongPressTimeoutMillis() { return Flags.viewconfigurationApis() ? mViewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } /** * Remove the longpress detection timer. */ Loading @@ -18540,6 +18531,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } private int getTapTimeoutMillis() { return Flags.viewconfigurationApis() ? mViewConfiguration.getTapTimeoutMillis() : ViewConfiguration.getTapTimeout(); } /** * 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 @@ -18950,15 +18947,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private HapticScrollFeedbackProvider getScrollFeedbackProvider() { if (mScrollFeedbackProvider == null) { mScrollFeedbackProvider = new HapticScrollFeedbackProvider(this, ViewConfiguration.get(mContext), /* isFromView= */ true); mViewConfiguration, /* isFromView= */ true); } return mScrollFeedbackProvider; } private void doRotaryProgressForScrollHaptics(MotionEvent rotaryEvent) { final float axisScrollValue = rotaryEvent.getAxisValue(MotionEvent.AXIS_SCROLL); final float verticalScrollFactor = ViewConfiguration.get(mContext).getScaledVerticalScrollFactor(); final float verticalScrollFactor = mViewConfiguration.getScaledVerticalScrollFactor(); final int scrollAmount = -Math.round(axisScrollValue * verticalScrollFactor); getScrollFeedbackProvider().onScrollProgress( rotaryEvent.getDeviceId(), InputDevice.SOURCE_ROTARY_ENCODER, Loading Loading @@ -22150,7 +22146,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @InspectableProperty(name = "scrollbarSize") public int getScrollBarSize() { return mScrollCache == null ? ViewConfiguration.get(mContext).getScaledScrollBarSize() : return mScrollCache == null ? mViewConfiguration.getScaledScrollBarSize() : mScrollCache.scrollBarSize; } Loading Loading @@ -24437,8 +24433,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final boolean use32BitCache = attachInfo != null && attachInfo.mUse32BitDrawingCache; final long projectedBitmapSize = width * height * (opaque && !use32BitCache ? 2 : 4); final long drawingCacheSize = ViewConfiguration.get(mContext).getScaledMaximumDrawingCacheSize(); final long drawingCacheSize = mViewConfiguration.getScaledMaximumDrawingCacheSize(); if (width <= 0 || height <= 0 || projectedBitmapSize > drawingCacheSize) { if (width > 0 && height > 0) { Log.w(VIEW_LOG_TAG, getClass().getSimpleName() + " not displayed because it is" Loading Loading @@ -31781,8 +31776,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() - getTapTimeoutMillis(); checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } } Loading Loading @@ -33775,7 +33769,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mTooltipInfo = new TooltipInfo(); mTooltipInfo.mShowTooltipRunnable = this::showHoverTooltip; mTooltipInfo.mHideTooltipRunnable = this::hideTooltip; mTooltipInfo.mHoverSlop = ViewConfiguration.get(mContext).getScaledHoverSlop(); mTooltipInfo.mHoverSlop = mViewConfiguration.getScaledHoverSlop(); mTooltipInfo.clearAnchorPos(); } mTooltipInfo.mTooltipText = tooltipText; Loading
core/java/android/inputmethodservice/KeyboardView.java +2 −4 Original line number Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup.LayoutParams; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; Loading Loading @@ -231,7 +230,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 @@ -1292,7 +1290,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, getLongPressTimeoutMillis()); } showPreview(keyIndex); break; Loading Loading @@ -1325,7 +1323,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, getLongPressTimeoutMillis()); } } showPreview(mCurrentKey); Loading
core/java/android/inputmethodservice/navigationbar/KeyButtonView.java +1 −1 Original line number Diff line number Diff line Loading @@ -210,7 +210,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface { } if (Flags.imeSwitcherRevamp() && isLongClickable()) { removeCallbacks(mCheckLongPress); postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout()); postDelayed(mCheckLongPress, getLongPressTimeoutMillis()); } break; case MotionEvent.ACTION_MOVE: Loading
core/java/android/view/GestureDetector.java +20 −13 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 ViewConfiguration mViewConfiguration = null; // constants for Message.what used by GestureHandler below private static final int SHOW_PRESS = 1; Loading Loading @@ -503,17 +504,17 @@ public class GestureDetector { mDoubleTapMinTime = ViewConfiguration.getDoubleTapMinTime(); } else { StrictMode.assertConfigurationContext(context, "GestureDetector#init"); final ViewConfiguration configuration = ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); doubleTapTouchSlop = configuration.getScaledDoubleTapTouchSlop(); doubleTapSlop = configuration.getScaledDoubleTapSlop(); mMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = configuration.getScaledMaximumFlingVelocity(); mAmbiguousGestureMultiplier = configuration.getScaledAmbiguousGestureMultiplier(); mViewConfiguration = ViewConfiguration.get(context); touchSlop = mViewConfiguration.getScaledTouchSlop(); doubleTapTouchSlop = mViewConfiguration.getScaledDoubleTapTouchSlop(); doubleTapSlop = mViewConfiguration.getScaledDoubleTapSlop(); mMinimumFlingVelocity = mViewConfiguration.getScaledMinimumFlingVelocity(); mMaximumFlingVelocity = mViewConfiguration.getScaledMaximumFlingVelocity(); mAmbiguousGestureMultiplier = mViewConfiguration.getScaledAmbiguousGestureMultiplier(); if (Flags.viewconfigurationApis()) { mTapTimeout = configuration.getTapTimeoutMillis(); mDoubleTapTimeout = configuration.getDoubleTapTimeoutMillis(); mDoubleTapMinTime = configuration.getDoubleTapMinTimeMillis(); mTapTimeout = mViewConfiguration.getTapTimeoutMillis(); mDoubleTapTimeout = mViewConfiguration.getDoubleTapTimeoutMillis(); mDoubleTapMinTime = mViewConfiguration.getDoubleTapMinTimeMillis(); } else { mTapTimeout = ViewConfiguration.getTapTimeout(); mDoubleTapTimeout = ViewConfiguration.getDoubleTapTimeout(); Loading Loading @@ -687,7 +688,7 @@ public class GestureDetector { TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), mCurrentDownEvent.getDownTime() + ViewConfiguration.getLongPressTimeout()); + getLongPressTimeoutMillis()); } mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + mTapTimeout); Loading Loading @@ -728,14 +729,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) (getLongPressTimeoutMillis() * mAmbiguousGestureMultiplier)); } // Inhibit default scroll. If a gesture is ambiguous, we prevent scroll // until the gesture is resolved. Loading Loading @@ -908,6 +909,12 @@ public class GestureDetector { mIgnoreNextUpEvent = false; } private int getLongPressTimeoutMillis() { return mViewConfiguration != null && Flags.viewconfigurationApis() ? mViewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } private boolean isConsideredDoubleTap(@NonNull MotionEvent firstDown, @NonNull MotionEvent firstUp, @NonNull MotionEvent secondDown) { if (!mAlwaysInBiggerTapRegion) { Loading
core/java/android/view/HandwritingInitiator.java +4 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,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 +39 −45 Original line number Diff line number Diff line Loading @@ -5519,21 +5519,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private ViewTreeObserver mFloatingTreeObserver; /** * Cache the touch slop from the context that created the view. */ private int mTouchSlop; /** * Cache the tap timeout from the context that created the view. */ private int mTapTimeoutMillis; /** * Cache the ambiguous gesture multiplier from the context that created the view. */ private float mAmbiguousGestureMultiplier; /** * Object that handles automatic animation of view properties. */ Loading Loading @@ -5905,9 +5890,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private float mFrameContentVelocity = -1; @Nullable private ViewTranslationResponse mViewTranslationResponse; private final ViewConfiguration mViewConfiguration; /** * The size in DP that is considered small for VRR purposes, if square. */ Loading Loading @@ -6010,11 +5996,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, (PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT) | (IMPORTANT_FOR_ACCESSIBILITY_DEFAULT << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = configuration.getScaledTouchSlop(); mTapTimeoutMillis = Flags.viewconfigurationApis() ? configuration.getTapTimeoutMillis() : ViewConfiguration.getTapTimeout(); mAmbiguousGestureMultiplier = configuration.getScaledAmbiguousGestureMultiplier(); mViewConfiguration = ViewConfiguration.get(context); setOverScrollMode(OVER_SCROLL_IF_CONTENT_SCROLLS); mUserPaddingStart = UNDEFINED_PADDING; Loading Loading @@ -7018,6 +7000,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, View() { mResources = null; mRenderNode = RenderNode.create(getClass().getName(), new ViewAnimationHostBridge(this)); mViewConfiguration = new ViewConfiguration(); } /** Loading Loading @@ -7274,7 +7257,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mScrollCache.fadingEdgeLength = a.getDimensionPixelSize( R.styleable.View_fadingEdgeLength, ViewConfiguration.get(mContext).getScaledFadingEdgeLength()); mViewConfiguration.getScaledFadingEdgeLength()); } /** Loading Loading @@ -7517,7 +7500,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, scrollabilityCache.scrollBarSize = a.getDimensionPixelSize( com.android.internal.R.styleable.View_scrollbarSize, ViewConfiguration.get(mContext).getScaledScrollBarSize()); mViewConfiguration.getScaledScrollBarSize()); Drawable track = a.getDrawable(R.styleable.View_scrollbarTrackHorizontal); scrollabilityCache.scrollBar.setHorizontalTrackDrawable(track); Loading Loading @@ -7676,7 +7659,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private void initScrollCache() { if (mScrollCache == null) { mScrollCache = new ScrollabilityCache(ViewConfiguration.get(mContext), this); mScrollCache = new ScrollabilityCache(mViewConfiguration, this); } } Loading Loading @@ -13335,7 +13318,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, List<Rect> collectPreferKeepClearRects() { ListenerInfo info = mListenerInfo; boolean keepClearForFocus = isFocused() && ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled(); && mViewConfiguration.isPreferKeepClearForFocusEnabled(); boolean keepBoundsClear = (info != null && info.mPreferKeepClear) || keepClearForFocus; boolean hasCustomKeepClearRects = info != null && info.mKeepClearRects != null; Loading @@ -13358,7 +13341,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } private void updatePreferKeepClearForFocus() { if (ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled()) { if (mViewConfiguration.isPreferKeepClearForFocusEnabled()) { updatePositionUpdateListener(); post(this::updateKeepClearRects); } Loading Loading @@ -16980,8 +16963,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // 2) Limits latency from the `ViewConfiguration` API, which may be slow due to feature // flag querying. if ((mPrivateFlags4 & PFLAG4_ROTARY_HAPTICS_DETERMINED) == 0) { if (ViewConfiguration.get(mContext) .isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()) { if (mViewConfiguration.isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()) { mPrivateFlags4 |= PFLAG4_ROTARY_HAPTICS_ENABLED; } mPrivateFlags4 |= PFLAG4_ROTARY_HAPTICS_DETERMINED; Loading Loading @@ -17582,7 +17564,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 @@ -18390,7 +18372,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!clickable) { checkForLongClick( ViewConfiguration.getLongPressTimeout(), getLongPressTimeoutMillis(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading @@ -18413,12 +18395,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } mPendingCheckForTap.x = event.getX(); mPendingCheckForTap.y = event.getY(); postDelayed(mPendingCheckForTap, mTapTimeoutMillis); postDelayed(mPendingCheckForTap, getTapTimeoutMillis()); } else { // 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 @@ -18445,15 +18427,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final int motionClassification = event.getClassification(); final boolean ambiguousGesture = motionClassification == MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE; int touchSlop = mTouchSlop; int touchSlop = mViewConfiguration.getScaledTouchSlop(); if (ambiguousGesture && hasPendingLongPressCallback()) { float ambiguousGestureMultiplier = mViewConfiguration.getScaledAmbiguousGestureMultiplier(); if (!pointInView(x, y, touchSlop)) { // The default action here is to cancel long press. But instead, we // just extend the timeout here, in case the classification // stays ambiguous. removeLongPressCallback(); long delay = (long) (ViewConfiguration.getLongPressTimeout() * mAmbiguousGestureMultiplier); long delay = (long) (getLongPressTimeoutMillis() * ambiguousGestureMultiplier); // Subtract the time already spent delay -= event.getEventTime() - event.getDownTime(); checkForLongClick( Loading @@ -18462,7 +18446,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } touchSlop *= mAmbiguousGestureMultiplier; touchSlop *= ambiguousGestureMultiplier; } // Be lenient about moving outside of buttons Loading Loading @@ -18531,6 +18515,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return false; } /** @hide */ protected int getLongPressTimeoutMillis() { return Flags.viewconfigurationApis() ? mViewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } /** * Remove the longpress detection timer. */ Loading @@ -18540,6 +18531,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } private int getTapTimeoutMillis() { return Flags.viewconfigurationApis() ? mViewConfiguration.getTapTimeoutMillis() : ViewConfiguration.getTapTimeout(); } /** * 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 @@ -18950,15 +18947,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private HapticScrollFeedbackProvider getScrollFeedbackProvider() { if (mScrollFeedbackProvider == null) { mScrollFeedbackProvider = new HapticScrollFeedbackProvider(this, ViewConfiguration.get(mContext), /* isFromView= */ true); mViewConfiguration, /* isFromView= */ true); } return mScrollFeedbackProvider; } private void doRotaryProgressForScrollHaptics(MotionEvent rotaryEvent) { final float axisScrollValue = rotaryEvent.getAxisValue(MotionEvent.AXIS_SCROLL); final float verticalScrollFactor = ViewConfiguration.get(mContext).getScaledVerticalScrollFactor(); final float verticalScrollFactor = mViewConfiguration.getScaledVerticalScrollFactor(); final int scrollAmount = -Math.round(axisScrollValue * verticalScrollFactor); getScrollFeedbackProvider().onScrollProgress( rotaryEvent.getDeviceId(), InputDevice.SOURCE_ROTARY_ENCODER, Loading Loading @@ -22150,7 +22146,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @InspectableProperty(name = "scrollbarSize") public int getScrollBarSize() { return mScrollCache == null ? ViewConfiguration.get(mContext).getScaledScrollBarSize() : return mScrollCache == null ? mViewConfiguration.getScaledScrollBarSize() : mScrollCache.scrollBarSize; } Loading Loading @@ -24437,8 +24433,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final boolean use32BitCache = attachInfo != null && attachInfo.mUse32BitDrawingCache; final long projectedBitmapSize = width * height * (opaque && !use32BitCache ? 2 : 4); final long drawingCacheSize = ViewConfiguration.get(mContext).getScaledMaximumDrawingCacheSize(); final long drawingCacheSize = mViewConfiguration.getScaledMaximumDrawingCacheSize(); if (width <= 0 || height <= 0 || projectedBitmapSize > drawingCacheSize) { if (width > 0 && height > 0) { Log.w(VIEW_LOG_TAG, getClass().getSimpleName() + " not displayed because it is" Loading Loading @@ -31781,8 +31776,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() - getTapTimeoutMillis(); checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } } Loading Loading @@ -33775,7 +33769,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mTooltipInfo = new TooltipInfo(); mTooltipInfo.mShowTooltipRunnable = this::showHoverTooltip; mTooltipInfo.mHideTooltipRunnable = this::hideTooltip; mTooltipInfo.mHoverSlop = ViewConfiguration.get(mContext).getScaledHoverSlop(); mTooltipInfo.mHoverSlop = mViewConfiguration.getScaledHoverSlop(); mTooltipInfo.clearAnchorPos(); } mTooltipInfo.mTooltipText = tooltipText;