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