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

Commit 6848eef3 authored by Michał Brzeziński's avatar Michał Brzeziński Committed by Android (Google) Code Review
Browse files

Merge changes Ie7aa6595,I5c530e47 into main

* changes:
  Not depending on system gesture distance for touchpad tutorial
  Passing animation markers between model layers
parents e62e7c83 0917ba7c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1977,6 +1977,9 @@
        slowing down. Also for tutorial it should be fine to lean to the side of being more strict
        rather than not strict enough and not teaching user the proper gesture as a result.-->
    <dimen name="touchpad_recent_apps_gesture_velocity_threshold">0.05dp</dimen>
    <!-- Normal gesture threshold is system_gestures_distance_threshold but for tutorial we can
         exaggerate gesture, which also works much better with live tracking -->
    <dimen name="touchpad_tutorial_gestures_distance_threshold">48dp</dimen>

    <!-- Broadcast dialog -->
    <dimen name="broadcast_dialog_title_img_margin_top">18dp</dimen>
+3 −5
Original line number Diff line number Diff line
@@ -51,8 +51,8 @@ fun BackGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: () -> Uni
        remember(recognizer) {
            GestureFlowAdapter(recognizer).gestureStateAsFlow.map {
                it.toGestureUiState(
                    progressStartMark = "",
                    progressEndMark = "",
                    progressStartMarker = "",
                    progressEndMarker = "",
                    successAnimation = R.raw.trackpad_back_success,
                )
            }
@@ -63,9 +63,7 @@ fun BackGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: () -> Uni
@Composable
private fun rememberBackGestureRecognizer(resources: Resources): GestureRecognizer {
    val distance =
        resources.getDimensionPixelSize(
            com.android.internal.R.dimen.system_gestures_distance_threshold
        )
        resources.getDimensionPixelSize(R.dimen.touchpad_tutorial_gestures_distance_threshold)
    return remember(distance) { BackGestureRecognizer(distance) }
}

+11 −7
Original line number Diff line number Diff line
@@ -51,20 +51,20 @@ sealed interface GestureUiState {

    data class InProgress(
        val progress: Float = 0f,
        val progressStartMark: String = "",
        val progressEndMark: String = "",
        val progressStartMarker: String,
        val progressEndMarker: String,
    ) : GestureUiState
}

fun GestureState.toGestureUiState(
    progressStartMark: String,
    progressEndMark: String,
    progressStartMarker: String,
    progressEndMarker: String,
    successAnimation: Int,
): GestureUiState {
    return when (this) {
        GestureState.NotStarted -> NotStarted
        is GestureState.InProgress ->
            GestureUiState.InProgress(this.progress, progressStartMark, progressEndMark)
            GestureUiState.InProgress(this.progress, progressStartMarker, progressEndMarker)
        is GestureState.Finished -> GestureUiState.Finished(successAnimation)
    }
}
@@ -72,8 +72,12 @@ fun GestureState.toGestureUiState(
fun GestureUiState.toTutorialActionState(): TutorialActionState {
    return when (this) {
        NotStarted -> TutorialActionState.NotStarted
        // progress is disabled for now as views are not ready to handle varying progress
        is GestureUiState.InProgress -> TutorialActionState.InProgress(progress = 0f)
        is GestureUiState.InProgress ->
            TutorialActionState.InProgress(
                progress = progress,
                startMarker = progressStartMarker,
                endMarker = progressEndMarker,
            )
        is Finished -> TutorialActionState.Finished(successAnimation)
    }
}
+3 −5
Original line number Diff line number Diff line
@@ -50,8 +50,8 @@ fun HomeGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: () -> Uni
        remember(recognizer) {
            GestureFlowAdapter(recognizer).gestureStateAsFlow.map {
                it.toGestureUiState(
                    progressStartMark = "",
                    progressEndMark = "",
                    progressStartMarker = "",
                    progressEndMarker = "",
                    successAnimation = R.raw.trackpad_home_success,
                )
            }
@@ -62,9 +62,7 @@ fun HomeGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: () -> Uni
@Composable
private fun rememberHomeGestureRecognizer(resources: Resources): GestureRecognizer {
    val distance =
        resources.getDimensionPixelSize(
            com.android.internal.R.dimen.system_gestures_distance_threshold
        )
        resources.getDimensionPixelSize(R.dimen.touchpad_tutorial_gestures_distance_threshold)
    return remember(distance) { HomeGestureRecognizer(distance) }
}

+3 −5
Original line number Diff line number Diff line
@@ -51,8 +51,8 @@ fun RecentAppsGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: ()
        remember(recognizer) {
            GestureFlowAdapter(recognizer).gestureStateAsFlow.map {
                it.toGestureUiState(
                    progressStartMark = "",
                    progressEndMark = "",
                    progressStartMarker = "",
                    progressEndMarker = "",
                    successAnimation = R.raw.trackpad_recent_apps_success,
                )
            }
@@ -63,9 +63,7 @@ fun RecentAppsGestureTutorialScreen(onDoneButtonClicked: () -> Unit, onBack: ()
@Composable
private fun rememberRecentAppsGestureRecognizer(resources: Resources): GestureRecognizer {
    val distance =
        resources.getDimensionPixelSize(
            com.android.internal.R.dimen.system_gestures_distance_threshold
        )
        resources.getDimensionPixelSize(R.dimen.touchpad_tutorial_gestures_distance_threshold)
    val velocity = resources.getDimension(R.dimen.touchpad_recent_apps_gesture_velocity_threshold)
    return remember(distance, velocity) { RecentAppsGestureRecognizer(distance, velocity) }
}