blob: 3082976ec7ea301807001c05765d8624e461be10 [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 /**
100 * Defines the maximum duration in milliseconds between a touch pad
101 * touch and release for a given touch to be considered a tap (click) as
102 * opposed to a hover movement gesture.
103 */
104 private static final int HOVER_TAP_TIMEOUT = 150;
105
106 /**
107 * Defines the maximum distance in pixels that a touch pad touch can move
108 * before being released for it to be considered a tap (click) as opposed
109 * to a hover movement gesture.
110 */
111 private static final int HOVER_TAP_SLOP = 20;
112
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800113 /**
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700114 * Defines the duration in milliseconds we want to display zoom controls in response
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115 * to a user panning within an application.
116 */
117 private static final int ZOOM_CONTROLS_TIMEOUT = 3000;
118
119 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700120 * 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 -0800121 */
122 private static final int EDGE_SLOP = 12;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700123
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800124 /**
Adam Powell7d39f852011-12-05 19:26:54 -0800125 * Distance a touch can wander before we think the user is scrolling in dips.
126 * Note that this value defined here is only used as a fallback by legacy/misbehaving
127 * applications that do not provide a Context for determining density/configuration-dependent
128 * values.
129 *
130 * To alter this value, see the configuration resource config_viewConfigurationTouchSlop
131 * in frameworks/base/core/res/res/values/config.xml or the appropriate device resource overlay.
132 * It may be appropriate to tweak this on a device-specific basis in an overlay based on
133 * the characteristics of the touch panel and firmware.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 */
Adam Powell6720a872011-12-07 17:35:32 -0800135 private static final int TOUCH_SLOP = 8;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700136
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800137 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700138 * Distance the first touch can wander before we stop considering this event a double tap
139 * (in dips)
140 */
141 private static final int DOUBLE_TAP_TOUCH_SLOP = TOUCH_SLOP;
142
143 /**
Adam Powellde8d0832010-03-09 17:11:30 -0800144 * Distance a touch can wander before we think the user is attempting a paged scroll
145 * (in dips)
Adam Powell7d39f852011-12-05 19:26:54 -0800146 *
147 * Note that this value defined here is only used as a fallback by legacy/misbehaving
148 * applications that do not provide a Context for determining density/configuration-dependent
149 * values.
150 *
151 * See the note above on {@link #TOUCH_SLOP} regarding the dimen resource
152 * config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of
153 * config_viewConfigurationTouchSlop * 2 when provided with a Context.
Adam Powellde8d0832010-03-09 17:11:30 -0800154 */
Adam Powellb7ef1d92010-03-11 10:25:24 -0800155 private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700156
Adam Powellde8d0832010-03-09 17:11:30 -0800157 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700158 * 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 -0800159 */
160 private static final int DOUBLE_TAP_SLOP = 100;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700161
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800162 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700163 * 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 -0800164 * count as outside for purposes of dismissing the window.
165 */
166 private static final int WINDOW_TOUCH_SLOP = 16;
167
168 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700169 * Minimum velocity to initiate a fling, as measured in dips per second
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800170 */
171 private static final int MINIMUM_FLING_VELOCITY = 50;
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700172
Romain Guy4296fc42009-07-06 11:48:52 -0700173 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700174 * Maximum velocity to initiate a fling, as measured in dips per second
Romain Guy4296fc42009-07-06 11:48:52 -0700175 */
Adam Powell637d3372010-08-25 14:37:03 -0700176 private static final int MAXIMUM_FLING_VELOCITY = 8000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800177
178 /**
Svetoslav Ganova0156172011-06-26 17:55:44 -0700179 * Delay before dispatching a recurring accessibility event in milliseconds.
180 * This delay guarantees that a recurring event will be send at most once
181 * during the {@link #SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS} time
182 * frame.
183 */
Svetoslav Ganove15ccb92012-05-16 15:48:55 -0700184 private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 100;
Svetoslav Ganova0156172011-06-26 17:55:44 -0700185
186 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 * The maximum size of View's drawing cache, expressed in bytes. This size
188 * should be at least equal to the size of the screen in ARGB888 format.
189 */
190 @Deprecated
Romain Guy0211a0a2011-02-14 16:34:59 -0800191 private static final int MAXIMUM_DRAWING_CACHE_SIZE = 480 * 800 * 4; // ARGB8888
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800192
193 /**
194 * The coefficient of friction applied to flings/scrolls.
195 */
Romain Guy0211a0a2011-02-14 16:34:59 -0800196 private static final float SCROLL_FRICTION = 0.015f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800197
Adam Powell637d3372010-08-25 14:37:03 -0700198 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700199 * Max distance in dips to overscroll for edge effects
Adam Powell637d3372010-08-25 14:37:03 -0700200 */
201 private static final int OVERSCROLL_DISTANCE = 0;
202
203 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700204 * Max distance in dips to overfling for edge effects
Adam Powell637d3372010-08-25 14:37:03 -0700205 */
Gilles Debunne8ce7aab2011-01-25 11:23:30 -0800206 private static final int OVERFLING_DISTANCE = 6;
Adam Powell637d3372010-08-25 14:37:03 -0700207
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800208 private final int mEdgeSlop;
209 private final int mFadingEdgeLength;
210 private final int mMinimumFlingVelocity;
Romain Guy4296fc42009-07-06 11:48:52 -0700211 private final int mMaximumFlingVelocity;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800212 private final int mScrollbarSize;
213 private final int mTouchSlop;
Gilles Debunne006fa482011-10-27 17:23:36 -0700214 private final int mDoubleTapTouchSlop;
Adam Powellde8d0832010-03-09 17:11:30 -0800215 private final int mPagingTouchSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800216 private final int mDoubleTapSlop;
217 private final int mWindowTouchSlop;
218 private final int mMaximumDrawingCacheSize;
Adam Powell637d3372010-08-25 14:37:03 -0700219 private final int mOverscrollDistance;
220 private final int mOverflingDistance;
Romain Guy68055452011-08-02 16:33:02 -0700221 private final boolean mFadingMarqueeEnabled;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222
Adam Powell8c470622011-06-30 18:19:51 -0700223 private boolean sHasPermanentMenuKey;
224 private boolean sHasPermanentMenuKeySet;
225
Xavier Ducrohet7f9f99ea2011-08-11 10:16:17 -0700226 static final SparseArray<ViewConfiguration> sConfigurations =
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800227 new SparseArray<ViewConfiguration>(2);
228
229 /**
230 * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead.
231 */
232 @Deprecated
233 public ViewConfiguration() {
234 mEdgeSlop = EDGE_SLOP;
235 mFadingEdgeLength = FADING_EDGE_LENGTH;
236 mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY;
Romain Guy4296fc42009-07-06 11:48:52 -0700237 mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800238 mScrollbarSize = SCROLL_BAR_SIZE;
239 mTouchSlop = TOUCH_SLOP;
Gilles Debunne006fa482011-10-27 17:23:36 -0700240 mDoubleTapTouchSlop = DOUBLE_TAP_TOUCH_SLOP;
Adam Powellde8d0832010-03-09 17:11:30 -0800241 mPagingTouchSlop = PAGING_TOUCH_SLOP;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800242 mDoubleTapSlop = DOUBLE_TAP_SLOP;
243 mWindowTouchSlop = WINDOW_TOUCH_SLOP;
244 //noinspection deprecation
245 mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
Adam Powell637d3372010-08-25 14:37:03 -0700246 mOverscrollDistance = OVERSCROLL_DISTANCE;
247 mOverflingDistance = OVERFLING_DISTANCE;
Romain Guy68055452011-08-02 16:33:02 -0700248 mFadingMarqueeEnabled = true;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249 }
250
251 /**
252 * Creates a new configuration for the specified context. The configuration depends on
253 * various parameters of the context, like the dimension of the display or the density
254 * of the display.
255 *
256 * @param context The application context used to initialize this view configuration.
257 *
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700258 * @see #get(android.content.Context)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 * @see android.util.DisplayMetrics
260 */
261 private ViewConfiguration(Context context) {
Adam Powell8c470622011-06-30 18:19:51 -0700262 final Resources res = context.getResources();
263 final DisplayMetrics metrics = res.getDisplayMetrics();
264 final Configuration config = res.getConfiguration();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265 final float density = metrics.density;
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800266 final float sizeAndDensity;
Adam Powell8c470622011-06-30 18:19:51 -0700267 if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800268 sizeAndDensity = density * 1.5f;
269 } else {
270 sizeAndDensity = density;
271 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800272
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800273 mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f);
274 mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800275 mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f);
Romain Guy4296fc42009-07-06 11:48:52 -0700276 mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800277 mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f);
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800278 mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
279 mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280
281 // Size of the screen in bytes, in ARGB_8888 format
Jeff Browna8b9def2012-07-23 14:22:49 -0700282 final Display display = WindowManagerImpl.getDefault().getDefaultDisplay();
283 final Point size = new Point();
284 display.getRealSize(size);
285 mMaximumDrawingCacheSize = 4 * size.x * size.y;
Adam Powell637d3372010-08-25 14:37:03 -0700286
Dianne Hackbornff801ec2011-01-22 18:05:38 -0800287 mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
288 mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
Adam Powell8c470622011-06-30 18:19:51 -0700289
290 if (!sHasPermanentMenuKeySet) {
Jeff Browna8b9def2012-07-23 14:22:49 -0700291 IWindowManager wm = WindowManagerImpl.getWindowManagerService();
Adam Powell8c470622011-06-30 18:19:51 -0700292 try {
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700293 sHasPermanentMenuKey = !wm.hasSystemNavBar() && !wm.hasNavigationBar();
Adam Powell8c470622011-06-30 18:19:51 -0700294 sHasPermanentMenuKeySet = true;
295 } catch (RemoteException ex) {
296 sHasPermanentMenuKey = false;
297 }
298 }
Romain Guy68055452011-08-02 16:33:02 -0700299
300 mFadingMarqueeEnabled = res.getBoolean(
301 com.android.internal.R.bool.config_ui_enableFadingMarquee);
Adam Powell7d39f852011-12-05 19:26:54 -0800302 mTouchSlop = res.getDimensionPixelSize(
303 com.android.internal.R.dimen.config_viewConfigurationTouchSlop);
304 mPagingTouchSlop = mTouchSlop * 2;
Adam Powelle4b8ff82011-12-06 16:40:49 -0800305
306 mDoubleTapTouchSlop = mTouchSlop;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800307 }
308
309 /**
310 * Returns a configuration for the specified context. The configuration depends on
311 * various parameters of the context, like the dimension of the display or the
312 * density of the display.
313 *
314 * @param context The application context used to initialize the view configuration.
315 */
316 public static ViewConfiguration get(Context context) {
317 final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
318 final int density = (int) (100.0f * metrics.density);
319
320 ViewConfiguration configuration = sConfigurations.get(density);
321 if (configuration == null) {
322 configuration = new ViewConfiguration(context);
323 sConfigurations.put(density, configuration);
324 }
325
326 return configuration;
327 }
328
329 /**
330 * @return The width of the horizontal scrollbar and the height of the vertical
Gilles Debunne006fa482011-10-27 17:23:36 -0700331 * scrollbar in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800332 *
333 * @deprecated Use {@link #getScaledScrollBarSize()} instead.
334 */
335 @Deprecated
336 public static int getScrollBarSize() {
337 return SCROLL_BAR_SIZE;
338 }
339
340 /**
341 * @return The width of the horizontal scrollbar and the height of the vertical
342 * scrollbar in pixels
343 */
344 public int getScaledScrollBarSize() {
345 return mScrollbarSize;
346 }
347
348 /**
Mike Cleronf116bf82009-09-27 19:14:12 -0700349 * @return Duration of the fade when scrollbars fade away in milliseconds
350 */
351 public static int getScrollBarFadeDuration() {
352 return SCROLL_BAR_FADE_DURATION;
353 }
354
355 /**
356 * @return Default delay before the scrollbars fade in milliseconds
357 */
358 public static int getScrollDefaultDelay() {
359 return SCROLL_BAR_DEFAULT_DELAY;
360 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700361
Mike Cleronf116bf82009-09-27 19:14:12 -0700362 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700363 * @return the length of the fading edges in dips
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800364 *
365 * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
366 */
367 @Deprecated
368 public static int getFadingEdgeLength() {
369 return FADING_EDGE_LENGTH;
370 }
371
372 /**
373 * @return the length of the fading edges in pixels
374 */
375 public int getScaledFadingEdgeLength() {
376 return mFadingEdgeLength;
377 }
378
379 /**
380 * @return the duration in milliseconds of the pressed state in child
381 * components.
382 */
383 public static int getPressedStateDuration() {
384 return PRESSED_STATE_DURATION;
385 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800386
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800387 /**
388 * @return the duration in milliseconds before a press turns into
389 * a long press
390 */
391 public static int getLongPressTimeout() {
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800392 return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT,
Jeff Browna4547672011-03-02 21:38:11 -0800393 DEFAULT_LONG_PRESS_TIMEOUT);
394 }
395
396 /**
397 * @return the time before the first key repeat in milliseconds.
398 */
399 public static int getKeyRepeatTimeout() {
400 return getLongPressTimeout();
401 }
402
403 /**
404 * @return the time between successive key repeats in milliseconds.
405 */
406 public static int getKeyRepeatDelay() {
407 return KEY_REPEAT_DELAY;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800408 }
Svetoslav Ganov54d068e2011-03-02 12:58:40 -0800409
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800410 /**
411 * @return the duration in milliseconds we will wait to see if a touch event
412 * is a tap or a scroll. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700413 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800414 */
415 public static int getTapTimeout() {
416 return TAP_TIMEOUT;
417 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700418
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800419 /**
420 * @return the duration in milliseconds we will wait to see if a touch event
421 * is a jump tap. If the user does not move within this interval, it is
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700422 * considered to be a tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800423 */
424 public static int getJumpTapTimeout() {
425 return JUMP_TAP_TIMEOUT;
426 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700427
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800428 /**
429 * @return the duration in milliseconds between the first tap's up event and
430 * the second tap's down event for an interaction to be considered a
431 * double-tap.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800432 */
433 public static int getDoubleTapTimeout() {
434 return DOUBLE_TAP_TIMEOUT;
435 }
Jeff Brownbb3fcba0c2011-06-06 19:23:05 -0700436
437 /**
438 * @return the maximum duration in milliseconds between a touch pad
439 * touch and release for a given touch to be considered a tap (click) as
440 * opposed to a hover movement gesture.
441 * @hide
442 */
443 public static int getHoverTapTimeout() {
444 return HOVER_TAP_TIMEOUT;
445 }
446
447 /**
448 * @return the maximum distance in pixels that a touch pad touch can move
449 * before being released for it to be considered a tap (click) as opposed
450 * to a hover movement gesture.
451 * @hide
452 */
453 public static int getHoverTapSlop() {
454 return HOVER_TAP_SLOP;
455 }
456
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800457 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700458 * @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 -0800459 * screen
460 *
461 * @deprecated Use {@link #getScaledEdgeSlop()} instead.
462 */
463 @Deprecated
464 public static int getEdgeSlop() {
465 return EDGE_SLOP;
466 }
467
468 /**
469 * @return Inset in pixels to look for touchable content when the user touches the edge of the
470 * screen
471 */
472 public int getScaledEdgeSlop() {
473 return mEdgeSlop;
474 }
475
476 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700477 * @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 -0800478 *
479 * @deprecated Use {@link #getScaledTouchSlop()} instead.
480 */
481 @Deprecated
482 public static int getTouchSlop() {
483 return TOUCH_SLOP;
484 }
485
486 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700487 * @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 -0800488 */
489 public int getScaledTouchSlop() {
490 return mTouchSlop;
491 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700492
Adam Powellde8d0832010-03-09 17:11:30 -0800493 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700494 * @return Distance in pixels the first touch can wander before we do not consider this a
495 * potential double tap event
496 * @hide
497 */
498 public int getScaledDoubleTapTouchSlop() {
499 return mDoubleTapTouchSlop;
500 }
501
502 /**
503 * @return Distance in pixels a touch can wander before we think the user is scrolling a full
504 * page
Adam Powellde8d0832010-03-09 17:11:30 -0800505 */
506 public int getScaledPagingTouchSlop() {
507 return mPagingTouchSlop;
508 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800509
510 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700511 * @return Distance in dips between the first touch and second touch to still be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800512 * considered a double tap
513 * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
514 * @hide The only client of this should be GestureDetector, which needs this
515 * for clients that still use its deprecated constructor.
516 */
517 @Deprecated
518 public static int getDoubleTapSlop() {
519 return DOUBLE_TAP_SLOP;
520 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700521
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800522 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700523 * @return Distance in pixels between the first touch and second touch to still be
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800524 * considered a double tap
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800525 */
526 public int getScaledDoubleTapSlop() {
527 return mDoubleTapSlop;
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 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700544 * @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 -0800545 * 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 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700556 * @return Distance in pixels 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 window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800558 */
559 public int getScaledWindowTouchSlop() {
560 return mWindowTouchSlop;
561 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700562
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800563 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700564 * @return Minimum velocity to initiate a fling, as measured in dips per second.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800565 *
566 * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
567 */
568 @Deprecated
569 public static int getMinimumFlingVelocity() {
570 return MINIMUM_FLING_VELOCITY;
571 }
572
573 /**
574 * @return Minimum velocity to initiate a fling, as measured in pixels per second.
575 */
576 public int getScaledMinimumFlingVelocity() {
577 return mMinimumFlingVelocity;
578 }
579
580 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700581 * @return Maximum velocity to initiate a fling, as measured in dips per second.
Romain Guy4296fc42009-07-06 11:48:52 -0700582 *
583 * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead.
584 */
585 @Deprecated
586 public static int getMaximumFlingVelocity() {
587 return MAXIMUM_FLING_VELOCITY;
588 }
589
590 /**
591 * @return Maximum velocity to initiate a fling, as measured in pixels per second.
592 */
593 public int getScaledMaximumFlingVelocity() {
594 return mMaximumFlingVelocity;
595 }
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700596
Romain Guy4296fc42009-07-06 11:48:52 -0700597 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800598 * The maximum drawing cache size expressed in bytes.
599 *
600 * @return the maximum size of View's drawing cache expressed in bytes
601 *
602 * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
603 */
604 @Deprecated
605 public static int getMaximumDrawingCacheSize() {
606 //noinspection deprecation
607 return MAXIMUM_DRAWING_CACHE_SIZE;
608 }
609
610 /**
611 * The maximum drawing cache size expressed in bytes.
612 *
613 * @return the maximum size of View's drawing cache expressed in bytes
614 */
615 public int getScaledMaximumDrawingCacheSize() {
616 return mMaximumDrawingCacheSize;
617 }
618
619 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700620 * @return The maximum distance a View should overscroll by when showing edge effects (in
621 * pixels).
Adam Powell637d3372010-08-25 14:37:03 -0700622 */
623 public int getScaledOverscrollDistance() {
624 return mOverscrollDistance;
625 }
626
627 /**
Gilles Debunne006fa482011-10-27 17:23:36 -0700628 * @return The maximum distance a View should overfling by when showing edge effects (in
629 * pixels).
Adam Powell637d3372010-08-25 14:37:03 -0700630 */
631 public int getScaledOverflingDistance() {
632 return mOverflingDistance;
633 }
634
635 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800636 * The amount of time that the zoom controls should be
637 * displayed on the screen expressed in milliseconds.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700638 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800639 * @return the time the zoom controls should be visible expressed
640 * in milliseconds.
641 */
642 public static long getZoomControlsTimeout() {
643 return ZOOM_CONTROLS_TIMEOUT;
644 }
645
646 /**
647 * The amount of time a user needs to press the relevant key to bring up
648 * the global actions dialog.
649 *
650 * @return how long a user needs to press the relevant key to bring up
651 * the global actions dialog.
652 */
653 public static long getGlobalActionKeyTimeout() {
654 return GLOBAL_ACTIONS_KEY_TIMEOUT;
655 }
656
657 /**
658 * The amount of friction applied to scrolls and flings.
Daisuke Miyakawac19895f2012-04-03 12:25:26 -0700659 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800660 * @return A scalar dimensionless value representing the coefficient of
661 * friction.
662 */
663 public static float getScrollFriction() {
664 return SCROLL_FRICTION;
665 }
Adam Powell8c470622011-06-30 18:19:51 -0700666
667 /**
668 * Report if the device has a permanent menu key available to the user.
669 *
670 * <p>As of Android 3.0, devices may not have a permanent menu key available.
671 * Apps should use the action bar to present menu options to users.
672 * However, there are some apps where the action bar is inappropriate
673 * or undesirable. This method may be used to detect if a menu key is present.
674 * If not, applications should provide another on-screen affordance to access
675 * functionality.
676 *
677 * @return true if a permanent menu key is present, false otherwise.
678 */
679 public boolean hasPermanentMenuKey() {
680 return sHasPermanentMenuKey;
681 }
Romain Guy68055452011-08-02 16:33:02 -0700682
683 /**
684 * @hide
685 * @return Whether or not marquee should use fading edges.
686 */
687 public boolean isFadingMarqueeEnabled() {
688 return mFadingMarqueeEnabled;
689 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800690}