blob: 5e104f9e373fab2c08f17cb7df3c2c0c1a081d14 [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 /**
142 * Distance a touch can wander before we think the user is scrolling in pixels
143 */
Dianne Hackborn3e2ac882009-09-25 01:34:28 -0700144 private static final int TOUCH_SLOP = 16;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800145
146 /**
Adam Powellde8d0832010-03-09 17:11:30 -0800147 * Distance a touch can wander before we think the user is attempting a paged scroll
148 * (in dips)
149 */
Adam Powellb7ef1d92010-03-11 10:25:24 -0800150 private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
Adam Powellde8d0832010-03-09 17:11:30 -0800151
152 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800153 * Distance between the first touch and second touch to still be considered a double tap
154 */
155 private static final int DOUBLE_TAP_SLOP = 100;
156
157 /**
158 * Distance a touch needs to be outside of a window's bounds for it to
159 * count as outside for purposes of dismissing the window.
160 */
161 private static final int WINDOW_TOUCH_SLOP = 16;
162
163 /**
164 * Minimum velocity to initiate a fling, as measured in pixels per second
165 */
166 private static final int MINIMUM_FLING_VELOCITY = 50;
Romain Guy4296fc42009-07-06 11:48:52 -0700167
168 /**
169 * Maximum velocity to initiate a fling, as measured in pixels per second
170 */
Adam Powell637d3372010-08-25 14:37:03 -0700171 private static final int MAXIMUM_FLING_VELOCITY = 8000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800172
173 /**
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700174 * Distance between a touch up event denoting the end of a touch exploration
175 * gesture and the touch up event of a subsequent tap for the latter tap to be
176 * considered as a tap i.e. to perform a click.
177 */
178 private static final int TOUCH_EXPLORATION_TAP_SLOP = 80;
179
180 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700181 * Delay before dispatching a recurring accessibility event in milliseconds.
182 * This delay guarantees that a recurring event will be send at most once
183 * during the {@link #SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS} time
184 * frame.
185 */
186 private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 400;
187
188 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800189 * The maximum size of View's drawing cache, expressed in bytes. This size
190 * should be at least equal to the size of the screen in ARGB888 format.
191 */
192 @Deprecated
Romain Guy0211a0a2011-02-14 16:34:59 -0800193 private static final int MAXIMUM_DRAWING_CACHE_SIZE = 480 * 800 * 4; // ARGB8888
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194
195 /**
196 * The coefficient of friction applied to flings/scrolls.
197 */
Romain Guy0211a0a2011-02-14 16:34:59 -0800198 private static final float SCROLL_FRICTION = 0.015f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800199
Adam Powell637d3372010-08-25 14:37:03 -0700200 /**
201 * Max distance to overscroll for edge effects
202 */
203 private static final int OVERSCROLL_DISTANCE = 0;
204
205 /**
206 * Max distance to overfling for edge effects
207 */
Gilles Debunne8ce7aab2011-01-25 11:23:30 -0800208 private static final int OVERFLING_DISTANCE = 6;
Adam Powell637d3372010-08-25 14:37:03 -0700209
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800210 private final int mEdgeSlop;
211 private final int mFadingEdgeLength;
212 private final int mMinimumFlingVelocity;
Romain Guy4296fc42009-07-06 11:48:52 -0700213 private final int mMaximumFlingVelocity;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800214 private final int mScrollbarSize;
215 private final int mTouchSlop;
Adam Powellde8d0832010-03-09 17:11:30 -0800216 private final int mPagingTouchSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800217 private final int mDoubleTapSlop;
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700218 private final int mScaledTouchExplorationTapSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800219 private final int mWindowTouchSlop;
220 private final int mMaximumDrawingCacheSize;
Adam Powell637d3372010-08-25 14:37:03 -0700221 private final int mOverscrollDistance;
222 private final int mOverflingDistance;
Romain Guy68055452011-08-02 16:33:02 -0700223 private final boolean mFadingMarqueeEnabled;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800224
Adam Powell8c470622011-06-30 18:19:51 -0700225 private boolean sHasPermanentMenuKey;
226 private boolean sHasPermanentMenuKeySet;
227
Xavier Ducrohet7f9f99ea2011-08-11 10:16:17 -0700228 static final SparseArray<ViewConfiguration> sConfigurations =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800229 new SparseArray<ViewConfiguration>(2);
230
231 /**
232 * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead.
233 */
234 @Deprecated
235 public ViewConfiguration() {
236 mEdgeSlop = EDGE_SLOP;
237 mFadingEdgeLength = FADING_EDGE_LENGTH;
238 mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY;
Romain Guy4296fc42009-07-06 11:48:52 -0700239 mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800240 mScrollbarSize = SCROLL_BAR_SIZE;
241 mTouchSlop = TOUCH_SLOP;
Adam Powellde8d0832010-03-09 17:11:30 -0800242 mPagingTouchSlop = PAGING_TOUCH_SLOP;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800243 mDoubleTapSlop = DOUBLE_TAP_SLOP;
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700244 mScaledTouchExplorationTapSlop = TOUCH_EXPLORATION_TAP_SLOP;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800245 mWindowTouchSlop = WINDOW_TOUCH_SLOP;
246 //noinspection deprecation
247 mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
Adam Powell637d3372010-08-25 14:37:03 -0700248 mOverscrollDistance = OVERSCROLL_DISTANCE;
249 mOverflingDistance = OVERFLING_DISTANCE;
Romain Guy68055452011-08-02 16:33:02 -0700250 mFadingMarqueeEnabled = true;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800251 }
252
253 /**
254 * Creates a new configuration for the specified context. The configuration depends on
255 * various parameters of the context, like the dimension of the display or the density
256 * of the display.
257 *
258 * @param context The application context used to initialize this view configuration.
259 *
260 * @see #get(android.content.Context)
261 * @see android.util.DisplayMetrics
262 */
263 private ViewConfiguration(Context context) {
Adam Powell8c470622011-06-30 18:19:51 -0700264 final Resources res = context.getResources();
265 final DisplayMetrics metrics = res.getDisplayMetrics();
266 final Configuration config = res.getConfiguration();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800267 final float density = metrics.density;
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800268 final float sizeAndDensity;
Adam Powell8c470622011-06-30 18:19:51 -0700269 if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800270 sizeAndDensity = density * 1.5f;
271 } else {
272 sizeAndDensity = density;
273 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800274
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800275 mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f);
276 mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800277 mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
Romain Guy4296fc42009-07-06 11:48:52 -0700278 mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800279 mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800280 mTouchSlop = (int) (sizeAndDensity * TOUCH_SLOP + 0.5f);
281 mPagingTouchSlop = (int) (sizeAndDensity * PAGING_TOUCH_SLOP + 0.5f);
282 mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700283 mScaledTouchExplorationTapSlop = (int) (density * TOUCH_EXPLORATION_TAP_SLOP + 0.5f);
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800284 mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800285
286 // Size of the screen in bytes, in ARGB_8888 format
287 mMaximumDrawingCacheSize = 4 * metrics.widthPixels * metrics.heightPixels;
Adam Powell637d3372010-08-25 14:37:03 -0700288
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800289 mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
290 mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
Adam Powell8c470622011-06-30 18:19:51 -0700291
292 if (!sHasPermanentMenuKeySet) {
293 IWindowManager wm = Display.getWindowManager();
294 try {
295 sHasPermanentMenuKey = wm.canStatusBarHide() && !res.getBoolean(
296 com.android.internal.R.bool.config_showNavigationBar);
297 sHasPermanentMenuKeySet = true;
298 } catch (RemoteException ex) {
299 sHasPermanentMenuKey = false;
300 }
301 }
Romain Guy68055452011-08-02 16:33:02 -0700302
303 mFadingMarqueeEnabled = res.getBoolean(
304 com.android.internal.R.bool.config_ui_enableFadingMarquee);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800305 }
306
307 /**
308 * Returns a configuration for the specified context. The configuration depends on
309 * various parameters of the context, like the dimension of the display or the
310 * density of the display.
311 *
312 * @param context The application context used to initialize the view configuration.
313 */
314 public static ViewConfiguration get(Context context) {
315 final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
316 final int density = (int) (100.0f * metrics.density);
317
318 ViewConfiguration configuration = sConfigurations.get(density);
319 if (configuration == null) {
320 configuration = new ViewConfiguration(context);
321 sConfigurations.put(density, configuration);
322 }
323
324 return configuration;
325 }
326
327 /**
328 * @return The width of the horizontal scrollbar and the height of the vertical
329 * scrollbar in pixels
330 *
331 * @deprecated Use {@link #getScaledScrollBarSize()} instead.
332 */
333 @Deprecated
334 public static int getScrollBarSize() {
335 return SCROLL_BAR_SIZE;
336 }
337
338 /**
339 * @return The width of the horizontal scrollbar and the height of the vertical
340 * scrollbar in pixels
341 */
342 public int getScaledScrollBarSize() {
343 return mScrollbarSize;
344 }
345
346 /**
Mike Cleronf116bf82009-09-27 19:14:12 -0700347 * @return Duration of the fade when scrollbars fade away in milliseconds
348 */
349 public static int getScrollBarFadeDuration() {
350 return SCROLL_BAR_FADE_DURATION;
351 }
352
353 /**
354 * @return Default delay before the scrollbars fade in milliseconds
355 */
356 public static int getScrollDefaultDelay() {
357 return SCROLL_BAR_DEFAULT_DELAY;
358 }
359
360 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800361 * @return the length of the fading edges in pixels
362 *
363 * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
364 */
365 @Deprecated
366 public static int getFadingEdgeLength() {
367 return FADING_EDGE_LENGTH;
368 }
369
370 /**
371 * @return the length of the fading edges in pixels
372 */
373 public int getScaledFadingEdgeLength() {
374 return mFadingEdgeLength;
375 }
376
377 /**
378 * @return the duration in milliseconds of the pressed state in child
379 * components.
380 */
381 public static int getPressedStateDuration() {
382 return PRESSED_STATE_DURATION;
383 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800384
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800385 /**
386 * @return the duration in milliseconds before a press turns into
387 * a long press
388 */
389 public static int getLongPressTimeout() {
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800390 return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT,
Jeff Browna4547672011-03-02 21:38:11 -0800391 DEFAULT_LONG_PRESS_TIMEOUT);
392 }
393
394 /**
395 * @return the time before the first key repeat in milliseconds.
396 */
397 public static int getKeyRepeatTimeout() {
398 return getLongPressTimeout();
399 }
400
401 /**
402 * @return the time between successive key repeats in milliseconds.
403 */
404 public static int getKeyRepeatDelay() {
405 return KEY_REPEAT_DELAY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800406 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800407
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800408 /**
409 * @return the duration in milliseconds we will wait to see if a touch event
410 * is a tap or a scroll. If the user does not move within this interval, it is
411 * considered to be a tap.
412 */
413 public static int getTapTimeout() {
414 return TAP_TIMEOUT;
415 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700416
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800417 /**
418 * @return the duration in milliseconds we will wait to see if a touch event
419 * is a jump tap. If the user does not move within this interval, it is
420 * considered to be a tap.
421 */
422 public static int getJumpTapTimeout() {
423 return JUMP_TAP_TIMEOUT;
424 }
425
426 /**
427 * @return the duration in milliseconds between the first tap's up event and
428 * the second tap's down event for an interaction to be considered a
429 * double-tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800430 */
431 public static int getDoubleTapTimeout() {
432 return DOUBLE_TAP_TIMEOUT;
433 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700434
435 /**
436 * @return the maximum duration in milliseconds between a touch pad
437 * touch and release for a given touch to be considered a tap (click) as
438 * opposed to a hover movement gesture.
439 * @hide
440 */
441 public static int getHoverTapTimeout() {
442 return HOVER_TAP_TIMEOUT;
443 }
444
445 /**
446 * @return the maximum distance in pixels that a touch pad touch can move
447 * before being released for it to be considered a tap (click) as opposed
448 * to a hover movement gesture.
449 * @hide
450 */
451 public static int getHoverTapSlop() {
452 return HOVER_TAP_SLOP;
453 }
454
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455 /**
456 * @return Inset in pixels to look for touchable content when the user touches the edge of the
457 * screen
458 *
459 * @deprecated Use {@link #getScaledEdgeSlop()} instead.
460 */
461 @Deprecated
462 public static int getEdgeSlop() {
463 return EDGE_SLOP;
464 }
465
466 /**
467 * @return Inset in pixels to look for touchable content when the user touches the edge of the
468 * screen
469 */
470 public int getScaledEdgeSlop() {
471 return mEdgeSlop;
472 }
473
474 /**
475 * @return Distance a touch can wander before we think the user is scrolling in pixels
476 *
477 * @deprecated Use {@link #getScaledTouchSlop()} instead.
478 */
479 @Deprecated
480 public static int getTouchSlop() {
481 return TOUCH_SLOP;
482 }
483
484 /**
485 * @return Distance a touch can wander before we think the user is scrolling in pixels
486 */
487 public int getScaledTouchSlop() {
488 return mTouchSlop;
489 }
Adam Powellde8d0832010-03-09 17:11:30 -0800490
491 /**
492 * @return Distance a touch can wander before we think the user is scrolling a full page
493 * in dips
494 */
495 public int getScaledPagingTouchSlop() {
496 return mPagingTouchSlop;
497 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800498
499 /**
500 * @return Distance between the first touch and second touch to still be
501 * considered a double tap
502 * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
503 * @hide The only client of this should be GestureDetector, which needs this
504 * for clients that still use its deprecated constructor.
505 */
506 @Deprecated
507 public static int getDoubleTapSlop() {
508 return DOUBLE_TAP_SLOP;
509 }
510
511 /**
512 * @return Distance between the first touch and second touch to still be
513 * considered a double tap
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800514 */
515 public int getScaledDoubleTapSlop() {
516 return mDoubleTapSlop;
517 }
518
519 /**
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700520 * @return Distance between a touch up event denoting the end of a touch exploration
521 * gesture and the touch up event of a subsequent tap for the latter tap to be
522 * considered as a tap i.e. to perform a click.
523 *
524 * @hide
525 */
526 public int getScaledTouchExplorationTapSlop() {
527 return mScaledTouchExplorationTapSlop;
528 }
529
530 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700531 * Interval for dispatching a recurring accessibility event in milliseconds.
532 * This interval guarantees that a recurring event will be send at most once
533 * during the {@link #getSendRecurringAccessibilityEventsInterval()} time frame.
534 *
535 * @return The delay in milliseconds.
536 *
537 * @hide
538 */
539 public static long getSendRecurringAccessibilityEventsInterval() {
540 return SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS;
541 }
542
543 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 * @return Distance a touch must be outside the bounds of a window for it
545 * to be counted as outside the window for purposes of dismissing that
546 * window.
547 *
548 * @deprecated Use {@link #getScaledWindowTouchSlop()} instead.
549 */
550 @Deprecated
551 public static int getWindowTouchSlop() {
552 return WINDOW_TOUCH_SLOP;
553 }
554
555 /**
556 * @return Distance a touch must be outside the bounds of a window for it
557 * to be counted as outside the window for purposes of dismissing that
558 * window.
559 */
560 public int getScaledWindowTouchSlop() {
561 return mWindowTouchSlop;
562 }
563
564 /**
565 * @return Minimum velocity to initiate a fling, as measured in pixels per second.
566 *
567 * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
568 */
569 @Deprecated
570 public static int getMinimumFlingVelocity() {
571 return MINIMUM_FLING_VELOCITY;
572 }
573
574 /**
575 * @return Minimum velocity to initiate a fling, as measured in pixels per second.
576 */
577 public int getScaledMinimumFlingVelocity() {
578 return mMinimumFlingVelocity;
579 }
580
581 /**
Romain Guy4296fc42009-07-06 11:48:52 -0700582 * @return Maximum velocity to initiate a fling, as measured in pixels per second.
583 *
584 * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead.
585 */
586 @Deprecated
587 public static int getMaximumFlingVelocity() {
588 return MAXIMUM_FLING_VELOCITY;
589 }
590
591 /**
592 * @return Maximum velocity to initiate a fling, as measured in pixels per second.
593 */
594 public int getScaledMaximumFlingVelocity() {
595 return mMaximumFlingVelocity;
596 }
597
598 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800599 * The maximum drawing cache size expressed in bytes.
600 *
601 * @return the maximum size of View's drawing cache expressed in bytes
602 *
603 * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
604 */
605 @Deprecated
606 public static int getMaximumDrawingCacheSize() {
607 //noinspection deprecation
608 return MAXIMUM_DRAWING_CACHE_SIZE;
609 }
610
611 /**
612 * The maximum drawing cache size expressed in bytes.
613 *
614 * @return the maximum size of View's drawing cache expressed in bytes
615 */
616 public int getScaledMaximumDrawingCacheSize() {
617 return mMaximumDrawingCacheSize;
618 }
619
620 /**
Adam Powell637d3372010-08-25 14:37:03 -0700621 * @return The maximum distance a View should overscroll by when showing edge effects.
622 */
623 public int getScaledOverscrollDistance() {
624 return mOverscrollDistance;
625 }
626
627 /**
628 * @return The maximum distance a View should overfling by when showing edge effects.
629 */
630 public int getScaledOverflingDistance() {
631 return mOverflingDistance;
632 }
633
634 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800635 * The amount of time that the zoom controls should be
636 * displayed on the screen expressed in milliseconds.
637 *
638 * @return the time the zoom controls should be visible expressed
639 * in milliseconds.
640 */
641 public static long getZoomControlsTimeout() {
642 return ZOOM_CONTROLS_TIMEOUT;
643 }
644
645 /**
646 * The amount of time a user needs to press the relevant key to bring up
647 * the global actions dialog.
648 *
649 * @return how long a user needs to press the relevant key to bring up
650 * the global actions dialog.
651 */
652 public static long getGlobalActionKeyTimeout() {
653 return GLOBAL_ACTIONS_KEY_TIMEOUT;
654 }
655
656 /**
657 * The amount of friction applied to scrolls and flings.
658 *
659 * @return A scalar dimensionless value representing the coefficient of
660 * friction.
661 */
662 public static float getScrollFriction() {
663 return SCROLL_FRICTION;
664 }
Adam Powell8c470622011-06-30 18:19:51 -0700665
666 /**
667 * Report if the device has a permanent menu key available to the user.
668 *
669 * <p>As of Android 3.0, devices may not have a permanent menu key available.
670 * Apps should use the action bar to present menu options to users.
671 * However, there are some apps where the action bar is inappropriate
672 * or undesirable. This method may be used to detect if a menu key is present.
673 * If not, applications should provide another on-screen affordance to access
674 * functionality.
675 *
676 * @return true if a permanent menu key is present, false otherwise.
677 */
678 public boolean hasPermanentMenuKey() {
679 return sHasPermanentMenuKey;
680 }
Romain Guy68055452011-08-02 16:33:02 -0700681
682 /**
683 * @hide
684 * @return Whether or not marquee should use fading edges.
685 */
686 public boolean isFadingMarqueeEnabled() {
687 return mFadingMarqueeEnabled;
688 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800689}