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

Commit bce001cc authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Android (Google) Code Review
Browse files

Merge changes Ibe1f0387,I2d1ec382 into tm-qpr-dev

* changes:
  Moves quick affordances to data layer.
  Changes quick affordance key to string.
parents facf686c 7237112d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ credit card, etc.
### Step 1: create a new quick affordance config
* Create a new class under the [systemui/keyguard/domain/quickaffordance](../../src/com/android/systemui/keyguard/domain/quickaffordance) directory
* Please make sure that the class is injected through the Dagger dependency injection system by using the `@Inject` annotation on its main constructor and the `@SysUISingleton` annotation at class level, to make sure only one instance of the class is ever instantiated
* Have the class implement the [KeyguardQuickAffordanceConfig](../../src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceConfig.kt) interface, notes:
* Have the class implement the [KeyguardQuickAffordanceConfig](../../src/com/android/systemui/keyguard/data/quickaffordance/KeyguardQuickAffordanceConfig.kt) interface, notes:
  * The `state` Flow property must emit `State.Hidden` when the feature is not enabled!
  * It is safe to assume that `onQuickAffordanceClicked` will not be invoked if-and-only-if the previous rule is followed
  * When implementing `onQuickAffordanceClicked`, the implementation can do something or it can ask the framework to start an activity using an `Intent` provided by the implementation
+31 −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

/**
 * Unique identifier keys for all known built-in quick affordances.
 *
 * Please ensure uniqueness by never associating more than one class with each key.
 */
object BuiltInKeyguardQuickAffordanceKeys {
    // Please keep alphabetical order of const names to simplify future maintenance.
    const val HOME_CONTROLS = "home"
    const val QR_CODE_SCANNER = "qr_code_scanner"
    const val QUICK_ACCESS_WALLET = "wallet"
    // Please keep alphabetical order of const names to simplify future maintenance.
}
+13 −11
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 *
 */

package com.android.systemui.keyguard.domain.quickaffordance
package com.android.systemui.keyguard.data.quickaffordance

import android.content.Context
import android.content.Intent
@@ -51,6 +51,8 @@ constructor(

    private val appContext = context.applicationContext

    override val key: String = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS

    override val state: Flow<KeyguardQuickAffordanceConfig.State> =
        component.canShowWhileLockedSetting.flatMapLatest { canShowWhileLocked ->
            if (canShowWhileLocked) {
+21 −11
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 *
 */

package com.android.systemui.keyguard.domain.quickaffordance
package com.android.systemui.keyguard.data.quickaffordance

import android.content.Intent
import com.android.systemui.animation.Expandable
@@ -26,8 +26,18 @@ import kotlinx.coroutines.flow.Flow
/** Defines interface that can act as data source for a single quick affordance model. */
interface KeyguardQuickAffordanceConfig {

    /** Unique identifier for this quick affordance. It must be globally unique. */
    val key: String

    /** The observable [State] of the affordance. */
    val state: Flow<State>

    /**
     * Notifies that the affordance was clicked by the user.
     *
     * @param expandable An [Expandable] to use when animating dialogs or activities
     * @return An [OnClickedResult] telling the caller what to do next
     */
    fun onQuickAffordanceClicked(expandable: Expandable?): OnClickedResult

    /**
+13 −11
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 *
 */

package com.android.systemui.keyguard.domain.quickaffordance
package com.android.systemui.keyguard.data.quickaffordance

import com.android.systemui.R
import com.android.systemui.animation.Expandable
@@ -37,6 +37,8 @@ constructor(
    private val controller: QRCodeScannerController,
) : KeyguardQuickAffordanceConfig {

    override val key: String = BuiltInKeyguardQuickAffordanceKeys.QR_CODE_SCANNER

    override val state: Flow<KeyguardQuickAffordanceConfig.State> = conflatedCallbackFlow {
        val callback =
            object : QRCodeScannerController.Callback {
Loading