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

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

Merge "Shortcut Helper - Connect UI layer to shortcuts" into main

parents aad32e06 6900a41a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ private val ShortcutCategory.labelResId: Int
    get() =
        when (type) {
            ShortcutCategoryType.SYSTEM -> R.string.shortcut_helper_category_system
            ShortcutCategoryType.MULTI_TASKING -> R.string.shortcut_helper_category_system
            ShortcutCategoryType.MULTI_TASKING -> R.string.shortcut_helper_category_multitasking
            ShortcutCategoryType.IME -> R.string.shortcut_helper_category_input
        }

+1 −5
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import com.android.compose.theme.PlatformTheme
import com.android.systemui.keyboard.shortcut.ui.composable.ShortcutHelper
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutsUiState
import com.android.systemui.keyboard.shortcut.ui.viewmodel.ShortcutHelperViewModel
import com.android.systemui.res.R
import com.google.android.material.bottomsheet.BottomSheetBehavior
@@ -81,10 +80,7 @@ constructor(
        requireViewById<ComposeView>(R.id.shortcut_helper_compose_container).apply {
            setContent {
                PlatformTheme {
                    val shortcutsUiState by
                        viewModel.shortcutsUiState.collectAsStateWithLifecycle(
                            initialValue = ShortcutsUiState.Inactive
                        )
                    val shortcutsUiState by viewModel.shortcutsUiState.collectAsStateWithLifecycle()
                    ShortcutHelper(
                        shortcutsUiState = shortcutsUiState,
                        onKeyboardSettingsClicked = ::onKeyboardSettingsClicked,
+19 −9
Original line number Diff line number Diff line
@@ -23,13 +23,17 @@ import com.android.systemui.keyboard.shortcut.shared.model.ShortcutHelperState
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutsUiState
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn

class ShortcutHelperViewModel
@Inject
constructor(
    @Background private val backgroundScope: CoroutineScope,
    @Background private val backgroundDispatcher: CoroutineDispatcher,
    private val stateInteractor: ShortcutHelperStateInteractor,
    categoriesInteractor: ShortcutHelperCategoriesInteractor,
@@ -42,7 +46,8 @@ constructor(
            .flowOn(backgroundDispatcher)

    val shortcutsUiState =
        categoriesInteractor.shortcutCategories.map {
        categoriesInteractor.shortcutCategories
            .map {
                if (it.isEmpty()) {
                    ShortcutsUiState.Inactive
                } else {
@@ -52,6 +57,11 @@ constructor(
                    )
                }
            }
            .stateIn(
                scope = backgroundScope,
                started = SharingStarted.Lazily,
                initialValue = ShortcutsUiState.Inactive
            )

    fun onViewClosed() {
        stateInteractor.onViewClosed()
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ val Kosmos.shortcutHelperCategoriesInteractor by
val Kosmos.shortcutHelperViewModel by
    Kosmos.Fixture {
        ShortcutHelperViewModel(
            applicationCoroutineScope,
            testDispatcher,
            shortcutHelperStateInteractor,
            shortcutHelperCategoriesInteractor