Merge "Use event time instead of System.currentTimeMillis" into tm-qpr-dev
This commit is contained in:
@@ -342,14 +342,12 @@ object KeyguardBottomAreaViewBinder {
|
|||||||
|
|
||||||
private val longPressDurationMs = ViewConfiguration.getLongPressTimeout().toLong()
|
private val longPressDurationMs = ViewConfiguration.getLongPressTimeout().toLong()
|
||||||
private var longPressAnimator: ViewPropertyAnimator? = null
|
private var longPressAnimator: ViewPropertyAnimator? = null
|
||||||
private var downTimestamp = 0L
|
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
|
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
|
||||||
return when (event?.actionMasked) {
|
return when (event?.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN ->
|
MotionEvent.ACTION_DOWN ->
|
||||||
if (viewModel.configKey != null) {
|
if (viewModel.configKey != null) {
|
||||||
downTimestamp = System.currentTimeMillis()
|
|
||||||
longPressAnimator =
|
longPressAnimator =
|
||||||
view
|
view
|
||||||
.animate()
|
.animate()
|
||||||
@@ -396,7 +394,7 @@ object KeyguardBottomAreaViewBinder {
|
|||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
cancel(
|
cancel(
|
||||||
onAnimationEnd =
|
onAnimationEnd =
|
||||||
if (System.currentTimeMillis() - downTimestamp < longPressDurationMs) {
|
if (event.eventTime - event.downTime < longPressDurationMs) {
|
||||||
Runnable {
|
Runnable {
|
||||||
messageDisplayer.invoke(
|
messageDisplayer.invoke(
|
||||||
R.string.keyguard_affordance_press_too_short
|
R.string.keyguard_affordance_press_too_short
|
||||||
@@ -437,7 +435,6 @@ object KeyguardBottomAreaViewBinder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun cancel(onAnimationEnd: Runnable? = null) {
|
private fun cancel(onAnimationEnd: Runnable? = null) {
|
||||||
downTimestamp = 0L
|
|
||||||
longPressAnimator?.cancel()
|
longPressAnimator?.cancel()
|
||||||
longPressAnimator = null
|
longPressAnimator = null
|
||||||
view.animate().scaleX(1f).scaleY(1f).withEndAction(onAnimationEnd)
|
view.animate().scaleX(1f).scaleY(1f).withEndAction(onAnimationEnd)
|
||||||
|
|||||||
Reference in New Issue
Block a user