blob: ce8aecc12ec04593b2c89c8f96c92115fff547e7 [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.
34 *
35 * @hide
36 */
37 public static final float PANEL_BIT_DEPTH = 24;
38
39 /**
40 * Minimum alpha required for a view to draw.
41 *
42 * @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
52 * pixels
53 */
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 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067 * Defines the length of the fading edges in pixels
68 */
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 */
Adam Powelle14579b2009-12-16 18:39:52 -080075 private static final int PRESSED_STATE_DURATION = 125;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076
77 /**
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;
94
95 /**
96 * Defines the duration in milliseconds we will wait to see if a touch event
97 * is a tap or a scroll. If the user does not move within this interval, it is
98 * considered to be a tap.
99 */
Patrick Dubroye0a799a2011-05-04 16:19:22 -0700100 private static final int TAP_TIMEOUT = 180;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101
102 /**
103 * Defines the duration in milliseconds we will wait to see if a touch event
104 * is a jump tap. If the user does not complete the jump tap within this interval, it is
105 * considered to be a tap.
106 */
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 /**
131 * Defines the duration in milliseconds we want to display zoom controls in response
132 * to a user panning within an application.
133 */
134 private static final int ZOOM_CONTROLS_TIMEOUT = 3000;
135
136 /**
137 * Inset in pixels to look for touchable content when the user touches the edge of the screen
138 */
139 private static final int EDGE_SLOP = 12;
140
141 /**
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 Powell7d39f852011-12-05 19:26:54 -0800152 private static final int TOUCH_SLOP = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800153
154 /**
Adam Powellde8d0832010-03-09 17:11:30 -0800155 * Distance a touch can wander before we think the user is attempting a paged scroll
156 * (in dips)
Adam Powell7d39f852011-12-05 19:26:54 -0800157 *
158 * Note that this value defined here is only used as a fallback by legacy/misbehaving
159 * applications that do not provide a Context for determining density/configuration-dependent
160 * values.
161 *
162 * See the note above on {@link #TOUCH_SLOP} regarding the dimen resource
163 * config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of
164 * config_viewConfigurationTouchSlop * 2 when provided with a Context.
Adam Powellde8d0832010-03-09 17:11:30 -0800165 */
Adam Powellb7ef1d92010-03-11 10:25:24 -0800166 private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
Adam Powellde8d0832010-03-09 17:11:30 -0800167
168 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800169 * Distance between the first touch and second touch to still be considered a double tap
170 */
171 private static final int DOUBLE_TAP_SLOP = 100;
172
173 /**
174 * Distance a touch needs to be outside of a window's bounds for it to
175 * count as outside for purposes of dismissing the window.
176 */
177 private static final int WINDOW_TOUCH_SLOP = 16;
178
179 /**
180 * Minimum velocity to initiate a fling, as measured in pixels per second
181 */
182 private static final int MINIMUM_FLING_VELOCITY = 50;
Romain Guy4296fc42009-07-06 11:48:52 -0700183
184 /**
185 * Maximum velocity to initiate a fling, as measured in pixels per second
186 */
Adam Powell637d3372010-08-25 14:37:03 -0700187 private static final int MAXIMUM_FLING_VELOCITY = 8000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800188
189 /**
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700190 * Distance between a touch up event denoting the end of a touch exploration
191 * gesture and the touch up event of a subsequent tap for the latter tap to be
192 * considered as a tap i.e. to perform a click.
193 */
194 private static final int TOUCH_EXPLORATION_TAP_SLOP = 80;
195
196 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700197 * Delay before dispatching a recurring accessibility event in milliseconds.
198 * This delay guarantees that a recurring event will be send at most once
199 * during the {@link #SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS} time
200 * frame.
201 */
202 private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 400;
203
204 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 * The maximum size of View's drawing cache, expressed in bytes. This size
206 * should be at least equal to the size of the screen in ARGB888 format.
207 */
208 @Deprecated
Romain Guy0211a0a2011-02-14 16:34:59 -0800209 private static final int MAXIMUM_DRAWING_CACHE_SIZE = 480 * 800 * 4; // ARGB8888
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800210
211 /**
212 * The coefficient of friction applied to flings/scrolls.
213 */
Romain Guy0211a0a2011-02-14 16:34:59 -0800214 private static final float SCROLL_FRICTION = 0.015f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800215
Adam Powell637d3372010-08-25 14:37:03 -0700216 /**
217 * Max distance to overscroll for edge effects
218 */
219 private static final int OVERSCROLL_DISTANCE = 0;
220
221 /**
222 * Max distance to overfling for edge effects
223 */
Gilles Debunne8ce7aab2011-01-25 11:23:30 -0800224 private static final int OVERFLING_DISTANCE = 6;
Adam Powell637d3372010-08-25 14:37:03 -0700225
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800226 private final int mEdgeSlop;
227 private final int mFadingEdgeLength;
228 private final int mMinimumFlingVelocity;
Romain Guy4296fc42009-07-06 11:48:52 -0700229 private final int mMaximumFlingVelocity;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800230 private final int mScrollbarSize;
231 private final int mTouchSlop;
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;
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700234 private final int mScaledTouchExplorationTapSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800235 private final int mWindowTouchSlop;
236 private final int mMaximumDrawingCacheSize;
Adam Powell637d3372010-08-25 14:37:03 -0700237 private final int mOverscrollDistance;
238 private final int mOverflingDistance;
Romain Guy68055452011-08-02 16:33:02 -0700239 private final boolean mFadingMarqueeEnabled;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800240
Adam Powell8c470622011-06-30 18:19:51 -0700241 private boolean sHasPermanentMenuKey;
242 private boolean sHasPermanentMenuKeySet;
243
Xavier Ducrohet7f9f99ea2011-08-11 10:16:17 -0700244 static final SparseArray<ViewConfiguration> sConfigurations =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800245 new SparseArray<ViewConfiguration>(2);
246
247 /**
248 * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead.
249 */
250 @Deprecated
251 public ViewConfiguration() {
252 mEdgeSlop = EDGE_SLOP;
253 mFadingEdgeLength = FADING_EDGE_LENGTH;
254 mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY;
Romain Guy4296fc42009-07-06 11:48:52 -0700255 mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800256 mScrollbarSize = SCROLL_BAR_SIZE;
257 mTouchSlop = 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;
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700260 mScaledTouchExplorationTapSlop = TOUCH_EXPLORATION_TAP_SLOP;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800261 mWindowTouchSlop = WINDOW_TOUCH_SLOP;
262 //noinspection deprecation
263 mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
Adam Powell637d3372010-08-25 14:37:03 -0700264 mOverscrollDistance = OVERSCROLL_DISTANCE;
265 mOverflingDistance = OVERFLING_DISTANCE;
Romain Guy68055452011-08-02 16:33:02 -0700266 mFadingMarqueeEnabled = true;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800267 }
268
269 /**
270 * Creates a new configuration for the specified context. The configuration depends on
271 * various parameters of the context, like the dimension of the display or the density
272 * of the display.
273 *
274 * @param context The application context used to initialize this view configuration.
275 *
276 * @see #get(android.content.Context)
277 * @see android.util.DisplayMetrics
278 */
279 private ViewConfiguration(Context context) {
Adam Powell8c470622011-06-30 18:19:51 -0700280 final Resources res = context.getResources();
281 final DisplayMetrics metrics = res.getDisplayMetrics();
282 final Configuration config = res.getConfiguration();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800283 final float density = metrics.density;
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800284 final float sizeAndDensity;
Adam Powell8c470622011-06-30 18:19:51 -0700285 if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800286 sizeAndDensity = density * 1.5f;
287 } else {
288 sizeAndDensity = density;
289 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800290
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800291 mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f);
292 mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
Romain Guy4296fc42009-07-06 11:48:52 -0700294 mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800295 mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800296 mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700297 mScaledTouchExplorationTapSlop = (int) (density * TOUCH_EXPLORATION_TAP_SLOP + 0.5f);
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800298 mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299
300 // Size of the screen in bytes, in ARGB_8888 format
301 mMaximumDrawingCacheSize = 4 * metrics.widthPixels * metrics.heightPixels;
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) {
307 IWindowManager wm = Display.getWindowManager();
308 try {
Daniel Sandler0c4ccff2011-10-19 16:39:14 -0400309 sHasPermanentMenuKey = wm.canStatusBarHide() && !wm.hasNavigationBar();
Adam Powell8c470622011-06-30 18:19:51 -0700310 sHasPermanentMenuKeySet = true;
311 } catch (RemoteException ex) {
312 sHasPermanentMenuKey = false;
313 }
314 }
Romain Guy68055452011-08-02 16:33:02 -0700315
316 mFadingMarqueeEnabled = res.getBoolean(
317 com.android.internal.R.bool.config_ui_enableFadingMarquee);
Adam Powell7d39f852011-12-05 19:26:54 -0800318 mTouchSlop = res.getDimensionPixelSize(
319 com.android.internal.R.dimen.config_viewConfigurationTouchSlop);
320 mPagingTouchSlop = mTouchSlop * 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 }
322
323 /**
324 * Returns a configuration for the specified context. The configuration depends on
325 * various parameters of the context, like the dimension of the display or the
326 * density of the display.
327 *
328 * @param context The application context used to initialize the view configuration.
329 */
330 public static ViewConfiguration get(Context context) {
331 final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
332 final int density = (int) (100.0f * metrics.density);
333
334 ViewConfiguration configuration = sConfigurations.get(density);
335 if (configuration == null) {
336 configuration = new ViewConfiguration(context);
337 sConfigurations.put(density, configuration);
338 }
339
340 return configuration;
341 }
342
343 /**
344 * @return The width of the horizontal scrollbar and the height of the vertical
345 * scrollbar in pixels
346 *
347 * @deprecated Use {@link #getScaledScrollBarSize()} instead.
348 */
349 @Deprecated
350 public static int getScrollBarSize() {
351 return SCROLL_BAR_SIZE;
352 }
353
354 /**
355 * @return The width of the horizontal scrollbar and the height of the vertical
356 * scrollbar in pixels
357 */
358 public int getScaledScrollBarSize() {
359 return mScrollbarSize;
360 }
361
362 /**
Mike Cleronf116bf82009-09-27 19:14:12 -0700363 * @return Duration of the fade when scrollbars fade away in milliseconds
364 */
365 public static int getScrollBarFadeDuration() {
366 return SCROLL_BAR_FADE_DURATION;
367 }
368
369 /**
370 * @return Default delay before the scrollbars fade in milliseconds
371 */
372 public static int getScrollDefaultDelay() {
373 return SCROLL_BAR_DEFAULT_DELAY;
374 }
375
376 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800377 * @return the length of the fading edges in pixels
378 *
379 * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
380 */
381 @Deprecated
382 public static int getFadingEdgeLength() {
383 return FADING_EDGE_LENGTH;
384 }
385
386 /**
387 * @return the length of the fading edges in pixels
388 */
389 public int getScaledFadingEdgeLength() {
390 return mFadingEdgeLength;
391 }
392
393 /**
394 * @return the duration in milliseconds of the pressed state in child
395 * components.
396 */
397 public static int getPressedStateDuration() {
398 return PRESSED_STATE_DURATION;
399 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800400
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800401 /**
402 * @return the duration in milliseconds before a press turns into
403 * a long press
404 */
405 public static int getLongPressTimeout() {
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800406 return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT,
Jeff Browna4547672011-03-02 21:38:11 -0800407 DEFAULT_LONG_PRESS_TIMEOUT);
408 }
409
410 /**
411 * @return the time before the first key repeat in milliseconds.
412 */
413 public static int getKeyRepeatTimeout() {
414 return getLongPressTimeout();
415 }
416
417 /**
418 * @return the time between successive key repeats in milliseconds.
419 */
420 public static int getKeyRepeatDelay() {
421 return KEY_REPEAT_DELAY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800423
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800424 /**
425 * @return the duration in milliseconds we will wait to see if a touch event
426 * is a tap or a scroll. If the user does not move within this interval, it is
427 * considered to be a tap.
428 */
429 public static int getTapTimeout() {
430 return TAP_TIMEOUT;
431 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700432
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800433 /**
434 * @return the duration in milliseconds we will wait to see if a touch event
435 * is a jump tap. If the user does not move within this interval, it is
436 * considered to be a tap.
437 */
438 public static int getJumpTapTimeout() {
439 return JUMP_TAP_TIMEOUT;
440 }
441
442 /**
443 * @return the duration in milliseconds between the first tap's up event and
444 * the second tap's down event for an interaction to be considered a
445 * double-tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 */
447 public static int getDoubleTapTimeout() {
448 return DOUBLE_TAP_TIMEOUT;
449 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700450
451 /**
452 * @return the maximum duration in milliseconds between a touch pad
453 * touch and release for a given touch to be considered a tap (click) as
454 * opposed to a hover movement gesture.
455 * @hide
456 */
457 public static int getHoverTapTimeout() {
458 return HOVER_TAP_TIMEOUT;
459 }
460
461 /**
462 * @return the maximum distance in pixels that a touch pad touch can move
463 * before being released for it to be considered a tap (click) as opposed
464 * to a hover movement gesture.
465 * @hide
466 */
467 public static int getHoverTapSlop() {
468 return HOVER_TAP_SLOP;
469 }
470
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800471 /**
472 * @return Inset in pixels to look for touchable content when the user touches the edge of the
473 * screen
474 *
475 * @deprecated Use {@link #getScaledEdgeSlop()} instead.
476 */
477 @Deprecated
478 public static int getEdgeSlop() {
479 return EDGE_SLOP;
480 }
481
482 /**
483 * @return Inset in pixels to look for touchable content when the user touches the edge of the
484 * screen
485 */
486 public int getScaledEdgeSlop() {
487 return mEdgeSlop;
488 }
489
490 /**
491 * @return Distance a touch can wander before we think the user is scrolling in pixels
492 *
493 * @deprecated Use {@link #getScaledTouchSlop()} instead.
494 */
495 @Deprecated
496 public static int getTouchSlop() {
497 return TOUCH_SLOP;
498 }
499
500 /**
501 * @return Distance a touch can wander before we think the user is scrolling in pixels
502 */
503 public int getScaledTouchSlop() {
504 return mTouchSlop;
505 }
Adam Powellde8d0832010-03-09 17:11:30 -0800506
507 /**
508 * @return Distance a touch can wander before we think the user is scrolling a full page
509 * in dips
510 */
511 public int getScaledPagingTouchSlop() {
512 return mPagingTouchSlop;
513 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800514
515 /**
516 * @return Distance between the first touch and second touch to still be
517 * considered a double tap
518 * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
519 * @hide The only client of this should be GestureDetector, which needs this
520 * for clients that still use its deprecated constructor.
521 */
522 @Deprecated
523 public static int getDoubleTapSlop() {
524 return DOUBLE_TAP_SLOP;
525 }
526
527 /**
528 * @return Distance between the first touch and second touch to still be
529 * considered a double tap
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800530 */
531 public int getScaledDoubleTapSlop() {
532 return mDoubleTapSlop;
533 }
534
535 /**
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700536 * @return Distance between a touch up event denoting the end of a touch exploration
537 * gesture and the touch up event of a subsequent tap for the latter tap to be
538 * considered as a tap i.e. to perform a click.
539 *
540 * @hide
541 */
542 public int getScaledTouchExplorationTapSlop() {
543 return mScaledTouchExplorationTapSlop;
544 }
545
546 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700547 * Interval for dispatching a recurring accessibility event in milliseconds.
548 * This interval guarantees that a recurring event will be send at most once
549 * during the {@link #getSendRecurringAccessibilityEventsInterval()} time frame.
550 *
551 * @return The delay in milliseconds.
552 *
553 * @hide
554 */
555 public static long getSendRecurringAccessibilityEventsInterval() {
556 return SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS;
557 }
558
559 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800560 * @return Distance a touch must be outside the bounds of a window for it
561 * to be counted as outside the window for purposes of dismissing that
562 * window.
563 *
564 * @deprecated Use {@link #getScaledWindowTouchSlop()} instead.
565 */
566 @Deprecated
567 public static int getWindowTouchSlop() {
568 return WINDOW_TOUCH_SLOP;
569 }
570
571 /**
572 * @return Distance a touch must be outside the bounds of a window for it
573 * to be counted as outside the window for purposes of dismissing that
574 * window.
575 */
576 public int getScaledWindowTouchSlop() {
577 return mWindowTouchSlop;
578 }
579
580 /**
581 * @return Minimum velocity to initiate a fling, as measured in pixels per second.
582 *
583 * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
584 */
585 @Deprecated
586 public static int getMinimumFlingVelocity() {
587 return MINIMUM_FLING_VELOCITY;
588 }
589
590 /**
591 * @return Minimum velocity to initiate a fling, as measured in pixels per second.
592 */
593 public int getScaledMinimumFlingVelocity() {
594 return mMinimumFlingVelocity;
595 }
596
597 /**
Romain Guy4296fc42009-07-06 11:48:52 -0700598 * @return Maximum velocity to initiate a fling, as measured in pixels per second.
599 *
600 * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead.
601 */
602 @Deprecated
603 public static int getMaximumFlingVelocity() {
604 return MAXIMUM_FLING_VELOCITY;
605 }
606
607 /**
608 * @return Maximum velocity to initiate a fling, as measured in pixels per second.
609 */
610 public int getScaledMaximumFlingVelocity() {
611 return mMaximumFlingVelocity;
612 }
613
614 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800615 * The maximum drawing cache size expressed in bytes.
616 *
617 * @return the maximum size of View's drawing cache expressed in bytes
618 *
619 * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
620 */
621 @Deprecated
622 public static int getMaximumDrawingCacheSize() {
623 //noinspection deprecation
624 return MAXIMUM_DRAWING_CACHE_SIZE;
625 }
626
627 /**
628 * The maximum drawing cache size expressed in bytes.
629 *
630 * @return the maximum size of View's drawing cache expressed in bytes
631 */
632 public int getScaledMaximumDrawingCacheSize() {
633 return mMaximumDrawingCacheSize;
634 }
635
636 /**
Adam Powell637d3372010-08-25 14:37:03 -0700637 * @return The maximum distance a View should overscroll by when showing edge effects.
638 */
639 public int getScaledOverscrollDistance() {
640 return mOverscrollDistance;
641 }
642
643 /**
644 * @return The maximum distance a View should overfling by when showing edge effects.
645 */
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.
653 *
654 * @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.
674 *
675 * @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}