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

Commit 62991477 authored by George Lin's avatar George Lin Committed by Android (Google) Code Review
Browse files

Merge "Handle inital deep link shortcut slot ID (1/2)" into main

parents 82aa8d5f 94d045e1
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,
            )
    }