Skip to content
Snippets Groups Projects
Commit ebd0bbe4 authored by Brad Hinegardner's avatar Brad Hinegardner Committed by Automerger Merge Worker
Browse files

Merge "Move shortcut falsing shake and vibration to onclicklistener" into...

Merge "Move shortcut falsing shake and vibration to onclicklistener" into udc-qpr-dev am: 7adeffd9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24875873



Change-Id: I038184aa73266dcc6b62788ce79eed044fd3f456
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ac2a84f7 7adeffd9
No related branches found
No related tags found
No related merge requests found
......@@ -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 {
......
......@@ -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 {
......
......@@ -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 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment