Loading core/java/android/inputmethodservice/KeyboardView.java +3 −10 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ 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 @@ -221,7 +220,6 @@ 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 @@ -233,6 +231,7 @@ 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 @@ -369,12 +368,6 @@ 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 @@ -1299,7 +1292,7 @@ public class KeyboardView extends View implements View.OnClickListener { } if (mCurrentKey != NOT_A_KEY) { Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me); mHandler.sendMessageDelayed(msg, mLongPressTimeoutMillis); mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT); } showPreview(keyIndex); break; Loading Loading @@ -1332,7 +1325,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, mLongPressTimeoutMillis); mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT); } } showPreview(mCurrentKey); Loading core/java/android/inputmethodservice/navigationbar/KeyButtonView.java +1 −7 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ 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 @@ -108,11 +107,6 @@ 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 @@ -216,7 +210,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface { } if (Flags.imeSwitcherRevamp() && isLongClickable()) { removeCallbacks(mCheckLongPress); postDelayed(mCheckLongPress, mLongPressTimeoutMillis); postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout()); } break; case MotionEvent.ACTION_MOVE: Loading core/java/android/view/GestureDetector.java +3 −6 Original line number Diff line number Diff line Loading @@ -250,7 +250,6 @@ 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 @@ -515,12 +514,10 @@ 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 @@ -690,7 +687,7 @@ public class GestureDetector { TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), mCurrentDownEvent.getDownTime() + mLongPressTimeoutMillis); + ViewConfiguration.getLongPressTimeout()); } mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + mTapTimeout); Loading Loading @@ -731,14 +728,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) (mLongPressTimeoutMillis * mAmbiguousGestureMultiplier)); + (long) (longPressTimeout * mAmbiguousGestureMultiplier)); } // Inhibit default scroll. If a gesture is ambiguous, we prevent scroll // until the gesture is resolved. Loading core/java/android/view/HandwritingInitiator.java +1 −4 Original line number Diff line number Diff line Loading @@ -149,10 +149,7 @@ public class HandwritingInitiator { public HandwritingInitiator(@NonNull ViewConfiguration viewConfiguration, @NonNull InputMethodManager inputMethodManager) { mHandwritingSlop = viewConfiguration.getScaledHandwritingSlop(); mHandwritingTimeoutInMillis = android.companion.virtualdevice.flags.Flags.viewconfigurationApis() ? viewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); mHandwritingTimeoutInMillis = ViewConfiguration.getLongPressTimeout(); mImm = inputMethodManager; } Loading core/java/android/view/View.java +45 −38 Original line number Diff line number Diff line Loading @@ -5519,6 +5519,21 @@ 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 @@ -5890,9 +5905,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private float mFrameContentVelocity = -1; @Nullable private ViewTranslationResponse mViewTranslationResponse; private final ViewConfiguration mViewConfiguration; private ViewTranslationResponse mViewTranslationResponse; /** * The size in DP that is considered small for VRR purposes, if square. Loading Loading @@ -5996,7 +6010,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, (PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT) | (IMPORTANT_FOR_ACCESSIBILITY_DEFAULT << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT); mViewConfiguration = ViewConfiguration.get(context); 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); mUserPaddingStart = UNDEFINED_PADDING; Loading Loading @@ -7000,7 +7018,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, View() { mResources = null; mRenderNode = RenderNode.create(getClass().getName(), new ViewAnimationHostBridge(this)); mViewConfiguration = new ViewConfiguration(); } /** Loading Loading @@ -7257,7 +7274,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mScrollCache.fadingEdgeLength = a.getDimensionPixelSize( R.styleable.View_fadingEdgeLength, mViewConfiguration.getScaledFadingEdgeLength()); ViewConfiguration.get(mContext).getScaledFadingEdgeLength()); } /** Loading Loading @@ -7500,7 +7517,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, scrollabilityCache.scrollBarSize = a.getDimensionPixelSize( com.android.internal.R.styleable.View_scrollbarSize, mViewConfiguration.getScaledScrollBarSize()); ViewConfiguration.get(mContext).getScaledScrollBarSize()); Drawable track = a.getDrawable(R.styleable.View_scrollbarTrackHorizontal); scrollabilityCache.scrollBar.setHorizontalTrackDrawable(track); Loading Loading @@ -7659,7 +7676,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private void initScrollCache() { if (mScrollCache == null) { mScrollCache = new ScrollabilityCache(mViewConfiguration, this); mScrollCache = new ScrollabilityCache(ViewConfiguration.get(mContext), this); } } Loading Loading @@ -13309,7 +13326,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, List<Rect> collectPreferKeepClearRects() { ListenerInfo info = mListenerInfo; boolean keepClearForFocus = isFocused() && mViewConfiguration.isPreferKeepClearForFocusEnabled(); && ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled(); boolean keepBoundsClear = (info != null && info.mPreferKeepClear) || keepClearForFocus; boolean hasCustomKeepClearRects = info != null && info.mKeepClearRects != null; Loading @@ -13332,7 +13349,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } private void updatePreferKeepClearForFocus() { if (mViewConfiguration.isPreferKeepClearForFocusEnabled()) { if (ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled()) { updatePositionUpdateListener(); post(this::updateKeepClearRects); } Loading Loading @@ -16954,7 +16971,8 @@ 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 (mViewConfiguration.isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()) { if (ViewConfiguration.get(mContext) .isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()) { mPrivateFlags4 |= PFLAG4_ROTARY_HAPTICS_ENABLED; } mPrivateFlags4 |= PFLAG4_ROTARY_HAPTICS_DETERMINED; Loading Loading @@ -17555,7 +17573,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, setPressed(true, x, y); } checkForLongClick( getLongPressTimeoutMillis(), ViewConfiguration.getLongPressTimeout(), x, y, // This is not a touch gesture -- do not classify it as one. Loading Loading @@ -18363,7 +18381,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!clickable) { checkForLongClick( getLongPressTimeoutMillis(), ViewConfiguration.getLongPressTimeout(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading @@ -18386,12 +18404,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } mPendingCheckForTap.x = event.getX(); mPendingCheckForTap.y = event.getY(); postDelayed(mPendingCheckForTap, getTapTimeoutMillis()); postDelayed(mPendingCheckForTap, mTapTimeoutMillis); } else { // Not inside a scrolling container, so show the feedback right away setPressed(true, x, y); checkForLongClick( getLongPressTimeoutMillis(), ViewConfiguration.getLongPressTimeout(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading @@ -18418,17 +18436,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final int motionClassification = event.getClassification(); final boolean ambiguousGesture = motionClassification == MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE; int touchSlop = mViewConfiguration.getScaledTouchSlop(); int touchSlop = mTouchSlop; 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) (getLongPressTimeoutMillis() * ambiguousGestureMultiplier); long delay = (long) (ViewConfiguration.getLongPressTimeout() * mAmbiguousGestureMultiplier); // Subtract the time already spent delay -= event.getEventTime() - event.getDownTime(); checkForLongClick( Loading @@ -18437,7 +18453,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } touchSlop *= ambiguousGestureMultiplier; touchSlop *= mAmbiguousGestureMultiplier; } // Be lenient about moving outside of buttons Loading Loading @@ -18515,18 +18531,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } private int getLongPressTimeoutMillis() { return Flags.viewconfigurationApis() ? mViewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } 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 @@ -18937,14 +18941,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private HapticScrollFeedbackProvider getScrollFeedbackProvider() { if (mScrollFeedbackProvider == null) { mScrollFeedbackProvider = new HapticScrollFeedbackProvider(this, mViewConfiguration, /* isFromView= */ true); ViewConfiguration.get(mContext), /* isFromView= */ true); } return mScrollFeedbackProvider; } private void doRotaryProgressForScrollHaptics(MotionEvent rotaryEvent) { final float axisScrollValue = rotaryEvent.getAxisValue(MotionEvent.AXIS_SCROLL); final float verticalScrollFactor = mViewConfiguration.getScaledVerticalScrollFactor(); final float verticalScrollFactor = ViewConfiguration.get(mContext).getScaledVerticalScrollFactor(); final int scrollAmount = -Math.round(axisScrollValue * verticalScrollFactor); getScrollFeedbackProvider().onScrollProgress( rotaryEvent.getDeviceId(), InputDevice.SOURCE_ROTARY_ENCODER, Loading Loading @@ -22133,7 +22138,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @InspectableProperty(name = "scrollbarSize") public int getScrollBarSize() { return mScrollCache == null ? mViewConfiguration.getScaledScrollBarSize() : return mScrollCache == null ? ViewConfiguration.get(mContext).getScaledScrollBarSize() : mScrollCache.scrollBarSize; } Loading Loading @@ -24420,7 +24425,8 @@ 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 = mViewConfiguration.getScaledMaximumDrawingCacheSize(); final long drawingCacheSize = ViewConfiguration.get(mContext).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 @@ -31763,7 +31769,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public void run() { mPrivateFlags &= ~PFLAG_PREPRESSED; setPressed(true, x, y); final int delay = getLongPressTimeoutMillis() - getTapTimeoutMillis(); final long delay = (long) ViewConfiguration.getLongPressTimeout() - mTapTimeoutMillis; checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } } Loading Loading @@ -33753,7 +33760,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mTooltipInfo = new TooltipInfo(); mTooltipInfo.mShowTooltipRunnable = this::showHoverTooltip; mTooltipInfo.mHideTooltipRunnable = this::hideTooltip; mTooltipInfo.mHoverSlop = mViewConfiguration.getScaledHoverSlop(); mTooltipInfo.mHoverSlop = ViewConfiguration.get(mContext).getScaledHoverSlop(); mTooltipInfo.clearAnchorPos(); } mTooltipInfo.mTooltipText = tooltipText; Loading
core/java/android/inputmethodservice/KeyboardView.java +3 −10 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ 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 @@ -221,7 +220,6 @@ 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 @@ -233,6 +231,7 @@ 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 @@ -369,12 +368,6 @@ 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 @@ -1299,7 +1292,7 @@ public class KeyboardView extends View implements View.OnClickListener { } if (mCurrentKey != NOT_A_KEY) { Message msg = mHandler.obtainMessage(MSG_LONGPRESS, me); mHandler.sendMessageDelayed(msg, mLongPressTimeoutMillis); mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT); } showPreview(keyIndex); break; Loading Loading @@ -1332,7 +1325,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, mLongPressTimeoutMillis); mHandler.sendMessageDelayed(msg, LONGPRESS_TIMEOUT); } } showPreview(mCurrentKey); Loading
core/java/android/inputmethodservice/navigationbar/KeyButtonView.java +1 −7 Original line number Diff line number Diff line Loading @@ -74,7 +74,6 @@ 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 @@ -108,11 +107,6 @@ 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 @@ -216,7 +210,7 @@ public class KeyButtonView extends ImageView implements ButtonInterface { } if (Flags.imeSwitcherRevamp() && isLongClickable()) { removeCallbacks(mCheckLongPress); postDelayed(mCheckLongPress, mLongPressTimeoutMillis); postDelayed(mCheckLongPress, ViewConfiguration.getLongPressTimeout()); } break; case MotionEvent.ACTION_MOVE: Loading
core/java/android/view/GestureDetector.java +3 −6 Original line number Diff line number Diff line Loading @@ -250,7 +250,6 @@ 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 @@ -515,12 +514,10 @@ 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 @@ -690,7 +687,7 @@ public class GestureDetector { TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), mCurrentDownEvent.getDownTime() + mLongPressTimeoutMillis); + ViewConfiguration.getLongPressTimeout()); } mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + mTapTimeout); Loading Loading @@ -731,14 +728,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) (mLongPressTimeoutMillis * mAmbiguousGestureMultiplier)); + (long) (longPressTimeout * mAmbiguousGestureMultiplier)); } // Inhibit default scroll. If a gesture is ambiguous, we prevent scroll // until the gesture is resolved. Loading
core/java/android/view/HandwritingInitiator.java +1 −4 Original line number Diff line number Diff line Loading @@ -149,10 +149,7 @@ public class HandwritingInitiator { public HandwritingInitiator(@NonNull ViewConfiguration viewConfiguration, @NonNull InputMethodManager inputMethodManager) { mHandwritingSlop = viewConfiguration.getScaledHandwritingSlop(); mHandwritingTimeoutInMillis = android.companion.virtualdevice.flags.Flags.viewconfigurationApis() ? viewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); mHandwritingTimeoutInMillis = ViewConfiguration.getLongPressTimeout(); mImm = inputMethodManager; } Loading
core/java/android/view/View.java +45 −38 Original line number Diff line number Diff line Loading @@ -5519,6 +5519,21 @@ 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 @@ -5890,9 +5905,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private float mFrameContentVelocity = -1; @Nullable private ViewTranslationResponse mViewTranslationResponse; private final ViewConfiguration mViewConfiguration; private ViewTranslationResponse mViewTranslationResponse; /** * The size in DP that is considered small for VRR purposes, if square. Loading Loading @@ -5996,7 +6010,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, (PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT) | (IMPORTANT_FOR_ACCESSIBILITY_DEFAULT << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT); mViewConfiguration = ViewConfiguration.get(context); 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); mUserPaddingStart = UNDEFINED_PADDING; Loading Loading @@ -7000,7 +7018,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, View() { mResources = null; mRenderNode = RenderNode.create(getClass().getName(), new ViewAnimationHostBridge(this)); mViewConfiguration = new ViewConfiguration(); } /** Loading Loading @@ -7257,7 +7274,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mScrollCache.fadingEdgeLength = a.getDimensionPixelSize( R.styleable.View_fadingEdgeLength, mViewConfiguration.getScaledFadingEdgeLength()); ViewConfiguration.get(mContext).getScaledFadingEdgeLength()); } /** Loading Loading @@ -7500,7 +7517,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, scrollabilityCache.scrollBarSize = a.getDimensionPixelSize( com.android.internal.R.styleable.View_scrollbarSize, mViewConfiguration.getScaledScrollBarSize()); ViewConfiguration.get(mContext).getScaledScrollBarSize()); Drawable track = a.getDrawable(R.styleable.View_scrollbarTrackHorizontal); scrollabilityCache.scrollBar.setHorizontalTrackDrawable(track); Loading Loading @@ -7659,7 +7676,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ private void initScrollCache() { if (mScrollCache == null) { mScrollCache = new ScrollabilityCache(mViewConfiguration, this); mScrollCache = new ScrollabilityCache(ViewConfiguration.get(mContext), this); } } Loading Loading @@ -13309,7 +13326,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, List<Rect> collectPreferKeepClearRects() { ListenerInfo info = mListenerInfo; boolean keepClearForFocus = isFocused() && mViewConfiguration.isPreferKeepClearForFocusEnabled(); && ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled(); boolean keepBoundsClear = (info != null && info.mPreferKeepClear) || keepClearForFocus; boolean hasCustomKeepClearRects = info != null && info.mKeepClearRects != null; Loading @@ -13332,7 +13349,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } private void updatePreferKeepClearForFocus() { if (mViewConfiguration.isPreferKeepClearForFocusEnabled()) { if (ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled()) { updatePositionUpdateListener(); post(this::updateKeepClearRects); } Loading Loading @@ -16954,7 +16971,8 @@ 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 (mViewConfiguration.isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()) { if (ViewConfiguration.get(mContext) .isViewBasedRotaryEncoderHapticScrollFeedbackEnabled()) { mPrivateFlags4 |= PFLAG4_ROTARY_HAPTICS_ENABLED; } mPrivateFlags4 |= PFLAG4_ROTARY_HAPTICS_DETERMINED; Loading Loading @@ -17555,7 +17573,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, setPressed(true, x, y); } checkForLongClick( getLongPressTimeoutMillis(), ViewConfiguration.getLongPressTimeout(), x, y, // This is not a touch gesture -- do not classify it as one. Loading Loading @@ -18363,7 +18381,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!clickable) { checkForLongClick( getLongPressTimeoutMillis(), ViewConfiguration.getLongPressTimeout(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading @@ -18386,12 +18404,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } mPendingCheckForTap.x = event.getX(); mPendingCheckForTap.y = event.getY(); postDelayed(mPendingCheckForTap, getTapTimeoutMillis()); postDelayed(mPendingCheckForTap, mTapTimeoutMillis); } else { // Not inside a scrolling container, so show the feedback right away setPressed(true, x, y); checkForLongClick( getLongPressTimeoutMillis(), ViewConfiguration.getLongPressTimeout(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); Loading @@ -18418,17 +18436,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, final int motionClassification = event.getClassification(); final boolean ambiguousGesture = motionClassification == MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE; int touchSlop = mViewConfiguration.getScaledTouchSlop(); int touchSlop = mTouchSlop; 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) (getLongPressTimeoutMillis() * ambiguousGestureMultiplier); long delay = (long) (ViewConfiguration.getLongPressTimeout() * mAmbiguousGestureMultiplier); // Subtract the time already spent delay -= event.getEventTime() - event.getDownTime(); checkForLongClick( Loading @@ -18437,7 +18453,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } touchSlop *= ambiguousGestureMultiplier; touchSlop *= mAmbiguousGestureMultiplier; } // Be lenient about moving outside of buttons Loading Loading @@ -18515,18 +18531,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } private int getLongPressTimeoutMillis() { return Flags.viewconfigurationApis() ? mViewConfiguration.getLongPressTimeoutMillis() : ViewConfiguration.getLongPressTimeout(); } 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 @@ -18937,14 +18941,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private HapticScrollFeedbackProvider getScrollFeedbackProvider() { if (mScrollFeedbackProvider == null) { mScrollFeedbackProvider = new HapticScrollFeedbackProvider(this, mViewConfiguration, /* isFromView= */ true); ViewConfiguration.get(mContext), /* isFromView= */ true); } return mScrollFeedbackProvider; } private void doRotaryProgressForScrollHaptics(MotionEvent rotaryEvent) { final float axisScrollValue = rotaryEvent.getAxisValue(MotionEvent.AXIS_SCROLL); final float verticalScrollFactor = mViewConfiguration.getScaledVerticalScrollFactor(); final float verticalScrollFactor = ViewConfiguration.get(mContext).getScaledVerticalScrollFactor(); final int scrollAmount = -Math.round(axisScrollValue * verticalScrollFactor); getScrollFeedbackProvider().onScrollProgress( rotaryEvent.getDeviceId(), InputDevice.SOURCE_ROTARY_ENCODER, Loading Loading @@ -22133,7 +22138,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @InspectableProperty(name = "scrollbarSize") public int getScrollBarSize() { return mScrollCache == null ? mViewConfiguration.getScaledScrollBarSize() : return mScrollCache == null ? ViewConfiguration.get(mContext).getScaledScrollBarSize() : mScrollCache.scrollBarSize; } Loading Loading @@ -24420,7 +24425,8 @@ 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 = mViewConfiguration.getScaledMaximumDrawingCacheSize(); final long drawingCacheSize = ViewConfiguration.get(mContext).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 @@ -31763,7 +31769,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public void run() { mPrivateFlags &= ~PFLAG_PREPRESSED; setPressed(true, x, y); final int delay = getLongPressTimeoutMillis() - getTapTimeoutMillis(); final long delay = (long) ViewConfiguration.getLongPressTimeout() - mTapTimeoutMillis; checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); } } Loading Loading @@ -33753,7 +33760,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mTooltipInfo = new TooltipInfo(); mTooltipInfo.mShowTooltipRunnable = this::showHoverTooltip; mTooltipInfo.mHideTooltipRunnable = this::hideTooltip; mTooltipInfo.mHoverSlop = mViewConfiguration.getScaledHoverSlop(); mTooltipInfo.mHoverSlop = ViewConfiguration.get(mContext).getScaledHoverSlop(); mTooltipInfo.clearAnchorPos(); } mTooltipInfo.mTooltipText = tooltipText;