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; |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 22 | import android.os.Bundle; |
| 23 | import android.provider.Settings; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.util.DisplayMetrics; |
| 25 | import android.util.SparseArray; |
| 26 | |
| 27 | /** |
| 28 | * Contains methods to standard constants used in the UI for timeouts, sizes, and distances. |
| 29 | */ |
| 30 | public class ViewConfiguration { |
| 31 | /** |
Romain Guy | dbc26d2 | 2010-10-11 17:58:29 -0700 | [diff] [blame] | 32 | * Expected bit depth of the display panel. |
| 33 | * |
| 34 | * @hide |
| 35 | */ |
| 36 | public static final float PANEL_BIT_DEPTH = 24; |
| 37 | |
| 38 | /** |
| 39 | * Minimum alpha required for a view to draw. |
| 40 | * |
| 41 | * @hide |
| 42 | */ |
| 43 | public static final float ALPHA_THRESHOLD = 0.5f / PANEL_BIT_DEPTH; |
Romain Guy | 909cbaf | 2010-10-13 18:19:48 -0700 | [diff] [blame] | 44 | /** |
| 45 | * @hide |
| 46 | */ |
| 47 | public static final float ALPHA_THRESHOLD_INT = 0x7f / PANEL_BIT_DEPTH; |
| 48 | |
Romain Guy | dbc26d2 | 2010-10-11 17:58:29 -0700 | [diff] [blame] | 49 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | * Defines the width of the horizontal scrollbar and the height of the vertical scrollbar in |
| 51 | * pixels |
| 52 | */ |
| 53 | private static final int SCROLL_BAR_SIZE = 10; |
| 54 | |
| 55 | /** |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 56 | * Duration of the fade when scrollbars fade away in milliseconds |
| 57 | */ |
| 58 | private static final int SCROLL_BAR_FADE_DURATION = 250; |
| 59 | |
| 60 | /** |
| 61 | * Default delay before the scrollbars fade in milliseconds |
| 62 | */ |
| 63 | private static final int SCROLL_BAR_DEFAULT_DELAY = 300; |
| 64 | |
| 65 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | * Defines the length of the fading edges in pixels |
| 67 | */ |
| 68 | private static final int FADING_EDGE_LENGTH = 12; |
| 69 | |
| 70 | /** |
| 71 | * Defines the duration in milliseconds of the pressed state in child |
| 72 | * components. |
| 73 | */ |
Adam Powell | e14579b | 2009-12-16 18:39:52 -0800 | [diff] [blame] | 74 | private static final int PRESSED_STATE_DURATION = 125; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | |
| 76 | /** |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame^] | 77 | * 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] | 78 | * a long press |
| 79 | */ |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame^] | 80 | private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; |
| 81 | |
| 82 | /** |
| 83 | * Defines the time between successive key repeats in milliseconds. |
| 84 | */ |
| 85 | private static final int KEY_REPEAT_DELAY = 50; |
| 86 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | /** |
| 88 | * Defines the duration in milliseconds a user needs to hold down the |
| 89 | * appropriate button to bring up the global actions dialog (power off, |
| 90 | * lock screen, etc). |
| 91 | */ |
| 92 | private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500; |
| 93 | |
| 94 | /** |
| 95 | * Defines the duration in milliseconds we will wait to see if a touch event |
| 96 | * is a tap or a scroll. If the user does not move within this interval, it is |
| 97 | * considered to be a tap. |
| 98 | */ |
Adam Powell | e14579b | 2009-12-16 18:39:52 -0800 | [diff] [blame] | 99 | private static final int TAP_TIMEOUT = 115; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | |
| 101 | /** |
| 102 | * Defines the duration in milliseconds we will wait to see if a touch event |
| 103 | * is a jump tap. If the user does not complete the jump tap within this interval, it is |
| 104 | * considered to be a tap. |
| 105 | */ |
| 106 | private static final int JUMP_TAP_TIMEOUT = 500; |
| 107 | |
| 108 | /** |
| 109 | * Defines the duration in milliseconds between the first tap's up event and |
| 110 | * the second tap's down event for an interaction to be considered a |
| 111 | * double-tap. |
| 112 | */ |
| 113 | private static final int DOUBLE_TAP_TIMEOUT = 300; |
| 114 | |
| 115 | /** |
| 116 | * Defines the duration in milliseconds we want to display zoom controls in response |
| 117 | * to a user panning within an application. |
| 118 | */ |
| 119 | private static final int ZOOM_CONTROLS_TIMEOUT = 3000; |
| 120 | |
| 121 | /** |
| 122 | * Inset in pixels to look for touchable content when the user touches the edge of the screen |
| 123 | */ |
| 124 | private static final int EDGE_SLOP = 12; |
| 125 | |
| 126 | /** |
| 127 | * Distance a touch can wander before we think the user is scrolling in pixels |
| 128 | */ |
Dianne Hackborn | 3e2ac88 | 2009-09-25 01:34:28 -0700 | [diff] [blame] | 129 | private static final int TOUCH_SLOP = 16; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 130 | |
| 131 | /** |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 132 | * Distance a touch can wander before we think the user is attempting a paged scroll |
| 133 | * (in dips) |
| 134 | */ |
Adam Powell | b7ef1d9 | 2010-03-11 10:25:24 -0800 | [diff] [blame] | 135 | private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2; |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 136 | |
| 137 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 138 | * Distance between the first touch and second touch to still be considered a double tap |
| 139 | */ |
| 140 | private static final int DOUBLE_TAP_SLOP = 100; |
| 141 | |
| 142 | /** |
| 143 | * Distance a touch needs to be outside of a window's bounds for it to |
| 144 | * count as outside for purposes of dismissing the window. |
| 145 | */ |
| 146 | private static final int WINDOW_TOUCH_SLOP = 16; |
| 147 | |
| 148 | /** |
| 149 | * Minimum velocity to initiate a fling, as measured in pixels per second |
| 150 | */ |
| 151 | private static final int MINIMUM_FLING_VELOCITY = 50; |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 152 | |
| 153 | /** |
| 154 | * Maximum velocity to initiate a fling, as measured in pixels per second |
| 155 | */ |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 156 | private static final int MAXIMUM_FLING_VELOCITY = 8000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 157 | |
| 158 | /** |
| 159 | * The maximum size of View's drawing cache, expressed in bytes. This size |
| 160 | * should be at least equal to the size of the screen in ARGB888 format. |
| 161 | */ |
| 162 | @Deprecated |
Romain Guy | 0211a0a | 2011-02-14 16:34:59 -0800 | [diff] [blame] | 163 | 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] | 164 | |
| 165 | /** |
| 166 | * The coefficient of friction applied to flings/scrolls. |
| 167 | */ |
Romain Guy | 0211a0a | 2011-02-14 16:34:59 -0800 | [diff] [blame] | 168 | private static final float SCROLL_FRICTION = 0.015f; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 170 | /** |
| 171 | * Max distance to overscroll for edge effects |
| 172 | */ |
| 173 | private static final int OVERSCROLL_DISTANCE = 0; |
| 174 | |
| 175 | /** |
| 176 | * Max distance to overfling for edge effects |
| 177 | */ |
Gilles Debunne | 8ce7aab | 2011-01-25 11:23:30 -0800 | [diff] [blame] | 178 | private static final int OVERFLING_DISTANCE = 6; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 179 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 180 | private final int mEdgeSlop; |
| 181 | private final int mFadingEdgeLength; |
| 182 | private final int mMinimumFlingVelocity; |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 183 | private final int mMaximumFlingVelocity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 184 | private final int mScrollbarSize; |
| 185 | private final int mTouchSlop; |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 186 | private final int mPagingTouchSlop; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 187 | private final int mDoubleTapSlop; |
| 188 | private final int mWindowTouchSlop; |
| 189 | private final int mMaximumDrawingCacheSize; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 190 | private final int mOverscrollDistance; |
| 191 | private final int mOverflingDistance; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 192 | |
| 193 | private static final SparseArray<ViewConfiguration> sConfigurations = |
| 194 | new SparseArray<ViewConfiguration>(2); |
| 195 | |
| 196 | /** |
| 197 | * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead. |
| 198 | */ |
| 199 | @Deprecated |
| 200 | public ViewConfiguration() { |
| 201 | mEdgeSlop = EDGE_SLOP; |
| 202 | mFadingEdgeLength = FADING_EDGE_LENGTH; |
| 203 | mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY; |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 204 | mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 205 | mScrollbarSize = SCROLL_BAR_SIZE; |
| 206 | mTouchSlop = TOUCH_SLOP; |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 207 | mPagingTouchSlop = PAGING_TOUCH_SLOP; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 208 | mDoubleTapSlop = DOUBLE_TAP_SLOP; |
| 209 | mWindowTouchSlop = WINDOW_TOUCH_SLOP; |
| 210 | //noinspection deprecation |
| 211 | mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 212 | mOverscrollDistance = OVERSCROLL_DISTANCE; |
| 213 | mOverflingDistance = OVERFLING_DISTANCE; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Creates a new configuration for the specified context. The configuration depends on |
| 218 | * various parameters of the context, like the dimension of the display or the density |
| 219 | * of the display. |
| 220 | * |
| 221 | * @param context The application context used to initialize this view configuration. |
| 222 | * |
| 223 | * @see #get(android.content.Context) |
| 224 | * @see android.util.DisplayMetrics |
| 225 | */ |
| 226 | private ViewConfiguration(Context context) { |
| 227 | final DisplayMetrics metrics = context.getResources().getDisplayMetrics(); |
| 228 | final float density = metrics.density; |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 229 | final float sizeAndDensity; |
| 230 | if (context.getResources().getConfiguration().isLayoutSizeAtLeast( |
| 231 | Configuration.SCREENLAYOUT_SIZE_XLARGE)) { |
| 232 | sizeAndDensity = density * 1.5f; |
| 233 | } else { |
| 234 | sizeAndDensity = density; |
| 235 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 237 | mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f); |
| 238 | mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 239 | mMinimumFlingVelocity = (int) (density * MINIMUM_FLING_VELOCITY + 0.5f); |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 240 | mMaximumFlingVelocity = (int) (density * MAXIMUM_FLING_VELOCITY + 0.5f); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 241 | mScrollbarSize = (int) (density * SCROLL_BAR_SIZE + 0.5f); |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 242 | mTouchSlop = (int) (sizeAndDensity * TOUCH_SLOP + 0.5f); |
| 243 | mPagingTouchSlop = (int) (sizeAndDensity * PAGING_TOUCH_SLOP + 0.5f); |
| 244 | mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f); |
| 245 | mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | |
| 247 | // Size of the screen in bytes, in ARGB_8888 format |
| 248 | mMaximumDrawingCacheSize = 4 * metrics.widthPixels * metrics.heightPixels; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 249 | |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 250 | mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f); |
| 251 | mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Returns a configuration for the specified context. The configuration depends on |
| 256 | * various parameters of the context, like the dimension of the display or the |
| 257 | * density of the display. |
| 258 | * |
| 259 | * @param context The application context used to initialize the view configuration. |
| 260 | */ |
| 261 | public static ViewConfiguration get(Context context) { |
| 262 | final DisplayMetrics metrics = context.getResources().getDisplayMetrics(); |
| 263 | final int density = (int) (100.0f * metrics.density); |
| 264 | |
| 265 | ViewConfiguration configuration = sConfigurations.get(density); |
| 266 | if (configuration == null) { |
| 267 | configuration = new ViewConfiguration(context); |
| 268 | sConfigurations.put(density, configuration); |
| 269 | } |
| 270 | |
| 271 | return configuration; |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * @return The width of the horizontal scrollbar and the height of the vertical |
| 276 | * scrollbar in pixels |
| 277 | * |
| 278 | * @deprecated Use {@link #getScaledScrollBarSize()} instead. |
| 279 | */ |
| 280 | @Deprecated |
| 281 | public static int getScrollBarSize() { |
| 282 | return SCROLL_BAR_SIZE; |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * @return The width of the horizontal scrollbar and the height of the vertical |
| 287 | * scrollbar in pixels |
| 288 | */ |
| 289 | public int getScaledScrollBarSize() { |
| 290 | return mScrollbarSize; |
| 291 | } |
| 292 | |
| 293 | /** |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 294 | * @return Duration of the fade when scrollbars fade away in milliseconds |
| 295 | */ |
| 296 | public static int getScrollBarFadeDuration() { |
| 297 | return SCROLL_BAR_FADE_DURATION; |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * @return Default delay before the scrollbars fade in milliseconds |
| 302 | */ |
| 303 | public static int getScrollDefaultDelay() { |
| 304 | return SCROLL_BAR_DEFAULT_DELAY; |
| 305 | } |
| 306 | |
| 307 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 308 | * @return the length of the fading edges in pixels |
| 309 | * |
| 310 | * @deprecated Use {@link #getScaledFadingEdgeLength()} instead. |
| 311 | */ |
| 312 | @Deprecated |
| 313 | public static int getFadingEdgeLength() { |
| 314 | return FADING_EDGE_LENGTH; |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * @return the length of the fading edges in pixels |
| 319 | */ |
| 320 | public int getScaledFadingEdgeLength() { |
| 321 | return mFadingEdgeLength; |
| 322 | } |
| 323 | |
| 324 | /** |
| 325 | * @return the duration in milliseconds of the pressed state in child |
| 326 | * components. |
| 327 | */ |
| 328 | public static int getPressedStateDuration() { |
| 329 | return PRESSED_STATE_DURATION; |
| 330 | } |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 331 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | /** |
| 333 | * @return the duration in milliseconds before a press turns into |
| 334 | * a long press |
| 335 | */ |
| 336 | public static int getLongPressTimeout() { |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 337 | return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT, |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame^] | 338 | DEFAULT_LONG_PRESS_TIMEOUT); |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * @return the time before the first key repeat in milliseconds. |
| 343 | */ |
| 344 | public static int getKeyRepeatTimeout() { |
| 345 | return getLongPressTimeout(); |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * @return the time between successive key repeats in milliseconds. |
| 350 | */ |
| 351 | public static int getKeyRepeatDelay() { |
| 352 | return KEY_REPEAT_DELAY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 353 | } |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 354 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 355 | /** |
| 356 | * @return the duration in milliseconds we will wait to see if a touch event |
| 357 | * is a tap or a scroll. If the user does not move within this interval, it is |
| 358 | * considered to be a tap. |
| 359 | */ |
| 360 | public static int getTapTimeout() { |
| 361 | return TAP_TIMEOUT; |
| 362 | } |
| 363 | |
| 364 | /** |
| 365 | * @return the duration in milliseconds we will wait to see if a touch event |
| 366 | * is a jump tap. If the user does not move within this interval, it is |
| 367 | * considered to be a tap. |
| 368 | */ |
| 369 | public static int getJumpTapTimeout() { |
| 370 | return JUMP_TAP_TIMEOUT; |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * @return the duration in milliseconds between the first tap's up event and |
| 375 | * the second tap's down event for an interaction to be considered a |
| 376 | * double-tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 377 | */ |
| 378 | public static int getDoubleTapTimeout() { |
| 379 | return DOUBLE_TAP_TIMEOUT; |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * @return Inset in pixels to look for touchable content when the user touches the edge of the |
| 384 | * screen |
| 385 | * |
| 386 | * @deprecated Use {@link #getScaledEdgeSlop()} instead. |
| 387 | */ |
| 388 | @Deprecated |
| 389 | public static int getEdgeSlop() { |
| 390 | return EDGE_SLOP; |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * @return Inset in pixels to look for touchable content when the user touches the edge of the |
| 395 | * screen |
| 396 | */ |
| 397 | public int getScaledEdgeSlop() { |
| 398 | return mEdgeSlop; |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * @return Distance a touch can wander before we think the user is scrolling in pixels |
| 403 | * |
| 404 | * @deprecated Use {@link #getScaledTouchSlop()} instead. |
| 405 | */ |
| 406 | @Deprecated |
| 407 | public static int getTouchSlop() { |
| 408 | return TOUCH_SLOP; |
| 409 | } |
| 410 | |
| 411 | /** |
| 412 | * @return Distance a touch can wander before we think the user is scrolling in pixels |
| 413 | */ |
| 414 | public int getScaledTouchSlop() { |
| 415 | return mTouchSlop; |
| 416 | } |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 417 | |
| 418 | /** |
| 419 | * @return Distance a touch can wander before we think the user is scrolling a full page |
| 420 | * in dips |
| 421 | */ |
| 422 | public int getScaledPagingTouchSlop() { |
| 423 | return mPagingTouchSlop; |
| 424 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 425 | |
| 426 | /** |
| 427 | * @return Distance between the first touch and second touch to still be |
| 428 | * considered a double tap |
| 429 | * @deprecated Use {@link #getScaledDoubleTapSlop()} instead. |
| 430 | * @hide The only client of this should be GestureDetector, which needs this |
| 431 | * for clients that still use its deprecated constructor. |
| 432 | */ |
| 433 | @Deprecated |
| 434 | public static int getDoubleTapSlop() { |
| 435 | return DOUBLE_TAP_SLOP; |
| 436 | } |
| 437 | |
| 438 | /** |
| 439 | * @return Distance between the first touch and second touch to still be |
| 440 | * considered a double tap |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 441 | */ |
| 442 | public int getScaledDoubleTapSlop() { |
| 443 | return mDoubleTapSlop; |
| 444 | } |
| 445 | |
| 446 | /** |
| 447 | * @return Distance a touch must be outside the bounds of a window for it |
| 448 | * to be counted as outside the window for purposes of dismissing that |
| 449 | * window. |
| 450 | * |
| 451 | * @deprecated Use {@link #getScaledWindowTouchSlop()} instead. |
| 452 | */ |
| 453 | @Deprecated |
| 454 | public static int getWindowTouchSlop() { |
| 455 | return WINDOW_TOUCH_SLOP; |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * @return Distance a touch must be outside the bounds of a window for it |
| 460 | * to be counted as outside the window for purposes of dismissing that |
| 461 | * window. |
| 462 | */ |
| 463 | public int getScaledWindowTouchSlop() { |
| 464 | return mWindowTouchSlop; |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * @return Minimum velocity to initiate a fling, as measured in pixels per second. |
| 469 | * |
| 470 | * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead. |
| 471 | */ |
| 472 | @Deprecated |
| 473 | public static int getMinimumFlingVelocity() { |
| 474 | return MINIMUM_FLING_VELOCITY; |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * @return Minimum velocity to initiate a fling, as measured in pixels per second. |
| 479 | */ |
| 480 | public int getScaledMinimumFlingVelocity() { |
| 481 | return mMinimumFlingVelocity; |
| 482 | } |
| 483 | |
| 484 | /** |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 485 | * @return Maximum velocity to initiate a fling, as measured in pixels per second. |
| 486 | * |
| 487 | * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead. |
| 488 | */ |
| 489 | @Deprecated |
| 490 | public static int getMaximumFlingVelocity() { |
| 491 | return MAXIMUM_FLING_VELOCITY; |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * @return Maximum velocity to initiate a fling, as measured in pixels per second. |
| 496 | */ |
| 497 | public int getScaledMaximumFlingVelocity() { |
| 498 | return mMaximumFlingVelocity; |
| 499 | } |
| 500 | |
| 501 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 502 | * The maximum drawing cache size expressed in bytes. |
| 503 | * |
| 504 | * @return the maximum size of View's drawing cache expressed in bytes |
| 505 | * |
| 506 | * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead. |
| 507 | */ |
| 508 | @Deprecated |
| 509 | public static int getMaximumDrawingCacheSize() { |
| 510 | //noinspection deprecation |
| 511 | return MAXIMUM_DRAWING_CACHE_SIZE; |
| 512 | } |
| 513 | |
| 514 | /** |
| 515 | * The maximum drawing cache size expressed in bytes. |
| 516 | * |
| 517 | * @return the maximum size of View's drawing cache expressed in bytes |
| 518 | */ |
| 519 | public int getScaledMaximumDrawingCacheSize() { |
| 520 | return mMaximumDrawingCacheSize; |
| 521 | } |
| 522 | |
| 523 | /** |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 524 | * @return The maximum distance a View should overscroll by when showing edge effects. |
| 525 | */ |
| 526 | public int getScaledOverscrollDistance() { |
| 527 | return mOverscrollDistance; |
| 528 | } |
| 529 | |
| 530 | /** |
| 531 | * @return The maximum distance a View should overfling by when showing edge effects. |
| 532 | */ |
| 533 | public int getScaledOverflingDistance() { |
| 534 | return mOverflingDistance; |
| 535 | } |
| 536 | |
| 537 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 538 | * The amount of time that the zoom controls should be |
| 539 | * displayed on the screen expressed in milliseconds. |
| 540 | * |
| 541 | * @return the time the zoom controls should be visible expressed |
| 542 | * in milliseconds. |
| 543 | */ |
| 544 | public static long getZoomControlsTimeout() { |
| 545 | return ZOOM_CONTROLS_TIMEOUT; |
| 546 | } |
| 547 | |
| 548 | /** |
| 549 | * The amount of time a user needs to press the relevant key to bring up |
| 550 | * the global actions dialog. |
| 551 | * |
| 552 | * @return how long a user needs to press the relevant key to bring up |
| 553 | * the global actions dialog. |
| 554 | */ |
| 555 | public static long getGlobalActionKeyTimeout() { |
| 556 | return GLOBAL_ACTIONS_KEY_TIMEOUT; |
| 557 | } |
| 558 | |
| 559 | /** |
| 560 | * The amount of friction applied to scrolls and flings. |
| 561 | * |
| 562 | * @return A scalar dimensionless value representing the coefficient of |
| 563 | * friction. |
| 564 | */ |
| 565 | public static float getScrollFriction() { |
| 566 | return SCROLL_FRICTION; |
| 567 | } |
| 568 | } |