diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt index 1669f44604614d2d08ec134c5dd2ad87d7a5eca7..0ed9dfa06e107f413dda5ca7835cccb988e090f7 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt @@ -24,6 +24,8 @@ import android.view.View import android.view.ViewGroup import android.view.ViewPropertyAnimator import android.widget.ImageView +import androidx.core.animation.CycleInterpolator +import androidx.core.animation.ObjectAnimator import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams @@ -382,6 +384,27 @@ object KeyguardBottomAreaViewBinder { falsingManager, ) view.setOnTouchListener(onTouchListener) + view.setOnClickListener { + messageDisplayer.invoke(R.string.keyguard_affordance_press_too_short) + val amplitude = + view.context.resources + .getDimensionPixelSize(R.dimen.keyguard_affordance_shake_amplitude) + .toFloat() + val shakeAnimator = + ObjectAnimator.ofFloat( + view, + "translationX", + -amplitude / 2, + amplitude / 2, + ) + shakeAnimator.duration = + KeyguardBottomAreaVibrations.ShakeAnimationDuration.inWholeMilliseconds + shakeAnimator.interpolator = + CycleInterpolator(KeyguardBottomAreaVibrations.ShakeAnimationCycles) + shakeAnimator.start() + + vibratorHelper?.vibrate(KeyguardBottomAreaVibrations.Shake) + } view.onLongClickListener = OnLongClickListener(falsingManager, viewModel, vibratorHelper, onTouchListener) } else { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt index 7685345805f4442619afbe34a90c0f75f04a5d06..518bd7a39a9e58b4fab86e1f83d79beaade7eb85 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt @@ -99,41 +99,7 @@ class KeyguardQuickAffordanceOnTouchListener( // When not using a stylus, lifting the finger/pointer will actually cancel // the long-press gesture. Calling cancel after the quick affordance was // already long-press activated is a no-op, so it's safe to call from here. - cancel( - onAnimationEnd = - if (event.eventTime - event.downTime < longPressDurationMs) { - Runnable { - messageDisplayer.invoke( - R.string.keyguard_affordance_press_too_short - ) - val amplitude = - view.context.resources - .getDimensionPixelSize( - R.dimen.keyguard_affordance_shake_amplitude - ) - .toFloat() - val shakeAnimator = - ObjectAnimator.ofFloat( - view, - "translationX", - -amplitude / 2, - amplitude / 2, - ) - shakeAnimator.duration = - KeyguardBottomAreaVibrations.ShakeAnimationDuration - .inWholeMilliseconds - shakeAnimator.interpolator = - CycleInterpolator( - KeyguardBottomAreaVibrations.ShakeAnimationCycles - ) - shakeAnimator.start() - - vibratorHelper?.vibrate(KeyguardBottomAreaVibrations.Shake) - } - } else { - null - } - ) + cancel() } false } @@ -168,10 +134,10 @@ class KeyguardQuickAffordanceOnTouchListener( view.setOnClickListener(null) } - fun cancel(onAnimationEnd: Runnable? = null) { + fun cancel() { longPressAnimator?.cancel() longPressAnimator = null - view.animate().scaleX(1f).scaleY(1f).withEndAction(onAnimationEnd) + view.animate().scaleX(1f).scaleY(1f) } companion object { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt index 83b5463ea19c91cf3ed012643e10ef845ffacc79..11dea4fa037f69e9f88ad1faf02f375b54c4b8bf 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt @@ -23,6 +23,8 @@ import android.util.Size import android.view.View import android.view.ViewGroup import android.widget.ImageView +import androidx.core.animation.CycleInterpolator +import androidx.core.animation.ObjectAnimator import androidx.core.view.isInvisible import androidx.core.view.isVisible import androidx.core.view.updateLayoutParams @@ -216,6 +218,27 @@ object KeyguardQuickAffordanceViewBinder { falsingManager, ) view.setOnTouchListener(onTouchListener) + view.setOnClickListener { + messageDisplayer.invoke(R.string.keyguard_affordance_press_too_short) + val amplitude = + view.context.resources + .getDimensionPixelSize(R.dimen.keyguard_affordance_shake_amplitude) + .toFloat() + val shakeAnimator = + ObjectAnimator.ofFloat( + view, + "translationX", + -amplitude / 2, + amplitude / 2, + ) + shakeAnimator.duration = + KeyguardBottomAreaVibrations.ShakeAnimationDuration.inWholeMilliseconds + shakeAnimator.interpolator = + CycleInterpolator(KeyguardBottomAreaVibrations.ShakeAnimationCycles) + shakeAnimator.start() + + vibratorHelper?.vibrate(KeyguardBottomAreaVibrations.Shake) + } view.onLongClickListener = OnLongClickListener(falsingManager, viewModel, vibratorHelper, onTouchListener) } else {