From 7e5d0d5b90d8a00537c40d9f2d2506fdd0c670b3 Mon Sep 17 00:00:00 2001 From: Beverly Date: Mon, 6 Jun 2022 16:08:11 +0000 Subject: [PATCH] Make min longpress lock icon time configurable Time required to longpress can be adjusted in SystemUI config.xml Fixes: 231712181 Test: manual Change-Id: Iac4b661794c37a74b22864fb1acee8e5fd07f8a1 --- packages/SystemUI/res/values/config.xml | 3 +++ .../src/com/android/keyguard/LockIconViewController.java | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index bc644f475009c..7a72a58e5b9a4 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -580,6 +580,9 @@ 280 + + 200 + diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java index 680b8bd708371..c1b2aba22b578 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -83,8 +83,8 @@ public class LockIconViewController extends ViewController impleme private static final int sLockIconRadiusPx = (int) (sDefaultDensity * 36); private static final VibrationAttributes TOUCH_VIBRATION_ATTRIBUTES = VibrationAttributes.createForUsage(VibrationAttributes.USAGE_TOUCH); - private static final long LONG_PRESS_TIMEOUT = 200L; // milliseconds + private final long mLongPressTimeout; @NonNull private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; @NonNull private final KeyguardViewController mKeyguardViewController; @NonNull private final StatusBarStateController mStatusBarStateController; @@ -176,6 +176,7 @@ public class LockIconViewController extends ViewController impleme mView.setImageDrawable(mIcon); mUnlockedLabel = resources.getString(R.string.accessibility_unlock_button); mLockedLabel = resources.getString(R.string.accessibility_lock_icon); + mLongPressTimeout = resources.getInteger(R.integer.config_lockIconLongPress); dumpManager.registerDumpable(TAG, this); } @@ -545,7 +546,7 @@ public class LockIconViewController extends ViewController impleme /** * Handles the touch if it is within the lock icon view and {@link #isActionable()} is true. * Subsequently, will trigger {@link #onLongPress()} if a touch is continuously in the lock icon - * area for {@link #LONG_PRESS_TIMEOUT} ms. + * area for {@link #mLongPressTimeout} ms. * * Touch speed debouncing mimics logic from the velocity tracker in {@link UdfpsController}. */ @@ -585,7 +586,7 @@ public class LockIconViewController extends ViewController impleme mDownDetected = true; mLongPressCancelRunnable = mExecutor.executeDelayed( - this::onLongPress, LONG_PRESS_TIMEOUT); + this::onLongPress, mLongPressTimeout); break; case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_HOVER_MOVE: @@ -600,7 +601,7 @@ public class LockIconViewController extends ViewController impleme + "high pointer velocity=" + velocity); mLongPressCancelRunnable.run(); mLongPressCancelRunnable = mExecutor.executeDelayed( - this::onLongPress, LONG_PRESS_TIMEOUT); + this::onLongPress, mLongPressTimeout); } break; case MotionEvent.ACTION_UP: