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