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