1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.accessibility.common; 18 19 import static com.android.internal.accessibility.AccessibilityShortcutController.ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME; 20 import static com.android.internal.accessibility.AccessibilityShortcutController.ACCESSIBILITY_HEARING_AIDS_TILE_COMPONENT_NAME; 21 import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME; 22 import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_TILE_COMPONENT_NAME; 23 import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME; 24 import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_TILE_COMPONENT_NAME; 25 import static com.android.internal.accessibility.AccessibilityShortcutController.FONT_SIZE_COMPONENT_NAME; 26 import static com.android.internal.accessibility.AccessibilityShortcutController.FONT_SIZE_TILE_COMPONENT_NAME; 27 import static com.android.internal.accessibility.AccessibilityShortcutController.ONE_HANDED_COMPONENT_NAME; 28 import static com.android.internal.accessibility.AccessibilityShortcutController.ONE_HANDED_TILE_COMPONENT_NAME; 29 import static com.android.internal.accessibility.AccessibilityShortcutController.REDUCE_BRIGHT_COLORS_COMPONENT_NAME; 30 import static com.android.internal.accessibility.AccessibilityShortcutController.REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME; 31 32 import android.annotation.IntDef; 33 import android.content.ComponentName; 34 35 import java.lang.annotation.Retention; 36 import java.lang.annotation.RetentionPolicy; 37 import java.util.Map; 38 39 /** 40 * Collection of common constants for accessibility shortcut. 41 */ 42 public final class ShortcutConstants { ShortcutConstants()43 private ShortcutConstants() {} 44 45 /** 46 * Package name of the accessibility chooser and used for {@link android.content.Intent}. 47 */ 48 public static final String CHOOSER_PACKAGE_NAME = "android"; 49 50 public static final char SERVICES_SEPARATOR = ':'; 51 52 /** 53 * Annotation for different user shortcut type UI type. 54 * 55 * {@code DEFAULT} for displaying default value. 56 * {@code SOFTWARE} for displaying specifying the accessibility services or features which 57 * choose accessibility button in the navigation bar as preferred shortcut. 58 * {@code HARDWARE} for displaying specifying the accessibility services or features which 59 * choose accessibility shortcut as preferred shortcut. 60 * {@code TRIPLETAP} for displaying specifying magnification to be toggled via quickly 61 * tapping screen 3 times as preferred shortcut. 62 * {@code TWOFINGER_DOUBLETAP} for displaying specifying magnification to be toggled via 63 * quickly tapping screen 2 times with two fingers as preferred shortcut. 64 * {@code QUICK_SETTINGS} for displaying specifying the accessibility services or features which 65 * choose Quick Settings as preferred shortcut. 66 * {@code KEY_GESTURE} for shortcuts which are directly from key gestures and should be 67 * activated always. 68 */ 69 @Retention(RetentionPolicy.SOURCE) 70 @IntDef({ 71 UserShortcutType.DEFAULT, 72 UserShortcutType.SOFTWARE, 73 UserShortcutType.HARDWARE, 74 UserShortcutType.TRIPLETAP, 75 UserShortcutType.TWOFINGER_DOUBLETAP, 76 UserShortcutType.QUICK_SETTINGS, 77 UserShortcutType.GESTURE, 78 UserShortcutType.KEY_GESTURE, 79 UserShortcutType.ALL 80 }) 81 public @interface UserShortcutType { 82 int DEFAULT = 0; 83 // LINT.IfChange(shortcut_type_intdef) 84 int SOFTWARE = 1 << 0; 85 int HARDWARE = 1 << 1; 86 int TRIPLETAP = 1 << 2; 87 int TWOFINGER_DOUBLETAP = 1 << 3; 88 int QUICK_SETTINGS = 1 << 4; 89 int GESTURE = 1 << 5; 90 int KEY_GESTURE = 1 << 6; 91 // LINT.ThenChange(:shortcut_type_array) 92 int ALL = SOFTWARE | HARDWARE | TRIPLETAP | TWOFINGER_DOUBLETAP | QUICK_SETTINGS | GESTURE 93 | KEY_GESTURE; 94 } 95 96 /** 97 * A list of possible {@link UserShortcutType}. Should stay in sync with the 98 * non-default IntDef types. 99 */ 100 public static final int[] USER_SHORTCUT_TYPES = { 101 // LINT.IfChange(shortcut_type_array) 102 UserShortcutType.SOFTWARE, 103 UserShortcutType.HARDWARE, 104 UserShortcutType.TRIPLETAP, 105 UserShortcutType.TWOFINGER_DOUBLETAP, 106 UserShortcutType.QUICK_SETTINGS, 107 UserShortcutType.GESTURE, 108 UserShortcutType.KEY_GESTURE 109 // LINT.ThenChange(:shortcut_type_intdef) 110 }; 111 112 113 /** 114 * Annotation for the different accessibility fragment type. 115 * 116 * {@code VOLUME_SHORTCUT_TOGGLE} for displaying appearance with switch bar and only one 117 * shortcut option that is volume key shortcut. 118 * {@code INVISIBLE_TOGGLE} for displaying appearance without switch bar. 119 * {@code TOGGLE} for displaying appearance with switch bar. 120 * {@code LAUNCH_ACTIVITY} for displaying appearance with pop-up action that is for launch 121 * activity. 122 */ 123 @Retention(RetentionPolicy.SOURCE) 124 @IntDef({ 125 AccessibilityFragmentType.VOLUME_SHORTCUT_TOGGLE, 126 AccessibilityFragmentType.INVISIBLE_TOGGLE, 127 AccessibilityFragmentType.TOGGLE, 128 AccessibilityFragmentType.LAUNCH_ACTIVITY, 129 }) 130 public @interface AccessibilityFragmentType { 131 int VOLUME_SHORTCUT_TOGGLE = 0; 132 int INVISIBLE_TOGGLE = 1; 133 int TOGGLE = 2; 134 int LAUNCH_ACTIVITY = 3; 135 } 136 137 /** 138 * Annotation for different shortcut menu mode. 139 * 140 * {@code LAUNCH} for clicking list item to trigger the service callback. 141 * {@code EDIT} for clicking list item and save button to disable the service. 142 */ 143 @Retention(RetentionPolicy.SOURCE) 144 @IntDef({ 145 ShortcutMenuMode.LAUNCH, 146 ShortcutMenuMode.EDIT, 147 }) 148 public @interface ShortcutMenuMode { 149 int LAUNCH = 0; 150 int EDIT = 1; 151 } 152 153 /** 154 * Annotation for different FAB shortcut type's menu size 155 */ 156 @Retention(RetentionPolicy.SOURCE) 157 @IntDef({ 158 FloatingMenuSize.UNKNOWN, 159 FloatingMenuSize.SMALL, 160 FloatingMenuSize.LARGE, 161 }) 162 public @interface FloatingMenuSize { 163 int UNKNOWN = -1; 164 int SMALL = 0; 165 int LARGE = 1; 166 } 167 168 /** 169 * A map of a11y feature to its qs tile component 170 */ 171 public static final Map<ComponentName, ComponentName> A11Y_FEATURE_TO_FRAMEWORK_TILE = Map.of( 172 COLOR_INVERSION_COMPONENT_NAME, COLOR_INVERSION_TILE_COMPONENT_NAME, 173 DALTONIZER_COMPONENT_NAME, DALTONIZER_TILE_COMPONENT_NAME, 174 ONE_HANDED_COMPONENT_NAME, ONE_HANDED_TILE_COMPONENT_NAME, 175 REDUCE_BRIGHT_COLORS_COMPONENT_NAME, REDUCE_BRIGHT_COLORS_TILE_SERVICE_COMPONENT_NAME, 176 FONT_SIZE_COMPONENT_NAME, FONT_SIZE_TILE_COMPONENT_NAME, 177 ACCESSIBILITY_HEARING_AIDS_COMPONENT_NAME, 178 ACCESSIBILITY_HEARING_AIDS_TILE_COMPONENT_NAME 179 ); 180 } 181