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

Commit a15c524e authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Adding basic TouchpadTutorialActivity with starting ViewModels

Test: activity launches when triggered from intent: adb shell am start -a com.android.systemui.action.TOUCHPAD_TUTORIAL -c android.intent.category.DEFAULT
Bug: 309928033
Flag: com.android.systemui.new_touchpad_gestures_tutorial
Change-Id: I45aeb771ea8318c95085cd3dd323df98c8686e13
parent ae8fb7fa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -483,6 +483,7 @@ android_library {
        "androidx.compose.material_material-icons-extended",
        "androidx.activity_activity-compose",
        "androidx.compose.animation_animation-graphics",
        "androidx.lifecycle_lifecycle-viewmodel-compose",
        "device_policy_aconfig_flags_lib",
    ],
    libs: [
@@ -644,6 +645,7 @@ android_library {
        "androidx.compose.material_material-icons-extended",
        "androidx.activity_activity-compose",
        "androidx.compose.animation_animation-graphics",
        "androidx.lifecycle_lifecycle-viewmodel-compose",
        "TraceurCommon",
    ],
}
+9 −0
Original line number Diff line number Diff line
@@ -475,6 +475,15 @@
            android:exported="false"
            android:noHistory="true" />

        <activity android:name=".touchpad.tutorial.ui.view.TouchpadTutorialActivity"
            android:exported="true"
            android:theme="@style/Theme.AppCompat.NoActionBar">
            <intent-filter>
                <action android:name="com.android.systemui.action.TOUCHPAD_TUTORIAL"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>

        <service android:name=".screenshot.appclips.AppClipsScreenshotHelperService"
            android:exported="false"
            android:singleUser="true"
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.screenshot.scroll.LongScreenshotActivity;
import com.android.systemui.sensorprivacy.SensorUseStartedActivity;
import com.android.systemui.settings.brightness.BrightnessDialog;
import com.android.systemui.telephony.ui.activity.SwitchToManagedProfileForCallActivity;
import com.android.systemui.touchpad.tutorial.ui.view.TouchpadTutorialActivity;
import com.android.systemui.tuner.TunerActivity;
import com.android.systemui.usb.UsbAccessoryUriActivity;
import com.android.systemui.usb.UsbConfirmActivity;
@@ -156,4 +157,10 @@ public abstract class DefaultActivityBinder {
    @ClassKey(SwitchToManagedProfileForCallActivity.class)
    public abstract Activity bindSwitchToManagedProfileForCallActivity(
            SwitchToManagedProfileForCallActivity activity);

    /** Inject into TouchpadTutorialActivity. */
    @Binds
    @IntoMap
    @ClassKey(TouchpadTutorialActivity.class)
    public abstract Activity bindTouchpadTutorialActivity(TouchpadTutorialActivity activity);
}
+39 −0
Original line number Diff line number Diff line
/*
 * 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.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider

sealed class GestureTutorialViewModel : ViewModel()

class BackGestureTutorialViewModel : GestureTutorialViewModel()

class HomeGestureTutorialViewModel : GestureTutorialViewModel()

class GestureViewModelFactory : ViewModelProvider.Factory {

    @Suppress("UNCHECKED_CAST")
    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        return when (modelClass) {
            BackGestureTutorialViewModel::class.java -> BackGestureTutorialViewModel()
            HomeGestureTutorialViewModel::class.java -> HomeGestureTutorialViewModel()
            else -> error("Unknown ViewModel class: ${modelClass.name}")
        }
            as T
    }
}
+43 −0
Original line number Diff line number Diff line
/*
 * 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.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import javax.inject.Inject

class TouchpadTutorialViewModel : ViewModel() {

    private val _screen = MutableStateFlow(Screen.TUTORIAL_SELECTION)
    val screen: StateFlow<Screen> = _screen

    class Factory @Inject constructor() : ViewModelProvider.Factory {

        @Suppress("UNCHECKED_CAST")
        override fun <T : ViewModel> create(modelClass: Class<T>): T {
            return TouchpadTutorialViewModel() as T
        }
    }
}

enum class Screen {
    TUTORIAL_SELECTION,
    BACK_GESTURE,
    HOME_GESTURE,
}
Loading