1 /* 2 * Copyright (C) 2009 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 android.view; 18 19 /** 20 * Constants to be used to perform haptic feedback effects via 21 * {@link View#performHapticFeedback(int)} 22 */ 23 public class HapticFeedbackConstants { 24 HapticFeedbackConstants()25 private HapticFeedbackConstants() {} 26 27 /** 28 * No haptic feedback should be performed. Applications may use this value to indicate skipping 29 * a call to {@link View#performHapticFeedback} entirely, or else rely that it will immediately 30 * return {@code false}. 31 */ 32 public static final int NO_HAPTICS = -1; 33 34 /** 35 * The user has performed a long press on an object that is resulting 36 * in an action being performed. 37 */ 38 public static final int LONG_PRESS = 0; 39 40 /** 41 * The user has pressed on a virtual on-screen key. 42 */ 43 public static final int VIRTUAL_KEY = 1; 44 45 /** 46 * The user has pressed a soft keyboard key. 47 */ 48 public static final int KEYBOARD_TAP = 3; 49 50 /** 51 * The user has pressed either an hour or minute tick of a Clock. 52 */ 53 public static final int CLOCK_TICK = 4; 54 55 /** 56 * The user has pressed either a day or month or year date of a Calendar. 57 * @hide 58 */ 59 public static final int CALENDAR_DATE = 5; 60 61 /** 62 * The user has performed a context click on an object. 63 */ 64 public static final int CONTEXT_CLICK = 6; 65 66 /** 67 * The user has pressed a virtual or software keyboard key. 68 */ 69 public static final int KEYBOARD_PRESS = KEYBOARD_TAP; 70 71 /** 72 * The user has released a virtual keyboard key. 73 */ 74 public static final int KEYBOARD_RELEASE = 7; 75 76 /** 77 * The user has released a virtual key. 78 */ 79 public static final int VIRTUAL_KEY_RELEASE = 8; 80 81 /** 82 * The user has performed a selection/insertion handle move on text field. 83 */ 84 public static final int TEXT_HANDLE_MOVE = 9; 85 86 // REMOVED: ENTRY_BUMP = 10 87 88 /** 89 * The user has moved the dragged object within a droppable area. 90 * @hide 91 */ 92 public static final int DRAG_CROSSING = 11; 93 94 /** 95 * The user has started a gesture (e.g. on the soft keyboard). 96 */ 97 public static final int GESTURE_START = 12; 98 99 /** 100 * The user has finished a gesture (e.g. on the soft keyboard). 101 */ 102 public static final int GESTURE_END = 13; 103 104 /** 105 * The user's squeeze crossed the gesture's initiation threshold. 106 * @hide 107 */ 108 public static final int EDGE_SQUEEZE = 14; 109 110 /** 111 * The user's squeeze crossed the gesture's release threshold. 112 * @hide 113 */ 114 public static final int EDGE_RELEASE = 15; 115 116 /** 117 * A haptic effect to signal the confirmation or successful completion of a user 118 * interaction. 119 */ 120 public static final int CONFIRM = 16; 121 122 /** 123 * A haptic effect to signal the rejection or failure of a user interaction. 124 */ 125 public static final int REJECT = 17; 126 127 /** 128 * A haptic effect to provide texture while scrolling. 129 * 130 * @hide 131 */ 132 public static final int SCROLL_TICK = 18; 133 134 /** 135 * A haptic effect to signal that a list element has been focused while scrolling. 136 * 137 * @hide 138 */ 139 public static final int SCROLL_ITEM_FOCUS = 19; 140 141 /** 142 * A haptic effect to signal reaching the scrolling limits of a list while scrolling. 143 * 144 * @hide 145 */ 146 public static final int SCROLL_LIMIT = 20; 147 148 /** 149 * The user has toggled a switch or button into the on position. 150 */ 151 public static final int TOGGLE_ON = 21; 152 153 /** 154 * The user has toggled a switch or button into the off position. 155 */ 156 public static final int TOGGLE_OFF = 22; 157 158 /** 159 * The user is executing a swipe/drag-style gesture, such as pull-to-refresh, where the 160 * gesture action is “eligible” at a certain threshold of movement, and can be cancelled by 161 * moving back past the threshold. This constant indicates that the user's motion has just 162 * passed the threshold for the action to be activated on release. 163 * 164 * @see #GESTURE_THRESHOLD_DEACTIVATE 165 */ 166 public static final int GESTURE_THRESHOLD_ACTIVATE = 23; 167 168 /** 169 * The user is executing a swipe/drag-style gesture, such as pull-to-refresh, where the 170 * gesture action is “eligible” at a certain threshold of movement, and can be cancelled by 171 * moving back past the threshold. This constant indicates that the user's motion has just 172 * re-crossed back "under" the threshold for the action to be activated, meaning the gesture is 173 * currently in a cancelled state. 174 * 175 * @see #GESTURE_THRESHOLD_ACTIVATE 176 */ 177 public static final int GESTURE_THRESHOLD_DEACTIVATE = 24; 178 179 /** 180 * The user has started a drag-and-drop gesture. The drag target has just been "picked up". 181 */ 182 public static final int DRAG_START = 25; 183 184 /** 185 * The user is switching between a series of potential choices, for example items in a list 186 * or discrete points on a slider. 187 * 188 * <p>See also {@link #SEGMENT_FREQUENT_TICK} for cases where density of choices is high, and 189 * the haptics should be lighter or suppressed for a better user experience. 190 */ 191 public static final int SEGMENT_TICK = 26; 192 193 /** 194 * The user is switching between a series of many potential choices, for example minutes on a 195 * clock face, or individual percentages. This constant is expected to be very soft, so as 196 * not to be uncomfortable when performed a lot in quick succession. If the device can’t make 197 * a suitably soft vibration, then it may not make any vibration. 198 * 199 * <p>Some specializations of this constant exist for specific actions, notably 200 * {@link #CLOCK_TICK} and {@link #TEXT_HANDLE_MOVE}. 201 * 202 * <p>See also {@link #SEGMENT_TICK}. 203 */ 204 public static final int SEGMENT_FREQUENT_TICK = 27; 205 206 /** 207 * The phone has booted with safe mode enabled. 208 * This is a private constant. Feel free to renumber as desired. 209 * @hide 210 */ 211 public static final int SAFE_MODE_ENABLED = 10001; 212 213 /** 214 * Invocation of the voice assistant via hardware button. 215 * This is a private constant. Feel free to renumber as desired. 216 * @hide 217 */ 218 public static final int ASSISTANT_BUTTON = 10002; 219 220 /** 221 * The user has performed a long press on the power button hardware that is resulting 222 * in an action being performed. 223 * This is a private constant. Feel free to renumber as desired. 224 * @hide 225 */ 226 public static final int LONG_PRESS_POWER_BUTTON = 10003; 227 228 /** 229 * A haptic effect to signal the confirmation of a user biometric authentication 230 * (e.g. fingerprint reading). 231 * This is a private constant to be used only by system apps. 232 * @hide 233 */ 234 public static final int BIOMETRIC_CONFIRM = 10004; 235 236 /** 237 * A haptic effect to signal the rejection of a user biometric authentication attempt 238 * (e.g. fingerprint reading). 239 * This is a private constant to be used only by system apps. 240 * @hide 241 */ 242 public static final int BIOMETRIC_REJECT = 10005; 243 244 /** 245 * Flag for {@link View#performHapticFeedback(int, int) 246 * View.performHapticFeedback(int, int)}: Ignore the setting in the 247 * view for whether to perform haptic feedback, do it always. 248 */ 249 public static final int FLAG_IGNORE_VIEW_SETTING = 0x0001; 250 251 /** 252 * Flag for {@link View#performHapticFeedback(int, int) 253 * View.performHapticFeedback(int, int)}: Ignore the global setting 254 * for whether to perform haptic feedback, do it always. 255 * 256 * @deprecated Starting from {@link android.os.Build.VERSION_CODES#TIRAMISU} only privileged 257 * apps can ignore user settings for touch feedback. 258 */ 259 @Deprecated 260 public static final int FLAG_IGNORE_GLOBAL_SETTING = 0x0002; 261 } 262