The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 19 | import android.app.AppGlobals; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.content.Context; |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 21 | import android.content.res.Configuration; |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 22 | import android.content.res.Resources; |
Jeff Brown | a8b9def | 2012-07-23 14:22:49 -0700 | [diff] [blame] | 23 | import android.graphics.Point; |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 24 | import android.os.RemoteException; |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 25 | import android.provider.Settings; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.util.DisplayMetrics; |
| 27 | import android.util.SparseArray; |
| 28 | |
| 29 | /** |
| 30 | * Contains methods to standard constants used in the UI for timeouts, sizes, and distances. |
| 31 | */ |
| 32 | public class ViewConfiguration { |
| 33 | /** |
| 34 | * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 35 | * dips |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | */ |
| 37 | private static final int SCROLL_BAR_SIZE = 10; |
| 38 | |
| 39 | /** |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 40 | * Duration of the fade when scrollbars fade away in milliseconds |
| 41 | */ |
| 42 | private static final int SCROLL_BAR_FADE_DURATION = 250; |
| 43 | |
| 44 | /** |
| 45 | * Default delay before the scrollbars fade in milliseconds |
| 46 | */ |
| 47 | private static final int SCROLL_BAR_DEFAULT_DELAY = 300; |
| 48 | |
| 49 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 50 | * Defines the length of the fading edges in dips |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | */ |
| 52 | private static final int FADING_EDGE_LENGTH = 12; |
| 53 | |
| 54 | /** |
| 55 | * Defines the duration in milliseconds of the pressed state in child |
| 56 | * components. |
| 57 | */ |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 58 | private static final int PRESSED_STATE_DURATION = 64; |
| 59 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | /** |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 61 | * Defines the default duration in milliseconds before a press turns into |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | * a long press |
| 63 | */ |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 64 | private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; |
| 65 | |
| 66 | /** |
| 67 | * Defines the time between successive key repeats in milliseconds. |
| 68 | */ |
| 69 | private static final int KEY_REPEAT_DELAY = 50; |
| 70 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | /** |
| 72 | * Defines the duration in milliseconds a user needs to hold down the |
| 73 | * appropriate button to bring up the global actions dialog (power off, |
| 74 | * lock screen, etc). |
| 75 | */ |
| 76 | private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 77 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | /** |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 79 | * Defines the duration in milliseconds we will wait to see if a touch event |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | * is a tap or a scroll. If the user does not move within this interval, it is |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 81 | * considered to be a tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | */ |
Alan Viverette | 97d9b65 | 2014-03-17 15:33:05 -0700 | [diff] [blame] | 83 | private static final int TAP_TIMEOUT = 100; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 84 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 85 | /** |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 86 | * Defines the duration in milliseconds we will wait to see if a touch event |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | * is a jump tap. If the user does not complete the jump tap within this interval, it is |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 88 | * considered to be a tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | */ |
| 90 | private static final int JUMP_TAP_TIMEOUT = 500; |
| 91 | |
| 92 | /** |
| 93 | * Defines the duration in milliseconds between the first tap's up event and |
| 94 | * the second tap's down event for an interaction to be considered a |
| 95 | * double-tap. |
| 96 | */ |
| 97 | private static final int DOUBLE_TAP_TIMEOUT = 300; |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 98 | |
| 99 | /** |
Adam Powell | af1785f | 2013-09-05 13:44:45 -0700 | [diff] [blame] | 100 | * Defines the minimum duration in milliseconds between the first tap's up event and |
| 101 | * the second tap's down event for an interaction to be considered a |
| 102 | * double-tap. |
| 103 | */ |
| 104 | private static final int DOUBLE_TAP_MIN_TIME = 40; |
| 105 | |
| 106 | /** |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 107 | * Defines the maximum duration in milliseconds between a touch pad |
| 108 | * touch and release for a given touch to be considered a tap (click) as |
| 109 | * opposed to a hover movement gesture. |
| 110 | */ |
| 111 | private static final int HOVER_TAP_TIMEOUT = 150; |
| 112 | |
| 113 | /** |
| 114 | * Defines the maximum distance in pixels that a touch pad touch can move |
| 115 | * before being released for it to be considered a tap (click) as opposed |
| 116 | * to a hover movement gesture. |
| 117 | */ |
| 118 | private static final int HOVER_TAP_SLOP = 20; |
| 119 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 120 | /** |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 121 | * Defines the duration in milliseconds we want to display zoom controls in response |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 122 | * to a user panning within an application. |
| 123 | */ |
| 124 | private static final int ZOOM_CONTROLS_TIMEOUT = 3000; |
| 125 | |
| 126 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 127 | * Inset in dips to look for touchable content when the user touches the edge of the screen |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 128 | */ |
| 129 | private static final int EDGE_SLOP = 12; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 130 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | /** |
Adam Powell | 7d39f85 | 2011-12-05 19:26:54 -0800 | [diff] [blame] | 132 | * Distance a touch can wander before we think the user is scrolling in dips. |
| 133 | * Note that this value defined here is only used as a fallback by legacy/misbehaving |
| 134 | * applications that do not provide a Context for determining density/configuration-dependent |
| 135 | * values. |
| 136 | * |
| 137 | * To alter this value, see the configuration resource config_viewConfigurationTouchSlop |
| 138 | * in frameworks/base/core/res/res/values/config.xml or the appropriate device resource overlay. |
| 139 | * It may be appropriate to tweak this on a device-specific basis in an overlay based on |
| 140 | * the characteristics of the touch panel and firmware. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | */ |
Adam Powell | 6720a87 | 2011-12-07 17:35:32 -0800 | [diff] [blame] | 142 | private static final int TOUCH_SLOP = 8; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 143 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 144 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 145 | * Distance the first touch can wander before we stop considering this event a double tap |
| 146 | * (in dips) |
| 147 | */ |
| 148 | private static final int DOUBLE_TAP_TOUCH_SLOP = TOUCH_SLOP; |
| 149 | |
| 150 | /** |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 151 | * Distance a touch can wander before we think the user is attempting a paged scroll |
| 152 | * (in dips) |
Adam Powell | 7d39f85 | 2011-12-05 19:26:54 -0800 | [diff] [blame] | 153 | * |
| 154 | * Note that this value defined here is only used as a fallback by legacy/misbehaving |
| 155 | * applications that do not provide a Context for determining density/configuration-dependent |
| 156 | * values. |
| 157 | * |
| 158 | * See the note above on {@link #TOUCH_SLOP} regarding the dimen resource |
| 159 | * config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of |
| 160 | * config_viewConfigurationTouchSlop * 2 when provided with a Context. |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 161 | */ |
Adam Powell | b7ef1d9 | 2010-03-11 10:25:24 -0800 | [diff] [blame] | 162 | private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 163 | |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 164 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 165 | * Distance in dips between the first touch and second touch to still be considered a double tap |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | */ |
| 167 | private static final int DOUBLE_TAP_SLOP = 100; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 168 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 170 | * Distance in dips a touch needs to be outside of a window's bounds for it to |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 | * count as outside for purposes of dismissing the window. |
| 172 | */ |
| 173 | private static final int WINDOW_TOUCH_SLOP = 16; |
| 174 | |
| 175 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 176 | * Minimum velocity to initiate a fling, as measured in dips per second |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | */ |
| 178 | private static final int MINIMUM_FLING_VELOCITY = 50; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 179 | |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 180 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 181 | * Maximum velocity to initiate a fling, as measured in dips per second |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 182 | */ |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 183 | private static final int MAXIMUM_FLING_VELOCITY = 8000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 184 | |
| 185 | /** |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 186 | * Delay before dispatching a recurring accessibility event in milliseconds. |
| 187 | * This delay guarantees that a recurring event will be send at most once |
| 188 | * during the {@link #SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS} time |
| 189 | * frame. |
| 190 | */ |
Svetoslav Ganov | e15ccb9 | 2012-05-16 15:48:55 -0700 | [diff] [blame] | 191 | private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 100; |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 192 | |
| 193 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | * The maximum size of View's drawing cache, expressed in bytes. This size |
| 195 | * should be at least equal to the size of the screen in ARGB888 format. |
| 196 | */ |
| 197 | @Deprecated |
Romain Guy | 0211a0a | 2011-02-14 16:34:59 -0800 | [diff] [blame] | 198 | private static final int MAXIMUM_DRAWING_CACHE_SIZE = 480 * 800 * 4; // ARGB8888 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 199 | |
| 200 | /** |
| 201 | * The coefficient of friction applied to flings/scrolls. |
| 202 | */ |
Romain Guy | 0211a0a | 2011-02-14 16:34:59 -0800 | [diff] [blame] | 203 | private static final float SCROLL_FRICTION = 0.015f; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 204 | |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 205 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 206 | * Max distance in dips to overscroll for edge effects |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 207 | */ |
| 208 | private static final int OVERSCROLL_DISTANCE = 0; |
| 209 | |
| 210 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 211 | * Max distance in dips to overfling for edge effects |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 212 | */ |
Gilles Debunne | 8ce7aab | 2011-01-25 11:23:30 -0800 | [diff] [blame] | 213 | private static final int OVERFLING_DISTANCE = 6; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 214 | |
Adam Powell | cc84ff4 | 2013-12-04 11:15:29 -0800 | [diff] [blame] | 215 | /** |
Abodunrinwa Toki | 9e21128 | 2015-06-05 02:46:57 +0100 | [diff] [blame] | 216 | * Default duration to hide an action mode for. |
Abodunrinwa Toki | fd3a3a1 | 2015-05-05 20:04:34 +0100 | [diff] [blame] | 217 | */ |
Abodunrinwa Toki | 9e21128 | 2015-06-05 02:46:57 +0100 | [diff] [blame] | 218 | private static final long ACTION_MODE_HIDE_DURATION_DEFAULT = 2000; |
Abodunrinwa Toki | fd3a3a1 | 2015-05-05 20:04:34 +0100 | [diff] [blame] | 219 | |
| 220 | /** |
Adam Powell | cc84ff4 | 2013-12-04 11:15:29 -0800 | [diff] [blame] | 221 | * Configuration values for overriding {@link #hasPermanentMenuKey()} behavior. |
| 222 | * These constants must match the definition in res/values/config.xml. |
| 223 | */ |
| 224 | private static final int HAS_PERMANENT_MENU_KEY_AUTODETECT = 0; |
| 225 | private static final int HAS_PERMANENT_MENU_KEY_TRUE = 1; |
| 226 | private static final int HAS_PERMANENT_MENU_KEY_FALSE = 2; |
| 227 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 228 | private final int mEdgeSlop; |
| 229 | private final int mFadingEdgeLength; |
| 230 | private final int mMinimumFlingVelocity; |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 231 | private final int mMaximumFlingVelocity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 232 | private final int mScrollbarSize; |
| 233 | private final int mTouchSlop; |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 234 | private final int mDoubleTapTouchSlop; |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 235 | private final int mPagingTouchSlop; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | private final int mDoubleTapSlop; |
| 237 | private final int mWindowTouchSlop; |
| 238 | private final int mMaximumDrawingCacheSize; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 239 | private final int mOverscrollDistance; |
| 240 | private final int mOverflingDistance; |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 241 | private final boolean mFadingMarqueeEnabled; |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 242 | private final long mGlobalActionsKeyTimeout; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 243 | |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 244 | private boolean sHasPermanentMenuKey; |
| 245 | private boolean sHasPermanentMenuKeySet; |
| 246 | |
Xavier Ducrohet | 7f9f99ea | 2011-08-11 10:16:17 -0700 | [diff] [blame] | 247 | static final SparseArray<ViewConfiguration> sConfigurations = |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 248 | new SparseArray<ViewConfiguration>(2); |
| 249 | |
| 250 | /** |
| 251 | * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead. |
| 252 | */ |
| 253 | @Deprecated |
| 254 | public ViewConfiguration() { |
| 255 | mEdgeSlop = EDGE_SLOP; |
| 256 | mFadingEdgeLength = FADING_EDGE_LENGTH; |
| 257 | mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY; |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 258 | mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | mScrollbarSize = SCROLL_BAR_SIZE; |
| 260 | mTouchSlop = TOUCH_SLOP; |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 261 | mDoubleTapTouchSlop = DOUBLE_TAP_TOUCH_SLOP; |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 262 | mPagingTouchSlop = PAGING_TOUCH_SLOP; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 263 | mDoubleTapSlop = DOUBLE_TAP_SLOP; |
| 264 | mWindowTouchSlop = WINDOW_TOUCH_SLOP; |
| 265 | //noinspection deprecation |
| 266 | mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 267 | mOverscrollDistance = OVERSCROLL_DISTANCE; |
| 268 | mOverflingDistance = OVERFLING_DISTANCE; |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 269 | mFadingMarqueeEnabled = true; |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 270 | mGlobalActionsKeyTimeout = GLOBAL_ACTIONS_KEY_TIMEOUT; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Creates a new configuration for the specified context. The configuration depends on |
| 275 | * various parameters of the context, like the dimension of the display or the density |
| 276 | * of the display. |
| 277 | * |
| 278 | * @param context The application context used to initialize this view configuration. |
| 279 | * |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 280 | * @see #get(android.content.Context) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 281 | * @see android.util.DisplayMetrics |
| 282 | */ |
| 283 | private ViewConfiguration(Context context) { |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 284 | final Resources res = context.getResources(); |
| 285 | final DisplayMetrics metrics = res.getDisplayMetrics(); |
| 286 | final Configuration config = res.getConfiguration(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 287 | final float density = metrics.density; |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 288 | final float sizeAndDensity; |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 289 | if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) { |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 290 | sizeAndDensity = density * 1.5f; |
| 291 | } else { |
| 292 | sizeAndDensity = density; |
| 293 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 294 | |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 295 | mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f); |
| 296 | mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 297 | mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f); |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 298 | mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f); |
| 299 | mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 300 | |
| 301 | // Size of the screen in bytes, in ARGB_8888 format |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 302 | final WindowManager win = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 303 | final Display display = win.getDefaultDisplay(); |
Jeff Brown | a8b9def | 2012-07-23 14:22:49 -0700 | [diff] [blame] | 304 | final Point size = new Point(); |
| 305 | display.getRealSize(size); |
| 306 | mMaximumDrawingCacheSize = 4 * size.x * size.y; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 307 | |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 308 | mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f); |
| 309 | mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f); |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 310 | |
| 311 | if (!sHasPermanentMenuKeySet) { |
Adam Powell | cc84ff4 | 2013-12-04 11:15:29 -0800 | [diff] [blame] | 312 | final int configVal = res.getInteger( |
| 313 | com.android.internal.R.integer.config_overrideHasPermanentMenuKey); |
| 314 | |
| 315 | switch (configVal) { |
| 316 | default: |
| 317 | case HAS_PERMANENT_MENU_KEY_AUTODETECT: { |
| 318 | IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); |
| 319 | try { |
| 320 | sHasPermanentMenuKey = !wm.hasNavigationBar(); |
| 321 | sHasPermanentMenuKeySet = true; |
| 322 | } catch (RemoteException ex) { |
| 323 | sHasPermanentMenuKey = false; |
| 324 | } |
| 325 | } |
| 326 | break; |
| 327 | |
| 328 | case HAS_PERMANENT_MENU_KEY_TRUE: |
| 329 | sHasPermanentMenuKey = true; |
| 330 | sHasPermanentMenuKeySet = true; |
| 331 | break; |
| 332 | |
| 333 | case HAS_PERMANENT_MENU_KEY_FALSE: |
| 334 | sHasPermanentMenuKey = false; |
| 335 | sHasPermanentMenuKeySet = true; |
| 336 | break; |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 337 | } |
| 338 | } |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 339 | |
| 340 | mFadingMarqueeEnabled = res.getBoolean( |
| 341 | com.android.internal.R.bool.config_ui_enableFadingMarquee); |
Adam Powell | 7d39f85 | 2011-12-05 19:26:54 -0800 | [diff] [blame] | 342 | mTouchSlop = res.getDimensionPixelSize( |
| 343 | com.android.internal.R.dimen.config_viewConfigurationTouchSlop); |
| 344 | mPagingTouchSlop = mTouchSlop * 2; |
Adam Powell | e4b8ff8 | 2011-12-06 16:40:49 -0800 | [diff] [blame] | 345 | |
| 346 | mDoubleTapTouchSlop = mTouchSlop; |
Mindy Pereira | 23ffc73 | 2014-04-30 17:09:35 -0700 | [diff] [blame] | 347 | |
| 348 | mMinimumFlingVelocity = res.getDimensionPixelSize( |
| 349 | com.android.internal.R.dimen.config_viewMinFlingVelocity); |
| 350 | mMaximumFlingVelocity = res.getDimensionPixelSize( |
| 351 | com.android.internal.R.dimen.config_viewMaxFlingVelocity); |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 352 | mGlobalActionsKeyTimeout = res.getInteger( |
| 353 | com.android.internal.R.integer.config_globalActionsKeyTimeout); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Returns a configuration for the specified context. The configuration depends on |
| 358 | * various parameters of the context, like the dimension of the display or the |
| 359 | * density of the display. |
| 360 | * |
| 361 | * @param context The application context used to initialize the view configuration. |
| 362 | */ |
| 363 | public static ViewConfiguration get(Context context) { |
| 364 | final DisplayMetrics metrics = context.getResources().getDisplayMetrics(); |
| 365 | final int density = (int) (100.0f * metrics.density); |
| 366 | |
| 367 | ViewConfiguration configuration = sConfigurations.get(density); |
| 368 | if (configuration == null) { |
| 369 | configuration = new ViewConfiguration(context); |
| 370 | sConfigurations.put(density, configuration); |
| 371 | } |
| 372 | |
| 373 | return configuration; |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * @return The width of the horizontal scrollbar and the height of the vertical |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 378 | * scrollbar in dips |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 379 | * |
| 380 | * @deprecated Use {@link #getScaledScrollBarSize()} instead. |
| 381 | */ |
| 382 | @Deprecated |
| 383 | public static int getScrollBarSize() { |
| 384 | return SCROLL_BAR_SIZE; |
| 385 | } |
| 386 | |
| 387 | /** |
| 388 | * @return The width of the horizontal scrollbar and the height of the vertical |
| 389 | * scrollbar in pixels |
| 390 | */ |
| 391 | public int getScaledScrollBarSize() { |
| 392 | return mScrollbarSize; |
| 393 | } |
| 394 | |
| 395 | /** |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 396 | * @return Duration of the fade when scrollbars fade away in milliseconds |
| 397 | */ |
| 398 | public static int getScrollBarFadeDuration() { |
| 399 | return SCROLL_BAR_FADE_DURATION; |
| 400 | } |
| 401 | |
| 402 | /** |
Alan Viverette | 25f0e61 | 2015-02-27 12:34:30 -0800 | [diff] [blame] | 403 | * @return Default delay before the scrollbars fade in milliseconds |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 404 | */ |
| 405 | public static int getScrollDefaultDelay() { |
| 406 | return SCROLL_BAR_DEFAULT_DELAY; |
| 407 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 408 | |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 409 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 410 | * @return the length of the fading edges in dips |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 411 | * |
| 412 | * @deprecated Use {@link #getScaledFadingEdgeLength()} instead. |
| 413 | */ |
| 414 | @Deprecated |
| 415 | public static int getFadingEdgeLength() { |
| 416 | return FADING_EDGE_LENGTH; |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * @return the length of the fading edges in pixels |
| 421 | */ |
| 422 | public int getScaledFadingEdgeLength() { |
| 423 | return mFadingEdgeLength; |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * @return the duration in milliseconds of the pressed state in child |
| 428 | * components. |
| 429 | */ |
| 430 | public static int getPressedStateDuration() { |
| 431 | return PRESSED_STATE_DURATION; |
| 432 | } |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 433 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 434 | /** |
| 435 | * @return the duration in milliseconds before a press turns into |
| 436 | * a long press |
| 437 | */ |
| 438 | public static int getLongPressTimeout() { |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 439 | return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT, |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 440 | DEFAULT_LONG_PRESS_TIMEOUT); |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * @return the time before the first key repeat in milliseconds. |
| 445 | */ |
| 446 | public static int getKeyRepeatTimeout() { |
| 447 | return getLongPressTimeout(); |
| 448 | } |
| 449 | |
| 450 | /** |
| 451 | * @return the time between successive key repeats in milliseconds. |
| 452 | */ |
| 453 | public static int getKeyRepeatDelay() { |
| 454 | return KEY_REPEAT_DELAY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 455 | } |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 456 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 457 | /** |
| 458 | * @return the duration in milliseconds we will wait to see if a touch event |
| 459 | * is a tap or a scroll. If the user does not move within this interval, it is |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 460 | * considered to be a tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 461 | */ |
| 462 | public static int getTapTimeout() { |
| 463 | return TAP_TIMEOUT; |
| 464 | } |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 465 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 466 | /** |
| 467 | * @return the duration in milliseconds we will wait to see if a touch event |
| 468 | * is a jump tap. If the user does not move within this interval, it is |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 469 | * considered to be a tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 470 | */ |
| 471 | public static int getJumpTapTimeout() { |
| 472 | return JUMP_TAP_TIMEOUT; |
| 473 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 474 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 475 | /** |
| 476 | * @return the duration in milliseconds between the first tap's up event and |
| 477 | * the second tap's down event for an interaction to be considered a |
| 478 | * double-tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 479 | */ |
| 480 | public static int getDoubleTapTimeout() { |
| 481 | return DOUBLE_TAP_TIMEOUT; |
| 482 | } |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 483 | |
| 484 | /** |
Adam Powell | af1785f | 2013-09-05 13:44:45 -0700 | [diff] [blame] | 485 | * @return the minimum duration in milliseconds between the first tap's |
| 486 | * up event and the second tap's down event for an interaction to be considered a |
| 487 | * double-tap. |
| 488 | * |
| 489 | * @hide |
| 490 | */ |
| 491 | public static int getDoubleTapMinTime() { |
| 492 | return DOUBLE_TAP_MIN_TIME; |
| 493 | } |
| 494 | |
| 495 | /** |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 496 | * @return the maximum duration in milliseconds between a touch pad |
| 497 | * touch and release for a given touch to be considered a tap (click) as |
| 498 | * opposed to a hover movement gesture. |
| 499 | * @hide |
| 500 | */ |
| 501 | public static int getHoverTapTimeout() { |
| 502 | return HOVER_TAP_TIMEOUT; |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * @return the maximum distance in pixels that a touch pad touch can move |
| 507 | * before being released for it to be considered a tap (click) as opposed |
| 508 | * to a hover movement gesture. |
| 509 | * @hide |
| 510 | */ |
| 511 | public static int getHoverTapSlop() { |
| 512 | return HOVER_TAP_SLOP; |
| 513 | } |
| 514 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 515 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 516 | * @return Inset in dips to look for touchable content when the user touches the edge of the |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 517 | * screen |
| 518 | * |
| 519 | * @deprecated Use {@link #getScaledEdgeSlop()} instead. |
| 520 | */ |
| 521 | @Deprecated |
| 522 | public static int getEdgeSlop() { |
| 523 | return EDGE_SLOP; |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * @return Inset in pixels to look for touchable content when the user touches the edge of the |
| 528 | * screen |
| 529 | */ |
| 530 | public int getScaledEdgeSlop() { |
| 531 | return mEdgeSlop; |
| 532 | } |
| 533 | |
| 534 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 535 | * @return Distance in dips a touch can wander before we think the user is scrolling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 536 | * |
| 537 | * @deprecated Use {@link #getScaledTouchSlop()} instead. |
| 538 | */ |
| 539 | @Deprecated |
| 540 | public static int getTouchSlop() { |
| 541 | return TOUCH_SLOP; |
| 542 | } |
| 543 | |
| 544 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 545 | * @return Distance in pixels a touch can wander before we think the user is scrolling |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 546 | */ |
| 547 | public int getScaledTouchSlop() { |
| 548 | return mTouchSlop; |
| 549 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 550 | |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 551 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 552 | * @return Distance in pixels the first touch can wander before we do not consider this a |
| 553 | * potential double tap event |
| 554 | * @hide |
| 555 | */ |
| 556 | public int getScaledDoubleTapTouchSlop() { |
| 557 | return mDoubleTapTouchSlop; |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * @return Distance in pixels a touch can wander before we think the user is scrolling a full |
| 562 | * page |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 563 | */ |
| 564 | public int getScaledPagingTouchSlop() { |
| 565 | return mPagingTouchSlop; |
| 566 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 567 | |
| 568 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 569 | * @return Distance in dips between the first touch and second touch to still be |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 570 | * considered a double tap |
| 571 | * @deprecated Use {@link #getScaledDoubleTapSlop()} instead. |
| 572 | * @hide The only client of this should be GestureDetector, which needs this |
| 573 | * for clients that still use its deprecated constructor. |
| 574 | */ |
| 575 | @Deprecated |
| 576 | public static int getDoubleTapSlop() { |
| 577 | return DOUBLE_TAP_SLOP; |
| 578 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 579 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 580 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 581 | * @return Distance in pixels between the first touch and second touch to still be |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 582 | * considered a double tap |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 583 | */ |
| 584 | public int getScaledDoubleTapSlop() { |
| 585 | return mDoubleTapSlop; |
| 586 | } |
| 587 | |
| 588 | /** |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 589 | * Interval for dispatching a recurring accessibility event in milliseconds. |
| 590 | * This interval guarantees that a recurring event will be send at most once |
| 591 | * during the {@link #getSendRecurringAccessibilityEventsInterval()} time frame. |
| 592 | * |
| 593 | * @return The delay in milliseconds. |
| 594 | * |
| 595 | * @hide |
| 596 | */ |
| 597 | public static long getSendRecurringAccessibilityEventsInterval() { |
| 598 | return SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS; |
| 599 | } |
| 600 | |
| 601 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 602 | * @return Distance in dips a touch must be outside the bounds of a window for it |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 603 | * to be counted as outside the window for purposes of dismissing that |
| 604 | * window. |
| 605 | * |
| 606 | * @deprecated Use {@link #getScaledWindowTouchSlop()} instead. |
| 607 | */ |
| 608 | @Deprecated |
| 609 | public static int getWindowTouchSlop() { |
| 610 | return WINDOW_TOUCH_SLOP; |
| 611 | } |
| 612 | |
| 613 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 614 | * @return Distance in pixels a touch must be outside the bounds of a window for it |
| 615 | * to be counted as outside the window for purposes of dismissing that window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 616 | */ |
| 617 | public int getScaledWindowTouchSlop() { |
| 618 | return mWindowTouchSlop; |
| 619 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 620 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 621 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 622 | * @return Minimum velocity to initiate a fling, as measured in dips per second. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 623 | * |
| 624 | * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead. |
| 625 | */ |
| 626 | @Deprecated |
| 627 | public static int getMinimumFlingVelocity() { |
| 628 | return MINIMUM_FLING_VELOCITY; |
| 629 | } |
| 630 | |
| 631 | /** |
| 632 | * @return Minimum velocity to initiate a fling, as measured in pixels per second. |
| 633 | */ |
| 634 | public int getScaledMinimumFlingVelocity() { |
| 635 | return mMinimumFlingVelocity; |
| 636 | } |
| 637 | |
| 638 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 639 | * @return Maximum velocity to initiate a fling, as measured in dips per second. |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 640 | * |
| 641 | * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead. |
| 642 | */ |
| 643 | @Deprecated |
| 644 | public static int getMaximumFlingVelocity() { |
| 645 | return MAXIMUM_FLING_VELOCITY; |
| 646 | } |
| 647 | |
| 648 | /** |
| 649 | * @return Maximum velocity to initiate a fling, as measured in pixels per second. |
| 650 | */ |
| 651 | public int getScaledMaximumFlingVelocity() { |
| 652 | return mMaximumFlingVelocity; |
| 653 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 654 | |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 655 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 656 | * The maximum drawing cache size expressed in bytes. |
| 657 | * |
| 658 | * @return the maximum size of View's drawing cache expressed in bytes |
| 659 | * |
| 660 | * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead. |
| 661 | */ |
| 662 | @Deprecated |
| 663 | public static int getMaximumDrawingCacheSize() { |
| 664 | //noinspection deprecation |
| 665 | return MAXIMUM_DRAWING_CACHE_SIZE; |
| 666 | } |
| 667 | |
| 668 | /** |
| 669 | * The maximum drawing cache size expressed in bytes. |
| 670 | * |
| 671 | * @return the maximum size of View's drawing cache expressed in bytes |
| 672 | */ |
| 673 | public int getScaledMaximumDrawingCacheSize() { |
| 674 | return mMaximumDrawingCacheSize; |
| 675 | } |
| 676 | |
| 677 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 678 | * @return The maximum distance a View should overscroll by when showing edge effects (in |
| 679 | * pixels). |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 680 | */ |
| 681 | public int getScaledOverscrollDistance() { |
| 682 | return mOverscrollDistance; |
| 683 | } |
| 684 | |
| 685 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 686 | * @return The maximum distance a View should overfling by when showing edge effects (in |
| 687 | * pixels). |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 688 | */ |
| 689 | public int getScaledOverflingDistance() { |
| 690 | return mOverflingDistance; |
| 691 | } |
| 692 | |
| 693 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 694 | * The amount of time that the zoom controls should be |
| 695 | * displayed on the screen expressed in milliseconds. |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 696 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 697 | * @return the time the zoom controls should be visible expressed |
| 698 | * in milliseconds. |
| 699 | */ |
| 700 | public static long getZoomControlsTimeout() { |
| 701 | return ZOOM_CONTROLS_TIMEOUT; |
| 702 | } |
| 703 | |
| 704 | /** |
| 705 | * The amount of time a user needs to press the relevant key to bring up |
| 706 | * the global actions dialog. |
| 707 | * |
| 708 | * @return how long a user needs to press the relevant key to bring up |
| 709 | * the global actions dialog. |
Justin Koh | 8031fa0 | 2014-05-05 16:28:49 -0700 | [diff] [blame] | 710 | * @deprecated This timeout should not be used by applications |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 711 | */ |
Justin Koh | 1aa59f8 | 2014-05-04 12:13:25 -0700 | [diff] [blame] | 712 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 713 | public static long getGlobalActionKeyTimeout() { |
| 714 | return GLOBAL_ACTIONS_KEY_TIMEOUT; |
| 715 | } |
| 716 | |
| 717 | /** |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 718 | * The amount of time a user needs to press the relevant key to bring up |
| 719 | * the global actions dialog. |
| 720 | * |
| 721 | * @return how long a user needs to press the relevant key to bring up |
| 722 | * the global actions dialog. |
Justin Koh | 1aa59f8 | 2014-05-04 12:13:25 -0700 | [diff] [blame] | 723 | * @hide |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 724 | */ |
| 725 | public long getDeviceGlobalActionKeyTimeout() { |
| 726 | return mGlobalActionsKeyTimeout; |
| 727 | } |
| 728 | |
| 729 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 730 | * The amount of friction applied to scrolls and flings. |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 731 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 732 | * @return A scalar dimensionless value representing the coefficient of |
| 733 | * friction. |
| 734 | */ |
| 735 | public static float getScrollFriction() { |
| 736 | return SCROLL_FRICTION; |
| 737 | } |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 738 | |
| 739 | /** |
Abodunrinwa Toki | 9e21128 | 2015-06-05 02:46:57 +0100 | [diff] [blame] | 740 | * @return the default duration in milliseconds for {@link ActionMode#hide(long)}. |
Abodunrinwa Toki | fd3a3a1 | 2015-05-05 20:04:34 +0100 | [diff] [blame] | 741 | */ |
Abodunrinwa Toki | 9e21128 | 2015-06-05 02:46:57 +0100 | [diff] [blame] | 742 | public static long getDefaultActionModeHideDuration() { |
| 743 | return ACTION_MODE_HIDE_DURATION_DEFAULT; |
Abodunrinwa Toki | fd3a3a1 | 2015-05-05 20:04:34 +0100 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | /** |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 747 | * Report if the device has a permanent menu key available to the user. |
| 748 | * |
| 749 | * <p>As of Android 3.0, devices may not have a permanent menu key available. |
| 750 | * Apps should use the action bar to present menu options to users. |
| 751 | * However, there are some apps where the action bar is inappropriate |
| 752 | * or undesirable. This method may be used to detect if a menu key is present. |
| 753 | * If not, applications should provide another on-screen affordance to access |
| 754 | * functionality. |
| 755 | * |
| 756 | * @return true if a permanent menu key is present, false otherwise. |
| 757 | */ |
| 758 | public boolean hasPermanentMenuKey() { |
| 759 | return sHasPermanentMenuKey; |
| 760 | } |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 761 | |
| 762 | /** |
| 763 | * @hide |
| 764 | * @return Whether or not marquee should use fading edges. |
| 765 | */ |
| 766 | public boolean isFadingMarqueeEnabled() { |
| 767 | return mFadingMarqueeEnabled; |
| 768 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 769 | } |