summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt13
-rw-r--r--packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt26
2 files changed, 8 insertions, 31 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt
index bccc3c5dc284..f1a8faf87417 100644
--- a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt
+++ b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt
@@ -19,7 +19,6 @@ package com.android.systemui.haptics.qs
import android.animation.ValueAnimator
import android.os.VibrationEffect
import android.view.View
-import android.view.ViewConfiguration
import android.view.animation.AccelerateDecelerateInterpolator
import androidx.annotation.VisibleForTesting
import androidx.core.animation.doOnCancel
@@ -32,7 +31,6 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
-import kotlinx.coroutines.flow.map
/**
* A class that handles the long press visuo-haptic effect for a QS tile.
@@ -76,9 +74,6 @@ constructor(
}
}
- // Should a tap timeout countdown begin
- val shouldWaitForTapTimeout: Flow<Boolean> = state.map { it == State.TIMEOUT_WAIT }
-
/** Haptic effects */
private val durations =
vibratorHelper?.getPrimitiveDurations(
@@ -247,12 +242,4 @@ constructor(
LONG_PRESS,
RESET_AND_LONG_PRESS,
}
-
- companion object {
- /**
- * A timeout to let the tile resolve if it is being swiped/scrolled. Since QS tiles are
- * inside a scrollable container, they will be considered pressed only after a tap timeout.
- */
- val PRESSED_TIMEOUT = ViewConfiguration.getTapTimeout().toLong() + 20L
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt
index 2ef901d34dd1..dd7a285eeaae 100644
--- a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt
@@ -18,15 +18,13 @@ package com.android.systemui.haptics.qs
import android.annotation.SuppressLint
import android.view.MotionEvent
+import android.view.ViewConfiguration
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.app.tracing.coroutines.launch
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.qs.tileimpl.QSTileViewImpl
-import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.DisposableHandle
-import kotlinx.coroutines.delay
-import kotlinx.coroutines.flow.filter
object QSLongPressEffectViewBinder {
@@ -71,20 +69,6 @@ object QSLongPressEffectViewBinder {
}
}
}
-
- // Tap timeout wait
- launch({ "${tileSpec ?: "unknownTileSpec"}#LongPressEffect#timeout" }) {
- qsLongPressEffect.shouldWaitForTapTimeout
- .filter { it }
- .collect {
- try {
- delay(QSLongPressEffect.PRESSED_TIMEOUT)
- qsLongPressEffect.handleTimeoutComplete()
- } catch (_: CancellationException) {
- qsLongPressEffect.resetEffect()
- }
- }
- }
}
}
}
@@ -93,7 +77,13 @@ object QSLongPressEffectViewBinder {
private fun setTouchListener(tile: QSTileViewImpl, longPressEffect: QSLongPressEffect?) {
tile.setOnTouchListener { _, event ->
when (event.actionMasked) {
- MotionEvent.ACTION_DOWN -> longPressEffect?.handleActionDown()
+ MotionEvent.ACTION_DOWN -> {
+ tile.postDelayed(
+ { longPressEffect?.handleTimeoutComplete() },
+ ViewConfiguration.getTapTimeout().toLong(),
+ )
+ longPressEffect?.handleActionDown()
+ }
MotionEvent.ACTION_UP -> longPressEffect?.handleActionUp()
MotionEvent.ACTION_CANCEL -> longPressEffect?.handleActionCancel()
}