blob: 823befb22f7b83befabc8530d7b8eb3857c79cb0 [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;
23import android.os.RemoteException;
Svetoslav Ganov54d068e2011-03-02 12:58:40 -080024import android.provider.Settings;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.util.DisplayMetrics;
26import android.util.SparseArray;
27
28/**
29 * Contains methods to standard constants used in the UI for timeouts, sizes, and distances.
30 */
31public class ViewConfiguration {
32 /**
Romain Guydbc26d22010-10-11 17:58:29 -070033 * Expected bit depth of the display panel.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070034 *
Romain Guydbc26d22010-10-11 17:58:29 -070035 * @hide
36 */
37 public static final float PANEL_BIT_DEPTH = 24;
38
39 /**
40 * Minimum alpha required for a view to draw.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070041 *
Romain Guydbc26d22010-10-11 17:58:29 -070042 * @hide
43 */
44 public static final float ALPHA_THRESHOLD = 0.5f / PANEL_BIT_DEPTH;
Romain Guy909cbaf2010-10-13 18:19:48 -070045 /**
46 * @hide
47 */
48 public static final float ALPHA_THRESHOLD_INT = 0x7f / PANEL_BIT_DEPTH;
49
Romain Guydbc26d22010-10-11 17:58:29 -070050 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051 * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in
Gilles Debunne006fa482011-10-27 17:23:36 -070052 * dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 */
54 private static final int SCROLL_BAR_SIZE = 10;
55
56 /**
Mike Cleronf116bf82009-09-27 19:14:12 -070057 * Duration of the fade when scrollbars fade away in milliseconds
58 */
59 private static final int SCROLL_BAR_FADE_DURATION = 250;
60
61 /**
62 * Default delay before the scrollbars fade in milliseconds
63 */
64 private static final int SCROLL_BAR_DEFAULT_DELAY = 300;
65
66 /**
Gilles Debunne006fa482011-10-27 17:23:36 -070067 * Defines the length of the fading edges in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068 */
69 private static final int FADING_EDGE_LENGTH = 12;
70
71 /**
72 * Defines the duration in milliseconds of the pressed state in child
73 * components.
74 */
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070075 private static final int PRESSED_STATE_DURATION = 64;
76
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080077 /**
Jeff Browna4547672011-03-02 21:38:11 -080078 * Defines the default duration in milliseconds before a press turns into
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079 * a long press
80 */
Jeff Browna4547672011-03-02 21:38:11 -080081 private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500;
82
83 /**
84 * Defines the time between successive key repeats in milliseconds.
85 */
86 private static final int KEY_REPEAT_DELAY = 50;
87
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 /**
89 * Defines the duration in milliseconds a user needs to hold down the
90 * appropriate button to bring up the global actions dialog (power off,
91 * lock screen, etc).
92 */
93 private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070094
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070096 * Defines the duration in milliseconds we will wait to see if a touch event
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 * is a tap or a scroll. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -070098 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 */
Patrick Dubroye0a799a2011-05-04 16:19:22 -0700100 private static final int TAP_TIMEOUT = 180;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700101
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700103 * Defines the duration in milliseconds we will wait to see if a touch event
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104 * 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 -0700105 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106 */
107 private static final int JUMP_TAP_TIMEOUT = 500;
108
109 /**
110 * Defines the duration in milliseconds between the first tap's up event and
111 * the second tap's down event for an interaction to be considered a
112 * double-tap.
113 */
114 private static final int DOUBLE_TAP_TIMEOUT = 300;
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700115
116 /**
117 * Defines the maximum duration in milliseconds between a touch pad
118 * touch and release for a given touch to be considered a tap (click) as
119 * opposed to a hover movement gesture.
120 */
121 private static final int HOVER_TAP_TIMEOUT = 150;
122
123 /**
124 * Defines the maximum distance in pixels that a touch pad touch can move
125 * before being released for it to be considered a tap (click) as opposed
126 * to a hover movement gesture.
127 */
128 private static final int HOVER_TAP_SLOP = 20;
129
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800130 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700131 * Defines the duration in milliseconds we want to display zoom controls in response
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800132 * to a user panning within an application.
133 */
134 private static final int ZOOM_CONTROLS_TIMEOUT = 3000;
135
136 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700137 * 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 -0800138 */
139 private static final int EDGE_SLOP = 12;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700140
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800141 /**
Adam Powell7d39f852011-12-05 19:26:54 -0800142 * Distance a touch can wander before we think the user is scrolling in dips.
143 * Note that this value defined here is only used as a fallback by legacy/misbehaving
144 * applications that do not provide a Context for determining density/configuration-dependent
145 * values.
146 *
147 * To alter this value, see the configuration resource config_viewConfigurationTouchSlop
148 * in frameworks/base/core/res/res/values/config.xml or the appropriate device resource overlay.
149 * It may be appropriate to tweak this on a device-specific basis in an overlay based on
150 * the characteristics of the touch panel and firmware.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800151 */
Adam Powell6720a872011-12-07 17:35:32 -0800152 private static final int TOUCH_SLOP = 8;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700153
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800154 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700155 * Distance the first touch can wander before we stop considering this event a double tap
156 * (in dips)
157 */
158 private static final int DOUBLE_TAP_TOUCH_SLOP = TOUCH_SLOP;
159
160 /**
Adam Powellde8d0832010-03-09 17:11:30 -0800161 * Distance a touch can wander before we think the user is attempting a paged scroll
162 * (in dips)
Adam Powell7d39f852011-12-05 19:26:54 -0800163 *
164 * Note that this value defined here is only used as a fallback by legacy/misbehaving
165 * applications that do not provide a Context for determining density/configuration-dependent
166 * values.
167 *
168 * See the note above on {@link #TOUCH_SLOP} regarding the dimen resource
169 * config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of
170 * config_viewConfigurationTouchSlop * 2 when provided with a Context.
Adam Powellde8d0832010-03-09 17:11:30 -0800171 */
Adam Powellb7ef1d92010-03-11 10:25:24 -0800172 private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700173
Adam Powellde8d0832010-03-09 17:11:30 -0800174 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700175 * 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 -0800176 */
177 private static final int DOUBLE_TAP_SLOP = 100;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700178
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700180 * 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 -0800181 * count as outside for purposes of dismissing the window.
182 */
183 private static final int WINDOW_TOUCH_SLOP = 16;
184
185 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700186 * Minimum velocity to initiate a fling, as measured in dips per second
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 */
188 private static final int MINIMUM_FLING_VELOCITY = 50;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700189
Romain Guy4296fc42009-07-06 11:48:52 -0700190 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700191 * Maximum velocity to initiate a fling, as measured in dips per second
Romain Guy4296fc42009-07-06 11:48:52 -0700192 */
Adam Powell637d3372010-08-25 14:37:03 -0700193 private static final int MAXIMUM_FLING_VELOCITY = 8000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194
195 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700196 * Delay before dispatching a recurring accessibility event in milliseconds.
197 * This delay guarantees that a recurring event will be send at most once
198 * during the {@link #SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS} time
199 * frame.
200 */
Svetoslav Ganove15ccb92012-05-16 15:48:55 -0700201 private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 100;
Svetoslav Ganova0156172011-06-26 17:55:44 -0700202
203 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800204 * The maximum size of View's drawing cache, expressed in bytes. This size
205 * should be at least equal to the size of the screen in ARGB888 format.
206 */
207 @Deprecated
Romain Guy0211a0a2011-02-14 16:34:59 -0800208 private static final int MAXIMUM_DRAWING_CACHE_SIZE = 480 * 800 * 4; // ARGB8888
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800209
210 /**
211 * The coefficient of friction applied to flings/scrolls.
212 */
Romain Guy0211a0a2011-02-14 16:34:59 -0800213 private static final float SCROLL_FRICTION = 0.015f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800214
Adam Powell637d3372010-08-25 14:37:03 -0700215 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700216 * Max distance in dips to overscroll for edge effects
Adam Powell637d3372010-08-25 14:37:03 -0700217 */
218 private static final int OVERSCROLL_DISTANCE = 0;
219
220 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700221 * Max distance in dips to overfling for edge effects
Adam Powell637d3372010-08-25 14:37:03 -0700222 */
Gilles Debunne8ce7aab2011-01-25 11:23:30 -0800223 private static final int OVERFLING_DISTANCE = 6;
Adam Powell637d3372010-08-25 14:37:03 -0700224
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800225 private final int mEdgeSlop;
226 private final int mFadingEdgeLength;
227 private final int mMinimumFlingVelocity;
Romain Guy4296fc42009-07-06 11:48:52 -0700228 private final int mMaximumFlingVelocity;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800229 private final int mScrollbarSize;
230 private final int mTouchSlop;
Gilles Debunne006fa482011-10-27 17:23:36 -0700231 private final int mDoubleTapTouchSlop;
Adam Powellde8d0832010-03-09 17:11:30 -0800232 private final int mPagingTouchSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800233 private final int mDoubleTapSlop;
234 private final int mWindowTouchSlop;
235 private final int mMaximumDrawingCacheSize;
Adam Powell637d3372010-08-25 14:37:03 -0700236 private final int mOverscrollDistance;
237 private final int mOverflingDistance;
Romain Guy68055452011-08-02 16:33:02 -0700238 private final boolean mFadingMarqueeEnabled;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800239
Adam Powell8c470622011-06-30 18:19:51 -0700240 private boolean sHasPermanentMenuKey;
241 private boolean sHasPermanentMenuKeySet;
242
Xavier Ducrohet7f9f99ea2011-08-11 10:16:17 -0700243 static final SparseArray<ViewConfiguration> sConfigurations =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800244 new SparseArray<ViewConfiguration>(2);
245
246 /**
247 * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead.
248 */
249 @Deprecated
250 public ViewConfiguration() {
251 mEdgeSlop = EDGE_SLOP;
252 mFadingEdgeLength = FADING_EDGE_LENGTH;
253 mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY;
Romain Guy4296fc42009-07-06 11:48:52 -0700254 mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800255 mScrollbarSize = SCROLL_BAR_SIZE;
256 mTouchSlop = TOUCH_SLOP;
Gilles Debunne006fa482011-10-27 17:23:36 -0700257 mDoubleTapTouchSlop = DOUBLE_TAP_TOUCH_SLOP;
Adam Powellde8d0832010-03-09 17:11:30 -0800258 mPagingTouchSlop = PAGING_TOUCH_SLOP;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 mDoubleTapSlop = DOUBLE_TAP_SLOP;
260 mWindowTouchSlop = WINDOW_TOUCH_SLOP;
261 //noinspection deprecation
262 mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
Adam Powell637d3372010-08-25 14:37:03 -0700263 mOverscrollDistance = OVERSCROLL_DISTANCE;
264 mOverflingDistance = OVERFLING_DISTANCE;
Romain Guy68055452011-08-02 16:33:02 -0700265 mFadingMarqueeEnabled = true;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800266 }
267
268 /**
269 * Creates a new configuration for the specified context. The configuration depends on
270 * various parameters of the context, like the dimension of the display or the density
271 * of the display.
272 *
273 * @param context The application context used to initialize this view configuration.
274 *
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700275 * @see #get(android.content.Context)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800276 * @see android.util.DisplayMetrics
277 */
278 private ViewConfiguration(Context context) {
Adam Powell8c470622011-06-30 18:19:51 -0700279 final Resources res = context.getResources();
280 final DisplayMetrics metrics = res.getDisplayMetrics();
281 final Configuration config = res.getConfiguration();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800282 final float density = metrics.density;
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800283 final float sizeAndDensity;
Adam Powell8c470622011-06-30 18:19:51 -0700284 if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800285 sizeAndDensity = density * 1.5f;
286 } else {
287 sizeAndDensity = density;
288 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800290 mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f);
291 mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292 mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
Romain Guy4296fc42009-07-06 11:48:52 -0700293 mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800295 mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
296 mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297
Romain Guy887c2ee2012-03-09 16:57:58 -0800298 final Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299 // Size of the screen in bytes, in ARGB_8888 format
Romain Guy887c2ee2012-03-09 16:57:58 -0800300 mMaximumDrawingCacheSize = 4 * display.getRawWidth() * display.getRawHeight();
Adam Powell637d3372010-08-25 14:37:03 -0700301
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800302 mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
303 mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
Adam Powell8c470622011-06-30 18:19:51 -0700304
305 if (!sHasPermanentMenuKeySet) {
306 IWindowManager wm = Display.getWindowManager();
307 try {
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700308 sHasPermanentMenuKey = !wm.hasSystemNavBar() && !wm.hasNavigationBar();
Adam Powell8c470622011-06-30 18:19:51 -0700309 sHasPermanentMenuKeySet = true;
310 } catch (RemoteException ex) {
311 sHasPermanentMenuKey = false;
312 }
313 }
Romain Guy68055452011-08-02 16:33:02 -0700314
315 mFadingMarqueeEnabled = res.getBoolean(
316 com.android.internal.R.bool.config_ui_enableFadingMarquee);
Adam Powell7d39f852011-12-05 19:26:54 -0800317 mTouchSlop = res.getDimensionPixelSize(
318 com.android.internal.R.dimen.config_viewConfigurationTouchSlop);
319 mPagingTouchSlop = mTouchSlop * 2;
Adam Powelle4b8ff82011-12-06 16:40:49 -0800320
321 mDoubleTapTouchSlop = mTouchSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800322 }
323
324 /**
325 * Returns a configuration for the specified context. The configuration depends on
326 * various parameters of the context, like the dimension of the display or the
327 * density of the display.
328 *
329 * @param context The application context used to initialize the view configuration.
330 */
331 public static ViewConfiguration get(Context context) {
332 final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
333 final int density = (int) (100.0f * metrics.density);
334
335 ViewConfiguration configuration = sConfigurations.get(density);
336 if (configuration == null) {
337 configuration = new ViewConfiguration(context);
338 sConfigurations.put(density, configuration);
339 }
340
341 return configuration;
342 }
343
344 /**
345 * @return The width of the horizontal scrollbar and the height of the vertical
Gilles Debunne006fa482011-10-27 17:23:36 -0700346 * scrollbar in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800347 *
348 * @deprecated Use {@link #getScaledScrollBarSize()} instead.
349 */
350 @Deprecated
351 public static int getScrollBarSize() {
352 return SCROLL_BAR_SIZE;
353 }
354
355 /**
356 * @return The width of the horizontal scrollbar and the height of the vertical
357 * scrollbar in pixels
358 */
359 public int getScaledScrollBarSize() {
360 return mScrollbarSize;
361 }
362
363 /**
Mike Cleronf116bf82009-09-27 19:14:12 -0700364 * @return Duration of the fade when scrollbars fade away in milliseconds
365 */
366 public static int getScrollBarFadeDuration() {
367 return SCROLL_BAR_FADE_DURATION;
368 }
369
370 /**
371 * @return Default delay before the scrollbars fade in milliseconds
372 */
373 public static int getScrollDefaultDelay() {
374 return SCROLL_BAR_DEFAULT_DELAY;
375 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700376
Mike Cleronf116bf82009-09-27 19:14:12 -0700377 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700378 * @return the length of the fading edges in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800379 *
380 * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
381 */
382 @Deprecated
383 public static int getFadingEdgeLength() {
384 return FADING_EDGE_LENGTH;
385 }
386
387 /**
388 * @return the length of the fading edges in pixels
389 */
390 public int getScaledFadingEdgeLength() {
391 return mFadingEdgeLength;
392 }
393
394 /**
395 * @return the duration in milliseconds of the pressed state in child
396 * components.
397 */
398 public static int getPressedStateDuration() {
399 return PRESSED_STATE_DURATION;
400 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800401
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800402 /**
403 * @return the duration in milliseconds before a press turns into
404 * a long press
405 */
406 public static int getLongPressTimeout() {
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800407 return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT,
Jeff Browna4547672011-03-02 21:38:11 -0800408 DEFAULT_LONG_PRESS_TIMEOUT);
409 }
410
411 /**
412 * @return the time before the first key repeat in milliseconds.
413 */
414 public static int getKeyRepeatTimeout() {
415 return getLongPressTimeout();
416 }
417
418 /**
419 * @return the time between successive key repeats in milliseconds.
420 */
421 public static int getKeyRepeatDelay() {
422 return KEY_REPEAT_DELAY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800423 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800424
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800425 /**
426 * @return the duration in milliseconds we will wait to see if a touch event
427 * is a tap or a scroll. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700428 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800429 */
430 public static int getTapTimeout() {
431 return TAP_TIMEOUT;
432 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700433
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800434 /**
435 * @return the duration in milliseconds we will wait to see if a touch event
436 * is a jump tap. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700437 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438 */
439 public static int getJumpTapTimeout() {
440 return JUMP_TAP_TIMEOUT;
441 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700442
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800443 /**
444 * @return the duration in milliseconds between the first tap's up event and
445 * the second tap's down event for an interaction to be considered a
446 * double-tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800447 */
448 public static int getDoubleTapTimeout() {
449 return DOUBLE_TAP_TIMEOUT;
450 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700451
452 /**
453 * @return the maximum duration in milliseconds between a touch pad
454 * touch and release for a given touch to be considered a tap (click) as
455 * opposed to a hover movement gesture.
456 * @hide
457 */
458 public static int getHoverTapTimeout() {
459 return HOVER_TAP_TIMEOUT;
460 }
461
462 /**
463 * @return the maximum distance in pixels that a touch pad touch can move
464 * before being released for it to be considered a tap (click) as opposed
465 * to a hover movement gesture.
466 * @hide
467 */
468 public static int getHoverTapSlop() {
469 return HOVER_TAP_SLOP;
470 }
471
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800472 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700473 * @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 -0800474 * screen
475 *
476 * @deprecated Use {@link #getScaledEdgeSlop()} instead.
477 */
478 @Deprecated
479 public static int getEdgeSlop() {
480 return EDGE_SLOP;
481 }
482
483 /**
484 * @return Inset in pixels to look for touchable content when the user touches the edge of the
485 * screen
486 */
487 public int getScaledEdgeSlop() {
488 return mEdgeSlop;
489 }
490
491 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700492 * @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 -0800493 *
494 * @deprecated Use {@link #getScaledTouchSlop()} instead.
495 */
496 @Deprecated
497 public static int getTouchSlop() {
498 return TOUCH_SLOP;
499 }
500
501 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700502 * @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 -0800503 */
504 public int getScaledTouchSlop() {
505 return mTouchSlop;
506 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700507
Adam Powellde8d0832010-03-09 17:11:30 -0800508 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700509 * @return Distance in pixels the first touch can wander before we do not consider this a
510 * potential double tap event
511 * @hide
512 */
513 public int getScaledDoubleTapTouchSlop() {
514 return mDoubleTapTouchSlop;
515 }
516
517 /**
518 * @return Distance in pixels a touch can wander before we think the user is scrolling a full
519 * page
Adam Powellde8d0832010-03-09 17:11:30 -0800520 */
521 public int getScaledPagingTouchSlop() {
522 return mPagingTouchSlop;
523 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800524
525 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700526 * @return Distance in dips between the first touch and second touch to still be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800527 * considered a double tap
528 * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
529 * @hide The only client of this should be GestureDetector, which needs this
530 * for clients that still use its deprecated constructor.
531 */
532 @Deprecated
533 public static int getDoubleTapSlop() {
534 return DOUBLE_TAP_SLOP;
535 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700536
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800537 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700538 * @return Distance in pixels between the first touch and second touch to still be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 * considered a double tap
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800540 */
541 public int getScaledDoubleTapSlop() {
542 return mDoubleTapSlop;
543 }
544
545 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700546 * Interval for dispatching a recurring accessibility event in milliseconds.
547 * This interval guarantees that a recurring event will be send at most once
548 * during the {@link #getSendRecurringAccessibilityEventsInterval()} time frame.
549 *
550 * @return The delay in milliseconds.
551 *
552 * @hide
553 */
554 public static long getSendRecurringAccessibilityEventsInterval() {
555 return SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS;
556 }
557
558 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700559 * @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 -0800560 * to be counted as outside the window for purposes of dismissing that
561 * window.
562 *
563 * @deprecated Use {@link #getScaledWindowTouchSlop()} instead.
564 */
565 @Deprecated
566 public static int getWindowTouchSlop() {
567 return WINDOW_TOUCH_SLOP;
568 }
569
570 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700571 * @return Distance in pixels a touch must be outside the bounds of a window for it
572 * to be counted as outside the window for purposes of dismissing that window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800573 */
574 public int getScaledWindowTouchSlop() {
575 return mWindowTouchSlop;
576 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700577
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800578 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700579 * @return Minimum velocity to initiate a fling, as measured in dips per second.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800580 *
581 * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
582 */
583 @Deprecated
584 public static int getMinimumFlingVelocity() {
585 return MINIMUM_FLING_VELOCITY;
586 }
587
588 /**
589 * @return Minimum velocity to initiate a fling, as measured in pixels per second.
590 */
591 public int getScaledMinimumFlingVelocity() {
592 return mMinimumFlingVelocity;
593 }
594
595 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700596 * @return Maximum velocity to initiate a fling, as measured in dips per second.
Romain Guy4296fc42009-07-06 11:48:52 -0700597 *
598 * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead.
599 */
600 @Deprecated
601 public static int getMaximumFlingVelocity() {
602 return MAXIMUM_FLING_VELOCITY;
603 }
604
605 /**
606 * @return Maximum velocity to initiate a fling, as measured in pixels per second.
607 */
608 public int getScaledMaximumFlingVelocity() {
609 return mMaximumFlingVelocity;
610 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700611
Romain Guy4296fc42009-07-06 11:48:52 -0700612 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800613 * The maximum drawing cache size expressed in bytes.
614 *
615 * @return the maximum size of View's drawing cache expressed in bytes
616 *
617 * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
618 */
619 @Deprecated
620 public static int getMaximumDrawingCacheSize() {
621 //noinspection deprecation
622 return MAXIMUM_DRAWING_CACHE_SIZE;
623 }
624
625 /**
626 * The maximum drawing cache size expressed in bytes.
627 *
628 * @return the maximum size of View's drawing cache expressed in bytes
629 */
630 public int getScaledMaximumDrawingCacheSize() {
631 return mMaximumDrawingCacheSize;
632 }
633
634 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700635 * @return The maximum distance a View should overscroll by when showing edge effects (in
636 * pixels).
Adam Powell637d3372010-08-25 14:37:03 -0700637 */
638 public int getScaledOverscrollDistance() {
639 return mOverscrollDistance;
640 }
641
642 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700643 * @return The maximum distance a View should overfling by when showing edge effects (in
644 * pixels).
Adam Powell637d3372010-08-25 14:37:03 -0700645 */
646 public int getScaledOverflingDistance() {
647 return mOverflingDistance;
648 }
649
650 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800651 * The amount of time that the zoom controls should be
652 * displayed on the screen expressed in milliseconds.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700653 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800654 * @return the time the zoom controls should be visible expressed
655 * in milliseconds.
656 */
657 public static long getZoomControlsTimeout() {
658 return ZOOM_CONTROLS_TIMEOUT;
659 }
660
661 /**
662 * The amount of time a user needs to press the relevant key to bring up
663 * the global actions dialog.
664 *
665 * @return how long a user needs to press the relevant key to bring up
666 * the global actions dialog.
667 */
668 public static long getGlobalActionKeyTimeout() {
669 return GLOBAL_ACTIONS_KEY_TIMEOUT;
670 }
671
672 /**
673 * The amount of friction applied to scrolls and flings.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700674 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800675 * @return A scalar dimensionless value representing the coefficient of
676 * friction.
677 */
678 public static float getScrollFriction() {
679 return SCROLL_FRICTION;
680 }
Adam Powell8c470622011-06-30 18:19:51 -0700681
682 /**
683 * Report if the device has a permanent menu key available to the user.
684 *
685 * <p>As of Android 3.0, devices may not have a permanent menu key available.
686 * Apps should use the action bar to present menu options to users.
687 * However, there are some apps where the action bar is inappropriate
688 * or undesirable. This method may be used to detect if a menu key is present.
689 * If not, applications should provide another on-screen affordance to access
690 * functionality.
691 *
692 * @return true if a permanent menu key is present, false otherwise.
693 */
694 public boolean hasPermanentMenuKey() {
695 return sHasPermanentMenuKey;
696 }
Romain Guy68055452011-08-02 16:33:02 -0700697
698 /**
699 * @hide
700 * @return Whether or not marquee should use fading edges.
701 */
702 public boolean isFadingMarqueeEnabled() {
703 return mFadingMarqueeEnabled;
704 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800705}