blob: e67659c2485e0532e80d1a5deff581cfdb2f510d [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
Svetoslav Ganov54d068e2011-03-02 12:58:40 -080019import android.app.AppGlobals;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020import android.content.Context;
Dianne Hackbornff801ec2011-01-22 18:05:38 -080021import android.content.res.Configuration;
Adam Powell8c470622011-06-30 18:19:51 -070022import android.content.res.Resources;
Jeff Browna8b9def2012-07-23 14:22:49 -070023import android.graphics.Point;
Adam Powell8c470622011-06-30 18:19:51 -070024import android.os.RemoteException;
Svetoslav Ganov54d068e2011-03-02 12:58:40 -080025import android.provider.Settings;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.util.DisplayMetrics;
27import android.util.SparseArray;
28
29/**
30 * Contains methods to standard constants used in the UI for timeouts, sizes, and distances.
31 */
32public class ViewConfiguration {
33 /**
34 * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in
Gilles Debunne006fa482011-10-27 17:23:36 -070035 * dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036 */
37 private static final int SCROLL_BAR_SIZE = 10;
38
39 /**
Mike Cleronf116bf82009-09-27 19:14:12 -070040 * Duration of the fade when scrollbars fade away in milliseconds
41 */
42 private static final int SCROLL_BAR_FADE_DURATION = 250;
43
44 /**
45 * Default delay before the scrollbars fade in milliseconds
46 */
47 private static final int SCROLL_BAR_DEFAULT_DELAY = 300;
48
49 /**
Gilles Debunne006fa482011-10-27 17:23:36 -070050 * Defines the length of the fading edges in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051 */
52 private static final int FADING_EDGE_LENGTH = 12;
53
54 /**
55 * Defines the duration in milliseconds of the pressed state in child
56 * components.
57 */
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070058 private static final int PRESSED_STATE_DURATION = 64;
59
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060 /**
Jeff Browna4547672011-03-02 21:38:11 -080061 * Defines the default duration in milliseconds before a press turns into
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080062 * a long press
63 */
Jeff Browna4547672011-03-02 21:38:11 -080064 private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500;
65
66 /**
67 * Defines the time between successive key repeats in milliseconds.
68 */
69 private static final int KEY_REPEAT_DELAY = 50;
70
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071 /**
72 * Defines the duration in milliseconds a user needs to hold down the
73 * appropriate button to bring up the global actions dialog (power off,
74 * lock screen, etc).
75 */
76 private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070077
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080078 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070079 * Defines the duration in milliseconds we will wait to see if a touch event
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080 * is a tap or a scroll. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070081 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080082 */
Patrick Dubroye0a799a2011-05-04 16:19:22 -070083 private static final int TAP_TIMEOUT = 180;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070084
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080085 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070086 * Defines the duration in milliseconds we will wait to see if a touch event
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080087 * 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 -070088 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089 */
90 private static final int JUMP_TAP_TIMEOUT = 500;
91
92 /**
93 * Defines the duration in milliseconds between the first tap's up event and
94 * the second tap's down event for an interaction to be considered a
95 * double-tap.
96 */
97 private static final int DOUBLE_TAP_TIMEOUT = 300;
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -070098
99 /**
Adam Powellaf1785f2013-09-05 13:44:45 -0700100 * Defines the minimum duration in milliseconds between the first tap's up event and
101 * the second tap's down event for an interaction to be considered a
102 * double-tap.
103 */
104 private static final int DOUBLE_TAP_MIN_TIME = 40;
105
106 /**
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700107 * Defines the maximum duration in milliseconds between a touch pad
108 * touch and release for a given touch to be considered a tap (click) as
109 * opposed to a hover movement gesture.
110 */
111 private static final int HOVER_TAP_TIMEOUT = 150;
112
113 /**
114 * Defines the maximum distance in pixels that a touch pad touch can move
115 * before being released for it to be considered a tap (click) as opposed
116 * to a hover movement gesture.
117 */
118 private static final int HOVER_TAP_SLOP = 20;
119
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800120 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700121 * Defines the duration in milliseconds we want to display zoom controls in response
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800122 * to a user panning within an application.
123 */
124 private static final int ZOOM_CONTROLS_TIMEOUT = 3000;
125
126 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700127 * 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 -0800128 */
129 private static final int EDGE_SLOP = 12;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700130
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800131 /**
Adam Powell7d39f852011-12-05 19:26:54 -0800132 * Distance a touch can wander before we think the user is scrolling in dips.
133 * Note that this value defined here is only used as a fallback by legacy/misbehaving
134 * applications that do not provide a Context for determining density/configuration-dependent
135 * values.
136 *
137 * To alter this value, see the configuration resource config_viewConfigurationTouchSlop
138 * in frameworks/base/core/res/res/values/config.xml or the appropriate device resource overlay.
139 * It may be appropriate to tweak this on a device-specific basis in an overlay based on
140 * the characteristics of the touch panel and firmware.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800141 */
Adam Powell6720a872011-12-07 17:35:32 -0800142 private static final int TOUCH_SLOP = 8;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700143
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800144 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700145 * Distance the first touch can wander before we stop considering this event a double tap
146 * (in dips)
147 */
148 private static final int DOUBLE_TAP_TOUCH_SLOP = TOUCH_SLOP;
149
150 /**
Adam Powellde8d0832010-03-09 17:11:30 -0800151 * Distance a touch can wander before we think the user is attempting a paged scroll
152 * (in dips)
Adam Powell7d39f852011-12-05 19:26:54 -0800153 *
154 * Note that this value defined here is only used as a fallback by legacy/misbehaving
155 * applications that do not provide a Context for determining density/configuration-dependent
156 * values.
157 *
158 * See the note above on {@link #TOUCH_SLOP} regarding the dimen resource
159 * config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of
160 * config_viewConfigurationTouchSlop * 2 when provided with a Context.
Adam Powellde8d0832010-03-09 17:11:30 -0800161 */
Adam Powellb7ef1d92010-03-11 10:25:24 -0800162 private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700163
Adam Powellde8d0832010-03-09 17:11:30 -0800164 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700165 * 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 -0800166 */
167 private static final int DOUBLE_TAP_SLOP = 100;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700168
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800169 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700170 * 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 -0800171 * count as outside for purposes of dismissing the window.
172 */
173 private static final int WINDOW_TOUCH_SLOP = 16;
174
175 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700176 * Minimum velocity to initiate a fling, as measured in dips per second
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800177 */
178 private static final int MINIMUM_FLING_VELOCITY = 50;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700179
Romain Guy4296fc42009-07-06 11:48:52 -0700180 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700181 * Maximum velocity to initiate a fling, as measured in dips per second
Romain Guy4296fc42009-07-06 11:48:52 -0700182 */
Adam Powell637d3372010-08-25 14:37:03 -0700183 private static final int MAXIMUM_FLING_VELOCITY = 8000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800184
185 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700186 * Delay before dispatching a recurring accessibility event in milliseconds.
187 * This delay guarantees that a recurring event will be send at most once
188 * during the {@link #SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS} time
189 * frame.
190 */
Svetoslav Ganove15ccb92012-05-16 15:48:55 -0700191 private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 100;
Svetoslav Ganova0156172011-06-26 17:55:44 -0700192
193 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194 * The maximum size of View's drawing cache, expressed in bytes. This size
195 * should be at least equal to the size of the screen in ARGB888 format.
196 */
197 @Deprecated
Romain Guy0211a0a2011-02-14 16:34:59 -0800198 private static final int MAXIMUM_DRAWING_CACHE_SIZE = 480 * 800 * 4; // ARGB8888
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800199
200 /**
201 * The coefficient of friction applied to flings/scrolls.
202 */
Romain Guy0211a0a2011-02-14 16:34:59 -0800203 private static final float SCROLL_FRICTION = 0.015f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800204
Adam Powell637d3372010-08-25 14:37:03 -0700205 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700206 * Max distance in dips to overscroll for edge effects
Adam Powell637d3372010-08-25 14:37:03 -0700207 */
208 private static final int OVERSCROLL_DISTANCE = 0;
209
210 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700211 * Max distance in dips to overfling for edge effects
Adam Powell637d3372010-08-25 14:37:03 -0700212 */
Gilles Debunne8ce7aab2011-01-25 11:23:30 -0800213 private static final int OVERFLING_DISTANCE = 6;
Adam Powell637d3372010-08-25 14:37:03 -0700214
Adam Powellcc84ff42013-12-04 11:15:29 -0800215 /**
216 * Configuration values for overriding {@link #hasPermanentMenuKey()} behavior.
217 * These constants must match the definition in res/values/config.xml.
218 */
219 private static final int HAS_PERMANENT_MENU_KEY_AUTODETECT = 0;
220 private static final int HAS_PERMANENT_MENU_KEY_TRUE = 1;
221 private static final int HAS_PERMANENT_MENU_KEY_FALSE = 2;
222
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800223 private final int mEdgeSlop;
224 private final int mFadingEdgeLength;
225 private final int mMinimumFlingVelocity;
Romain Guy4296fc42009-07-06 11:48:52 -0700226 private final int mMaximumFlingVelocity;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800227 private final int mScrollbarSize;
228 private final int mTouchSlop;
Gilles Debunne006fa482011-10-27 17:23:36 -0700229 private final int mDoubleTapTouchSlop;
Adam Powellde8d0832010-03-09 17:11:30 -0800230 private final int mPagingTouchSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800231 private final int mDoubleTapSlop;
232 private final int mWindowTouchSlop;
233 private final int mMaximumDrawingCacheSize;
Adam Powell637d3372010-08-25 14:37:03 -0700234 private final int mOverscrollDistance;
235 private final int mOverflingDistance;
Romain Guy68055452011-08-02 16:33:02 -0700236 private final boolean mFadingMarqueeEnabled;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800237
Adam Powell8c470622011-06-30 18:19:51 -0700238 private boolean sHasPermanentMenuKey;
239 private boolean sHasPermanentMenuKeySet;
240
Xavier Ducrohet7f9f99ea2011-08-11 10:16:17 -0700241 static final SparseArray<ViewConfiguration> sConfigurations =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800242 new SparseArray<ViewConfiguration>(2);
243
244 /**
245 * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead.
246 */
247 @Deprecated
248 public ViewConfiguration() {
249 mEdgeSlop = EDGE_SLOP;
250 mFadingEdgeLength = FADING_EDGE_LENGTH;
251 mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY;
Romain Guy4296fc42009-07-06 11:48:52 -0700252 mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800253 mScrollbarSize = SCROLL_BAR_SIZE;
254 mTouchSlop = TOUCH_SLOP;
Gilles Debunne006fa482011-10-27 17:23:36 -0700255 mDoubleTapTouchSlop = DOUBLE_TAP_TOUCH_SLOP;
Adam Powellde8d0832010-03-09 17:11:30 -0800256 mPagingTouchSlop = PAGING_TOUCH_SLOP;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800257 mDoubleTapSlop = DOUBLE_TAP_SLOP;
258 mWindowTouchSlop = WINDOW_TOUCH_SLOP;
259 //noinspection deprecation
260 mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
Adam Powell637d3372010-08-25 14:37:03 -0700261 mOverscrollDistance = OVERSCROLL_DISTANCE;
262 mOverflingDistance = OVERFLING_DISTANCE;
Romain Guy68055452011-08-02 16:33:02 -0700263 mFadingMarqueeEnabled = true;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800264 }
265
266 /**
267 * Creates a new configuration for the specified context. The configuration depends on
268 * various parameters of the context, like the dimension of the display or the density
269 * of the display.
270 *
271 * @param context The application context used to initialize this view configuration.
272 *
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700273 * @see #get(android.content.Context)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800274 * @see android.util.DisplayMetrics
275 */
276 private ViewConfiguration(Context context) {
Adam Powell8c470622011-06-30 18:19:51 -0700277 final Resources res = context.getResources();
278 final DisplayMetrics metrics = res.getDisplayMetrics();
279 final Configuration config = res.getConfiguration();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 final float density = metrics.density;
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800281 final float sizeAndDensity;
Adam Powell8c470622011-06-30 18:19:51 -0700282 if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800283 sizeAndDensity = density * 1.5f;
284 } else {
285 sizeAndDensity = density;
286 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800288 mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f);
289 mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800290 mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
Romain Guy4296fc42009-07-06 11:48:52 -0700291 mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292 mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800293 mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
294 mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800295
296 // Size of the screen in bytes, in ARGB_8888 format
Jeff Brown98365d72012-08-19 20:30:52 -0700297 final WindowManager win = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
298 final Display display = win.getDefaultDisplay();
Jeff Browna8b9def2012-07-23 14:22:49 -0700299 final Point size = new Point();
300 display.getRealSize(size);
301 mMaximumDrawingCacheSize = 4 * size.x * size.y;
Adam Powell637d3372010-08-25 14:37:03 -0700302
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800303 mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
304 mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
Adam Powell8c470622011-06-30 18:19:51 -0700305
306 if (!sHasPermanentMenuKeySet) {
Adam Powellcc84ff42013-12-04 11:15:29 -0800307 final int configVal = res.getInteger(
308 com.android.internal.R.integer.config_overrideHasPermanentMenuKey);
309
310 switch (configVal) {
311 default:
312 case HAS_PERMANENT_MENU_KEY_AUTODETECT: {
313 IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
314 try {
315 sHasPermanentMenuKey = !wm.hasNavigationBar();
316 sHasPermanentMenuKeySet = true;
317 } catch (RemoteException ex) {
318 sHasPermanentMenuKey = false;
319 }
320 }
321 break;
322
323 case HAS_PERMANENT_MENU_KEY_TRUE:
324 sHasPermanentMenuKey = true;
325 sHasPermanentMenuKeySet = true;
326 break;
327
328 case HAS_PERMANENT_MENU_KEY_FALSE:
329 sHasPermanentMenuKey = false;
330 sHasPermanentMenuKeySet = true;
331 break;
Adam Powell8c470622011-06-30 18:19:51 -0700332 }
333 }
Romain Guy68055452011-08-02 16:33:02 -0700334
335 mFadingMarqueeEnabled = res.getBoolean(
336 com.android.internal.R.bool.config_ui_enableFadingMarquee);
Adam Powell7d39f852011-12-05 19:26:54 -0800337 mTouchSlop = res.getDimensionPixelSize(
338 com.android.internal.R.dimen.config_viewConfigurationTouchSlop);
339 mPagingTouchSlop = mTouchSlop * 2;
Adam Powelle4b8ff82011-12-06 16:40:49 -0800340
341 mDoubleTapTouchSlop = mTouchSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342 }
343
344 /**
345 * Returns a configuration for the specified context. The configuration depends on
346 * various parameters of the context, like the dimension of the display or the
347 * density of the display.
348 *
349 * @param context The application context used to initialize the view configuration.
350 */
351 public static ViewConfiguration get(Context context) {
352 final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
353 final int density = (int) (100.0f * metrics.density);
354
355 ViewConfiguration configuration = sConfigurations.get(density);
356 if (configuration == null) {
357 configuration = new ViewConfiguration(context);
358 sConfigurations.put(density, configuration);
359 }
360
361 return configuration;
362 }
363
364 /**
365 * @return The width of the horizontal scrollbar and the height of the vertical
Gilles Debunne006fa482011-10-27 17:23:36 -0700366 * scrollbar in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800367 *
368 * @deprecated Use {@link #getScaledScrollBarSize()} instead.
369 */
370 @Deprecated
371 public static int getScrollBarSize() {
372 return SCROLL_BAR_SIZE;
373 }
374
375 /**
376 * @return The width of the horizontal scrollbar and the height of the vertical
377 * scrollbar in pixels
378 */
379 public int getScaledScrollBarSize() {
380 return mScrollbarSize;
381 }
382
383 /**
Mike Cleronf116bf82009-09-27 19:14:12 -0700384 * @return Duration of the fade when scrollbars fade away in milliseconds
385 */
386 public static int getScrollBarFadeDuration() {
387 return SCROLL_BAR_FADE_DURATION;
388 }
389
390 /**
391 * @return Default delay before the scrollbars fade in milliseconds
392 */
393 public static int getScrollDefaultDelay() {
394 return SCROLL_BAR_DEFAULT_DELAY;
395 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700396
Mike Cleronf116bf82009-09-27 19:14:12 -0700397 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700398 * @return the length of the fading edges in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800399 *
400 * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
401 */
402 @Deprecated
403 public static int getFadingEdgeLength() {
404 return FADING_EDGE_LENGTH;
405 }
406
407 /**
408 * @return the length of the fading edges in pixels
409 */
410 public int getScaledFadingEdgeLength() {
411 return mFadingEdgeLength;
412 }
413
414 /**
415 * @return the duration in milliseconds of the pressed state in child
416 * components.
417 */
418 public static int getPressedStateDuration() {
419 return PRESSED_STATE_DURATION;
420 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800421
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422 /**
423 * @return the duration in milliseconds before a press turns into
424 * a long press
425 */
426 public static int getLongPressTimeout() {
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800427 return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT,
Jeff Browna4547672011-03-02 21:38:11 -0800428 DEFAULT_LONG_PRESS_TIMEOUT);
429 }
430
431 /**
432 * @return the time before the first key repeat in milliseconds.
433 */
434 public static int getKeyRepeatTimeout() {
435 return getLongPressTimeout();
436 }
437
438 /**
439 * @return the time between successive key repeats in milliseconds.
440 */
441 public static int getKeyRepeatDelay() {
442 return KEY_REPEAT_DELAY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800443 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800444
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800445 /**
446 * @return the duration in milliseconds we will wait to see if a touch event
447 * is a tap or a scroll. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700448 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800449 */
450 public static int getTapTimeout() {
451 return TAP_TIMEOUT;
452 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700453
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800454 /**
455 * @return the duration in milliseconds we will wait to see if a touch event
456 * is a jump tap. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700457 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800458 */
459 public static int getJumpTapTimeout() {
460 return JUMP_TAP_TIMEOUT;
461 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700462
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800463 /**
464 * @return the duration in milliseconds between the first tap's up event and
465 * the second tap's down event for an interaction to be considered a
466 * double-tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800467 */
468 public static int getDoubleTapTimeout() {
469 return DOUBLE_TAP_TIMEOUT;
470 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700471
472 /**
Adam Powellaf1785f2013-09-05 13:44:45 -0700473 * @return the minimum duration in milliseconds between the first tap's
474 * up event and the second tap's down event for an interaction to be considered a
475 * double-tap.
476 *
477 * @hide
478 */
479 public static int getDoubleTapMinTime() {
480 return DOUBLE_TAP_MIN_TIME;
481 }
482
483 /**
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700484 * @return the maximum duration in milliseconds between a touch pad
485 * touch and release for a given touch to be considered a tap (click) as
486 * opposed to a hover movement gesture.
487 * @hide
488 */
489 public static int getHoverTapTimeout() {
490 return HOVER_TAP_TIMEOUT;
491 }
492
493 /**
494 * @return the maximum distance in pixels that a touch pad touch can move
495 * before being released for it to be considered a tap (click) as opposed
496 * to a hover movement gesture.
497 * @hide
498 */
499 public static int getHoverTapSlop() {
500 return HOVER_TAP_SLOP;
501 }
502
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700504 * @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 -0800505 * screen
506 *
507 * @deprecated Use {@link #getScaledEdgeSlop()} instead.
508 */
509 @Deprecated
510 public static int getEdgeSlop() {
511 return EDGE_SLOP;
512 }
513
514 /**
515 * @return Inset in pixels to look for touchable content when the user touches the edge of the
516 * screen
517 */
518 public int getScaledEdgeSlop() {
519 return mEdgeSlop;
520 }
521
522 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700523 * @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 -0800524 *
525 * @deprecated Use {@link #getScaledTouchSlop()} instead.
526 */
527 @Deprecated
528 public static int getTouchSlop() {
529 return TOUCH_SLOP;
530 }
531
532 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700533 * @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 -0800534 */
535 public int getScaledTouchSlop() {
536 return mTouchSlop;
537 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700538
Adam Powellde8d0832010-03-09 17:11:30 -0800539 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700540 * @return Distance in pixels the first touch can wander before we do not consider this a
541 * potential double tap event
542 * @hide
543 */
544 public int getScaledDoubleTapTouchSlop() {
545 return mDoubleTapTouchSlop;
546 }
547
548 /**
549 * @return Distance in pixels a touch can wander before we think the user is scrolling a full
550 * page
Adam Powellde8d0832010-03-09 17:11:30 -0800551 */
552 public int getScaledPagingTouchSlop() {
553 return mPagingTouchSlop;
554 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800555
556 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700557 * @return Distance in dips between the first touch and second touch to still be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800558 * considered a double tap
559 * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
560 * @hide The only client of this should be GestureDetector, which needs this
561 * for clients that still use its deprecated constructor.
562 */
563 @Deprecated
564 public static int getDoubleTapSlop() {
565 return DOUBLE_TAP_SLOP;
566 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700567
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800568 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700569 * @return Distance in pixels between the first touch and second touch to still be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800570 * considered a double tap
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800571 */
572 public int getScaledDoubleTapSlop() {
573 return mDoubleTapSlop;
574 }
575
576 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700577 * Interval for dispatching a recurring accessibility event in milliseconds.
578 * This interval guarantees that a recurring event will be send at most once
579 * during the {@link #getSendRecurringAccessibilityEventsInterval()} time frame.
580 *
581 * @return The delay in milliseconds.
582 *
583 * @hide
584 */
585 public static long getSendRecurringAccessibilityEventsInterval() {
586 return SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS;
587 }
588
589 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700590 * @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 -0800591 * to be counted as outside the window for purposes of dismissing that
592 * window.
593 *
594 * @deprecated Use {@link #getScaledWindowTouchSlop()} instead.
595 */
596 @Deprecated
597 public static int getWindowTouchSlop() {
598 return WINDOW_TOUCH_SLOP;
599 }
600
601 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700602 * @return Distance in pixels a touch must be outside the bounds of a window for it
603 * to be counted as outside the window for purposes of dismissing that window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800604 */
605 public int getScaledWindowTouchSlop() {
606 return mWindowTouchSlop;
607 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700608
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800609 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700610 * @return Minimum velocity to initiate a fling, as measured in dips per second.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800611 *
612 * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
613 */
614 @Deprecated
615 public static int getMinimumFlingVelocity() {
616 return MINIMUM_FLING_VELOCITY;
617 }
618
619 /**
620 * @return Minimum velocity to initiate a fling, as measured in pixels per second.
621 */
622 public int getScaledMinimumFlingVelocity() {
623 return mMinimumFlingVelocity;
624 }
625
626 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700627 * @return Maximum velocity to initiate a fling, as measured in dips per second.
Romain Guy4296fc42009-07-06 11:48:52 -0700628 *
629 * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead.
630 */
631 @Deprecated
632 public static int getMaximumFlingVelocity() {
633 return MAXIMUM_FLING_VELOCITY;
634 }
635
636 /**
637 * @return Maximum velocity to initiate a fling, as measured in pixels per second.
638 */
639 public int getScaledMaximumFlingVelocity() {
640 return mMaximumFlingVelocity;
641 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700642
Romain Guy4296fc42009-07-06 11:48:52 -0700643 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800644 * The maximum drawing cache size expressed in bytes.
645 *
646 * @return the maximum size of View's drawing cache expressed in bytes
647 *
648 * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
649 */
650 @Deprecated
651 public static int getMaximumDrawingCacheSize() {
652 //noinspection deprecation
653 return MAXIMUM_DRAWING_CACHE_SIZE;
654 }
655
656 /**
657 * The maximum drawing cache size expressed in bytes.
658 *
659 * @return the maximum size of View's drawing cache expressed in bytes
660 */
661 public int getScaledMaximumDrawingCacheSize() {
662 return mMaximumDrawingCacheSize;
663 }
664
665 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700666 * @return The maximum distance a View should overscroll by when showing edge effects (in
667 * pixels).
Adam Powell637d3372010-08-25 14:37:03 -0700668 */
669 public int getScaledOverscrollDistance() {
670 return mOverscrollDistance;
671 }
672
673 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700674 * @return The maximum distance a View should overfling by when showing edge effects (in
675 * pixels).
Adam Powell637d3372010-08-25 14:37:03 -0700676 */
677 public int getScaledOverflingDistance() {
678 return mOverflingDistance;
679 }
680
681 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800682 * The amount of time that the zoom controls should be
683 * displayed on the screen expressed in milliseconds.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700684 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800685 * @return the time the zoom controls should be visible expressed
686 * in milliseconds.
687 */
688 public static long getZoomControlsTimeout() {
689 return ZOOM_CONTROLS_TIMEOUT;
690 }
691
692 /**
693 * The amount of time a user needs to press the relevant key to bring up
694 * the global actions dialog.
695 *
696 * @return how long a user needs to press the relevant key to bring up
697 * the global actions dialog.
698 */
699 public static long getGlobalActionKeyTimeout() {
700 return GLOBAL_ACTIONS_KEY_TIMEOUT;
701 }
702
703 /**
704 * The amount of friction applied to scrolls and flings.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700705 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800706 * @return A scalar dimensionless value representing the coefficient of
707 * friction.
708 */
709 public static float getScrollFriction() {
710 return SCROLL_FRICTION;
711 }
Adam Powell8c470622011-06-30 18:19:51 -0700712
713 /**
714 * Report if the device has a permanent menu key available to the user.
715 *
716 * <p>As of Android 3.0, devices may not have a permanent menu key available.
717 * Apps should use the action bar to present menu options to users.
718 * However, there are some apps where the action bar is inappropriate
719 * or undesirable. This method may be used to detect if a menu key is present.
720 * If not, applications should provide another on-screen affordance to access
721 * functionality.
722 *
723 * @return true if a permanent menu key is present, false otherwise.
724 */
725 public boolean hasPermanentMenuKey() {
726 return sHasPermanentMenuKey;
727 }
Romain Guy68055452011-08-02 16:33:02 -0700728
729 /**
730 * @hide
731 * @return Whether or not marquee should use fading edges.
732 */
733 public boolean isFadingMarqueeEnabled() {
734 return mFadingMarqueeEnabled;
735 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800736}