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

Commit 71c67e9f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[OOBE] Autoproceed" into main

parents b066cd6b 7221c360
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -247,6 +247,23 @@ class KeyboardTouchpadTutorialViewModelTest : SysuiTestCase() {
            assertGesturesNotDisabled()
        }

    @Test
    fun screensOrderUntilFinish_whenAutoProceed() =
        testScope.runTest {
            val screens by collectValues(viewModel.screen)
            val closeActivity by collectLastValue(viewModel.closeActivity)

            peripheralsState(keyboardConnected = true, touchpadConnected = true)

            autoProceed()
            autoProceed()
            // No autoproceeding at the last screen
            goToNextScreen()

            assertThat(screens).containsExactly(BACK_GESTURE, HOME_GESTURE, ACTION_KEY).inOrder()
            assertThat(closeActivity).isTrue()
        }

    @Test
    fun activityFinishes_ifTouchpadModuleIsNotPresent() =
        testScope.runTest {
@@ -299,6 +316,11 @@ class KeyboardTouchpadTutorialViewModelTest : SysuiTestCase() {
        runCurrent()
    }

    private suspend fun TestScope.autoProceed() {
        viewModel.onAutoProceed()
        runCurrent()
    }

    private fun TestScope.goBack() {
        viewModel.onBack()
        runCurrent()
+10 −2
Original line number Diff line number Diff line
@@ -21,8 +21,16 @@ import androidx.compose.runtime.Composable
interface TouchpadTutorialScreensProvider {

    @Composable
    fun BackGesture(onDoneButtonClicked: () -> Unit, onBack: () -> Unit, isAutoProceed: Boolean)
    fun BackGesture(
        onDoneButtonClicked: () -> Unit,
        onBack: () -> Unit,
        onAutoProceed: (suspend () -> Unit)?,
    )

    @Composable
    fun HomeGesture(onDoneButtonClicked: () -> Unit, onBack: () -> Unit, isAutoProceed: Boolean)
    fun HomeGesture(
        onDoneButtonClicked: () -> Unit,
        onBack: () -> Unit,
        onAutoProceed: (suspend () -> Unit)?,
    )
}
+5 −1
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ fun ActionTutorialContent(
    actionState: TutorialActionState,
    onDoneButtonClicked: () -> Unit,
    config: TutorialScreenConfig,
    onAutoProceed: (suspend () -> Unit)? = null,
) {
    Column(
        verticalArrangement = Arrangement.Center,
@@ -137,9 +138,12 @@ fun ActionTutorialContent(
            onDoneButtonClicked = onDoneButtonClicked,
            modifier = Modifier.padding(horizontal = 60.dp).graphicsLayer { alpha = buttonAlpha },
            enabled = actionState is Finished,
            isNext = config.hasNextButton,
            isNext = onAutoProceed != null,
        )
    }
    if (actionState is Finished) {
        LaunchedEffect(Unit) { onAutoProceed?.invoke() }
    }
}

@Composable
+0 −1
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ data class TutorialScreenConfig(
    val colors: Colors,
    val strings: Strings,
    val animations: Animations,
    val hasNextButton: Boolean = false,
) {

    data class Colors(
+2 −2
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ fun KeyboardTouchpadTutorialContainer(
                .BackGesture(
                    onDoneButtonClicked = vm::onDoneButtonClicked,
                    onBack = vm::onBack,
                    isAutoProceed = isAutoProceed,
                    onAutoProceed = if (isAutoProceed) vm::onAutoProceed else null,
                )
        HOME_GESTURE ->
            touchpadScreens
@@ -155,7 +155,7 @@ fun KeyboardTouchpadTutorialContainer(
                .HomeGesture(
                    onDoneButtonClicked = vm::onDoneButtonClicked,
                    onBack = vm::onBack,
                    isAutoProceed = isScopeAll,
                    onAutoProceed = if (isScopeAll) vm::onAutoProceed else null,
                )
        ACTION_KEY ->
            ActionKeyTutorialScreen(
Loading