• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package android.view;
18 
19 import android.annotation.TestApi;
20 import android.app.AppGlobals;
21 import android.content.Context;
22 import android.content.res.Configuration;
23 import android.content.res.Resources;
24 import android.graphics.Point;
25 import android.os.RemoteException;
26 import android.provider.Settings;
27 import android.util.DisplayMetrics;
28 import android.util.SparseArray;
29 
30 /**
31  * Contains methods to standard constants used in the UI for timeouts, sizes, and distances.
32  */
33 public class ViewConfiguration {
34     /**
35      * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in
36      * dips
37      */
38     private static final int SCROLL_BAR_SIZE = 4;
39 
40     /**
41      * Duration of the fade when scrollbars fade away in milliseconds
42      */
43     private static final int SCROLL_BAR_FADE_DURATION = 250;
44 
45     /**
46      * Default delay before the scrollbars fade in milliseconds
47      */
48     private static final int SCROLL_BAR_DEFAULT_DELAY = 300;
49 
50     /**
51      * Defines the length of the fading edges in dips
52      */
53     private static final int FADING_EDGE_LENGTH = 12;
54 
55     /**
56      * Defines the duration in milliseconds of the pressed state in child
57      * components.
58      */
59     private static final int PRESSED_STATE_DURATION = 64;
60 
61     /**
62      * Defines the default duration in milliseconds before a press turns into
63      * a long press
64      */
65     private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500;
66 
67     /**
68      * Defines the default duration in milliseconds between the first tap's up event and the second
69      * tap's down event for an interaction to be considered part of the same multi-press.
70      */
71     private static final int DEFAULT_MULTI_PRESS_TIMEOUT = 300;
72 
73     /**
74      * Defines the time between successive key repeats in milliseconds.
75      */
76     private static final int KEY_REPEAT_DELAY = 50;
77 
78     /**
79      * Defines the duration in milliseconds a user needs to hold down the
80      * appropriate button to bring up the global actions dialog (power off,
81      * lock screen, etc).
82      */
83     private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500;
84 
85     /**
86      * Defines the duration in milliseconds a user needs to hold down the
87      * appropriate button to bring up the accessibility shortcut (first time) or enable it
88      * (once shortcut is configured).
89      */
90     private static final int A11Y_SHORTCUT_KEY_TIMEOUT = 3000;
91 
92     /**
93      * Defines the duration in milliseconds we will wait to see if a touch event
94      * is a tap or a scroll. If the user does not move within this interval, it is
95      * considered to be a tap.
96      */
97     private static final int TAP_TIMEOUT = 100;
98 
99     /**
100      * Defines the duration in milliseconds we will wait to see if a touch event
101      * is a jump tap. If the user does not complete the jump tap within this interval, it is
102      * considered to be a tap.
103      */
104     private static final int JUMP_TAP_TIMEOUT = 500;
105 
106     /**
107      * Defines the duration in milliseconds between the first tap's up event and
108      * the second tap's down event for an interaction to be considered a
109      * double-tap.
110      */
111     private static final int DOUBLE_TAP_TIMEOUT = 300;
112 
113     /**
114      * Defines the minimum duration in milliseconds between the first tap's up event and
115      * the second tap's down event for an interaction to be considered a
116      * double-tap.
117      */
118     private static final int DOUBLE_TAP_MIN_TIME = 40;
119 
120     /**
121      * Defines the maximum duration in milliseconds between a touch pad
122      * touch and release for a given touch to be considered a tap (click) as
123      * opposed to a hover movement gesture.
124      */
125     private static final int HOVER_TAP_TIMEOUT = 150;
126 
127     /**
128      * Defines the maximum distance in pixels that a touch pad touch can move
129      * before being released for it to be considered a tap (click) as opposed
130      * to a hover movement gesture.
131      */
132     private static final int HOVER_TAP_SLOP = 20;
133 
134     /**
135      * Defines the duration in milliseconds we want to display zoom controls in response
136      * to a user panning within an application.
137      */
138     private static final int ZOOM_CONTROLS_TIMEOUT = 3000;
139 
140     /**
141      * Inset in dips to look for touchable content when the user touches the edge of the screen
142      */
143     private static final int EDGE_SLOP = 12;
144 
145     /**
146      * Distance a touch can wander before we think the user is scrolling in dips.
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      * To alter this value, see the configuration resource config_viewConfigurationTouchSlop
152      * in frameworks/base/core/res/res/values/config.xml or the appropriate device resource overlay.
153      * It may be appropriate to tweak this on a device-specific basis in an overlay based on
154      * the characteristics of the touch panel and firmware.
155      */
156     private static final int TOUCH_SLOP = 8;
157 
158     /**
159      * Defines the minimum size of the touch target for a scrollbar in dips
160      */
161     private static final int MIN_SCROLLBAR_TOUCH_TARGET = 48;
162 
163     /**
164      * Distance the first touch can wander before we stop considering this event a double tap
165      * (in dips)
166      */
167     private static final int DOUBLE_TAP_TOUCH_SLOP = TOUCH_SLOP;
168 
169     /**
170      * Distance a touch can wander before we think the user is attempting a paged scroll
171      * (in dips)
172      *
173      * Note that this value defined here is only used as a fallback by legacy/misbehaving
174      * applications that do not provide a Context for determining density/configuration-dependent
175      * values.
176      *
177      * See the note above on {@link #TOUCH_SLOP} regarding the dimen resource
178      * config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of
179      * config_viewConfigurationTouchSlop * 2 when provided with a Context.
180      */
181     private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2;
182 
183     /**
184      * Distance in dips between the first touch and second touch to still be considered a double tap
185      */
186     private static final int DOUBLE_TAP_SLOP = 100;
187 
188     /**
189      * Distance in dips a touch needs to be outside of a window's bounds for it to
190      * count as outside for purposes of dismissing the window.
191      */
192     private static final int WINDOW_TOUCH_SLOP = 16;
193 
194     /**
195      * Minimum velocity to initiate a fling, as measured in dips per second
196      */
197     private static final int MINIMUM_FLING_VELOCITY = 50;
198 
199     /**
200      * Maximum velocity to initiate a fling, as measured in dips per second
201      */
202     private static final int MAXIMUM_FLING_VELOCITY = 8000;
203 
204     /**
205      * Delay before dispatching a recurring accessibility event in milliseconds.
206      * This delay guarantees that a recurring event will be send at most once
207      * during the {@link #SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS} time
208      * frame.
209      */
210     private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 100;
211 
212     /**
213      * The maximum size of View's drawing cache, expressed in bytes. This size
214      * should be at least equal to the size of the screen in ARGB888 format.
215      */
216     @Deprecated
217     private static final int MAXIMUM_DRAWING_CACHE_SIZE = 480 * 800 * 4; // ARGB8888
218 
219     /**
220      * The coefficient of friction applied to flings/scrolls.
221      */
222     private static final float SCROLL_FRICTION = 0.015f;
223 
224     /**
225      * Max distance in dips to overscroll for edge effects
226      */
227     private static final int OVERSCROLL_DISTANCE = 0;
228 
229     /**
230      * Max distance in dips to overfling for edge effects
231      */
232     private static final int OVERFLING_DISTANCE = 6;
233 
234     /**
235      * Amount to scroll in response to a horizontal {@link MotionEvent#ACTION_SCROLL} event,
236      * in dips per axis value.
237      */
238     private static final float HORIZONTAL_SCROLL_FACTOR = 64;
239 
240     /**
241      * Amount to scroll in response to a vertical {@link MotionEvent#ACTION_SCROLL} event,
242      * in dips per axis value.
243      */
244     private static final float VERTICAL_SCROLL_FACTOR = 64;
245 
246     /**
247      * Default duration to hide an action mode for.
248      */
249     private static final long ACTION_MODE_HIDE_DURATION_DEFAULT = 2000;
250 
251     /**
252      * Defines the duration in milliseconds before an end of a long press causes a tooltip to be
253      * hidden.
254      */
255     private static final int LONG_PRESS_TOOLTIP_HIDE_TIMEOUT = 1500;
256 
257     /**
258      * Defines the duration in milliseconds before a hover event causes a tooltip to be shown.
259      */
260     private static final int HOVER_TOOLTIP_SHOW_TIMEOUT = 500;
261 
262     /**
263      * Defines the duration in milliseconds before mouse inactivity causes a tooltip to be hidden.
264      * (default variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is not set).
265      */
266     private static final int HOVER_TOOLTIP_HIDE_TIMEOUT = 15000;
267 
268     /**
269      * Defines the duration in milliseconds before mouse inactivity causes a tooltip to be hidden
270      * (short version to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is set).
271      */
272     private static final int HOVER_TOOLTIP_HIDE_SHORT_TIMEOUT = 3000;
273 
274     /**
275      * Configuration values for overriding {@link #hasPermanentMenuKey()} behavior.
276      * These constants must match the definition in res/values/config.xml.
277      */
278     private static final int HAS_PERMANENT_MENU_KEY_AUTODETECT = 0;
279     private static final int HAS_PERMANENT_MENU_KEY_TRUE = 1;
280     private static final int HAS_PERMANENT_MENU_KEY_FALSE = 2;
281 
282     private final int mEdgeSlop;
283     private final int mFadingEdgeLength;
284     private final int mMinimumFlingVelocity;
285     private final int mMaximumFlingVelocity;
286     private final int mScrollbarSize;
287     private final int mTouchSlop;
288     private final int mMinScrollbarTouchTarget;
289     private final int mDoubleTapTouchSlop;
290     private final int mPagingTouchSlop;
291     private final int mDoubleTapSlop;
292     private final int mWindowTouchSlop;
293     private final int mMaximumDrawingCacheSize;
294     private final int mOverscrollDistance;
295     private final int mOverflingDistance;
296     private final boolean mFadingMarqueeEnabled;
297     private final long mGlobalActionsKeyTimeout;
298     private final float mVerticalScrollFactor;
299     private final float mHorizontalScrollFactor;
300 
301     private boolean sHasPermanentMenuKey;
302     private boolean sHasPermanentMenuKeySet;
303 
304     static final SparseArray<ViewConfiguration> sConfigurations =
305             new SparseArray<ViewConfiguration>(2);
306 
307     /**
308      * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead.
309      */
310     @Deprecated
ViewConfiguration()311     public ViewConfiguration() {
312         mEdgeSlop = EDGE_SLOP;
313         mFadingEdgeLength = FADING_EDGE_LENGTH;
314         mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY;
315         mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY;
316         mScrollbarSize = SCROLL_BAR_SIZE;
317         mTouchSlop = TOUCH_SLOP;
318         mMinScrollbarTouchTarget = MIN_SCROLLBAR_TOUCH_TARGET;
319         mDoubleTapTouchSlop = DOUBLE_TAP_TOUCH_SLOP;
320         mPagingTouchSlop = PAGING_TOUCH_SLOP;
321         mDoubleTapSlop = DOUBLE_TAP_SLOP;
322         mWindowTouchSlop = WINDOW_TOUCH_SLOP;
323         //noinspection deprecation
324         mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE;
325         mOverscrollDistance = OVERSCROLL_DISTANCE;
326         mOverflingDistance = OVERFLING_DISTANCE;
327         mFadingMarqueeEnabled = true;
328         mGlobalActionsKeyTimeout = GLOBAL_ACTIONS_KEY_TIMEOUT;
329         mHorizontalScrollFactor = HORIZONTAL_SCROLL_FACTOR;
330         mVerticalScrollFactor = VERTICAL_SCROLL_FACTOR;
331     }
332 
333     /**
334      * Creates a new configuration for the specified context. The configuration depends on
335      * various parameters of the context, like the dimension of the display or the density
336      * of the display.
337      *
338      * @param context The application context used to initialize this view configuration.
339      *
340      * @see #get(android.content.Context)
341      * @see android.util.DisplayMetrics
342      */
ViewConfiguration(Context context)343     private ViewConfiguration(Context context) {
344         final Resources res = context.getResources();
345         final DisplayMetrics metrics = res.getDisplayMetrics();
346         final Configuration config = res.getConfiguration();
347         final float density = metrics.density;
348         final float sizeAndDensity;
349         if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) {
350             sizeAndDensity = density * 1.5f;
351         } else {
352             sizeAndDensity = density;
353         }
354 
355         mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f);
356         mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f);
357         mScrollbarSize = res.getDimensionPixelSize(
358                 com.android.internal.R.dimen.config_scrollbarSize);
359         mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
360         mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
361 
362         // Size of the screen in bytes, in ARGB_8888 format
363         final WindowManager win = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
364         final Display display = win.getDefaultDisplay();
365         final Point size = new Point();
366         display.getRealSize(size);
367         mMaximumDrawingCacheSize = 4 * size.x * size.y;
368 
369         mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
370         mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
371 
372         if (!sHasPermanentMenuKeySet) {
373             final int configVal = res.getInteger(
374                     com.android.internal.R.integer.config_overrideHasPermanentMenuKey);
375 
376             switch (configVal) {
377                 default:
378                 case HAS_PERMANENT_MENU_KEY_AUTODETECT: {
379                     IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
380                     try {
381                         sHasPermanentMenuKey = !wm.hasNavigationBar();
382                         sHasPermanentMenuKeySet = true;
383                     } catch (RemoteException ex) {
384                         sHasPermanentMenuKey = false;
385                     }
386                 }
387                 break;
388 
389                 case HAS_PERMANENT_MENU_KEY_TRUE:
390                     sHasPermanentMenuKey = true;
391                     sHasPermanentMenuKeySet = true;
392                     break;
393 
394                 case HAS_PERMANENT_MENU_KEY_FALSE:
395                     sHasPermanentMenuKey = false;
396                     sHasPermanentMenuKeySet = true;
397                     break;
398             }
399         }
400 
401         mFadingMarqueeEnabled = res.getBoolean(
402                 com.android.internal.R.bool.config_ui_enableFadingMarquee);
403         mTouchSlop = res.getDimensionPixelSize(
404                 com.android.internal.R.dimen.config_viewConfigurationTouchSlop);
405         mMinScrollbarTouchTarget = res.getDimensionPixelSize(
406                 com.android.internal.R.dimen.config_minScrollbarTouchTarget);
407         mPagingTouchSlop = mTouchSlop * 2;
408 
409         mDoubleTapTouchSlop = mTouchSlop;
410 
411         mMinimumFlingVelocity = res.getDimensionPixelSize(
412                 com.android.internal.R.dimen.config_viewMinFlingVelocity);
413         mMaximumFlingVelocity = res.getDimensionPixelSize(
414                 com.android.internal.R.dimen.config_viewMaxFlingVelocity);
415         mGlobalActionsKeyTimeout = res.getInteger(
416                 com.android.internal.R.integer.config_globalActionsKeyTimeout);
417 
418         mHorizontalScrollFactor = res.getDimensionPixelSize(
419                 com.android.internal.R.dimen.config_horizontalScrollFactor);
420         mVerticalScrollFactor = res.getDimensionPixelSize(
421                 com.android.internal.R.dimen.config_verticalScrollFactor);
422     }
423 
424     /**
425      * Returns a configuration for the specified context. The configuration depends on
426      * various parameters of the context, like the dimension of the display or the
427      * density of the display.
428      *
429      * @param context The application context used to initialize the view configuration.
430      */
get(Context context)431     public static ViewConfiguration get(Context context) {
432         final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
433         final int density = (int) (100.0f * metrics.density);
434 
435         ViewConfiguration configuration = sConfigurations.get(density);
436         if (configuration == null) {
437             configuration = new ViewConfiguration(context);
438             sConfigurations.put(density, configuration);
439         }
440 
441         return configuration;
442     }
443 
444     /**
445      * @return The width of the horizontal scrollbar and the height of the vertical
446      *         scrollbar in dips
447      *
448      * @deprecated Use {@link #getScaledScrollBarSize()} instead.
449      */
450     @Deprecated
getScrollBarSize()451     public static int getScrollBarSize() {
452         return SCROLL_BAR_SIZE;
453     }
454 
455     /**
456      * @return The width of the horizontal scrollbar and the height of the vertical
457      *         scrollbar in pixels
458      */
getScaledScrollBarSize()459     public int getScaledScrollBarSize() {
460         return mScrollbarSize;
461     }
462 
463     /**
464      * @return the minimum size of the scrollbar thumb's touch target in pixels
465      * @hide
466      */
getScaledMinScrollbarTouchTarget()467     public int getScaledMinScrollbarTouchTarget() {
468         return mMinScrollbarTouchTarget;
469     }
470 
471     /**
472      * @return Duration of the fade when scrollbars fade away in milliseconds
473      */
getScrollBarFadeDuration()474     public static int getScrollBarFadeDuration() {
475         return SCROLL_BAR_FADE_DURATION;
476     }
477 
478     /**
479      * @return Default delay before the scrollbars fade in milliseconds
480      */
getScrollDefaultDelay()481     public static int getScrollDefaultDelay() {
482         return SCROLL_BAR_DEFAULT_DELAY;
483     }
484 
485     /**
486      * @return the length of the fading edges in dips
487      *
488      * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
489      */
490     @Deprecated
getFadingEdgeLength()491     public static int getFadingEdgeLength() {
492         return FADING_EDGE_LENGTH;
493     }
494 
495     /**
496      * @return the length of the fading edges in pixels
497      */
getScaledFadingEdgeLength()498     public int getScaledFadingEdgeLength() {
499         return mFadingEdgeLength;
500     }
501 
502     /**
503      * @return the duration in milliseconds of the pressed state in child
504      * components.
505      */
getPressedStateDuration()506     public static int getPressedStateDuration() {
507         return PRESSED_STATE_DURATION;
508     }
509 
510     /**
511      * @return the duration in milliseconds before a press turns into
512      * a long press
513      */
getLongPressTimeout()514     public static int getLongPressTimeout() {
515         return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT,
516                 DEFAULT_LONG_PRESS_TIMEOUT);
517     }
518 
519     /**
520      * @return the duration in milliseconds between the first tap's up event and the second tap's
521      * down event for an interaction to be considered part of the same multi-press.
522      * @hide
523      */
getMultiPressTimeout()524     public static int getMultiPressTimeout() {
525         return AppGlobals.getIntCoreSetting(Settings.Secure.MULTI_PRESS_TIMEOUT,
526                 DEFAULT_MULTI_PRESS_TIMEOUT);
527     }
528 
529     /**
530      * @return the time before the first key repeat in milliseconds.
531      */
getKeyRepeatTimeout()532     public static int getKeyRepeatTimeout() {
533         return getLongPressTimeout();
534     }
535 
536     /**
537      * @return the time between successive key repeats in milliseconds.
538      */
getKeyRepeatDelay()539     public static int getKeyRepeatDelay() {
540         return KEY_REPEAT_DELAY;
541     }
542 
543     /**
544      * @return the duration in milliseconds we will wait to see if a touch event
545      * is a tap or a scroll. If the user does not move within this interval, it is
546      * considered to be a tap.
547      */
getTapTimeout()548     public static int getTapTimeout() {
549         return TAP_TIMEOUT;
550     }
551 
552     /**
553      * @return the duration in milliseconds we will wait to see if a touch event
554      * is a jump tap. If the user does not move within this interval, it is
555      * considered to be a tap.
556      */
getJumpTapTimeout()557     public static int getJumpTapTimeout() {
558         return JUMP_TAP_TIMEOUT;
559     }
560 
561     /**
562      * @return the duration in milliseconds between the first tap's up event and
563      * the second tap's down event for an interaction to be considered a
564      * double-tap.
565      */
getDoubleTapTimeout()566     public static int getDoubleTapTimeout() {
567         return DOUBLE_TAP_TIMEOUT;
568     }
569 
570     /**
571      * @return the minimum duration in milliseconds between the first tap's
572      * up event and the second tap's down event for an interaction to be considered a
573      * double-tap.
574      *
575      * @hide
576      */
getDoubleTapMinTime()577     public static int getDoubleTapMinTime() {
578         return DOUBLE_TAP_MIN_TIME;
579     }
580 
581     /**
582      * @return the maximum duration in milliseconds between a touch pad
583      * touch and release for a given touch to be considered a tap (click) as
584      * opposed to a hover movement gesture.
585      * @hide
586      */
getHoverTapTimeout()587     public static int getHoverTapTimeout() {
588         return HOVER_TAP_TIMEOUT;
589     }
590 
591     /**
592      * @return the maximum distance in pixels that a touch pad touch can move
593      * before being released for it to be considered a tap (click) as opposed
594      * to a hover movement gesture.
595      * @hide
596      */
getHoverTapSlop()597     public static int getHoverTapSlop() {
598         return HOVER_TAP_SLOP;
599     }
600 
601     /**
602      * @return Inset in dips to look for touchable content when the user touches the edge of the
603      *         screen
604      *
605      * @deprecated Use {@link #getScaledEdgeSlop()} instead.
606      */
607     @Deprecated
getEdgeSlop()608     public static int getEdgeSlop() {
609         return EDGE_SLOP;
610     }
611 
612     /**
613      * @return Inset in pixels to look for touchable content when the user touches the edge of the
614      *         screen
615      */
getScaledEdgeSlop()616     public int getScaledEdgeSlop() {
617         return mEdgeSlop;
618     }
619 
620     /**
621      * @return Distance in dips a touch can wander before we think the user is scrolling
622      *
623      * @deprecated Use {@link #getScaledTouchSlop()} instead.
624      */
625     @Deprecated
getTouchSlop()626     public static int getTouchSlop() {
627         return TOUCH_SLOP;
628     }
629 
630     /**
631      * @return Distance in pixels a touch can wander before we think the user is scrolling
632      */
getScaledTouchSlop()633     public int getScaledTouchSlop() {
634         return mTouchSlop;
635     }
636 
637     /**
638      * @return Distance in pixels the first touch can wander before we do not consider this a
639      * potential double tap event
640      * @hide
641      */
getScaledDoubleTapTouchSlop()642     public int getScaledDoubleTapTouchSlop() {
643         return mDoubleTapTouchSlop;
644     }
645 
646     /**
647      * @return Distance in pixels a touch can wander before we think the user is scrolling a full
648      * page
649      */
getScaledPagingTouchSlop()650     public int getScaledPagingTouchSlop() {
651         return mPagingTouchSlop;
652     }
653 
654     /**
655      * @return Distance in dips between the first touch and second touch to still be
656      *         considered a double tap
657      * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
658      * @hide The only client of this should be GestureDetector, which needs this
659      *       for clients that still use its deprecated constructor.
660      */
661     @Deprecated
getDoubleTapSlop()662     public static int getDoubleTapSlop() {
663         return DOUBLE_TAP_SLOP;
664     }
665 
666     /**
667      * @return Distance in pixels between the first touch and second touch to still be
668      *         considered a double tap
669      */
getScaledDoubleTapSlop()670     public int getScaledDoubleTapSlop() {
671         return mDoubleTapSlop;
672     }
673 
674     /**
675      * Interval for dispatching a recurring accessibility event in milliseconds.
676      * This interval guarantees that a recurring event will be send at most once
677      * during the {@link #getSendRecurringAccessibilityEventsInterval()} time frame.
678      *
679      * @return The delay in milliseconds.
680      *
681      * @hide
682      */
getSendRecurringAccessibilityEventsInterval()683     public static long getSendRecurringAccessibilityEventsInterval() {
684         return SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS;
685     }
686 
687     /**
688      * @return Distance in dips a touch must be outside the bounds of a window for it
689      * to be counted as outside the window for purposes of dismissing that
690      * window.
691      *
692      * @deprecated Use {@link #getScaledWindowTouchSlop()} instead.
693      */
694     @Deprecated
getWindowTouchSlop()695     public static int getWindowTouchSlop() {
696         return WINDOW_TOUCH_SLOP;
697     }
698 
699     /**
700      * @return Distance in pixels a touch must be outside the bounds of a window for it
701      * to be counted as outside the window for purposes of dismissing that window.
702      */
getScaledWindowTouchSlop()703     public int getScaledWindowTouchSlop() {
704         return mWindowTouchSlop;
705     }
706 
707     /**
708      * @return Minimum velocity to initiate a fling, as measured in dips per second.
709      *
710      * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
711      */
712     @Deprecated
getMinimumFlingVelocity()713     public static int getMinimumFlingVelocity() {
714         return MINIMUM_FLING_VELOCITY;
715     }
716 
717     /**
718      * @return Minimum velocity to initiate a fling, as measured in pixels per second.
719      */
getScaledMinimumFlingVelocity()720     public int getScaledMinimumFlingVelocity() {
721         return mMinimumFlingVelocity;
722     }
723 
724     /**
725      * @return Maximum velocity to initiate a fling, as measured in dips per second.
726      *
727      * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead.
728      */
729     @Deprecated
getMaximumFlingVelocity()730     public static int getMaximumFlingVelocity() {
731         return MAXIMUM_FLING_VELOCITY;
732     }
733 
734     /**
735      * @return Maximum velocity to initiate a fling, as measured in pixels per second.
736      */
getScaledMaximumFlingVelocity()737     public int getScaledMaximumFlingVelocity() {
738         return mMaximumFlingVelocity;
739     }
740 
741     /**
742      * @return Amount to scroll in response to a {@link MotionEvent#ACTION_SCROLL} event. Multiply
743      * this by the event's axis value to obtain the number of pixels to be scrolled.
744      *
745      * @removed
746      */
getScaledScrollFactor()747     public int getScaledScrollFactor() {
748         return (int) mVerticalScrollFactor;
749     }
750 
751     /**
752      * @return Amount to scroll in response to a horizontal {@link MotionEvent#ACTION_SCROLL} event.
753      * Multiply this by the event's axis value to obtain the number of pixels to be scrolled.
754      */
getScaledHorizontalScrollFactor()755     public float getScaledHorizontalScrollFactor() {
756         return mHorizontalScrollFactor;
757     }
758 
759     /**
760      * @return Amount to scroll in response to a vertical {@link MotionEvent#ACTION_SCROLL} event.
761      * Multiply this by the event's axis value to obtain the number of pixels to be scrolled.
762      */
getScaledVerticalScrollFactor()763     public float getScaledVerticalScrollFactor() {
764         return mVerticalScrollFactor;
765     }
766 
767     /**
768      * The maximum drawing cache size expressed in bytes.
769      *
770      * @return the maximum size of View's drawing cache expressed in bytes
771      *
772      * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
773      */
774     @Deprecated
getMaximumDrawingCacheSize()775     public static int getMaximumDrawingCacheSize() {
776         //noinspection deprecation
777         return MAXIMUM_DRAWING_CACHE_SIZE;
778     }
779 
780     /**
781      * The maximum drawing cache size expressed in bytes.
782      *
783      * @return the maximum size of View's drawing cache expressed in bytes
784      */
getScaledMaximumDrawingCacheSize()785     public int getScaledMaximumDrawingCacheSize() {
786         return mMaximumDrawingCacheSize;
787     }
788 
789     /**
790      * @return The maximum distance a View should overscroll by when showing edge effects (in
791      * pixels).
792      */
getScaledOverscrollDistance()793     public int getScaledOverscrollDistance() {
794         return mOverscrollDistance;
795     }
796 
797     /**
798      * @return The maximum distance a View should overfling by when showing edge effects (in
799      * pixels).
800      */
getScaledOverflingDistance()801     public int getScaledOverflingDistance() {
802         return mOverflingDistance;
803     }
804 
805     /**
806      * The amount of time that the zoom controls should be
807      * displayed on the screen expressed in milliseconds.
808      *
809      * @return the time the zoom controls should be visible expressed
810      * in milliseconds.
811      */
getZoomControlsTimeout()812     public static long getZoomControlsTimeout() {
813         return ZOOM_CONTROLS_TIMEOUT;
814     }
815 
816     /**
817      * The amount of time a user needs to press the relevant key to bring up
818      * the global actions dialog.
819      *
820      * @return how long a user needs to press the relevant key to bring up
821      *   the global actions dialog.
822      * @deprecated This timeout should not be used by applications
823      */
824     @Deprecated
getGlobalActionKeyTimeout()825     public static long getGlobalActionKeyTimeout() {
826         return GLOBAL_ACTIONS_KEY_TIMEOUT;
827     }
828 
829     /**
830      * The amount of time a user needs to press the relevant key to bring up
831      * the global actions dialog.
832      *
833      * @return how long a user needs to press the relevant key to bring up
834      *   the global actions dialog.
835      * @hide
836      */
getDeviceGlobalActionKeyTimeout()837     public long getDeviceGlobalActionKeyTimeout() {
838         return mGlobalActionsKeyTimeout;
839     }
840 
841     /**
842      * The amount of time a user needs to press the relevant keys to activate the accessibility
843      * shortcut.
844      *
845      * @return how long a user needs to press the relevant keys to activate the accessibility
846      *   shortcut.
847      * @hide
848      */
getAccessibilityShortcutKeyTimeout()849     public long getAccessibilityShortcutKeyTimeout() {
850         return A11Y_SHORTCUT_KEY_TIMEOUT;
851     }
852 
853     /**
854      * The amount of friction applied to scrolls and flings.
855      *
856      * @return A scalar dimensionless value representing the coefficient of
857      *         friction.
858      */
getScrollFriction()859     public static float getScrollFriction() {
860         return SCROLL_FRICTION;
861     }
862 
863     /**
864      * @return the default duration in milliseconds for {@link ActionMode#hide(long)}.
865      */
getDefaultActionModeHideDuration()866     public static long getDefaultActionModeHideDuration() {
867         return ACTION_MODE_HIDE_DURATION_DEFAULT;
868     }
869 
870     /**
871      * Report if the device has a permanent menu key available to the user.
872      *
873      * <p>As of Android 3.0, devices may not have a permanent menu key available.
874      * Apps should use the action bar to present menu options to users.
875      * However, there are some apps where the action bar is inappropriate
876      * or undesirable. This method may be used to detect if a menu key is present.
877      * If not, applications should provide another on-screen affordance to access
878      * functionality.
879      *
880      * @return true if a permanent menu key is present, false otherwise.
881      */
hasPermanentMenuKey()882     public boolean hasPermanentMenuKey() {
883         return sHasPermanentMenuKey;
884     }
885 
886     /**
887      * @hide
888      * @return Whether or not marquee should use fading edges.
889      */
isFadingMarqueeEnabled()890     public boolean isFadingMarqueeEnabled() {
891         return mFadingMarqueeEnabled;
892     }
893 
894     /**
895      * @return the duration in milliseconds before an end of a long press causes a tooltip to be
896      * hidden
897      * @hide
898      */
899     @TestApi
getLongPressTooltipHideTimeout()900     public static int getLongPressTooltipHideTimeout() {
901         return LONG_PRESS_TOOLTIP_HIDE_TIMEOUT;
902     }
903 
904     /**
905      * @return the duration in milliseconds before a hover event causes a tooltip to be shown
906      * @hide
907      */
908     @TestApi
getHoverTooltipShowTimeout()909     public static int getHoverTooltipShowTimeout() {
910         return HOVER_TOOLTIP_SHOW_TIMEOUT;
911     }
912 
913     /**
914      * @return the duration in milliseconds before mouse inactivity causes a tooltip to be hidden
915      * (default variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is not set).
916      * @hide
917      */
918     @TestApi
getHoverTooltipHideTimeout()919     public static int getHoverTooltipHideTimeout() {
920         return HOVER_TOOLTIP_HIDE_TIMEOUT;
921     }
922 
923     /**
924      * @return the duration in milliseconds before mouse inactivity causes a tooltip to be hidden
925      * (shorter variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is set).
926      * @hide
927      */
928     @TestApi
getHoverTooltipHideShortTimeout()929     public static int getHoverTooltipHideShortTimeout() {
930         return HOVER_TOOLTIP_HIDE_SHORT_TIMEOUT;
931     }
932 }
933