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

Commit fd0b20a6 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Playing long-press haptics on QS tiles regardless of the long-press

action.

According to UX refinements, we should play the haptic signal for a
long-press on a quick settings tile regardless of the action that the
tile performs when it is long-pressed.

Test: refactored unit tests
Test: manual. Verified long-press haptics play on small and large tiles
Bug: 430170257
Flag: com.android.systemui.msdl_feedback
Change-Id: I1cc69af5e9e094049f0d015927d633bba980a83d
parent 7aa6289b
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -101,14 +101,12 @@ class TileHapticsViewModelTest : SysuiTestCase() {
        }

    @Test
    fun whenLaunchingFromLongClick_playsLongPressHaptics() =
    fun whenLongClickOccurs_playsLongPressHaptics() =
        testScope.runTest {
            // WHEN the tile is long-clicked and its action state changes accordingly
            // WHEN the tile is long-clicked
            underTest.setTileInteractionState(
                TileHapticsViewModel.TileInteractionState.LONG_CLICKED
            )
            // WHEN the activity transition (from the long-click) starts
            underTest.onActivityLaunchTransitionStart()
            runCurrent()

            // THEN the long-press token plays
+6 −7
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import javax.inject.Inject
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.merge
@@ -78,12 +77,12 @@ constructor(
            .distinctUntilChanged()

    private val interactionHapticsState: Flow<TileHapticsState> =
        combine(tileInteractionState, tileAnimationState) { interactionState, animationState ->
                when {
                    interactionState == TileInteractionState.LONG_CLICKED &&
                        animationState == TileAnimationState.ACTIVITY_LAUNCH ->
        tileInteractionState
            .mapLatest {
                if (it == TileInteractionState.LONG_CLICKED) {
                    TileHapticsState.LONG_PRESS
                    else -> TileHapticsState.NO_HAPTICS
                } else {
                    TileHapticsState.NO_HAPTICS
                }
            }
            .distinctUntilChanged()