ShortcutPreference Toggle design (2/n)

- Removes edit shortcut disable condition.
- Shows "off" if user removes all items in edit dialog.
- Restores last time what user chosen options when show edit dialog.

Bug: 148989269
Test: Manually test
Change-Id: I105abda782999d38c92e3de9811e2fd378869e73
This commit is contained in:
menghanli
2020-03-04 21:47:57 +08:00
parent b6ab224ddb
commit 5d7083a103
6 changed files with 53 additions and 74 deletions

View File

@@ -73,7 +73,7 @@ final class AccessibilityUtil {
/**
* Annotation for different user shortcut type UI type.
*
* {@code DEFAULT} for displaying default value.
* {@code EMPTY} for displaying default value.
* {@code SOFTWARE} for displaying specifying the accessibility services or features which
* choose accessibility button in the navigation bar as preferred shortcut.
* {@code HARDWARE} for displaying specifying the accessibility services or features which
@@ -83,7 +83,7 @@ final class AccessibilityUtil {
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef({
UserShortcutType.DEFAULT,
UserShortcutType.EMPTY,
UserShortcutType.SOFTWARE,
UserShortcutType.HARDWARE,
UserShortcutType.TRIPLETAP,
@@ -91,7 +91,7 @@ final class AccessibilityUtil {
/** Denotes the user shortcut type. */
public @interface UserShortcutType {
int DEFAULT = 0;
int EMPTY = 0;
int SOFTWARE = 1; // 1 << 0
int HARDWARE = 2; // 1 << 1
int TRIPLETAP = 4; // 1 << 2
@@ -323,7 +323,7 @@ final class AccessibilityUtil {
*/
static int getUserShortcutTypesFromSettings(Context context,
@NonNull ComponentName componentName) {
int shortcutTypes = UserShortcutType.DEFAULT;
int shortcutTypes = UserShortcutType.EMPTY;
if (hasValuesInSettings(context, UserShortcutType.SOFTWARE, componentName)) {
shortcutTypes |= UserShortcutType.SOFTWARE;
}