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 /** 87 * The user unlocked the device 88 * @hide 89 */ 90 public static final int ENTRY_BUMP = 10; 91 92 /** 93 * The user has moved the dragged object within a droppable area. 94 * @hide 95 */ 96 public static final int DRAG_CROSSING = 11; 97 98 /** 99 * The user has started a gesture (e.g. on the soft keyboard). 100 */ 101 public static final int GESTURE_START = 12; 102 103 /** 104 * The user has finished a gesture (e.g. on the soft keyboard). 105 */ 106 public static final int GESTURE_END = 13; 107 108 /** 109 * The user's squeeze crossed the gesture's initiation threshold. 110 * @hide 111 */ 112 public static final int EDGE_SQUEEZE = 14; 113 114 /** 115 * The user's squeeze crossed the gesture's release threshold. 116 * @hide 117 */ 118 public static final int EDGE_RELEASE = 15; 119 120 /** 121 * A haptic effect to signal the confirmation or successful completion of a user 122 * interaction. 123 */ 124 public static final int CONFIRM = 16; 125 126 /** 127 * A haptic effect to signal the rejection or failure of a user interaction. 128 */ 129 public static final int REJECT = 17; 130 131 /** 132 * A haptic effect to provide texture while a rotary input device is being scrolled. 133 * 134 * @hide 135 */ 136 public static final int ROTARY_SCROLL_TICK = 18; 137 138 /** 139 * A haptic effect to signal that a list element has been focused while scrolling using a rotary 140 * input device. 141 * 142 * @hide 143 */ 144 public static final int ROTARY_SCROLL_ITEM_FOCUS = 19; 145 146 /** 147 * A haptic effect to signal reaching the scrolling limits of a list while scrolling using a 148 * rotary input device. 149 * 150 * @hide 151 */ 152 public static final int ROTARY_SCROLL_LIMIT = 20; 153 154 /** 155 * The user has toggled a switch or button into the on position. 156 */ 157 public static final int TOGGLE_ON = 21; 158 159 /** 160 * The user has toggled a switch or button into the off position. 161 */ 162 public static final int TOGGLE_OFF = 22; 163 164 /** 165 * The user is executing a swipe/drag-style gesture, such as pull-to-refresh, where the 166 * gesture action is “eligible” at a certain threshold of movement, and can be cancelled by 167 * moving back past the threshold. This constant indicates that the user's motion has just 168 * passed the threshold for the action to be activated on release. 169 * 170 * @see #GESTURE_THRESHOLD_DEACTIVATE 171 */ 172 public static final int GESTURE_THRESHOLD_ACTIVATE = 23; 173 174 /** 175 * The user is executing a swipe/drag-style gesture, such as pull-to-refresh, where the 176 * gesture action is “eligible” at a certain threshold of movement, and can be cancelled by 177 * moving back past the threshold. This constant indicates that the user's motion has just 178 * re-crossed back "under" the threshold for the action to be activated, meaning the gesture is 179 * currently in a cancelled state. 180 * 181 * @see #GESTURE_THRESHOLD_ACTIVATE 182 */ 183 public static final int GESTURE_THRESHOLD_DEACTIVATE = 24; 184 185 /** 186 * The user has started a drag-and-drop gesture. The drag target has just been "picked up". 187 */ 188 public static final int DRAG_START = 25; 189 190 /** 191 * The user is switching between a series of potential choices, for example items in a list 192 * or discrete points on a slider. 193 * 194 * <p>See also {@link #SEGMENT_FREQUENT_TICK} for cases where density of choices is high, and 195 * the haptics should be lighter or suppressed for a better user experience. 196 */ 197 public static final int SEGMENT_TICK = 26; 198 199 /** 200 * The user is switching between a series of many potential choices, for example minutes on a 201 * clock face, or individual percentages. This constant is expected to be very soft, so as 202 * not to be uncomfortable when performed a lot in quick succession. If the device can’t make 203 * a suitably soft vibration, then it may not make any vibration. 204 * 205 * <p>Some specializations of this constant exist for specific actions, notably 206 * {@link #CLOCK_TICK} and {@link #TEXT_HANDLE_MOVE}. 207 * 208 * <p>See also {@link #SEGMENT_TICK}. 209 */ 210 public static final int SEGMENT_FREQUENT_TICK = 27; 211 212 /** 213 * The phone has booted with safe mode enabled. 214 * This is a private constant. Feel free to renumber as desired. 215 * @hide 216 */ 217 public static final int SAFE_MODE_ENABLED = 10001; 218 219 /** 220 * Invocation of the voice assistant via hardware button. 221 * This is a private constant. Feel free to renumber as desired. 222 * @hide 223 */ 224 public static final int ASSISTANT_BUTTON = 10002; 225 226 /** 227 * The user has performed a long press on the power button hardware that is resulting 228 * in an action being performed. 229 * This is a private constant. Feel free to renumber as desired. 230 * @hide 231 */ 232 public static final int LONG_PRESS_POWER_BUTTON = 10003; 233 234 /** 235 * Flag for {@link View#performHapticFeedback(int, int) 236 * View.performHapticFeedback(int, int)}: Ignore the setting in the 237 * view for whether to perform haptic feedback, do it always. 238 */ 239 public static final int FLAG_IGNORE_VIEW_SETTING = 0x0001; 240 241 /** 242 * Flag for {@link View#performHapticFeedback(int, int) 243 * View.performHapticFeedback(int, int)}: Ignore the global setting 244 * for whether to perform haptic feedback, do it always. 245 * 246 * @deprecated Starting from {@link android.os.Build.VERSION_CODES#TIRAMISU} only privileged 247 * apps can ignore user settings for touch feedback. 248 */ 249 @Deprecated 250 public static final int FLAG_IGNORE_GLOBAL_SETTING = 0x0002; 251 } 252