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

Commit 94d045e1 authored by George Lin's avatar George Lin
Browse files

Handle inital deep link shortcut slot ID (1/2)

Handle the case if an initial shortcut slot ID is specified

Test: Manually tested.
Bug: 416056160
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: I554a9da35f09926859108f51a1114c490e1ce6a9
parent b153485a
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -62,9 +62,11 @@ constructor(
    private val quickAffordanceInteractor: KeyguardQuickAffordancePickerInteractor,
    private val logger: ThemesUserEventLogger,
    @Assisted private val viewModelScope: CoroutineScope,
    @Assisted initialDeepLinkShortcutSlotId: String?,
) {
    /** A locally-selected slot, if the user ever switched from the original one. */
    private val _selectedSlotId = MutableStateFlow<String?>(null)
    private val _selectedSlotId: MutableStateFlow<String?> =
        MutableStateFlow(initialDeepLinkShortcutSlotId)
    /** The ID of the selected slot. */
    val selectedSlotId: StateFlow<String> =
        combine(quickAffordanceInteractor.slots, _selectedSlotId) { slots, selectedSlotIdOrNull ->
@@ -81,14 +83,15 @@ constructor(
                started = SharingStarted.WhileSubscribed(),
                initialValue = "",
            )
    private val overridingQuickAffordances = MutableStateFlow<Map<String, String>>(emptyMap())
    private val overridingQuickAffordances: MutableStateFlow<Map<String, String>> =
        MutableStateFlow(emptyMap())
    private val selectedQuickAffordancesGroupBySlotId =
        quickAffordanceInteractor.selections
            .map { it.groupBy { selectionModel -> selectionModel.slotId } }
            .shareIn(viewModelScope, SharingStarted.WhileSubscribed(), 1)

    val _selectedQuickAffordanceIndex = MutableStateFlow<Int>(0)
    val selectedQuickAffordanceIndex = _selectedQuickAffordanceIndex.asStateFlow()
    private val _selectedQuickAffordanceIndex: MutableStateFlow<Int> = MutableStateFlow(0)
    val selectedQuickAffordanceIndex: StateFlow<Int> = _selectedQuickAffordanceIndex.asStateFlow()

    val previewingQuickAffordances =
        combine(
@@ -473,6 +476,9 @@ constructor(
    @ViewModelScoped
    @AssistedFactory
    interface Factory {
        fun create(viewModelScope: CoroutineScope): KeyguardQuickAffordancePickerViewModel2
        fun create(
            viewModelScope: CoroutineScope,
            initialDeepLinkShortcutSlotId: String?,
        ): KeyguardQuickAffordancePickerViewModel2
    }
}
+9 −3
Original line number Diff line number Diff line
@@ -65,13 +65,15 @@ constructor(
    val themedIconViewModel: ThemedIconViewModel,
    val packThemeViewModel: PackThemeViewModel,
    @Assisted private val viewModelScope: CoroutineScope,
    @Assisted initialDeepLinkDestination: String?,
    @Assisted("destination") initialDeepLinkDestination: String?,
    @Assisted("shortcutSlotId") initialDeepLinkShortcutSlotId: String?,
) : CustomizationOptionsViewModel {

    private val defaultCustomizationOptionsViewModel =
        defaultCustomizationOptionsViewModelFactory.create(
            viewModelScope,
            initialDeepLinkDestination,
            initialDeepLinkShortcutSlotId,
        )

    override val wallpaperCarouselViewModel =
@@ -79,7 +81,10 @@ constructor(

    val clockPickerViewModel = clockPickerViewModelFactory.create(viewModelScope = viewModelScope)
    val keyguardQuickAffordancePickerViewModel2 =
        keyguardQuickAffordancePickerViewModel2Factory.create(viewModelScope = viewModelScope)
        keyguardQuickAffordancePickerViewModel2Factory.create(
            viewModelScope = viewModelScope,
            initialDeepLinkShortcutSlotId = initialDeepLinkShortcutSlotId,
        )
    val colorPickerViewModel2 = colorPickerViewModel2Factory.create(viewModelScope = viewModelScope)
    val gridPickerViewModel = gridPickerViewModelFactory.create(viewModelScope = viewModelScope)
    val appIconPickerViewModel =
@@ -265,7 +270,8 @@ constructor(
    interface Factory : CustomizationOptionsViewModelFactory {
        override fun create(
            viewModelScope: CoroutineScope,
            initialDeepLinkDestination: String?,
            @Assisted("destination") initialDeepLinkDestination: String?,
            @Assisted("shortcutSlotId") initialDeepLinkShortcutSlotId: String?,
        ): ThemePickerCustomizationOptionsViewModel
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ class KeyguardQuickAffordancePickerViewModel2Test {
                quickAffordanceInteractor = quickAffordanceInteractor,
                logger = logger,
                viewModelScope = testScope.backgroundScope,
                initialDeepLinkShortcutSlotId = null,
            )
    }