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
17package android.view;
18
19import android.annotation.TestApi;
20import android.app.AppGlobals;
21import android.content.Context;
22import android.content.res.Configuration;
23import android.content.res.Resources;
24import android.graphics.Point;
25import android.os.RemoteException;
26import android.provider.Settings;
27import android.util.DisplayMetrics;
28import android.util.SparseArray;
29
30/**
31 * Contains methods to standard constants used in the UI for timeouts, sizes, and distances.
32 */
33public 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 = 10;
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
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     */
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 = (int) (density * SCROLL_BAR_SIZE + 0.5f);
358        mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f);
359        mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f);
360
361        // Size of the screen in bytes, in ARGB_8888 format
362        final WindowManager win = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
363        final Display display = win.getDefaultDisplay();
364        final Point size = new Point();
365        display.getRealSize(size);
366        mMaximumDrawingCacheSize = 4 * size.x * size.y;
367
368        mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
369        mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
370
371        if (!sHasPermanentMenuKeySet) {
372            final int configVal = res.getInteger(
373                    com.android.internal.R.integer.config_overrideHasPermanentMenuKey);
374
375            switch (configVal) {
376                default:
377                case HAS_PERMANENT_MENU_KEY_AUTODETECT: {
378                    IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
379                    try {
380                        sHasPermanentMenuKey = !wm.hasNavigationBar();
381                        sHasPermanentMenuKeySet = true;
382                    } catch (RemoteException ex) {
383                        sHasPermanentMenuKey = false;
384                    }
385                }
386                break;
387
388                case HAS_PERMANENT_MENU_KEY_TRUE:
389                    sHasPermanentMenuKey = true;
390                    sHasPermanentMenuKeySet = true;
391                    break;
392
393                case HAS_PERMANENT_MENU_KEY_FALSE:
394                    sHasPermanentMenuKey = false;
395                    sHasPermanentMenuKeySet = true;
396                    break;
397            }
398        }
399
400        mFadingMarqueeEnabled = res.getBoolean(
401                com.android.internal.R.bool.config_ui_enableFadingMarquee);
402        mTouchSlop = res.getDimensionPixelSize(
403                com.android.internal.R.dimen.config_viewConfigurationTouchSlop);
404        mMinScrollbarTouchTarget = res.getDimensionPixelSize(
405                com.android.internal.R.dimen.config_minScrollbarTouchTarget);
406        mPagingTouchSlop = mTouchSlop * 2;
407
408        mDoubleTapTouchSlop = mTouchSlop;
409
410        mMinimumFlingVelocity = res.getDimensionPixelSize(
411                com.android.internal.R.dimen.config_viewMinFlingVelocity);
412        mMaximumFlingVelocity = res.getDimensionPixelSize(
413                com.android.internal.R.dimen.config_viewMaxFlingVelocity);
414        mGlobalActionsKeyTimeout = res.getInteger(
415                com.android.internal.R.integer.config_globalActionsKeyTimeout);
416
417        mHorizontalScrollFactor = res.getDimensionPixelSize(
418                com.android.internal.R.dimen.config_horizontalScrollFactor);
419        mVerticalScrollFactor = res.getDimensionPixelSize(
420                com.android.internal.R.dimen.config_verticalScrollFactor);
421    }
422
423    /**
424     * Returns a configuration for the specified context. The configuration depends on
425     * various parameters of the context, like the dimension of the display or the
426     * density of the display.
427     *
428     * @param context The application context used to initialize the view configuration.
429     */
430    public static ViewConfiguration get(Context context) {
431        final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
432        final int density = (int) (100.0f * metrics.density);
433
434        ViewConfiguration configuration = sConfigurations.get(density);
435        if (configuration == null) {
436            configuration = new ViewConfiguration(context);
437            sConfigurations.put(density, configuration);
438        }
439
440        return configuration;
441    }
442
443    /**
444     * @return The width of the horizontal scrollbar and the height of the vertical
445     *         scrollbar in dips
446     *
447     * @deprecated Use {@link #getScaledScrollBarSize()} instead.
448     */
449    @Deprecated
450    public static int getScrollBarSize() {
451        return SCROLL_BAR_SIZE;
452    }
453
454    /**
455     * @return The width of the horizontal scrollbar and the height of the vertical
456     *         scrollbar in pixels
457     */
458    public int getScaledScrollBarSize() {
459        return mScrollbarSize;
460    }
461
462    /**
463     * @return the minimum size of the scrollbar thumb's touch target in pixels
464     * @hide
465     */
466    public int getScaledMinScrollbarTouchTarget() {
467        return mMinScrollbarTouchTarget;
468    }
469
470    /**
471     * @return Duration of the fade when scrollbars fade away in milliseconds
472     */
473    public static int getScrollBarFadeDuration() {
474        return SCROLL_BAR_FADE_DURATION;
475    }
476
477    /**
478     * @return Default delay before the scrollbars fade in milliseconds
479     */
480    public static int getScrollDefaultDelay() {
481        return SCROLL_BAR_DEFAULT_DELAY;
482    }
483
484    /**
485     * @return the length of the fading edges in dips
486     *
487     * @deprecated Use {@link #getScaledFadingEdgeLength()} instead.
488     */
489    @Deprecated
490    public static int getFadingEdgeLength() {
491        return FADING_EDGE_LENGTH;
492    }
493
494    /**
495     * @return the length of the fading edges in pixels
496     */
497    public int getScaledFadingEdgeLength() {
498        return mFadingEdgeLength;
499    }
500
501    /**
502     * @return the duration in milliseconds of the pressed state in child
503     * components.
504     */
505    public static int getPressedStateDuration() {
506        return PRESSED_STATE_DURATION;
507    }
508
509    /**
510     * @return the duration in milliseconds before a press turns into
511     * a long press
512     */
513    public static int getLongPressTimeout() {
514        return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT,
515                DEFAULT_LONG_PRESS_TIMEOUT);
516    }
517
518    /**
519     * @return the duration in milliseconds between the first tap's up event and the second tap's
520     * down event for an interaction to be considered part of the same multi-press.
521     * @hide
522     */
523    public static int getMultiPressTimeout() {
524        return AppGlobals.getIntCoreSetting(Settings.Secure.MULTI_PRESS_TIMEOUT,
525                DEFAULT_MULTI_PRESS_TIMEOUT);
526    }
527
528    /**
529     * @return the time before the first key repeat in milliseconds.
530     */
531    public static int getKeyRepeatTimeout() {
532        return getLongPressTimeout();
533    }
534
535    /**
536     * @return the time between successive key repeats in milliseconds.
537     */
538    public static int getKeyRepeatDelay() {
539        return KEY_REPEAT_DELAY;
540    }
541
542    /**
543     * @return the duration in milliseconds we will wait to see if a touch event
544     * is a tap or a scroll. If the user does not move within this interval, it is
545     * considered to be a tap.
546     */
547    public static int getTapTimeout() {
548        return TAP_TIMEOUT;
549    }
550
551    /**
552     * @return the duration in milliseconds we will wait to see if a touch event
553     * is a jump tap. If the user does not move within this interval, it is
554     * considered to be a tap.
555     */
556    public static int getJumpTapTimeout() {
557        return JUMP_TAP_TIMEOUT;
558    }
559
560    /**
561     * @return the duration in milliseconds between the first tap's up event and
562     * the second tap's down event for an interaction to be considered a
563     * double-tap.
564     */
565    public static int getDoubleTapTimeout() {
566        return DOUBLE_TAP_TIMEOUT;
567    }
568
569    /**
570     * @return the minimum duration in milliseconds between the first tap's
571     * up event and the second tap's down event for an interaction to be considered a
572     * double-tap.
573     *
574     * @hide
575     */
576    public static int getDoubleTapMinTime() {
577        return DOUBLE_TAP_MIN_TIME;
578    }
579
580    /**
581     * @return the maximum duration in milliseconds between a touch pad
582     * touch and release for a given touch to be considered a tap (click) as
583     * opposed to a hover movement gesture.
584     * @hide
585     */
586    public static int getHoverTapTimeout() {
587        return HOVER_TAP_TIMEOUT;
588    }
589
590    /**
591     * @return the maximum distance in pixels that a touch pad touch can move
592     * before being released for it to be considered a tap (click) as opposed
593     * to a hover movement gesture.
594     * @hide
595     */
596    public static int getHoverTapSlop() {
597        return HOVER_TAP_SLOP;
598    }
599
600    /**
601     * @return Inset in dips to look for touchable content when the user touches the edge of the
602     *         screen
603     *
604     * @deprecated Use {@link #getScaledEdgeSlop()} instead.
605     */
606    @Deprecated
607    public static int getEdgeSlop() {
608        return EDGE_SLOP;
609    }
610
611    /**
612     * @return Inset in pixels to look for touchable content when the user touches the edge of the
613     *         screen
614     */
615    public int getScaledEdgeSlop() {
616        return mEdgeSlop;
617    }
618
619    /**
620     * @return Distance in dips a touch can wander before we think the user is scrolling
621     *
622     * @deprecated Use {@link #getScaledTouchSlop()} instead.
623     */
624    @Deprecated
625    public static int getTouchSlop() {
626        return TOUCH_SLOP;
627    }
628
629    /**
630     * @return Distance in pixels a touch can wander before we think the user is scrolling
631     */
632    public int getScaledTouchSlop() {
633        return mTouchSlop;
634    }
635
636    /**
637     * @return Distance in pixels the first touch can wander before we do not consider this a
638     * potential double tap event
639     * @hide
640     */
641    public int getScaledDoubleTapTouchSlop() {
642        return mDoubleTapTouchSlop;
643    }
644
645    /**
646     * @return Distance in pixels a touch can wander before we think the user is scrolling a full
647     * page
648     */
649    public int getScaledPagingTouchSlop() {
650        return mPagingTouchSlop;
651    }
652
653    /**
654     * @return Distance in dips between the first touch and second touch to still be
655     *         considered a double tap
656     * @deprecated Use {@link #getScaledDoubleTapSlop()} instead.
657     * @hide The only client of this should be GestureDetector, which needs this
658     *       for clients that still use its deprecated constructor.
659     */
660    @Deprecated
661    public static int getDoubleTapSlop() {
662        return DOUBLE_TAP_SLOP;
663    }
664
665    /**
666     * @return Distance in pixels between the first touch and second touch to still be
667     *         considered a double tap
668     */
669    public int getScaledDoubleTapSlop() {
670        return mDoubleTapSlop;
671    }
672
673    /**
674     * Interval for dispatching a recurring accessibility event in milliseconds.
675     * This interval guarantees that a recurring event will be send at most once
676     * during the {@link #getSendRecurringAccessibilityEventsInterval()} time frame.
677     *
678     * @return The delay in milliseconds.
679     *
680     * @hide
681     */
682    public static long getSendRecurringAccessibilityEventsInterval() {
683        return SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS;
684    }
685
686    /**
687     * @return Distance in dips a touch must be outside the bounds of a window for it
688     * to be counted as outside the window for purposes of dismissing that
689     * window.
690     *
691     * @deprecated Use {@link #getScaledWindowTouchSlop()} instead.
692     */
693    @Deprecated
694    public static int getWindowTouchSlop() {
695        return WINDOW_TOUCH_SLOP;
696    }
697
698    /**
699     * @return Distance in pixels a touch must be outside the bounds of a window for it
700     * to be counted as outside the window for purposes of dismissing that window.
701     */
702    public int getScaledWindowTouchSlop() {
703        return mWindowTouchSlop;
704    }
705
706    /**
707     * @return Minimum velocity to initiate a fling, as measured in dips per second.
708     *
709     * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead.
710     */
711    @Deprecated
712    public static int getMinimumFlingVelocity() {
713        return MINIMUM_FLING_VELOCITY;
714    }
715
716    /**
717     * @return Minimum velocity to initiate a fling, as measured in pixels per second.
718     */
719    public int getScaledMinimumFlingVelocity() {
720        return mMinimumFlingVelocity;
721    }
722
723    /**
724     * @return Maximum velocity to initiate a fling, as measured in dips per second.
725     *
726     * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead.
727     */
728    @Deprecated
729    public static int getMaximumFlingVelocity() {
730        return MAXIMUM_FLING_VELOCITY;
731    }
732
733    /**
734     * @return Maximum velocity to initiate a fling, as measured in pixels per second.
735     */
736    public int getScaledMaximumFlingVelocity() {
737        return mMaximumFlingVelocity;
738    }
739
740    /**
741     * @return Amount to scroll in response to a {@link MotionEvent#ACTION_SCROLL} event. Multiply
742     * this by the event's axis value to obtain the number of pixels to be scrolled.
743     *
744     * @removed
745     */
746    public int getScaledScrollFactor() {
747        return (int) mVerticalScrollFactor;
748    }
749
750    /**
751     * @return Amount to scroll in response to a horizontal {@link MotionEvent#ACTION_SCROLL} event.
752     * Multiply this by the event's axis value to obtain the number of pixels to be scrolled.
753     */
754    public float getScaledHorizontalScrollFactor() {
755        return mHorizontalScrollFactor;
756    }
757
758    /**
759     * @return Amount to scroll in response to a vertical {@link MotionEvent#ACTION_SCROLL} event.
760     * Multiply this by the event's axis value to obtain the number of pixels to be scrolled.
761     */
762    public float getScaledVerticalScrollFactor() {
763        return mVerticalScrollFactor;
764    }
765
766    /**
767     * The maximum drawing cache size expressed in bytes.
768     *
769     * @return the maximum size of View's drawing cache expressed in bytes
770     *
771     * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead.
772     */
773    @Deprecated
774    public static int getMaximumDrawingCacheSize() {
775        //noinspection deprecation
776        return MAXIMUM_DRAWING_CACHE_SIZE;
777    }
778
779    /**
780     * The maximum drawing cache size expressed in bytes.
781     *
782     * @return the maximum size of View's drawing cache expressed in bytes
783     */
784    public int getScaledMaximumDrawingCacheSize() {
785        return mMaximumDrawingCacheSize;
786    }
787
788    /**
789     * @return The maximum distance a View should overscroll by when showing edge effects (in
790     * pixels).
791     */
792    public int getScaledOverscrollDistance() {
793        return mOverscrollDistance;
794    }
795
796    /**
797     * @return The maximum distance a View should overfling by when showing edge effects (in
798     * pixels).
799     */
800    public int getScaledOverflingDistance() {
801        return mOverflingDistance;
802    }
803
804    /**
805     * The amount of time that the zoom controls should be
806     * displayed on the screen expressed in milliseconds.
807     *
808     * @return the time the zoom controls should be visible expressed
809     * in milliseconds.
810     */
811    public static long getZoomControlsTimeout() {
812        return ZOOM_CONTROLS_TIMEOUT;
813    }
814
815    /**
816     * The amount of time a user needs to press the relevant key to bring up
817     * the global actions dialog.
818     *
819     * @return how long a user needs to press the relevant key to bring up
820     *   the global actions dialog.
821     * @deprecated This timeout should not be used by applications
822     */
823    @Deprecated
824    public static long getGlobalActionKeyTimeout() {
825        return GLOBAL_ACTIONS_KEY_TIMEOUT;
826    }
827
828    /**
829     * The amount of time a user needs to press the relevant key to bring up
830     * the global actions dialog.
831     *
832     * @return how long a user needs to press the relevant key to bring up
833     *   the global actions dialog.
834     * @hide
835     */
836    public long getDeviceGlobalActionKeyTimeout() {
837        return mGlobalActionsKeyTimeout;
838    }
839
840    /**
841     * The amount of time a user needs to press the relevant keys to activate the accessibility
842     * shortcut.
843     *
844     * @return how long a user needs to press the relevant keys to activate the accessibility
845     *   shortcut.
846     * @hide
847     */
848    public long getAccessibilityShortcutKeyTimeout() {
849        return A11Y_SHORTCUT_KEY_TIMEOUT;
850    }
851
852    /**
853     * The amount of friction applied to scrolls and flings.
854     *
855     * @return A scalar dimensionless value representing the coefficient of
856     *         friction.
857     */
858    public static float getScrollFriction() {
859        return SCROLL_FRICTION;
860    }
861
862    /**
863     * @return the default duration in milliseconds for {@link ActionMode#hide(long)}.
864     */
865    public static long getDefaultActionModeHideDuration() {
866        return ACTION_MODE_HIDE_DURATION_DEFAULT;
867    }
868
869    /**
870     * Report if the device has a permanent menu key available to the user.
871     *
872     * <p>As of Android 3.0, devices may not have a permanent menu key available.
873     * Apps should use the action bar to present menu options to users.
874     * However, there are some apps where the action bar is inappropriate
875     * or undesirable. This method may be used to detect if a menu key is present.
876     * If not, applications should provide another on-screen affordance to access
877     * functionality.
878     *
879     * @return true if a permanent menu key is present, false otherwise.
880     */
881    public boolean hasPermanentMenuKey() {
882        return sHasPermanentMenuKey;
883    }
884
885    /**
886     * @hide
887     * @return Whether or not marquee should use fading edges.
888     */
889    public boolean isFadingMarqueeEnabled() {
890        return mFadingMarqueeEnabled;
891    }
892
893    /**
894     * @return the duration in milliseconds before an end of a long press causes a tooltip to be
895     * hidden
896     * @hide
897     */
898    @TestApi
899    public static int getLongPressTooltipHideTimeout() {
900        return LONG_PRESS_TOOLTIP_HIDE_TIMEOUT;
901    }
902
903    /**
904     * @return the duration in milliseconds before a hover event causes a tooltip to be shown
905     * @hide
906     */
907    @TestApi
908    public static int getHoverTooltipShowTimeout() {
909        return HOVER_TOOLTIP_SHOW_TIMEOUT;
910    }
911
912    /**
913     * @return the duration in milliseconds before mouse inactivity causes a tooltip to be hidden
914     * (default variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is not set).
915     * @hide
916     */
917    @TestApi
918    public static int getHoverTooltipHideTimeout() {
919        return HOVER_TOOLTIP_HIDE_TIMEOUT;
920    }
921
922    /**
923     * @return the duration in milliseconds before mouse inactivity causes a tooltip to be hidden
924     * (shorter variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is set).
925     * @hide
926     */
927    @TestApi
928    public static int getHoverTooltipHideShortTimeout() {
929        return HOVER_TOOLTIP_HIDE_SHORT_TIMEOUT;
930    }
931}
932