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