blob: b4553adde2835f34ffdb58133358374ffa08f61e [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 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
17package android.view;
18
Vladislav Kaznacheevf847ee32016-11-21 14:11:00 -080019import android.annotation.TestApi;
Mathew Inwoode5ad5982018-08-17 15:07:52 +010020import android.annotation.UnsupportedAppUsage;
Svetoslav Ganov54d068e2011-03-02 12:58:40 -080021import android.app.AppGlobals;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.content.Context;
Dianne Hackbornff801ec2011-01-22 18:05:38 -080023import android.content.res.Configuration;
Adam Powell8c470622011-06-30 18:19:51 -070024import android.content.res.Resources;
Jeff Browna8b9def2012-07-23 14:22:49 -070025import android.graphics.Point;
Adam Powell8c470622011-06-30 18:19:51 -070026import android.os.RemoteException;
Svetoslav Ganov54d068e2011-03-02 12:58:40 -080027import android.provider.Settings;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028import android.util.DisplayMetrics;
29import android.util.SparseArray;
30
31/**
32 * Contains methods to standard constants used in the UI for timeouts, sizes, and distances.
33 */
34public class ViewConfiguration {
35 /**
36 * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in
Gilles Debunne006fa482011-10-27 17:23:36 -070037 * dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 */
Tarun Lohani8c89baa2017-06-16 17:21:04 +000039 private static final int SCROLL_BAR_SIZE = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040
41 /**
Mike Cleronf116bf82009-09-27 19:14:12 -070042 * Duration of the fade when scrollbars fade away in milliseconds
43 */
44 private static final int SCROLL_BAR_FADE_DURATION = 250;
45
46 /**
47 * Default delay before the scrollbars fade in milliseconds
48 */
49 private static final int SCROLL_BAR_DEFAULT_DELAY = 300;
50
51 /**
Gilles Debunne006fa482011-10-27 17:23:36 -070052 * Defines the length of the fading edges in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 */
54 private static final int FADING_EDGE_LENGTH = 12;
55
56 /**
57 * Defines the duration in milliseconds of the pressed state in child
58 * components.
59 */
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070060 private static final int PRESSED_STATE_DURATION = 64;
61
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080062 /**
Jeff Browna4547672011-03-02 21:38:11 -080063 * Defines the default duration in milliseconds before a press turns into
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064 * a long press
65 */
Jeff Browna4547672011-03-02 21:38:11 -080066 private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500;
67
68 /**
Anthony Hugh96e9cc52016-07-12 15:17:24 -070069 * Defines the default duration in milliseconds between the first tap's up event and the second
70 * tap's down event for an interaction to be considered part of the same multi-press.
71 */
72 private static final int DEFAULT_MULTI_PRESS_TIMEOUT = 300;
73
74 /**
Jeff Browna4547672011-03-02 21:38:11 -080075 * Defines the time between successive key repeats in milliseconds.
76 */
77 private static final int KEY_REPEAT_DELAY = 50;
78
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079 /**
80 * Defines the duration in milliseconds a user needs to hold down the
81 * appropriate button to bring up the global actions dialog (power off,
82 * lock screen, etc).
83 */
84 private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070085
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086 /**
Phil Weaver106fe732016-11-22 18:18:39 -080087 * Defines the duration in milliseconds a user needs to hold down the
Eugene Susla5f19cd32017-10-19 14:00:59 -070088 * appropriate button to bring up the accessibility shortcut for the first time
Phil Weaver106fe732016-11-22 18:18:39 -080089 */
90 private static final int A11Y_SHORTCUT_KEY_TIMEOUT = 3000;
91
92 /**
Eugene Susla5f19cd32017-10-19 14:00:59 -070093 * Defines the duration in milliseconds a user needs to hold down the
94 * appropriate button to enable the accessibility shortcut once it's configured.
95 */
Eugene Suslac8841582017-10-31 17:10:41 -070096 private static final int A11Y_SHORTCUT_KEY_TIMEOUT_AFTER_CONFIRMATION = 1000;
Eugene Susla5f19cd32017-10-19 14:00:59 -070097
98 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070099 * Defines the duration in milliseconds we will wait to see if a touch event
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100 * is a tap or a scroll. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700101 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102 */
Alan Viverette97d9b652014-03-17 15:33:05 -0700103 private static final int TAP_TIMEOUT = 100;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700104
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800105 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700106 * Defines the duration in milliseconds we will wait to see if a touch event
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800107 * is a jump tap. If the user does not complete the jump tap within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700108 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109 */
110 private static final int JUMP_TAP_TIMEOUT = 500;
111
112 /**
113 * Defines the duration in milliseconds between the first tap's up event and
114 * the second tap's down event for an interaction to be considered a
115 * double-tap.
116 */
117 private static final int DOUBLE_TAP_TIMEOUT = 300;
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700118
119 /**
Adam Powellaf1785f2013-09-05 13:44:45 -0700120 * Defines the minimum duration in milliseconds between the first tap's up event and
121 * the second tap's down event for an interaction to be considered a
122 * double-tap.
123 */
124 private static final int DOUBLE_TAP_MIN_TIME = 40;
125
126 /**
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700127 * Defines the maximum duration in milliseconds between a touch pad
128 * touch and release for a given touch to be considered a tap (click) as
129 * opposed to a hover movement gesture.
130 */
131 private static final int HOVER_TAP_TIMEOUT = 150;
132
133 /**
134 * Defines the maximum distance in pixels that a touch pad touch can move
135 * before being released for it to be considered a tap (click) as opposed
136 * to a hover movement gesture.
137 */
138 private static final int HOVER_TAP_SLOP = 20;
139
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800140 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700141 * Defines the duration in milliseconds we want to display zoom controls in response
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800142 * to a user panning within an application.
143 */
144 private static final int ZOOM_CONTROLS_TIMEOUT = 3000;
145
146 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700147 * Inset in dips to look for touchable content when the user touches the edge of the screen
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800148 */
149 private static final int EDGE_SLOP = 12;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700150
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800151 /**
Adam Powell7d39f852011-12-05 19:26:54 -0800152 * Distance a touch can wander before we think the user is scrolling in dips.
153 * Note that this value defined here is only used as a fallback by legacy/misbehaving
154 * applications that do not provide a Context for determining density/configuration-dependent
155 * values.
156 *
157 * To alter this value, see the configuration resource config_viewConfigurationTouchSlop
158 * in frameworks/base/core/res/res/values/config.xml or the appropriate device resource overlay.
159 * It may be appropriate to tweak this on a device-specific basis in an overlay based on
160 * the characteristics of the touch panel and firmware.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800161 */
Adam Powell6720a872011-12-07 17:35:32 -0800162 private static final int TOUCH_SLOP = 8;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700163
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800164 /**
Vladislav Kaznacheev4d2c60142017-02-07 17:11:54 -0800165 * Defines the minimum size of the touch target for a scrollbar in dips
166 */
167 private static final int MIN_SCROLLBAR_TOUCH_TARGET = 48;
168
169 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700170 * Distance the first touch can wander before we stop considering this event a double tap
171 * (in dips)
172 */
173 private static final int DOUBLE_TAP_TOUCH_SLOP = TOUCH_SLOP;
174
175 /**
Adam Powellde8d0832010-03-09 17:11:30 -0800176 * Distance a touch can wander before we think the user is attempting a paged scroll
177 * (in dips)
Adam Powell7d39f852011-12-05 19:26:54 -0800178 *
179 * Note that this value defined here is only used as a fallback by legacy/misbehaving
180 * applications that do not provide a Context for determining density/configuration-dependent
181 * values.
182 *
183 * See the note above on {@link #TOUCH_SLOP} regarding the dimen resource
184 * config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of
185 * config_viewConfigurationTouchSlop * 2 when provided with a Context.
Adam Powellde8d0832010-03-09 17:11:30 -0800186 */
Adam Powellb7ef1d92010-03-11 10:25:24 -0800187 private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700188
Adam Powellde8d0832010-03-09 17:11:30 -0800189 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700190 * Distance in dips between the first touch and second touch to still be considered a double tap
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800191 */
192 private static final int DOUBLE_TAP_SLOP = 100;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700193
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700195 * Distance in dips a touch needs to be outside of a window's bounds for it to
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800196 * count as outside for purposes of dismissing the window.
197 */
198 private static final int WINDOW_TOUCH_SLOP = 16;
199
200 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700201 * Minimum velocity to initiate a fling, as measured in dips per second
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800202 */
203 private static final int MINIMUM_FLING_VELOCITY = 50;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700204
Romain Guy4296fc42009-07-06 11:48:52 -0700205 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700206 * Maximum velocity to initiate a fling, as measured in dips per second
Romain Guy4296fc42009-07-06 11:48:52 -0700207 */
Adam Powell637d3372010-08-25 14:37:03 -0700208 private static final int MAXIMUM_FLING_VELOCITY = 8000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800209
210 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700211 * Delay before dispatching a recurring accessibility event in milliseconds.
212 * This delay guarantees that a recurring event will be send at most once
213 * during the {@link #SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS} time
214 * frame.
215 */
Svetoslav Ganove15ccb92012-05-16 15:48:55 -0700216 private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 100;
Svetoslav Ganova0156172011-06-26 17:55:44 -0700217
218 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800219 * The maximum size of View's drawing cache, expressed in bytes. This size
220 * should be at least equal to the size of the screen in ARGB888 format.
221 */
222 @Deprecated
Romain Guy0211a0a2011-02-14 16:34:59 -0800223 private static final int MAXIMUM_DRAWING_CACHE_SIZE = 480 * 800 * 4; // ARGB8888
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800224
225 /**
226 * The coefficient of friction applied to flings/scrolls.
227 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100228 @UnsupportedAppUsage
Romain Guy0211a0a2011-02-14 16:34:59 -0800229 private static final float SCROLL_FRICTION = 0.015f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800230
Adam Powell637d3372010-08-25 14:37:03 -0700231 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700232 * Max distance in dips to overscroll for edge effects
Adam Powell637d3372010-08-25 14:37:03 -0700233 */
234 private static final int OVERSCROLL_DISTANCE = 0;
235
236 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700237 * Max distance in dips to overfling for edge effects
Adam Powell637d3372010-08-25 14:37:03 -0700238 */
Gilles Debunne8ce7aab2011-01-25 11:23:30 -0800239 private static final int OVERFLING_DISTANCE = 6;
Adam Powell637d3372010-08-25 14:37:03 -0700240
Adam Powellcc84ff42013-12-04 11:15:29 -0800241 /**
Aaron Whytef8306522017-03-22 16:30:58 -0700242 * Amount to scroll in response to a horizontal {@link MotionEvent#ACTION_SCROLL} event,
243 * in dips per axis value.
Ned Burns69af4322016-08-17 17:30:25 -0400244 */
Aaron Whytef8306522017-03-22 16:30:58 -0700245 private static final float HORIZONTAL_SCROLL_FACTOR = 64;
246
247 /**
248 * Amount to scroll in response to a vertical {@link MotionEvent#ACTION_SCROLL} event,
249 * in dips per axis value.
250 */
251 private static final float VERTICAL_SCROLL_FACTOR = 64;
Ned Burns69af4322016-08-17 17:30:25 -0400252
253 /**
Abodunrinwa Toki9e211282015-06-05 02:46:57 +0100254 * Default duration to hide an action mode for.
Abodunrinwa Tokifd3a3a12015-05-05 20:04:34 +0100255 */
Abodunrinwa Toki9e211282015-06-05 02:46:57 +0100256 private static final long ACTION_MODE_HIDE_DURATION_DEFAULT = 2000;
Abodunrinwa Tokifd3a3a12015-05-05 20:04:34 +0100257
258 /**
Vladislav Kaznacheevf847ee32016-11-21 14:11:00 -0800259 * Defines the duration in milliseconds before an end of a long press causes a tooltip to be
260 * hidden.
261 */
262 private static final int LONG_PRESS_TOOLTIP_HIDE_TIMEOUT = 1500;
263
264 /**
265 * Defines the duration in milliseconds before a hover event causes a tooltip to be shown.
266 */
267 private static final int HOVER_TOOLTIP_SHOW_TIMEOUT = 500;
268
269 /**
270 * Defines the duration in milliseconds before mouse inactivity causes a tooltip to be hidden.
271 * (default variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is not set).
272 */
273 private static final int HOVER_TOOLTIP_HIDE_TIMEOUT = 15000;
274
275 /**
276 * Defines the duration in milliseconds before mouse inactivity causes a tooltip to be hidden
277 * (short version to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is set).
278 */
279 private static final int HOVER_TOOLTIP_HIDE_SHORT_TIMEOUT = 3000;
280
281 /**
Adam Powellcc84ff42013-12-04 11:15:29 -0800282 * Configuration values for overriding {@link #hasPermanentMenuKey()} behavior.
283 * These constants must match the definition in res/values/config.xml.
284 */
285 private static final int HAS_PERMANENT_MENU_KEY_AUTODETECT = 0;
286 private static final int HAS_PERMANENT_MENU_KEY_TRUE = 1;
287 private static final int HAS_PERMANENT_MENU_KEY_FALSE = 2;
288
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289 private final int mEdgeSlop;
290 private final int mFadingEdgeLength;
291 private final int mMinimumFlingVelocity;
Romain Guy4296fc42009-07-06 11:48:52 -0700292 private final int mMaximumFlingVelocity;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 private final int mScrollbarSize;
294 private final int mTouchSlop;
Vladislav Kaznacheev556ac612017-12-07 11:02:08 -0800295 private final int mHoverSlop;
Vladislav Kaznacheev4d2c60142017-02-07 17:11:54 -0800296 private final int mMinScrollbarTouchTarget;
Gilles Debunne006fa482011-10-27 17:23:36 -0700297 private final int mDoubleTapTouchSlop;
Adam Powellde8d0832010-03-09 17:11:30 -0800298 private final int mPagingTouchSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299 private final int mDoubleTapSlop;
300 private final int mWindowTouchSlop;
301 private final int mMaximumDrawingCacheSize;
Adam Powell637d3372010-08-25 14:37:03 -0700302 private final int mOverscrollDistance;
303 private final int mOverflingDistance;
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100304 @UnsupportedAppUsage
Romain Guy68055452011-08-02 16:33:02 -0700305 private final boolean mFadingMarqueeEnabled;
Justin Kohfeabd2c2014-05-02 10:02:44 -0700306 private final long mGlobalActionsKeyTimeout;
Aaron Whytef8306522017-03-22 16:30:58 -0700307 private final float mVerticalScrollFactor;
308 private final float mHorizontalScrollFactor;
Vladislav Kaznacheeva725df92018-02-26 16:22:34 -0800309 private final boolean mShowMenuShortcutsWhenKeyboardPresent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800310
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100311 @UnsupportedAppUsage
Adam Powell8c470622011-06-30 18:19:51 -0700312 private boolean sHasPermanentMenuKey;
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100313 @UnsupportedAppUsage
Adam Powell8c470622011-06-30 18:19:51 -0700314 private boolean sHasPermanentMenuKeySet;
315
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100316 @UnsupportedAppUsage
Xavier Ducrohet7f9f99ea2011-08-11 10:16:17 -0700317 static final SparseArray<ViewConfiguration> sConfigurations =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800318 new SparseArray<ViewConfiguration>(2);
319
320 /**
321 * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead.
322 */
323 @Deprecated
324 public ViewConfiguration() {
325 mEdgeSlop = EDGE_SLOP;
326 mFadingEdgeLength = FADING_EDGE_LENGTH;
327 mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY;
Romain Guy4296fc42009-07-06 11:48:52 -0700328 mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800329 mScrollbarSize = SCROLL_BAR_SIZE;
330 mTouchSlop = TOUCH_SLOP;
Vladislav Kaznacheev556ac612017-12-07 11:02:08 -0800331 mHoverSlop = TOUCH_SLOP / 2;
Vladislav Kaznacheev4d2c60142017-02-07 17:11:54 -0800332 mMinScrollbarTouchTarget = MIN_SCROLLBAR_TOUCH_TARGET;
Gilles Debunne006fa482011-10-27 17:23:36 -0700333 mDoubleTapTouchSlop = DOUBLE_TAP_TOUCH_SLOP;
Adam Powellde8d0832010-03-09 17:11:30 -0800334 mPagingTouchSlop = PAGING_TOUCH_SLOP;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800335 mDoubleTapSlop = DOUBLE_TAP_SLOP;
336 mWindowTouchSlop = WINDOW_TOUCH_SLOP;
337 //noinspection deprecation
338 mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
Adam Powell637d3372010-08-25 14:37:03 -0700339 mOverscrollDistance = OVERSCROLL_DISTANCE;
340 mOverflingDistance = OVERFLING_DISTANCE;
Romain Guy68055452011-08-02 16:33:02 -0700341 mFadingMarqueeEnabled = true;
Justin Kohfeabd2c2014-05-02 10:02:44 -0700342 mGlobalActionsKeyTimeout = GLOBAL_ACTIONS_KEY_TIMEOUT;
Aaron Whytef8306522017-03-22 16:30:58 -0700343 mHorizontalScrollFactor = HORIZONTAL_SCROLL_FACTOR;
344 mVerticalScrollFactor = VERTICAL_SCROLL_FACTOR;
Vladislav Kaznacheeva725df92018-02-26 16:22:34 -0800345 mShowMenuShortcutsWhenKeyboardPresent = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800346 }
347
348 /**
349 * Creates a new configuration for the specified context. The configuration depends on
350 * various parameters of the context, like the dimension of the display or the density
351 * of the display.
352 *
353 * @param context The application context used to initialize this view configuration.
354 *
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700355 * @see #get(android.content.Context)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800356 * @see android.util.DisplayMetrics
357 */
358 private ViewConfiguration(Context context) {
Adam Powell8c470622011-06-30 18:19:51 -0700359 final Resources res = context.getResources();
360 final DisplayMetrics metrics = res.getDisplayMetrics();
361 final Configuration config = res.getConfiguration();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800362 final float density = metrics.density;
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800363 final float sizeAndDensity;
Adam Powell8c470622011-06-30 18:19:51 -0700364 if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800365 sizeAndDensity = density * 1.5f;
366 } else {
367 sizeAndDensity = density;
368 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800369
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800370 mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f);
371 mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f);
Tarun Lohani8c89baa2017-06-16 17:21:04 +0000372 mScrollbarSize = res.getDimensionPixelSize(
373 com.android.internal.R.dimen.config_scrollbarSize);
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800374 mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
375 mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800376
377 // Size of the screen in bytes, in ARGB_8888 format
Jeff Brown98365d72012-08-19 20:30:52 -0700378 final WindowManager win = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
379 final Display display = win.getDefaultDisplay();
Jeff Browna8b9def2012-07-23 14:22:49 -0700380 final Point size = new Point();
381 display.getRealSize(size);
382 mMaximumDrawingCacheSize = 4 * size.x * size.y;
Adam Powell637d3372010-08-25 14:37:03 -0700383
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800384 mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
385 mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
Adam Powell8c470622011-06-30 18:19:51 -0700386
387 if (!sHasPermanentMenuKeySet) {
Adam Powellcc84ff42013-12-04 11:15:29 -0800388 final int configVal = res.getInteger(
389 com.android.internal.R.integer.config_overrideHasPermanentMenuKey);
390
391 switch (configVal) {
392 default:
393 case HAS_PERMANENT_MENU_KEY_AUTODETECT: {
394 IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
395 try {
396 sHasPermanentMenuKey = !wm.hasNavigationBar();
397 sHasPermanentMenuKeySet = true;
398 } catch (RemoteException ex) {
399 sHasPermanentMenuKey = false;
400 }
401 }
402 break;
403
404 case HAS_PERMANENT_MENU_KEY_TRUE:
405 sHasPermanentMenuKey = true;
406 sHasPermanentMenuKeySet = true;
407 break;
408
409 case HAS_PERMANENT_MENU_KEY_FALSE:
410 sHasPermanentMenuKey = false;
411 sHasPermanentMenuKeySet = true;
412 break;
Adam Powell8c470622011-06-30 18:19:51 -0700413 }
414 }
Romain Guy68055452011-08-02 16:33:02 -0700415
416 mFadingMarqueeEnabled = res.getBoolean(
417 com.android.internal.R.bool.config_ui_enableFadingMarquee);
Adam Powell7d39f852011-12-05 19:26:54 -0800418 mTouchSlop = res.getDimensionPixelSize(
419 com.android.internal.R.dimen.config_viewConfigurationTouchSlop);
Vladislav Kaznacheev556ac612017-12-07 11:02:08 -0800420 mHoverSlop = res.getDimensionPixelSize(
421 com.android.internal.R.dimen.config_viewConfigurationHoverSlop);
Vladislav Kaznacheev4d2c60142017-02-07 17:11:54 -0800422 mMinScrollbarTouchTarget = res.getDimensionPixelSize(
423 com.android.internal.R.dimen.config_minScrollbarTouchTarget);
Adam Powell7d39f852011-12-05 19:26:54 -0800424 mPagingTouchSlop = mTouchSlop * 2;
Adam Powelle4b8ff82011-12-06 16:40:49 -0800425
426 mDoubleTapTouchSlop = mTouchSlop;
Mindy Pereira23ffc732014-04-30 17:09:35 -0700427
428 mMinimumFlingVelocity = res.getDimensionPixelSize(
429 com.android.internal.R.dimen.config_viewMinFlingVelocity);
430 mMaximumFlingVelocity = res.getDimensionPixelSize(
431 com.android.internal.R.dimen.config_viewMaxFlingVelocity);
Justin Kohfeabd2c2014-05-02 10:02:44 -0700432 mGlobalActionsKeyTimeout = res.getInteger(
433 com.android.internal.R.integer.config_globalActionsKeyTimeout);
Aaron Whytef8306522017-03-22 16:30:58 -0700434
435 mHorizontalScrollFactor = res.getDimensionPixelSize(
436 com.android.internal.R.dimen.config_horizontalScrollFactor);
437 mVerticalScrollFactor = res.getDimensionPixelSize(
438 com.android.internal.R.dimen.config_verticalScrollFactor);
Vladislav Kaznacheeva725df92018-02-26 16:22:34 -0800439
440 mShowMenuShortcutsWhenKeyboardPresent = res.getBoolean(
441 com.android.internal.R.bool.config_showMenuShortcutsWhenKeyboardPresent);
442
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800443 }
444
445 /**
446 * Returns a configuration for the specified context. The configuration depends on
447 * various parameters of the context, like the dimension of the display or the
448 * density of the display.
449 *
450 * @param context The application context used to initialize the view configuration.
451 */
452 public static ViewConfiguration get(Context context) {
453 final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
454 final int density = (int) (100.0f * metrics.density);
455
456 ViewConfiguration configuration = sConfigurations.get(density);
457 if (configuration == null) {
458 configuration = new ViewConfiguration(context);
459 sConfigurations.put(density, configuration);
460 }
461
462 return configuration;
463 }
464
465 /**
466 * @return The width of the horizontal scrollbar and the height of the vertical
Gilles Debunne006fa482011-10-27 17:23:36 -0700467 * scrollbar in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800468 *
469 * @deprecated Use {@link #getScaledScrollBarSize()} instead.
470 */
471 @Deprecated
472 public static int getScrollBarSize() {
473 return SCROLL_BAR_SIZE;
474 }
475
476 /**
477 * @return The width of the horizontal scrollbar and the height of the vertical
478 * scrollbar in pixels
479 */
480 public int getScaledScrollBarSize() {
481 return mScrollbarSize;
482 }
483
484 /**
Vladislav Kaznacheev4d2c60142017-02-07 17:11:54 -0800485 * @return the minimum size of the scrollbar thumb's touch target in pixels
486 * @hide
487 */
488 public int getScaledMinScrollbarTouchTarget() {
489 return mMinScrollbarTouchTarget;
490 }
491
492 /**
Mike Cleronf116bf82009-09-27 19:14:12 -0700493 * @return Duration of the fade when scrollbars fade away in milliseconds
494 */
495 public static int getScrollBarFadeDuration() {
496 return SCROLL_BAR_FADE_DURATION;
497 }
498
499 /**
Alan Viverette25f0e612015-02-27 12:34:30 -0800500 * @return Default delay before the scrollbars fade in milliseconds
Mike Cleronf116bf82009-09-27 19:14:12 -0700501 */
502 public static int getScrollDefaultDelay() {
503 return SCROLL_BAR_DEFAULT_DELAY;
504 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700505
Mike Cleronf116bf82009-09-27 19:14:12 -0700506 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700507 * @return the length of the fading edges in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800508 *
509 * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
510 */
511 @Deprecated
512 public static int getFadingEdgeLength() {
513 return FADING_EDGE_LENGTH;
514 }
515
516 /**
517 * @return the length of the fading edges in pixels
518 */
519 public int getScaledFadingEdgeLength() {
520 return mFadingEdgeLength;
521 }
522
523 /**
524 * @return the duration in milliseconds of the pressed state in child
525 * components.
526 */
527 public static int getPressedStateDuration() {
528 return PRESSED_STATE_DURATION;
529 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800530
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800531 /**
532 * @return the duration in milliseconds before a press turns into
533 * a long press
534 */
535 public static int getLongPressTimeout() {
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800536 return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT,
Jeff Browna4547672011-03-02 21:38:11 -0800537 DEFAULT_LONG_PRESS_TIMEOUT);
538 }
539
540 /**
Anthony Hugh96e9cc52016-07-12 15:17:24 -0700541 * @return the duration in milliseconds between the first tap's up event and the second tap's
542 * down event for an interaction to be considered part of the same multi-press.
543 * @hide
544 */
545 public static int getMultiPressTimeout() {
546 return AppGlobals.getIntCoreSetting(Settings.Secure.MULTI_PRESS_TIMEOUT,
547 DEFAULT_MULTI_PRESS_TIMEOUT);
548 }
549
550 /**
Jeff Browna4547672011-03-02 21:38:11 -0800551 * @return the time before the first key repeat in milliseconds.
552 */
553 public static int getKeyRepeatTimeout() {
554 return getLongPressTimeout();
555 }
556
557 /**
558 * @return the time between successive key repeats in milliseconds.
559 */
560 public static int getKeyRepeatDelay() {
561 return KEY_REPEAT_DELAY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800562 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800563
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800564 /**
565 * @return the duration in milliseconds we will wait to see if a touch event
566 * is a tap or a scroll. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700567 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800568 */
569 public static int getTapTimeout() {
570 return TAP_TIMEOUT;
571 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700572
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800573 /**
574 * @return the duration in milliseconds we will wait to see if a touch event
575 * is a jump tap. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700576 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800577 */
578 public static int getJumpTapTimeout() {
579 return JUMP_TAP_TIMEOUT;
580 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700581
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800582 /**
583 * @return the duration in milliseconds between the first tap's up event and
584 * the second tap's down event for an interaction to be considered a
585 * double-tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800586 */
587 public static int getDoubleTapTimeout() {
588 return DOUBLE_TAP_TIMEOUT;
589 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700590
591 /**
Adam Powellaf1785f2013-09-05 13:44:45 -0700592 * @return the minimum duration in milliseconds between the first tap's
593 * up event and the second tap's down event for an interaction to be considered a
594 * double-tap.
595 *
596 * @hide
597 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100598 @UnsupportedAppUsage
Adam Powellaf1785f2013-09-05 13:44:45 -0700599 public static int getDoubleTapMinTime() {
600 return DOUBLE_TAP_MIN_TIME;
601 }
602
603 /**
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700604 * @return the maximum duration in milliseconds between a touch pad
605 * touch and release for a given touch to be considered a tap (click) as
606 * opposed to a hover movement gesture.
607 * @hide
608 */
609 public static int getHoverTapTimeout() {
610 return HOVER_TAP_TIMEOUT;
611 }
612
613 /**
614 * @return the maximum distance in pixels that a touch pad touch can move
615 * before being released for it to be considered a tap (click) as opposed
616 * to a hover movement gesture.
617 * @hide
618 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100619 @UnsupportedAppUsage
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700620 public static int getHoverTapSlop() {
621 return HOVER_TAP_SLOP;
622 }
623
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800624 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700625 * @return Inset in dips to look for touchable content when the user touches the edge of the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800626 * screen
627 *
628 * @deprecated Use {@link #getScaledEdgeSlop()} instead.
629 */
630 @Deprecated
631 public static int getEdgeSlop() {
632 return EDGE_SLOP;
633 }
634
635 /**
636 * @return Inset in pixels to look for touchable content when the user touches the edge of the
637 * screen
638 */
639 public int getScaledEdgeSlop() {
640 return mEdgeSlop;
641 }
642
643 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700644 * @return Distance in dips a touch can wander before we think the user is scrolling
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800645 *
646 * @deprecated Use {@link #getScaledTouchSlop()} instead.
647 */
648 @Deprecated
649 public static int getTouchSlop() {
650 return TOUCH_SLOP;
651 }
652
653 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700654 * @return Distance in pixels a touch can wander before we think the user is scrolling
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800655 */
656 public int getScaledTouchSlop() {
657 return mTouchSlop;
658 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700659
Adam Powellde8d0832010-03-09 17:11:30 -0800660 /**
Vladislav Kaznacheev556ac612017-12-07 11:02:08 -0800661 * @return Distance in pixels a hover can wander while it is still considered "stationary".
662 *
663 */
664 public int getScaledHoverSlop() {
665 return mHoverSlop;
666 }
667
668 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700669 * @return Distance in pixels the first touch can wander before we do not consider this a
670 * potential double tap event
671 * @hide
672 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100673 @UnsupportedAppUsage
Gilles Debunne006fa482011-10-27 17:23:36 -0700674 public int getScaledDoubleTapTouchSlop() {
675 return mDoubleTapTouchSlop;
676 }
677
678 /**
679 * @return Distance in pixels a touch can wander before we think the user is scrolling a full
680 * page
Adam Powellde8d0832010-03-09 17:11:30 -0800681 */
682 public int getScaledPagingTouchSlop() {
683 return mPagingTouchSlop;
684 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800685
686 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700687 * @return Distance in dips between the first touch and second touch to still be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800688 * considered a double tap
689 * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
690 * @hide The only client of this should be GestureDetector, which needs this
691 * for clients that still use its deprecated constructor.
692 */
693 @Deprecated
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100694 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800695 public static int getDoubleTapSlop() {
696 return DOUBLE_TAP_SLOP;
697 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700698
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800699 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700700 * @return Distance in pixels between the first touch and second touch to still be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800701 * considered a double tap
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800702 */
703 public int getScaledDoubleTapSlop() {
704 return mDoubleTapSlop;
705 }
706
707 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700708 * Interval for dispatching a recurring accessibility event in milliseconds.
709 * This interval guarantees that a recurring event will be send at most once
710 * during the {@link #getSendRecurringAccessibilityEventsInterval()} time frame.
711 *
712 * @return The delay in milliseconds.
713 *
714 * @hide
715 */
716 public static long getSendRecurringAccessibilityEventsInterval() {
717 return SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS;
718 }
719
720 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700721 * @return Distance in dips a touch must be outside the bounds of a window for it
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800722 * to be counted as outside the window for purposes of dismissing that
723 * window.
724 *
725 * @deprecated Use {@link #getScaledWindowTouchSlop()} instead.
726 */
727 @Deprecated
728 public static int getWindowTouchSlop() {
729 return WINDOW_TOUCH_SLOP;
730 }
731
732 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700733 * @return Distance in pixels a touch must be outside the bounds of a window for it
734 * to be counted as outside the window for purposes of dismissing that window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800735 */
736 public int getScaledWindowTouchSlop() {
737 return mWindowTouchSlop;
738 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700739
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800740 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700741 * @return Minimum velocity to initiate a fling, as measured in dips per second.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800742 *
743 * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
744 */
745 @Deprecated
746 public static int getMinimumFlingVelocity() {
747 return MINIMUM_FLING_VELOCITY;
748 }
749
750 /**
751 * @return Minimum velocity to initiate a fling, as measured in pixels per second.
752 */
753 public int getScaledMinimumFlingVelocity() {
754 return mMinimumFlingVelocity;
755 }
756
757 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700758 * @return Maximum velocity to initiate a fling, as measured in dips per second.
Romain Guy4296fc42009-07-06 11:48:52 -0700759 *
760 * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead.
761 */
762 @Deprecated
763 public static int getMaximumFlingVelocity() {
764 return MAXIMUM_FLING_VELOCITY;
765 }
766
767 /**
768 * @return Maximum velocity to initiate a fling, as measured in pixels per second.
769 */
770 public int getScaledMaximumFlingVelocity() {
771 return mMaximumFlingVelocity;
772 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700773
Romain Guy4296fc42009-07-06 11:48:52 -0700774 /**
Ned Burns69af4322016-08-17 17:30:25 -0400775 * @return Amount to scroll in response to a {@link MotionEvent#ACTION_SCROLL} event. Multiply
776 * this by the event's axis value to obtain the number of pixels to be scrolled.
Aaron Whytef8306522017-03-22 16:30:58 -0700777 *
778 * @removed
Ned Burns69af4322016-08-17 17:30:25 -0400779 */
780 public int getScaledScrollFactor() {
Aaron Whytef8306522017-03-22 16:30:58 -0700781 return (int) mVerticalScrollFactor;
782 }
783
784 /**
785 * @return Amount to scroll in response to a horizontal {@link MotionEvent#ACTION_SCROLL} event.
786 * Multiply this by the event's axis value to obtain the number of pixels to be scrolled.
787 */
788 public float getScaledHorizontalScrollFactor() {
789 return mHorizontalScrollFactor;
790 }
791
792 /**
793 * @return Amount to scroll in response to a vertical {@link MotionEvent#ACTION_SCROLL} event.
794 * Multiply this by the event's axis value to obtain the number of pixels to be scrolled.
795 */
796 public float getScaledVerticalScrollFactor() {
797 return mVerticalScrollFactor;
Ned Burns69af4322016-08-17 17:30:25 -0400798 }
799
800 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800801 * The maximum drawing cache size expressed in bytes.
802 *
803 * @return the maximum size of View's drawing cache expressed in bytes
804 *
805 * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
806 */
807 @Deprecated
808 public static int getMaximumDrawingCacheSize() {
809 //noinspection deprecation
810 return MAXIMUM_DRAWING_CACHE_SIZE;
811 }
812
813 /**
814 * The maximum drawing cache size expressed in bytes.
815 *
816 * @return the maximum size of View's drawing cache expressed in bytes
817 */
818 public int getScaledMaximumDrawingCacheSize() {
819 return mMaximumDrawingCacheSize;
820 }
821
822 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700823 * @return The maximum distance a View should overscroll by when showing edge effects (in
824 * pixels).
Adam Powell637d3372010-08-25 14:37:03 -0700825 */
826 public int getScaledOverscrollDistance() {
827 return mOverscrollDistance;
828 }
829
830 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700831 * @return The maximum distance a View should overfling by when showing edge effects (in
832 * pixels).
Adam Powell637d3372010-08-25 14:37:03 -0700833 */
834 public int getScaledOverflingDistance() {
835 return mOverflingDistance;
836 }
837
838 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800839 * The amount of time that the zoom controls should be
840 * displayed on the screen expressed in milliseconds.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700841 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800842 * @return the time the zoom controls should be visible expressed
843 * in milliseconds.
844 */
845 public static long getZoomControlsTimeout() {
846 return ZOOM_CONTROLS_TIMEOUT;
847 }
848
849 /**
850 * The amount of time a user needs to press the relevant key to bring up
851 * the global actions dialog.
852 *
853 * @return how long a user needs to press the relevant key to bring up
854 * the global actions dialog.
Justin Koh8031fa02014-05-05 16:28:49 -0700855 * @deprecated This timeout should not be used by applications
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800856 */
Justin Koh1aa59f82014-05-04 12:13:25 -0700857 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800858 public static long getGlobalActionKeyTimeout() {
859 return GLOBAL_ACTIONS_KEY_TIMEOUT;
860 }
861
862 /**
Justin Kohfeabd2c2014-05-02 10:02:44 -0700863 * The amount of time a user needs to press the relevant key to bring up
864 * the global actions dialog.
865 *
866 * @return how long a user needs to press the relevant key to bring up
867 * the global actions dialog.
Justin Koh1aa59f82014-05-04 12:13:25 -0700868 * @hide
Justin Kohfeabd2c2014-05-02 10:02:44 -0700869 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100870 @UnsupportedAppUsage
Justin Kohfeabd2c2014-05-02 10:02:44 -0700871 public long getDeviceGlobalActionKeyTimeout() {
872 return mGlobalActionsKeyTimeout;
873 }
874
875 /**
Phil Weaver106fe732016-11-22 18:18:39 -0800876 * The amount of time a user needs to press the relevant keys to activate the accessibility
877 * shortcut.
878 *
879 * @return how long a user needs to press the relevant keys to activate the accessibility
880 * shortcut.
881 * @hide
882 */
883 public long getAccessibilityShortcutKeyTimeout() {
884 return A11Y_SHORTCUT_KEY_TIMEOUT;
885 }
886
887 /**
Eugene Susla5f19cd32017-10-19 14:00:59 -0700888 * @return The amount of time a user needs to press the relevant keys to activate the
889 * accessibility shortcut after it's confirmed that accessibility shortcut is used.
890 * @hide
891 */
892 public long getAccessibilityShortcutKeyTimeoutAfterConfirmation() {
893 return A11Y_SHORTCUT_KEY_TIMEOUT_AFTER_CONFIRMATION;
894 }
895
896 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800897 * The amount of friction applied to scrolls and flings.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700898 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800899 * @return A scalar dimensionless value representing the coefficient of
900 * friction.
901 */
902 public static float getScrollFriction() {
903 return SCROLL_FRICTION;
904 }
Adam Powell8c470622011-06-30 18:19:51 -0700905
906 /**
Abodunrinwa Toki9e211282015-06-05 02:46:57 +0100907 * @return the default duration in milliseconds for {@link ActionMode#hide(long)}.
Abodunrinwa Tokifd3a3a12015-05-05 20:04:34 +0100908 */
Abodunrinwa Toki9e211282015-06-05 02:46:57 +0100909 public static long getDefaultActionModeHideDuration() {
910 return ACTION_MODE_HIDE_DURATION_DEFAULT;
Abodunrinwa Tokifd3a3a12015-05-05 20:04:34 +0100911 }
912
913 /**
Adam Powell8c470622011-06-30 18:19:51 -0700914 * Report if the device has a permanent menu key available to the user.
915 *
916 * <p>As of Android 3.0, devices may not have a permanent menu key available.
917 * Apps should use the action bar to present menu options to users.
918 * However, there are some apps where the action bar is inappropriate
919 * or undesirable. This method may be used to detect if a menu key is present.
920 * If not, applications should provide another on-screen affordance to access
921 * functionality.
922 *
923 * @return true if a permanent menu key is present, false otherwise.
924 */
925 public boolean hasPermanentMenuKey() {
926 return sHasPermanentMenuKey;
927 }
Romain Guy68055452011-08-02 16:33:02 -0700928
929 /**
Vladislav Kaznacheeva725df92018-02-26 16:22:34 -0800930 * Check if shortcuts should be displayed in menus.
931 *
932 * @return {@code True} if shortcuts should be displayed in menus.
933 */
934 public boolean shouldShowMenuShortcutsWhenKeyboardPresent() {
935 return mShowMenuShortcutsWhenKeyboardPresent;
936 }
937
938 /**
Romain Guy68055452011-08-02 16:33:02 -0700939 * @hide
940 * @return Whether or not marquee should use fading edges.
941 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100942 @UnsupportedAppUsage
Romain Guy68055452011-08-02 16:33:02 -0700943 public boolean isFadingMarqueeEnabled() {
944 return mFadingMarqueeEnabled;
945 }
Vladislav Kaznacheevf847ee32016-11-21 14:11:00 -0800946
947 /**
948 * @return the duration in milliseconds before an end of a long press causes a tooltip to be
949 * hidden
950 * @hide
951 */
952 @TestApi
953 public static int getLongPressTooltipHideTimeout() {
954 return LONG_PRESS_TOOLTIP_HIDE_TIMEOUT;
955 }
956
957 /**
958 * @return the duration in milliseconds before a hover event causes a tooltip to be shown
959 * @hide
960 */
961 @TestApi
962 public static int getHoverTooltipShowTimeout() {
963 return HOVER_TOOLTIP_SHOW_TIMEOUT;
964 }
965
966 /**
967 * @return the duration in milliseconds before mouse inactivity causes a tooltip to be hidden
968 * (default variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is not set).
969 * @hide
970 */
971 @TestApi
972 public static int getHoverTooltipHideTimeout() {
973 return HOVER_TOOLTIP_HIDE_TIMEOUT;
974 }
975
976 /**
977 * @return the duration in milliseconds before mouse inactivity causes a tooltip to be hidden
978 * (shorter variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is set).
979 * @hide
980 */
981 @TestApi
982 public static int getHoverTooltipHideShortTimeout() {
983 return HOVER_TOOLTIP_HIDE_SHORT_TIMEOUT;
984 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800985}