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

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

Merge "Playing long-press haptics on QS tiles regardless of the long-press action." into main

parents 3cb80002 fd0b20a6
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()