Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d64845f3 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez Committed by Android (Google) Code Review
Browse files

Merge "Removing manual tap timeout wait" into main

parents 249173da e690a19a
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -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
    }
}
+8 −18
Original line number Diff line number Diff line
@@ -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()
            }