diff options
| author | 2022-08-03 01:10:57 +0000 | |
|---|---|---|
| committer | 2022-08-03 01:10:57 +0000 | |
| commit | c800da57dc011b10535e4d255d5956c4b37e922c (patch) | |
| tree | e9510efaf6ee182e820a1bf6f0bd43b0533fa0dd | |
| parent | 2e020e8694a823d64b5f86b9348af4deeb96ebb8 (diff) | |
| parent | d381bf6409997fff33e1640c7db441a70b013640 (diff) | |
Merge "Merge "Developer-facing document for quick affordances" into tm-qpr-dev am: 34c2839d3c am: 56188023e7"
| -rw-r--r-- | packages/SystemUI/docs/device-entry/keyguard.md | 4 | ||||
| -rw-r--r-- | packages/SystemUI/docs/device-entry/quickaffordance.md | 25 |
2 files changed, 29 insertions, 0 deletions
diff --git a/packages/SystemUI/docs/device-entry/keyguard.md b/packages/SystemUI/docs/device-entry/keyguard.md index 337f73b79260..8634c950f96c 100644 --- a/packages/SystemUI/docs/device-entry/keyguard.md +++ b/packages/SystemUI/docs/device-entry/keyguard.md @@ -30,6 +30,10 @@ An indication to power off the device most likely comes from one of two signals: ### How the device locks +### Quick Affordances + +These are interactive UI elements that appear on the lockscreen when the device is locked. They allow the user to perform quick actions without unlocking their device. To learn more about them, please see [this dedicated document](quickaffordance.md) + ## Debugging Tips Enable verbose keyguard logs that will print to logcat. Should only be used temporarily for debugging. See [KeyguardConstants][5]. ``` diff --git a/packages/SystemUI/docs/device-entry/quickaffordance.md b/packages/SystemUI/docs/device-entry/quickaffordance.md new file mode 100644 index 000000000000..a96e533933f4 --- /dev/null +++ b/packages/SystemUI/docs/device-entry/quickaffordance.md @@ -0,0 +1,25 @@ +# Keyguard Quick Affordances +These are interactive UI elements that appear at the bottom of the lockscreen when the device is +locked. They allow the user to perform quick actions without unlocking their device. For example: +opening an screen that lets them control the smart devices in their home, access their touch-to-pay +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 +* 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: + * 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) + +### 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) +* 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 + +### Step 3: manually verify the new quick affordance +* Build and launch SysUI on a device +* Verify that the quick affordance button for the new implementation is correctly visible and clicking it does the right thing |