From 6b4f8b1adfd39c344d0d58e259a3d028c51319f7 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Mon, 8 Aug 2022 14:28:57 -0700 Subject: Moves quick affordances into domain layer. After much discussion, it became clear that it would be better to move quic affordance config definitions out of the data layer and into the domain layer. This CL does the following: 1. Moves config definitions to the domain layer 2. Moves the "configs" class to the domain layer and renames it to "registry" 3. Eliminates the quick affordance repository from the data layer, merging its logic into the observe quick affordance use-case 4. Updates the documentation Fix: 241681067 Test: Unit tests updated. Manually verified the bottom area quick affordances still work properly when locked, unlocked, and dozing. Played with the settings under Display > Lock screen to turn the on and off. Change-Id: I4b293eeef02e5546fc834008b096e4a7935657fe --- packages/SystemUI/docs/device-entry/quickaffordance.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/SystemUI/docs') diff --git a/packages/SystemUI/docs/device-entry/quickaffordance.md b/packages/SystemUI/docs/device-entry/quickaffordance.md index a96e533933f4..38d636d7ff82 100644 --- a/packages/SystemUI/docs/device-entry/quickaffordance.md +++ b/packages/SystemUI/docs/device-entry/quickaffordance.md @@ -6,16 +6,16 @@ credit card, etc. ## Adding a new Quick Affordance ### Step 1: create a new quick affordance config -* Create a new class under the [systemui/keyguard/data/quickaffordance](../../src/com/android/systemui/keyguard/data/quickaffordance) directory +* 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/data/quickaffordance/KeyguardQuickAffordanceConfig.kt) interface, notes: +* Have the class implement the [KeyguardQuickAffordanceConfig](../../src/com/android/systemui/keyguard/domain/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 -* Please include a unit test for your new implementation under [the correct directory](../../tests/src/com/android/systemui/keyguard/data/quickaffordance) +* Please include a unit test for your new implementation under [the correct directory](../../tests/src/com/android/systemui/keyguard/domain/quickaffordance) ### Step 2: choose a position and priority -* Add the new class as a dependency in the constructor of [KeyguardQuickAffordanceConfigs](../../src/com/android/systemui/keyguard/data/repository/KeyguardQuickAffordanceConfigs.kt) +* Add the new class as a dependency in the constructor of [KeyguardQuickAffordanceRegistry](../../src/com/android/systemui/keyguard/domain/quickaffordance/KeyguardQuickAffordanceRegistry.kt) * Place the new class in one of the available positions in the `configsByPosition` property, note: * In each position, there is a list. The order matters. The order of that list is the priority order in which the framework considers each config. The first config whose state property returns `State.Visible` determines the button that is shown for that position * Please only add to one position. The framework treats each position individually and there is no good way to prevent the same config from making its button appear in more than one position at the same time -- cgit v1.2.3-59-g8ed1b