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

Commit 36b511f1 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

Quick affordance repository.

This CL introduces KeyguardQuickAffordanceRepository which combines
the known built-in configs and the current selections from KeyguardQuickAffordanceSelectionManager to produce the current set of
available affordances and the current selected affordances for each
slot.

KeyguardQuickAffordanceSelectionManager is just an in-memory cache at
the moment as we will flesh it out in upcoming CLs such that it actually
uses a persistence layer.

Note that the repository is meant for use for both displaying the
affordances on the lock screen and for serving content provider queries
coming from the wallpaper picker, which is why it's got both a flow and
a "get" function as opposed to a single StateFlow.

Bug: 254858696,254853190
Test: unit tests included. Tested with followup CL to make sure that
quick affordances are still showing up on the lock screen.

Change-Id: I6947e1f729c2aa6470ba21582d664ca5b3e3af70
parent eaf2dc07
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.shared.keyguard.shared.model

/**
 * Collection of all supported "slots", placements where keyguard quick affordances can appear on
 * the lock screen.
 */
object KeyguardQuickAffordanceSlots {
    const val SLOT_ID_BOTTOM_START = "bottom_start"
    const val SLOT_ID_BOTTOM_END = "bottom_end"
}
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.data.quickaffordance.KeyguardDataQuickAffordanceModule;
import com.android.systemui.keyguard.data.repository.KeyguardRepositoryModule;
import com.android.systemui.keyguard.domain.interactor.StartKeyguardTransitionModule;
import com.android.systemui.keyguard.domain.quickaffordance.KeyguardQuickAffordanceModule;
@@ -71,6 +72,7 @@ import dagger.Provides;
        KeyguardUserSwitcherComponent.class},
        includes = {
            FalsingModule.class,
            KeyguardDataQuickAffordanceModule.class,
            KeyguardQuickAffordanceModule.class,
            KeyguardRepositoryModule.class,
            StartKeyguardTransitionModule.class,
+4 −0
Original line number Diff line number Diff line
@@ -53,6 +53,10 @@ constructor(

    override val key: String = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS

    override val pickerName: String by lazy { context.getString(component.getTileTitleId()) }

    override val pickerIconResourceId: Int by lazy { component.getTileImageId() }

    override val lockScreenState: Flow<KeyguardQuickAffordanceConfig.LockScreenState> =
        component.canShowWhileLockedSetting.flatMapLatest { canShowWhileLocked ->
            if (canShowWhileLocked) {
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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.keyguard.data.quickaffordance

import dagger.Module
import dagger.Provides
import dagger.multibindings.ElementsIntoSet

@Module
object KeyguardDataQuickAffordanceModule {
    @Provides
    @ElementsIntoSet
    fun quickAffordanceConfigs(
        home: HomeControlsKeyguardQuickAffordanceConfig,
        quickAccessWallet: QuickAccessWalletKeyguardQuickAffordanceConfig,
        qrCodeScanner: QrCodeScannerKeyguardQuickAffordanceConfig,
    ): Set<KeyguardQuickAffordanceConfig> {
        return setOf(
            home,
            quickAccessWallet,
            qrCodeScanner,
        )
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,10 @@ interface KeyguardQuickAffordanceConfig {
    /** Unique identifier for this quick affordance. It must be globally unique. */
    val key: String

    val pickerName: String

    val pickerIconResourceId: Int

    /**
     * The ever-changing state of the affordance.
     *
Loading