summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/StateTransitionsTest.kt111
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizerTest.kt5
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizerTest.kt5
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/ThreeFingerGestureRecognizerTest.kt9
-rw-r--r--packages/SystemUI/res/values/strings.xml11
-rw-r--r--packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionKeyTutorialScreen.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionTutorialContent.kt34
-rw-r--r--packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialAnimation.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialScreenConfig.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/BackGestureTutorialScreen.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/GestureTutorialScreen.kt38
-rw-r--r--packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/HomeGestureTutorialScreen.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/RecentAppsGestureTutorialScreen.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureState.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureStateUpdates.kt2
15 files changed, 208 insertions, 34 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/StateTransitionsTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/StateTransitionsTest.kt
new file mode 100644
index 000000000000..2ad1124d72d4
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/StateTransitionsTest.kt
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.touchpad.tutorial.ui
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.Error
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.Finished
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.InProgress
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.InProgressAfterError
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.NotStarted
+import com.android.systemui.touchpad.tutorial.ui.composable.toGestureUiState
+import com.android.systemui.touchpad.tutorial.ui.composable.toTutorialActionState
+import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class StateTransitionsTest : SysuiTestCase() {
+
+ companion object {
+ private const val START_MARKER = "startMarker"
+ private const val END_MARKER = "endMarker"
+ private const val SUCCESS_ANIMATION = 0
+ }
+
+ // needed to simulate caching last state as it's used to create new state
+ private var lastState: TutorialActionState = NotStarted
+
+ private fun GestureState.toTutorialActionState(): TutorialActionState {
+ val newState =
+ this.toGestureUiState(
+ progressStartMarker = START_MARKER,
+ progressEndMarker = END_MARKER,
+ successAnimation = SUCCESS_ANIMATION,
+ )
+ .toTutorialActionState(lastState)
+ lastState = newState
+ return lastState
+ }
+
+ @Test
+ fun gestureStateProducesEquivalentTutorialActionStateInHappyPath() {
+ val happyPath =
+ listOf(
+ GestureState.NotStarted,
+ GestureState.InProgress(0f),
+ GestureState.InProgress(0.5f),
+ GestureState.InProgress(1f),
+ GestureState.Finished,
+ )
+
+ val resultingStates = mutableListOf<TutorialActionState>()
+ happyPath.forEach { resultingStates.add(it.toTutorialActionState()) }
+
+ assertThat(resultingStates)
+ .containsExactly(
+ NotStarted,
+ InProgress(0f, START_MARKER, END_MARKER),
+ InProgress(0.5f, START_MARKER, END_MARKER),
+ InProgress(1f, START_MARKER, END_MARKER),
+ Finished(SUCCESS_ANIMATION),
+ )
+ .inOrder()
+ }
+
+ @Test
+ fun gestureStateProducesEquivalentTutorialActionStateInErrorPath() {
+ val errorPath =
+ listOf(
+ GestureState.NotStarted,
+ GestureState.InProgress(0f),
+ GestureState.Error,
+ GestureState.InProgress(0.5f),
+ GestureState.InProgress(1f),
+ GestureState.Finished,
+ )
+
+ val resultingStates = mutableListOf<TutorialActionState>()
+ errorPath.forEach { resultingStates.add(it.toTutorialActionState()) }
+
+ assertThat(resultingStates)
+ .containsExactly(
+ NotStarted,
+ InProgress(0f, START_MARKER, END_MARKER),
+ Error,
+ InProgressAfterError(InProgress(0.5f, START_MARKER, END_MARKER)),
+ InProgressAfterError(InProgress(1f, START_MARKER, END_MARKER)),
+ Finished(SUCCESS_ANIMATION),
+ )
+ .inOrder()
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizerTest.kt
index 8d0d172ada12..e23348be1590 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/HomeGestureRecognizerTest.kt
@@ -21,6 +21,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.testKosmos
+import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.Error
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.InProgress
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.NotStarted
import com.android.systemui.touchpad.tutorial.ui.gesture.MultiFingerGesture.Companion.SWIPE_DISTANCE
@@ -56,9 +57,9 @@ class HomeGestureRecognizerTest : SysuiTestCase() {
}
@Test
- fun doesntTriggerGestureFinished_onGestureSpeedTooSlow() {
+ fun triggersError_onGestureSpeedTooSlow() {
velocityTracker.setVelocity(Velocity(SLOW))
- assertStateAfterEvents(events = ThreeFingerGesture.swipeUp(), expectedState = NotStarted)
+ assertStateAfterEvents(events = ThreeFingerGesture.swipeUp(), expectedState = Error)
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizerTest.kt
index 7a77b63a8925..2fe37aef7e0b 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/RecentAppsGestureRecognizerTest.kt
@@ -21,6 +21,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.testKosmos
+import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.Error
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.InProgress
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.NotStarted
import com.android.systemui.touchpad.tutorial.ui.gesture.MultiFingerGesture.Companion.SWIPE_DISTANCE
@@ -57,9 +58,9 @@ class RecentAppsGestureRecognizerTest : SysuiTestCase() {
}
@Test
- fun doesntTriggerGestureFinished_onGestureSpeedTooHigh() {
+ fun triggersError_onGestureSpeedTooHigh() {
velocityTracker.setVelocity(Velocity(FAST))
- assertStateAfterEvents(events = ThreeFingerGesture.swipeUp(), expectedState = NotStarted)
+ assertStateAfterEvents(events = ThreeFingerGesture.swipeUp(), expectedState = Error)
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/ThreeFingerGestureRecognizerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/ThreeFingerGestureRecognizerTest.kt
index de410894d0c0..533665eaa626 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/ThreeFingerGestureRecognizerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/touchpad/tutorial/ui/gesture/ThreeFingerGestureRecognizerTest.kt
@@ -19,6 +19,7 @@ package com.android.systemui.touchpad.tutorial.ui.gesture
import android.view.MotionEvent
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
+import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.Error
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.Finished
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.InProgress
import com.android.systemui.touchpad.tutorial.ui.gesture.GestureState.NotStarted
@@ -64,12 +65,12 @@ class ThreeFingerGestureRecognizerTest(
}
@Test
- fun doesntTriggerGestureFinished_onGestureDistanceTooShort() {
- assertStateAfterEvents(events = tooShortGesture, expectedState = NotStarted)
+ fun triggersGestureError_onGestureDistanceTooShort() {
+ assertStateAfterEvents(events = tooShortGesture, expectedState = Error)
}
@Test
- fun doesntTriggerGestureFinished_onThreeFingersSwipeInOtherDirections() {
+ fun triggersGestureError_onThreeFingersSwipeInOtherDirections() {
val allThreeFingerGestures =
listOf(
ThreeFingerGesture.swipeUp(),
@@ -78,7 +79,7 @@ class ThreeFingerGestureRecognizerTest(
ThreeFingerGesture.swipeRight(),
)
val invalidGestures = allThreeFingerGestures.filter { it.differentFromAnyOf(validGestures) }
- invalidGestures.forEach { assertStateAfterEvents(events = it, expectedState = NotStarted) }
+ invalidGestures.forEach { assertStateAfterEvents(events = it, expectedState = Error) }
}
@Test
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index f927e26e0cd9..56aaf4c0c564 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -3932,6 +3932,8 @@
<string name="touchpad_tutorial_recent_apps_gesture_button">View recent apps</string>
<!-- Label for button finishing touchpad tutorial [CHAR LIMIT=NONE] -->
<string name="touchpad_tutorial_done_button">Done</string>
+ <!-- Screen title after gesture was not done correctly [CHAR LIMIT=NONE] -->
+ <string name="gesture_error_title">Try again!</string>
<!-- BACK GESTURE -->
<!-- Touchpad back gesture action name in tutorial [CHAR LIMIT=NONE] -->
<string name="touchpad_back_gesture_action_title">Go back</string>
@@ -3941,6 +3943,8 @@
<string name="touchpad_back_gesture_success_title">Nice!</string>
<!-- Text shown to the user after they complete back gesture tutorial [CHAR LIMIT=NONE] -->
<string name="touchpad_back_gesture_success_body">You completed the go back gesture.</string>
+ <!-- Text shown to the user after back gesture was not done correctly [CHAR LIMIT=NONE] -->
+ <string name="touchpad_back_gesture_error_body">To go back using your touchpad, swipe left or right using three fingers</string>
<!-- HOME GESTURE -->
<!-- Touchpad home gesture action name in tutorial [CHAR LIMIT=NONE] -->
<string name="touchpad_home_gesture_action_title">Go home</string>
@@ -3950,6 +3954,8 @@
<string name="touchpad_home_gesture_success_title">Great job!</string>
<!-- Text shown to the user after they complete home gesture tutorial [CHAR LIMIT=NONE] -->
<string name="touchpad_home_gesture_success_body">You completed the go home gesture</string>
+ <!-- Text shown to the user after home gesture was not done correctly [CHAR LIMIT=NONE] -->
+ <string name="touchpad_home_gesture_error_body">Swipe up with three fingers on your touchpad to go to your home screen</string>
<!-- RECENT APPS GESTURE -->
<!-- Touchpad recent apps gesture action name in tutorial [CHAR LIMIT=NONE] -->
<string name="touchpad_recent_apps_gesture_action_title">View recent apps</string>
@@ -3959,6 +3965,8 @@
<string name="touchpad_recent_apps_gesture_success_title">Great job!</string>
<!-- Text shown to the user after they complete recent apps gesture tutorial [CHAR LIMIT=NONE] -->
<string name="touchpad_recent_apps_gesture_success_body">You completed the view recent apps gesture.</string>
+ <!-- Text shown to the user after recent gesture was not done correctly [CHAR LIMIT=NONE] -->
+ <string name="touchpad_recent_gesture_error_body">To view recent apps, swipe up and hold using three fingers on your touchpad</string>
<!-- KEYBOARD TUTORIAL-->
<!-- Action key tutorial title [CHAR LIMIT=NONE] -->
@@ -3969,6 +3977,9 @@
<string name="tutorial_action_key_success_title">Well done!</string>
<!-- Text shown to the user after they complete action key tutorial [CHAR LIMIT=NONE] -->
<string name="tutorial_action_key_success_body">You completed the view all apps gesture</string>
+ <!-- Text shown to the user after action key tutorial was not done correctly [CHAR LIMIT=NONE] -->
+ <string name="touchpad_action_key_error_body">Press the action key on your keyboard to view all of your apps</string>
+
<!-- Content description for the animation playing during the tutorial. The user can click the animation to pause and unpause playback. [CHAR LIMIT=NONE] -->
<string name="tutorial_animation_content_description">Tutorial animation, click to pause and resume play.</string>
diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionKeyTutorialScreen.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionKeyTutorialScreen.kt
index 058e5874ae7c..950a727aedae 100644
--- a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionKeyTutorialScreen.kt
+++ b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionKeyTutorialScreen.kt
@@ -79,6 +79,9 @@ private fun buildScreenConfig() =
bodyResId = R.string.tutorial_action_key_guidance,
titleSuccessResId = R.string.tutorial_action_key_success_title,
bodySuccessResId = R.string.tutorial_action_key_success_body,
+ // error state for action key is not implemented yet so below should never appear
+ titleErrorResId = R.string.gesture_error_title,
+ bodyErrorResId = R.string.touchpad_action_key_error_body,
),
animations = TutorialScreenConfig.Animations(educationResId = R.raw.action_key_edu),
)
diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionTutorialContent.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionTutorialContent.kt
index 0c1bc835517a..c40adfe6baf8 100644
--- a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionTutorialContent.kt
+++ b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/ActionTutorialContent.kt
@@ -45,18 +45,33 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.Error
import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.Finished
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.InProgress
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.InProgressAfterError
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.NotStarted
sealed interface TutorialActionState {
data object NotStarted : TutorialActionState
data class InProgress(
- val progress: Float = 0f,
- val startMarker: String? = null,
- val endMarker: String? = null,
- ) : TutorialActionState
+ override val progress: Float = 0f,
+ override val startMarker: String? = null,
+ override val endMarker: String? = null,
+ ) : TutorialActionState, Progress
data class Finished(@RawRes val successAnimation: Int) : TutorialActionState
+
+ data object Error : TutorialActionState
+
+ data class InProgressAfterError(val inProgress: InProgress) :
+ TutorialActionState, Progress by inProgress
+}
+
+interface Progress {
+ val progress: Float
+ val startMarker: String?
+ val endMarker: String?
}
@Composable
@@ -133,10 +148,13 @@ fun TutorialDescription(
val focusRequester = remember { FocusRequester() }
LaunchedEffect(Unit) { focusRequester.requestFocus() }
val (titleTextId, bodyTextId) =
- if (actionState is Finished) {
- config.strings.titleSuccessResId to config.strings.bodySuccessResId
- } else {
- config.strings.titleResId to config.strings.bodyResId
+ when (actionState) {
+ is Finished -> config.strings.titleSuccessResId to config.strings.bodySuccessResId
+ Error,
+ is InProgressAfterError ->
+ config.strings.titleErrorResId to config.strings.bodyErrorResId
+ is NotStarted,
+ is InProgress -> config.strings.titleResId to config.strings.bodyResId
}
Column(verticalArrangement = Arrangement.Top, modifier = modifier) {
Text(
diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialAnimation.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialAnimation.kt
index ad18817704aa..b0816ce608a0 100644
--- a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialAnimation.kt
+++ b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialAnimation.kt
@@ -47,8 +47,10 @@ import com.airbnb.lottie.compose.LottieConstants
import com.airbnb.lottie.compose.LottieDynamicProperties
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.Error
import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.Finished
import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.InProgress
+import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.InProgressAfterError
import com.android.systemui.inputdevice.tutorial.ui.composable.TutorialActionState.NotStarted
import com.android.systemui.res.R
@@ -72,16 +74,18 @@ fun TutorialAnimation(
},
) { state ->
when (state) {
- NotStarted::class ->
+ NotStarted::class,
+ Error::class ->
EducationAnimation(
config.animations.educationResId,
config.colors.animationColors,
)
- InProgress::class ->
+ InProgress::class,
+ InProgressAfterError::class ->
InProgressAnimation(
// actionState can be already of different class while this composable is
// transitioning to another one
- actionState as? InProgress,
+ actionState as? Progress,
config.animations.educationResId,
config.colors.animationColors,
)
@@ -138,14 +142,14 @@ private fun SuccessAnimation(
@Composable
private fun InProgressAnimation(
- state: InProgress?,
+ state: Progress?,
@RawRes inProgressAnimationId: Int,
animationProperties: LottieDynamicProperties,
) {
// Caching latest progress for when we're animating this view away and state is null.
// Without this there's jumpcut in the animation while it's animating away.
// state should never be null when composable appears, only when disappearing
- val cached = remember { Ref<InProgress>() }
+ val cached = remember { Ref<Progress>() }
cached.value = state ?: cached.value
val progress = cached.value?.progress ?: 0f
diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialScreenConfig.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialScreenConfig.kt
index 60dfed3a67a4..26259912741a 100644
--- a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialScreenConfig.kt
+++ b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/ui/composable/TutorialScreenConfig.kt
@@ -38,6 +38,8 @@ data class TutorialScreenConfig(
@StringRes val bodyResId: Int,
@StringRes val titleSuccessResId: Int,
@StringRes val bodySuccessResId: Int,
+ @StringRes val titleErrorResId: Int,
+ @StringRes val bodyErrorResId: Int,
)
data class Animations(@RawRes val educationResId: Int)
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/BackGestureTutorialScreen.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/BackGestureTutorialScreen.kt
index bfdae626b5e8..e1cc11a7cfd1 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/BackGestureTutorialScreen.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/BackGestureTutorialScreen.kt
@@ -45,6 +45,8 @@ fun BackGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: () -> Uni
bodyResId = R.string.touchpad_back_gesture_guidance,
titleSuccessResId = R.string.touchpad_back_gesture_success_title,
bodySuccessResId = R.string.touchpad_back_gesture_success_body,
+ titleErrorResId = R.string.gesture_error_title,
+ bodyErrorResId = R.string.touchpad_back_gesture_error_body,
),
animations = TutorialScreenConfig.Animations(educationResId = R.raw.trackpad_back_edu),
)
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/GestureTutorialScreen.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/GestureTutorialScreen.kt
index 2332c0051c69..ed84f9c42c3a 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/GestureTutorialScreen.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/GestureTutorialScreen.kt
@@ -54,6 +54,8 @@ sealed interface GestureUiState {
val progressStartMarker: String,
val progressEndMarker: String,
) : GestureUiState
+
+ data object Error : GestureUiState
}
fun GestureState.toGestureUiState(
@@ -66,19 +68,31 @@ fun GestureState.toGestureUiState(
is GestureState.InProgress ->
GestureUiState.InProgress(this.progress, progressStartMarker, progressEndMarker)
is GestureState.Finished -> GestureUiState.Finished(successAnimation)
+ GestureState.Error -> GestureUiState.Error
}
}
-fun GestureUiState.toTutorialActionState(): TutorialActionState {
+fun GestureUiState.toTutorialActionState(previousState: TutorialActionState): TutorialActionState {
return when (this) {
NotStarted -> TutorialActionState.NotStarted
- is GestureUiState.InProgress ->
- TutorialActionState.InProgress(
- progress = progress,
- startMarker = progressStartMarker,
- endMarker = progressEndMarker,
- )
+ is GestureUiState.InProgress -> {
+ val inProgress =
+ TutorialActionState.InProgress(
+ progress = progress,
+ startMarker = progressStartMarker,
+ endMarker = progressEndMarker,
+ )
+ if (
+ previousState is TutorialActionState.InProgressAfterError ||
+ previousState is TutorialActionState.Error
+ ) {
+ return TutorialActionState.InProgressAfterError(inProgress)
+ } else {
+ return inProgress
+ }
+ }
is Finished -> TutorialActionState.Finished(successAnimation)
+ GestureUiState.Error -> TutorialActionState.Error
}
}
@@ -102,11 +116,11 @@ fun GestureTutorialScreen(
easterEggTriggered,
resetEasterEggFlag = { easterEggTriggered = false },
) {
- ActionTutorialContent(
- gestureState.toTutorialActionState(),
- onDoneButtonClicked,
- screenConfig,
- )
+ var lastState: TutorialActionState by remember {
+ mutableStateOf(TutorialActionState.NotStarted)
+ }
+ lastState = gestureState.toTutorialActionState(lastState)
+ ActionTutorialContent(lastState, onDoneButtonClicked, screenConfig)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/HomeGestureTutorialScreen.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/HomeGestureTutorialScreen.kt
index 45fdd21e795e..26604ca6b845 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/HomeGestureTutorialScreen.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/HomeGestureTutorialScreen.kt
@@ -42,6 +42,8 @@ fun HomeGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: () -> Uni
bodyResId = R.string.touchpad_home_gesture_guidance,
titleSuccessResId = R.string.touchpad_home_gesture_success_title,
bodySuccessResId = R.string.touchpad_home_gesture_success_body,
+ titleErrorResId = R.string.gesture_error_title,
+ bodyErrorResId = R.string.touchpad_home_gesture_error_body,
),
animations = TutorialScreenConfig.Animations(educationResId = R.raw.trackpad_home_edu),
)
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/RecentAppsGestureTutorialScreen.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/RecentAppsGestureTutorialScreen.kt
index 680b670f4d97..6400aca57693 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/RecentAppsGestureTutorialScreen.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/composable/RecentAppsGestureTutorialScreen.kt
@@ -42,6 +42,8 @@ fun RecentAppsGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: ()
bodyResId = R.string.touchpad_recent_apps_gesture_guidance,
titleSuccessResId = R.string.touchpad_recent_apps_gesture_success_title,
bodySuccessResId = R.string.touchpad_recent_apps_gesture_success_body,
+ titleErrorResId = R.string.gesture_error_title,
+ bodyErrorResId = R.string.touchpad_recent_gesture_error_body,
),
animations =
TutorialScreenConfig.Animations(educationResId = R.raw.trackpad_recent_apps_edu),
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureState.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureState.kt
index f27ddb515c24..7bc7e81ceb51 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureState.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureState.kt
@@ -23,6 +23,8 @@ sealed interface GestureState {
data class InProgress(val progress: Float = 0f, val direction: GestureDirection? = null) :
GestureState
+
+ data object Error : GestureState
}
enum class GestureDirection {
diff --git a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureStateUpdates.kt b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureStateUpdates.kt
index 24f5d1f00794..69886e4a1242 100644
--- a/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureStateUpdates.kt
+++ b/packages/SystemUI/src/com/android/systemui/touchpad/tutorial/ui/gesture/GestureStateUpdates.kt
@@ -28,7 +28,7 @@ inline fun updateGestureState(
if (isFinished(gestureState)) {
gestureStateChangedCallback(GestureState.Finished)
} else {
- gestureStateChangedCallback(GestureState.NotStarted)
+ gestureStateChangedCallback(GestureState.Error)
}
}
is Moving -> {