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 | |
Siarhei Vishniakou | 8b047dd | 2019-01-24 16:04:13 -0800 | [diff] [blame] | 19 | import android.annotation.FloatRange; |
Vladislav Kaznacheev | f847ee3 | 2016-11-21 14:11:00 -0800 | [diff] [blame] | 20 | import android.annotation.TestApi; |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 21 | import android.app.AppGlobals; |
Artur Satayev | ad9254c | 2019-12-10 17:47:54 +0000 | [diff] [blame] | 22 | import android.compat.annotation.UnsupportedAppUsage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | import android.content.Context; |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 24 | import android.content.res.Configuration; |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 25 | import android.content.res.Resources; |
John Reck | ab14923 | 2019-11-14 00:19:48 +0000 | [diff] [blame] | 26 | import android.graphics.Point; |
Sumir Kataria | 471709a | 2019-02-04 16:20:19 -0800 | [diff] [blame] | 27 | import android.os.Build; |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 28 | import android.os.RemoteException; |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 29 | import android.provider.Settings; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.util.DisplayMetrics; |
Andrii Kulian | e57f2dc | 2020-01-26 20:59:07 -0800 | [diff] [blame] | 31 | import android.util.Size; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.util.SparseArray; |
Philip Quinn | 1687d42 | 2020-01-24 12:49:46 -0800 | [diff] [blame] | 33 | import android.util.TypedValue; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Contains methods to standard constants used in the UI for timeouts, sizes, and distances. |
| 37 | */ |
| 38 | public class ViewConfiguration { |
| 39 | /** |
| 40 | * 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] | 41 | * dips |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | */ |
Tarun Lohani | 8c89baa | 2017-06-16 17:21:04 +0000 | [diff] [blame] | 43 | private static final int SCROLL_BAR_SIZE = 4; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | |
| 45 | /** |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 46 | * Duration of the fade when scrollbars fade away in milliseconds |
| 47 | */ |
| 48 | private static final int SCROLL_BAR_FADE_DURATION = 250; |
| 49 | |
| 50 | /** |
| 51 | * Default delay before the scrollbars fade in milliseconds |
| 52 | */ |
| 53 | private static final int SCROLL_BAR_DEFAULT_DELAY = 300; |
| 54 | |
| 55 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 56 | * Defines the length of the fading edges in dips |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | */ |
| 58 | private static final int FADING_EDGE_LENGTH = 12; |
| 59 | |
| 60 | /** |
| 61 | * Defines the duration in milliseconds of the pressed state in child |
| 62 | * components. |
| 63 | */ |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 64 | private static final int PRESSED_STATE_DURATION = 64; |
| 65 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | /** |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 67 | * 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] | 68 | * a long press |
| 69 | */ |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 70 | private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; |
| 71 | |
| 72 | /** |
Anthony Hugh | 96e9cc5 | 2016-07-12 15:17:24 -0700 | [diff] [blame] | 73 | * Defines the default duration in milliseconds between the first tap's up event and the second |
| 74 | * tap's down event for an interaction to be considered part of the same multi-press. |
| 75 | */ |
| 76 | private static final int DEFAULT_MULTI_PRESS_TIMEOUT = 300; |
| 77 | |
| 78 | /** |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 79 | * Defines the time between successive key repeats in milliseconds. |
| 80 | */ |
| 81 | private static final int KEY_REPEAT_DELAY = 50; |
| 82 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | /** |
| 84 | * Defines the duration in milliseconds a user needs to hold down the |
| 85 | * appropriate button to bring up the global actions dialog (power off, |
| 86 | * lock screen, etc). |
| 87 | */ |
| 88 | private static final int GLOBAL_ACTIONS_KEY_TIMEOUT = 500; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 89 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | /** |
Phil Weaver | 106fe73 | 2016-11-22 18:18:39 -0800 | [diff] [blame] | 91 | * Defines the duration in milliseconds a user needs to hold down the |
Edward Savage-Jones | 8f5c95b | 2018-11-14 22:19:28 +0100 | [diff] [blame] | 92 | * appropriate buttons (power + volume down) to trigger the screenshot chord. |
| 93 | */ |
| 94 | private static final int SCREENSHOT_CHORD_KEY_TIMEOUT = 500; |
| 95 | |
| 96 | /** |
| 97 | * Defines the duration in milliseconds a user needs to hold down the |
Eugene Susla | 5f19cd3 | 2017-10-19 14:00:59 -0700 | [diff] [blame] | 98 | * appropriate button to bring up the accessibility shortcut for the first time |
Phil Weaver | 106fe73 | 2016-11-22 18:18:39 -0800 | [diff] [blame] | 99 | */ |
| 100 | private static final int A11Y_SHORTCUT_KEY_TIMEOUT = 3000; |
| 101 | |
| 102 | /** |
Eugene Susla | 5f19cd3 | 2017-10-19 14:00:59 -0700 | [diff] [blame] | 103 | * Defines the duration in milliseconds a user needs to hold down the |
| 104 | * appropriate button to enable the accessibility shortcut once it's configured. |
| 105 | */ |
Eugene Susla | c884158 | 2017-10-31 17:10:41 -0700 | [diff] [blame] | 106 | private static final int A11Y_SHORTCUT_KEY_TIMEOUT_AFTER_CONFIRMATION = 1000; |
Eugene Susla | 5f19cd3 | 2017-10-19 14:00:59 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 109 | * 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] | 110 | * 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] | 111 | * considered to be a tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | */ |
Alan Viverette | 97d9b65 | 2014-03-17 15:33:05 -0700 | [diff] [blame] | 113 | private static final int TAP_TIMEOUT = 100; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 114 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | /** |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 116 | * 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] | 117 | * 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] | 118 | * considered to be a tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | */ |
| 120 | private static final int JUMP_TAP_TIMEOUT = 500; |
| 121 | |
| 122 | /** |
| 123 | * Defines the duration in milliseconds between the first tap's up event and |
| 124 | * the second tap's down event for an interaction to be considered a |
| 125 | * double-tap. |
| 126 | */ |
| 127 | private static final int DOUBLE_TAP_TIMEOUT = 300; |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 128 | |
| 129 | /** |
Adam Powell | af1785f | 2013-09-05 13:44:45 -0700 | [diff] [blame] | 130 | * Defines the minimum duration in milliseconds between the first tap's up event and |
| 131 | * the second tap's down event for an interaction to be considered a |
| 132 | * double-tap. |
| 133 | */ |
| 134 | private static final int DOUBLE_TAP_MIN_TIME = 40; |
| 135 | |
| 136 | /** |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 137 | * Defines the maximum duration in milliseconds between a touch pad |
| 138 | * touch and release for a given touch to be considered a tap (click) as |
| 139 | * opposed to a hover movement gesture. |
| 140 | */ |
| 141 | private static final int HOVER_TAP_TIMEOUT = 150; |
| 142 | |
| 143 | /** |
| 144 | * Defines the maximum distance in pixels that a touch pad touch can move |
| 145 | * before being released for it to be considered a tap (click) as opposed |
| 146 | * to a hover movement gesture. |
| 147 | */ |
| 148 | private static final int HOVER_TAP_SLOP = 20; |
| 149 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 150 | /** |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 151 | * 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] | 152 | * to a user panning within an application. |
| 153 | */ |
| 154 | private static final int ZOOM_CONTROLS_TIMEOUT = 3000; |
| 155 | |
| 156 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 157 | * 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] | 158 | */ |
| 159 | private static final int EDGE_SLOP = 12; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 160 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 161 | /** |
Adam Powell | 7d39f85 | 2011-12-05 19:26:54 -0800 | [diff] [blame] | 162 | * Distance a touch can wander before we think the user is scrolling in dips. |
| 163 | * Note that this value defined here is only used as a fallback by legacy/misbehaving |
| 164 | * applications that do not provide a Context for determining density/configuration-dependent |
| 165 | * values. |
| 166 | * |
| 167 | * To alter this value, see the configuration resource config_viewConfigurationTouchSlop |
| 168 | * in frameworks/base/core/res/res/values/config.xml or the appropriate device resource overlay. |
| 169 | * It may be appropriate to tweak this on a device-specific basis in an overlay based on |
| 170 | * the characteristics of the touch panel and firmware. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 | */ |
Adam Powell | 6720a87 | 2011-12-07 17:35:32 -0800 | [diff] [blame] | 172 | private static final int TOUCH_SLOP = 8; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 173 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | /** |
Vladislav Kaznacheev | 4d2c6014 | 2017-02-07 17:11:54 -0800 | [diff] [blame] | 175 | * Defines the minimum size of the touch target for a scrollbar in dips |
| 176 | */ |
| 177 | private static final int MIN_SCROLLBAR_TOUCH_TARGET = 48; |
| 178 | |
| 179 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 180 | * Distance the first touch can wander before we stop considering this event a double tap |
| 181 | * (in dips) |
| 182 | */ |
| 183 | private static final int DOUBLE_TAP_TOUCH_SLOP = TOUCH_SLOP; |
| 184 | |
| 185 | /** |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 186 | * Distance a touch can wander before we think the user is attempting a paged scroll |
| 187 | * (in dips) |
Adam Powell | 7d39f85 | 2011-12-05 19:26:54 -0800 | [diff] [blame] | 188 | * |
| 189 | * Note that this value defined here is only used as a fallback by legacy/misbehaving |
| 190 | * applications that do not provide a Context for determining density/configuration-dependent |
| 191 | * values. |
| 192 | * |
| 193 | * See the note above on {@link #TOUCH_SLOP} regarding the dimen resource |
| 194 | * config_viewConfigurationTouchSlop. ViewConfiguration will report a paging touch slop of |
| 195 | * config_viewConfigurationTouchSlop * 2 when provided with a Context. |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 196 | */ |
Adam Powell | b7ef1d9 | 2010-03-11 10:25:24 -0800 | [diff] [blame] | 197 | private static final int PAGING_TOUCH_SLOP = TOUCH_SLOP * 2; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 198 | |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 199 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 200 | * 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] | 201 | */ |
| 202 | private static final int DOUBLE_TAP_SLOP = 100; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 203 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 204 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 205 | * 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] | 206 | * count as outside for purposes of dismissing the window. |
| 207 | */ |
| 208 | private static final int WINDOW_TOUCH_SLOP = 16; |
| 209 | |
| 210 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 211 | * 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] | 212 | */ |
| 213 | private static final int MINIMUM_FLING_VELOCITY = 50; |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 214 | |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 215 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 216 | * Maximum velocity to initiate a fling, as measured in dips per second |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 217 | */ |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 218 | private static final int MAXIMUM_FLING_VELOCITY = 8000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 219 | |
| 220 | /** |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 221 | * Delay before dispatching a recurring accessibility event in milliseconds. |
| 222 | * This delay guarantees that a recurring event will be send at most once |
| 223 | * during the {@link #SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS} time |
| 224 | * frame. |
| 225 | */ |
Svetoslav Ganov | e15ccb9 | 2012-05-16 15:48:55 -0700 | [diff] [blame] | 226 | private static final long SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS = 100; |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 227 | |
| 228 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 229 | * The maximum size of View's drawing cache, expressed in bytes. This size |
| 230 | * should be at least equal to the size of the screen in ARGB888 format. |
| 231 | */ |
| 232 | @Deprecated |
Romain Guy | 0211a0a | 2011-02-14 16:34:59 -0800 | [diff] [blame] | 233 | 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] | 234 | |
| 235 | /** |
| 236 | * The coefficient of friction applied to flings/scrolls. |
| 237 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 238 | @UnsupportedAppUsage |
Romain Guy | 0211a0a | 2011-02-14 16:34:59 -0800 | [diff] [blame] | 239 | private static final float SCROLL_FRICTION = 0.015f; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 240 | |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 241 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 242 | * Max distance in dips to overscroll for edge effects |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 243 | */ |
| 244 | private static final int OVERSCROLL_DISTANCE = 0; |
| 245 | |
| 246 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 247 | * Max distance in dips to overfling for edge effects |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 248 | */ |
Gilles Debunne | 8ce7aab | 2011-01-25 11:23:30 -0800 | [diff] [blame] | 249 | private static final int OVERFLING_DISTANCE = 6; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 250 | |
Adam Powell | cc84ff4 | 2013-12-04 11:15:29 -0800 | [diff] [blame] | 251 | /** |
Aaron Whyte | f830652 | 2017-03-22 16:30:58 -0700 | [diff] [blame] | 252 | * Amount to scroll in response to a horizontal {@link MotionEvent#ACTION_SCROLL} event, |
| 253 | * in dips per axis value. |
Ned Burns | 69af432 | 2016-08-17 17:30:25 -0400 | [diff] [blame] | 254 | */ |
Aaron Whyte | f830652 | 2017-03-22 16:30:58 -0700 | [diff] [blame] | 255 | private static final float HORIZONTAL_SCROLL_FACTOR = 64; |
| 256 | |
| 257 | /** |
| 258 | * Amount to scroll in response to a vertical {@link MotionEvent#ACTION_SCROLL} event, |
| 259 | * in dips per axis value. |
| 260 | */ |
| 261 | private static final float VERTICAL_SCROLL_FACTOR = 64; |
Ned Burns | 69af432 | 2016-08-17 17:30:25 -0400 | [diff] [blame] | 262 | |
| 263 | /** |
Abodunrinwa Toki | 9e21128 | 2015-06-05 02:46:57 +0100 | [diff] [blame] | 264 | * Default duration to hide an action mode for. |
Abodunrinwa Toki | fd3a3a1 | 2015-05-05 20:04:34 +0100 | [diff] [blame] | 265 | */ |
Abodunrinwa Toki | 9e21128 | 2015-06-05 02:46:57 +0100 | [diff] [blame] | 266 | private static final long ACTION_MODE_HIDE_DURATION_DEFAULT = 2000; |
Abodunrinwa Toki | fd3a3a1 | 2015-05-05 20:04:34 +0100 | [diff] [blame] | 267 | |
| 268 | /** |
Vladislav Kaznacheev | f847ee3 | 2016-11-21 14:11:00 -0800 | [diff] [blame] | 269 | * Defines the duration in milliseconds before an end of a long press causes a tooltip to be |
| 270 | * hidden. |
| 271 | */ |
| 272 | private static final int LONG_PRESS_TOOLTIP_HIDE_TIMEOUT = 1500; |
| 273 | |
| 274 | /** |
| 275 | * Defines the duration in milliseconds before a hover event causes a tooltip to be shown. |
| 276 | */ |
| 277 | private static final int HOVER_TOOLTIP_SHOW_TIMEOUT = 500; |
| 278 | |
| 279 | /** |
| 280 | * Defines the duration in milliseconds before mouse inactivity causes a tooltip to be hidden. |
| 281 | * (default variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is not set). |
| 282 | */ |
| 283 | private static final int HOVER_TOOLTIP_HIDE_TIMEOUT = 15000; |
| 284 | |
| 285 | /** |
| 286 | * Defines the duration in milliseconds before mouse inactivity causes a tooltip to be hidden |
| 287 | * (short version to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is set). |
| 288 | */ |
| 289 | private static final int HOVER_TOOLTIP_HIDE_SHORT_TIMEOUT = 3000; |
| 290 | |
| 291 | /** |
Adam Powell | cc84ff4 | 2013-12-04 11:15:29 -0800 | [diff] [blame] | 292 | * Configuration values for overriding {@link #hasPermanentMenuKey()} behavior. |
| 293 | * These constants must match the definition in res/values/config.xml. |
| 294 | */ |
| 295 | private static final int HAS_PERMANENT_MENU_KEY_AUTODETECT = 0; |
| 296 | private static final int HAS_PERMANENT_MENU_KEY_TRUE = 1; |
| 297 | private static final int HAS_PERMANENT_MENU_KEY_FALSE = 2; |
| 298 | |
Siarhei Vishniakou | 8b047dd | 2019-01-24 16:04:13 -0800 | [diff] [blame] | 299 | /** |
| 300 | * The multiplication factor for inhibiting default gestures. |
| 301 | */ |
| 302 | private static final float AMBIGUOUS_GESTURE_MULTIPLIER = 2f; |
| 303 | |
shepshapard | ba6dbff | 2019-02-06 16:14:22 -0800 | [diff] [blame] | 304 | private final boolean mConstructedWithContext; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 305 | private final int mEdgeSlop; |
| 306 | private final int mFadingEdgeLength; |
| 307 | private final int mMinimumFlingVelocity; |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 308 | private final int mMaximumFlingVelocity; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 309 | private final int mScrollbarSize; |
| 310 | private final int mTouchSlop; |
shepshapard | ba6dbff | 2019-02-06 16:14:22 -0800 | [diff] [blame] | 311 | private final int mMinScalingSpan; |
Vladislav Kaznacheev | 556ac61 | 2017-12-07 11:02:08 -0800 | [diff] [blame] | 312 | private final int mHoverSlop; |
Vladislav Kaznacheev | 4d2c6014 | 2017-02-07 17:11:54 -0800 | [diff] [blame] | 313 | private final int mMinScrollbarTouchTarget; |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 314 | private final int mDoubleTapTouchSlop; |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 315 | private final int mPagingTouchSlop; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 316 | private final int mDoubleTapSlop; |
| 317 | private final int mWindowTouchSlop; |
Philip Quinn | 1687d42 | 2020-01-24 12:49:46 -0800 | [diff] [blame] | 318 | private final float mAmbiguousGestureMultiplier; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 319 | private final int mMaximumDrawingCacheSize; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 320 | private final int mOverscrollDistance; |
| 321 | private final int mOverflingDistance; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 322 | @UnsupportedAppUsage |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 323 | private final boolean mFadingMarqueeEnabled; |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 324 | private final long mGlobalActionsKeyTimeout; |
Aaron Whyte | f830652 | 2017-03-22 16:30:58 -0700 | [diff] [blame] | 325 | private final float mVerticalScrollFactor; |
| 326 | private final float mHorizontalScrollFactor; |
Vladislav Kaznacheev | a725df9 | 2018-02-26 16:22:34 -0800 | [diff] [blame] | 327 | private final boolean mShowMenuShortcutsWhenKeyboardPresent; |
Edward Savage-Jones | 8f5c95b | 2018-11-14 22:19:28 +0100 | [diff] [blame] | 328 | private final long mScreenshotChordKeyTimeout; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 329 | |
Sumir Kataria | 471709a | 2019-02-04 16:20:19 -0800 | [diff] [blame] | 330 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768915) |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 331 | private boolean sHasPermanentMenuKey; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 332 | @UnsupportedAppUsage |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 333 | private boolean sHasPermanentMenuKeySet; |
| 334 | |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 335 | @UnsupportedAppUsage |
Xavier Ducrohet | 7f9f99ea | 2011-08-11 10:16:17 -0700 | [diff] [blame] | 336 | static final SparseArray<ViewConfiguration> sConfigurations = |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 337 | new SparseArray<ViewConfiguration>(2); |
| 338 | |
| 339 | /** |
| 340 | * @deprecated Use {@link android.view.ViewConfiguration#get(android.content.Context)} instead. |
| 341 | */ |
| 342 | @Deprecated |
| 343 | public ViewConfiguration() { |
shepshapard | ba6dbff | 2019-02-06 16:14:22 -0800 | [diff] [blame] | 344 | mConstructedWithContext = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 345 | mEdgeSlop = EDGE_SLOP; |
| 346 | mFadingEdgeLength = FADING_EDGE_LENGTH; |
| 347 | mMinimumFlingVelocity = MINIMUM_FLING_VELOCITY; |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 348 | mMaximumFlingVelocity = MAXIMUM_FLING_VELOCITY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 349 | mScrollbarSize = SCROLL_BAR_SIZE; |
| 350 | mTouchSlop = TOUCH_SLOP; |
Vladislav Kaznacheev | 556ac61 | 2017-12-07 11:02:08 -0800 | [diff] [blame] | 351 | mHoverSlop = TOUCH_SLOP / 2; |
Vladislav Kaznacheev | 4d2c6014 | 2017-02-07 17:11:54 -0800 | [diff] [blame] | 352 | mMinScrollbarTouchTarget = MIN_SCROLLBAR_TOUCH_TARGET; |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 353 | mDoubleTapTouchSlop = DOUBLE_TAP_TOUCH_SLOP; |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 354 | mPagingTouchSlop = PAGING_TOUCH_SLOP; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 355 | mDoubleTapSlop = DOUBLE_TAP_SLOP; |
| 356 | mWindowTouchSlop = WINDOW_TOUCH_SLOP; |
Philip Quinn | 1687d42 | 2020-01-24 12:49:46 -0800 | [diff] [blame] | 357 | mAmbiguousGestureMultiplier = AMBIGUOUS_GESTURE_MULTIPLIER; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 358 | //noinspection deprecation |
| 359 | mMaximumDrawingCacheSize = MAXIMUM_DRAWING_CACHE_SIZE; |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 360 | mOverscrollDistance = OVERSCROLL_DISTANCE; |
| 361 | mOverflingDistance = OVERFLING_DISTANCE; |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 362 | mFadingMarqueeEnabled = true; |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 363 | mGlobalActionsKeyTimeout = GLOBAL_ACTIONS_KEY_TIMEOUT; |
Aaron Whyte | f830652 | 2017-03-22 16:30:58 -0700 | [diff] [blame] | 364 | mHorizontalScrollFactor = HORIZONTAL_SCROLL_FACTOR; |
| 365 | mVerticalScrollFactor = VERTICAL_SCROLL_FACTOR; |
Vladislav Kaznacheev | a725df9 | 2018-02-26 16:22:34 -0800 | [diff] [blame] | 366 | mShowMenuShortcutsWhenKeyboardPresent = false; |
Edward Savage-Jones | 8f5c95b | 2018-11-14 22:19:28 +0100 | [diff] [blame] | 367 | mScreenshotChordKeyTimeout = SCREENSHOT_CHORD_KEY_TIMEOUT; |
shepshapard | ba6dbff | 2019-02-06 16:14:22 -0800 | [diff] [blame] | 368 | |
| 369 | // Getter throws if mConstructedWithContext is false so doesn't matter what |
| 370 | // this value is. |
| 371 | mMinScalingSpan = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | /** |
| 375 | * Creates a new configuration for the specified context. The configuration depends on |
| 376 | * various parameters of the context, like the dimension of the display or the density |
| 377 | * of the display. |
| 378 | * |
| 379 | * @param context The application context used to initialize this view configuration. |
| 380 | * |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 381 | * @see #get(android.content.Context) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 382 | * @see android.util.DisplayMetrics |
| 383 | */ |
| 384 | private ViewConfiguration(Context context) { |
shepshapard | ba6dbff | 2019-02-06 16:14:22 -0800 | [diff] [blame] | 385 | mConstructedWithContext = true; |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 386 | final Resources res = context.getResources(); |
| 387 | final DisplayMetrics metrics = res.getDisplayMetrics(); |
| 388 | final Configuration config = res.getConfiguration(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 389 | final float density = metrics.density; |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 390 | final float sizeAndDensity; |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 391 | if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE)) { |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 392 | sizeAndDensity = density * 1.5f; |
| 393 | } else { |
| 394 | sizeAndDensity = density; |
| 395 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 396 | |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 397 | mEdgeSlop = (int) (sizeAndDensity * EDGE_SLOP + 0.5f); |
| 398 | mFadingEdgeLength = (int) (sizeAndDensity * FADING_EDGE_LENGTH + 0.5f); |
Tarun Lohani | 8c89baa | 2017-06-16 17:21:04 +0000 | [diff] [blame] | 399 | mScrollbarSize = res.getDimensionPixelSize( |
| 400 | com.android.internal.R.dimen.config_scrollbarSize); |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 401 | mDoubleTapSlop = (int) (sizeAndDensity * DOUBLE_TAP_SLOP + 0.5f); |
| 402 | mWindowTouchSlop = (int) (sizeAndDensity * WINDOW_TOUCH_SLOP + 0.5f); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 403 | |
Philip Quinn | 1687d42 | 2020-01-24 12:49:46 -0800 | [diff] [blame] | 404 | final TypedValue multiplierValue = new TypedValue(); |
| 405 | res.getValue( |
| 406 | com.android.internal.R.dimen.config_ambiguousGestureMultiplier, |
| 407 | multiplierValue, |
| 408 | true /*resolveRefs*/); |
| 409 | mAmbiguousGestureMultiplier = multiplierValue.getFloat(); |
| 410 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 411 | // Size of the screen in bytes, in ARGB_8888 format |
Andrii Kulian | e57f2dc | 2020-01-26 20:59:07 -0800 | [diff] [blame] | 412 | final WindowManager windowManager = context.getSystemService(WindowManager.class); |
| 413 | final Size maxWindowSize = windowManager.getMaximumWindowMetrics().getSize(); |
| 414 | mMaximumDrawingCacheSize = 4 * maxWindowSize.getWidth() * maxWindowSize.getHeight(); |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 415 | |
Dianne Hackborn | ff801ec | 2011-01-22 18:05:38 -0800 | [diff] [blame] | 416 | mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f); |
| 417 | mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f); |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 418 | |
| 419 | if (!sHasPermanentMenuKeySet) { |
Adam Powell | cc84ff4 | 2013-12-04 11:15:29 -0800 | [diff] [blame] | 420 | final int configVal = res.getInteger( |
| 421 | com.android.internal.R.integer.config_overrideHasPermanentMenuKey); |
| 422 | |
| 423 | switch (configVal) { |
| 424 | default: |
| 425 | case HAS_PERMANENT_MENU_KEY_AUTODETECT: { |
| 426 | IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); |
| 427 | try { |
Charles Chen | ea6e7f0 | 2018-11-19 21:37:45 +0800 | [diff] [blame] | 428 | sHasPermanentMenuKey = !wm.hasNavigationBar(context.getDisplayId()); |
Adam Powell | cc84ff4 | 2013-12-04 11:15:29 -0800 | [diff] [blame] | 429 | sHasPermanentMenuKeySet = true; |
| 430 | } catch (RemoteException ex) { |
| 431 | sHasPermanentMenuKey = false; |
| 432 | } |
| 433 | } |
| 434 | break; |
| 435 | |
| 436 | case HAS_PERMANENT_MENU_KEY_TRUE: |
| 437 | sHasPermanentMenuKey = true; |
| 438 | sHasPermanentMenuKeySet = true; |
| 439 | break; |
| 440 | |
| 441 | case HAS_PERMANENT_MENU_KEY_FALSE: |
| 442 | sHasPermanentMenuKey = false; |
| 443 | sHasPermanentMenuKeySet = true; |
| 444 | break; |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 445 | } |
| 446 | } |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 447 | |
| 448 | mFadingMarqueeEnabled = res.getBoolean( |
| 449 | com.android.internal.R.bool.config_ui_enableFadingMarquee); |
Adam Powell | 7d39f85 | 2011-12-05 19:26:54 -0800 | [diff] [blame] | 450 | mTouchSlop = res.getDimensionPixelSize( |
| 451 | com.android.internal.R.dimen.config_viewConfigurationTouchSlop); |
Vladislav Kaznacheev | 556ac61 | 2017-12-07 11:02:08 -0800 | [diff] [blame] | 452 | mHoverSlop = res.getDimensionPixelSize( |
| 453 | com.android.internal.R.dimen.config_viewConfigurationHoverSlop); |
Vladislav Kaznacheev | 4d2c6014 | 2017-02-07 17:11:54 -0800 | [diff] [blame] | 454 | mMinScrollbarTouchTarget = res.getDimensionPixelSize( |
| 455 | com.android.internal.R.dimen.config_minScrollbarTouchTarget); |
Adam Powell | 7d39f85 | 2011-12-05 19:26:54 -0800 | [diff] [blame] | 456 | mPagingTouchSlop = mTouchSlop * 2; |
Adam Powell | e4b8ff8 | 2011-12-06 16:40:49 -0800 | [diff] [blame] | 457 | |
| 458 | mDoubleTapTouchSlop = mTouchSlop; |
Mindy Pereira | 23ffc73 | 2014-04-30 17:09:35 -0700 | [diff] [blame] | 459 | |
| 460 | mMinimumFlingVelocity = res.getDimensionPixelSize( |
| 461 | com.android.internal.R.dimen.config_viewMinFlingVelocity); |
| 462 | mMaximumFlingVelocity = res.getDimensionPixelSize( |
| 463 | com.android.internal.R.dimen.config_viewMaxFlingVelocity); |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 464 | mGlobalActionsKeyTimeout = res.getInteger( |
| 465 | com.android.internal.R.integer.config_globalActionsKeyTimeout); |
Aaron Whyte | f830652 | 2017-03-22 16:30:58 -0700 | [diff] [blame] | 466 | |
| 467 | mHorizontalScrollFactor = res.getDimensionPixelSize( |
| 468 | com.android.internal.R.dimen.config_horizontalScrollFactor); |
| 469 | mVerticalScrollFactor = res.getDimensionPixelSize( |
| 470 | com.android.internal.R.dimen.config_verticalScrollFactor); |
Vladislav Kaznacheev | a725df9 | 2018-02-26 16:22:34 -0800 | [diff] [blame] | 471 | |
| 472 | mShowMenuShortcutsWhenKeyboardPresent = res.getBoolean( |
| 473 | com.android.internal.R.bool.config_showMenuShortcutsWhenKeyboardPresent); |
| 474 | |
shepshapard | ba6dbff | 2019-02-06 16:14:22 -0800 | [diff] [blame] | 475 | mMinScalingSpan = res.getDimensionPixelSize( |
| 476 | com.android.internal.R.dimen.config_minScalingSpan); |
Edward Savage-Jones | 8f5c95b | 2018-11-14 22:19:28 +0100 | [diff] [blame] | 477 | |
| 478 | mScreenshotChordKeyTimeout = res.getInteger( |
| 479 | com.android.internal.R.integer.config_screenshotChordKeyTimeout); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | /** |
| 483 | * Returns a configuration for the specified context. The configuration depends on |
| 484 | * various parameters of the context, like the dimension of the display or the |
| 485 | * density of the display. |
| 486 | * |
| 487 | * @param context The application context used to initialize the view configuration. |
| 488 | */ |
| 489 | public static ViewConfiguration get(Context context) { |
| 490 | final DisplayMetrics metrics = context.getResources().getDisplayMetrics(); |
| 491 | final int density = (int) (100.0f * metrics.density); |
| 492 | |
| 493 | ViewConfiguration configuration = sConfigurations.get(density); |
| 494 | if (configuration == null) { |
| 495 | configuration = new ViewConfiguration(context); |
| 496 | sConfigurations.put(density, configuration); |
| 497 | } |
| 498 | |
| 499 | return configuration; |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * @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] | 504 | * scrollbar in dips |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 505 | * |
| 506 | * @deprecated Use {@link #getScaledScrollBarSize()} instead. |
| 507 | */ |
| 508 | @Deprecated |
| 509 | public static int getScrollBarSize() { |
| 510 | return SCROLL_BAR_SIZE; |
| 511 | } |
| 512 | |
| 513 | /** |
| 514 | * @return The width of the horizontal scrollbar and the height of the vertical |
| 515 | * scrollbar in pixels |
| 516 | */ |
| 517 | public int getScaledScrollBarSize() { |
| 518 | return mScrollbarSize; |
| 519 | } |
| 520 | |
| 521 | /** |
Vladislav Kaznacheev | 4d2c6014 | 2017-02-07 17:11:54 -0800 | [diff] [blame] | 522 | * @return the minimum size of the scrollbar thumb's touch target in pixels |
| 523 | * @hide |
| 524 | */ |
| 525 | public int getScaledMinScrollbarTouchTarget() { |
| 526 | return mMinScrollbarTouchTarget; |
| 527 | } |
| 528 | |
| 529 | /** |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 530 | * @return Duration of the fade when scrollbars fade away in milliseconds |
| 531 | */ |
| 532 | public static int getScrollBarFadeDuration() { |
| 533 | return SCROLL_BAR_FADE_DURATION; |
| 534 | } |
| 535 | |
| 536 | /** |
Alan Viverette | 25f0e61 | 2015-02-27 12:34:30 -0800 | [diff] [blame] | 537 | * @return Default delay before the scrollbars fade in milliseconds |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 538 | */ |
| 539 | public static int getScrollDefaultDelay() { |
| 540 | return SCROLL_BAR_DEFAULT_DELAY; |
| 541 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 542 | |
Mike Cleron | f116bf8 | 2009-09-27 19:14:12 -0700 | [diff] [blame] | 543 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 544 | * @return the length of the fading edges in dips |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 545 | * |
| 546 | * @deprecated Use {@link #getScaledFadingEdgeLength()} instead. |
| 547 | */ |
| 548 | @Deprecated |
| 549 | public static int getFadingEdgeLength() { |
| 550 | return FADING_EDGE_LENGTH; |
| 551 | } |
| 552 | |
| 553 | /** |
| 554 | * @return the length of the fading edges in pixels |
| 555 | */ |
| 556 | public int getScaledFadingEdgeLength() { |
| 557 | return mFadingEdgeLength; |
| 558 | } |
| 559 | |
| 560 | /** |
| 561 | * @return the duration in milliseconds of the pressed state in child |
| 562 | * components. |
| 563 | */ |
| 564 | public static int getPressedStateDuration() { |
| 565 | return PRESSED_STATE_DURATION; |
| 566 | } |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 567 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | /** |
| 569 | * @return the duration in milliseconds before a press turns into |
| 570 | * a long press |
| 571 | */ |
| 572 | public static int getLongPressTimeout() { |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 573 | return AppGlobals.getIntCoreSetting(Settings.Secure.LONG_PRESS_TIMEOUT, |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 574 | DEFAULT_LONG_PRESS_TIMEOUT); |
| 575 | } |
| 576 | |
| 577 | /** |
Anthony Hugh | 96e9cc5 | 2016-07-12 15:17:24 -0700 | [diff] [blame] | 578 | * @return the duration in milliseconds between the first tap's up event and the second tap's |
| 579 | * down event for an interaction to be considered part of the same multi-press. |
| 580 | * @hide |
| 581 | */ |
| 582 | public static int getMultiPressTimeout() { |
| 583 | return AppGlobals.getIntCoreSetting(Settings.Secure.MULTI_PRESS_TIMEOUT, |
| 584 | DEFAULT_MULTI_PRESS_TIMEOUT); |
| 585 | } |
| 586 | |
| 587 | /** |
Jeff Brown | a454767 | 2011-03-02 21:38:11 -0800 | [diff] [blame] | 588 | * @return the time before the first key repeat in milliseconds. |
| 589 | */ |
| 590 | public static int getKeyRepeatTimeout() { |
| 591 | return getLongPressTimeout(); |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * @return the time between successive key repeats in milliseconds. |
| 596 | */ |
| 597 | public static int getKeyRepeatDelay() { |
| 598 | return KEY_REPEAT_DELAY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 599 | } |
Svetoslav Ganov | 54d068e | 2011-03-02 12:58:40 -0800 | [diff] [blame] | 600 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 601 | /** |
| 602 | * @return the duration in milliseconds we will wait to see if a touch event |
| 603 | * 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] | 604 | * considered to be a tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 605 | */ |
| 606 | public static int getTapTimeout() { |
| 607 | return TAP_TIMEOUT; |
| 608 | } |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 609 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 610 | /** |
| 611 | * @return the duration in milliseconds we will wait to see if a touch event |
| 612 | * 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] | 613 | * considered to be a tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 614 | */ |
| 615 | public static int getJumpTapTimeout() { |
| 616 | return JUMP_TAP_TIMEOUT; |
| 617 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 618 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 619 | /** |
| 620 | * @return the duration in milliseconds between the first tap's up event and |
| 621 | * the second tap's down event for an interaction to be considered a |
| 622 | * double-tap. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 623 | */ |
| 624 | public static int getDoubleTapTimeout() { |
| 625 | return DOUBLE_TAP_TIMEOUT; |
| 626 | } |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 627 | |
| 628 | /** |
Adam Powell | af1785f | 2013-09-05 13:44:45 -0700 | [diff] [blame] | 629 | * @return the minimum duration in milliseconds between the first tap's |
| 630 | * up event and the second tap's down event for an interaction to be considered a |
| 631 | * double-tap. |
| 632 | * |
| 633 | * @hide |
| 634 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 635 | @UnsupportedAppUsage |
Adam Powell | af1785f | 2013-09-05 13:44:45 -0700 | [diff] [blame] | 636 | public static int getDoubleTapMinTime() { |
| 637 | return DOUBLE_TAP_MIN_TIME; |
| 638 | } |
| 639 | |
| 640 | /** |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 641 | * @return the maximum duration in milliseconds between a touch pad |
| 642 | * touch and release for a given touch to be considered a tap (click) as |
| 643 | * opposed to a hover movement gesture. |
| 644 | * @hide |
| 645 | */ |
| 646 | public static int getHoverTapTimeout() { |
| 647 | return HOVER_TAP_TIMEOUT; |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * @return the maximum distance in pixels that a touch pad touch can move |
| 652 | * before being released for it to be considered a tap (click) as opposed |
| 653 | * to a hover movement gesture. |
| 654 | * @hide |
| 655 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 656 | @UnsupportedAppUsage |
Jeff Brown | bb3fcba0c | 2011-06-06 19:23:05 -0700 | [diff] [blame] | 657 | public static int getHoverTapSlop() { |
| 658 | return HOVER_TAP_SLOP; |
| 659 | } |
| 660 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 661 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 662 | * @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] | 663 | * screen |
| 664 | * |
| 665 | * @deprecated Use {@link #getScaledEdgeSlop()} instead. |
| 666 | */ |
| 667 | @Deprecated |
| 668 | public static int getEdgeSlop() { |
| 669 | return EDGE_SLOP; |
| 670 | } |
| 671 | |
| 672 | /** |
| 673 | * @return Inset in pixels to look for touchable content when the user touches the edge of the |
| 674 | * screen |
| 675 | */ |
| 676 | public int getScaledEdgeSlop() { |
| 677 | return mEdgeSlop; |
| 678 | } |
| 679 | |
| 680 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 681 | * @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] | 682 | * |
| 683 | * @deprecated Use {@link #getScaledTouchSlop()} instead. |
| 684 | */ |
| 685 | @Deprecated |
| 686 | public static int getTouchSlop() { |
| 687 | return TOUCH_SLOP; |
| 688 | } |
| 689 | |
| 690 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 691 | * @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] | 692 | */ |
| 693 | public int getScaledTouchSlop() { |
| 694 | return mTouchSlop; |
| 695 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 696 | |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 697 | /** |
Vladislav Kaznacheev | 556ac61 | 2017-12-07 11:02:08 -0800 | [diff] [blame] | 698 | * @return Distance in pixels a hover can wander while it is still considered "stationary". |
| 699 | * |
| 700 | */ |
| 701 | public int getScaledHoverSlop() { |
| 702 | return mHoverSlop; |
| 703 | } |
| 704 | |
| 705 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 706 | * @return Distance in pixels the first touch can wander before we do not consider this a |
| 707 | * potential double tap event |
| 708 | * @hide |
| 709 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 710 | @UnsupportedAppUsage |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 711 | public int getScaledDoubleTapTouchSlop() { |
| 712 | return mDoubleTapTouchSlop; |
| 713 | } |
| 714 | |
| 715 | /** |
| 716 | * @return Distance in pixels a touch can wander before we think the user is scrolling a full |
| 717 | * page |
Adam Powell | de8d083 | 2010-03-09 17:11:30 -0800 | [diff] [blame] | 718 | */ |
| 719 | public int getScaledPagingTouchSlop() { |
| 720 | return mPagingTouchSlop; |
| 721 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 722 | |
| 723 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 724 | * @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] | 725 | * considered a double tap |
| 726 | * @deprecated Use {@link #getScaledDoubleTapSlop()} instead. |
| 727 | * @hide The only client of this should be GestureDetector, which needs this |
| 728 | * for clients that still use its deprecated constructor. |
| 729 | */ |
| 730 | @Deprecated |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 731 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 732 | public static int getDoubleTapSlop() { |
| 733 | return DOUBLE_TAP_SLOP; |
| 734 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 735 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 736 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 737 | * @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] | 738 | * considered a double tap |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 739 | */ |
| 740 | public int getScaledDoubleTapSlop() { |
| 741 | return mDoubleTapSlop; |
| 742 | } |
| 743 | |
| 744 | /** |
Svetoslav Ganov | a015617 | 2011-06-26 17:55:44 -0700 | [diff] [blame] | 745 | * Interval for dispatching a recurring accessibility event in milliseconds. |
| 746 | * This interval guarantees that a recurring event will be send at most once |
| 747 | * during the {@link #getSendRecurringAccessibilityEventsInterval()} time frame. |
| 748 | * |
| 749 | * @return The delay in milliseconds. |
| 750 | * |
| 751 | * @hide |
| 752 | */ |
| 753 | public static long getSendRecurringAccessibilityEventsInterval() { |
| 754 | return SEND_RECURRING_ACCESSIBILITY_EVENTS_INTERVAL_MILLIS; |
| 755 | } |
| 756 | |
| 757 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 758 | * @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] | 759 | * to be counted as outside the window for purposes of dismissing that |
| 760 | * window. |
| 761 | * |
| 762 | * @deprecated Use {@link #getScaledWindowTouchSlop()} instead. |
| 763 | */ |
| 764 | @Deprecated |
| 765 | public static int getWindowTouchSlop() { |
| 766 | return WINDOW_TOUCH_SLOP; |
| 767 | } |
| 768 | |
| 769 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 770 | * @return Distance in pixels a touch must be outside the bounds of a window for it |
| 771 | * 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] | 772 | */ |
| 773 | public int getScaledWindowTouchSlop() { |
| 774 | return mWindowTouchSlop; |
| 775 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 776 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 777 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 778 | * @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] | 779 | * |
| 780 | * @deprecated Use {@link #getScaledMinimumFlingVelocity()} instead. |
| 781 | */ |
| 782 | @Deprecated |
| 783 | public static int getMinimumFlingVelocity() { |
| 784 | return MINIMUM_FLING_VELOCITY; |
| 785 | } |
| 786 | |
| 787 | /** |
| 788 | * @return Minimum velocity to initiate a fling, as measured in pixels per second. |
| 789 | */ |
| 790 | public int getScaledMinimumFlingVelocity() { |
| 791 | return mMinimumFlingVelocity; |
| 792 | } |
| 793 | |
| 794 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 795 | * @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] | 796 | * |
| 797 | * @deprecated Use {@link #getScaledMaximumFlingVelocity()} instead. |
| 798 | */ |
| 799 | @Deprecated |
| 800 | public static int getMaximumFlingVelocity() { |
| 801 | return MAXIMUM_FLING_VELOCITY; |
| 802 | } |
| 803 | |
| 804 | /** |
| 805 | * @return Maximum velocity to initiate a fling, as measured in pixels per second. |
| 806 | */ |
| 807 | public int getScaledMaximumFlingVelocity() { |
| 808 | return mMaximumFlingVelocity; |
| 809 | } |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 810 | |
Romain Guy | 4296fc4 | 2009-07-06 11:48:52 -0700 | [diff] [blame] | 811 | /** |
Ned Burns | 69af432 | 2016-08-17 17:30:25 -0400 | [diff] [blame] | 812 | * @return Amount to scroll in response to a {@link MotionEvent#ACTION_SCROLL} event. Multiply |
| 813 | * this by the event's axis value to obtain the number of pixels to be scrolled. |
Aaron Whyte | f830652 | 2017-03-22 16:30:58 -0700 | [diff] [blame] | 814 | * |
| 815 | * @removed |
Ned Burns | 69af432 | 2016-08-17 17:30:25 -0400 | [diff] [blame] | 816 | */ |
| 817 | public int getScaledScrollFactor() { |
Aaron Whyte | f830652 | 2017-03-22 16:30:58 -0700 | [diff] [blame] | 818 | return (int) mVerticalScrollFactor; |
| 819 | } |
| 820 | |
| 821 | /** |
| 822 | * @return Amount to scroll in response to a horizontal {@link MotionEvent#ACTION_SCROLL} event. |
| 823 | * Multiply this by the event's axis value to obtain the number of pixels to be scrolled. |
| 824 | */ |
| 825 | public float getScaledHorizontalScrollFactor() { |
| 826 | return mHorizontalScrollFactor; |
| 827 | } |
| 828 | |
| 829 | /** |
| 830 | * @return Amount to scroll in response to a vertical {@link MotionEvent#ACTION_SCROLL} event. |
| 831 | * Multiply this by the event's axis value to obtain the number of pixels to be scrolled. |
| 832 | */ |
| 833 | public float getScaledVerticalScrollFactor() { |
| 834 | return mVerticalScrollFactor; |
Ned Burns | 69af432 | 2016-08-17 17:30:25 -0400 | [diff] [blame] | 835 | } |
| 836 | |
| 837 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 838 | * The maximum drawing cache size expressed in bytes. |
| 839 | * |
| 840 | * @return the maximum size of View's drawing cache expressed in bytes |
| 841 | * |
| 842 | * @deprecated Use {@link #getScaledMaximumDrawingCacheSize()} instead. |
| 843 | */ |
| 844 | @Deprecated |
| 845 | public static int getMaximumDrawingCacheSize() { |
| 846 | //noinspection deprecation |
| 847 | return MAXIMUM_DRAWING_CACHE_SIZE; |
| 848 | } |
| 849 | |
| 850 | /** |
| 851 | * The maximum drawing cache size expressed in bytes. |
| 852 | * |
| 853 | * @return the maximum size of View's drawing cache expressed in bytes |
| 854 | */ |
| 855 | public int getScaledMaximumDrawingCacheSize() { |
| 856 | return mMaximumDrawingCacheSize; |
| 857 | } |
| 858 | |
| 859 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 860 | * @return The maximum distance a View should overscroll by when showing edge effects (in |
| 861 | * pixels). |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 862 | */ |
| 863 | public int getScaledOverscrollDistance() { |
| 864 | return mOverscrollDistance; |
| 865 | } |
| 866 | |
| 867 | /** |
Gilles Debunne | 006fa48 | 2011-10-27 17:23:36 -0700 | [diff] [blame] | 868 | * @return The maximum distance a View should overfling by when showing edge effects (in |
| 869 | * pixels). |
Adam Powell | 637d337 | 2010-08-25 14:37:03 -0700 | [diff] [blame] | 870 | */ |
| 871 | public int getScaledOverflingDistance() { |
| 872 | return mOverflingDistance; |
| 873 | } |
| 874 | |
| 875 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 876 | * The amount of time that the zoom controls should be |
| 877 | * displayed on the screen expressed in milliseconds. |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 878 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 879 | * @return the time the zoom controls should be visible expressed |
| 880 | * in milliseconds. |
| 881 | */ |
| 882 | public static long getZoomControlsTimeout() { |
| 883 | return ZOOM_CONTROLS_TIMEOUT; |
| 884 | } |
| 885 | |
| 886 | /** |
| 887 | * The amount of time a user needs to press the relevant key to bring up |
| 888 | * the global actions dialog. |
| 889 | * |
| 890 | * @return how long a user needs to press the relevant key to bring up |
| 891 | * the global actions dialog. |
Justin Koh | 8031fa0 | 2014-05-05 16:28:49 -0700 | [diff] [blame] | 892 | * @deprecated This timeout should not be used by applications |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 893 | */ |
Justin Koh | 1aa59f8 | 2014-05-04 12:13:25 -0700 | [diff] [blame] | 894 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 895 | public static long getGlobalActionKeyTimeout() { |
| 896 | return GLOBAL_ACTIONS_KEY_TIMEOUT; |
| 897 | } |
| 898 | |
| 899 | /** |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 900 | * The amount of time a user needs to press the relevant key to bring up |
| 901 | * the global actions dialog. |
| 902 | * |
| 903 | * @return how long a user needs to press the relevant key to bring up |
| 904 | * the global actions dialog. |
Justin Koh | 1aa59f8 | 2014-05-04 12:13:25 -0700 | [diff] [blame] | 905 | * @hide |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 906 | */ |
Aurimas Liutikas | 80e4e18 | 2018-08-13 16:13:37 -0700 | [diff] [blame] | 907 | @TestApi |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 908 | public long getDeviceGlobalActionKeyTimeout() { |
| 909 | return mGlobalActionsKeyTimeout; |
| 910 | } |
| 911 | |
| 912 | /** |
Edward Savage-Jones | 8f5c95b | 2018-11-14 22:19:28 +0100 | [diff] [blame] | 913 | * The amount of time a user needs to press the relevant keys to trigger |
| 914 | * the screenshot chord. |
| 915 | * |
| 916 | * @return how long a user needs to press the relevant keys to trigger |
| 917 | * the screenshot chord. |
| 918 | * @hide |
| 919 | */ |
| 920 | public long getScreenshotChordKeyTimeout() { |
| 921 | return mScreenshotChordKeyTimeout; |
| 922 | } |
| 923 | |
| 924 | /** |
Phil Weaver | 106fe73 | 2016-11-22 18:18:39 -0800 | [diff] [blame] | 925 | * The amount of time a user needs to press the relevant keys to activate the accessibility |
| 926 | * shortcut. |
| 927 | * |
| 928 | * @return how long a user needs to press the relevant keys to activate the accessibility |
| 929 | * shortcut. |
| 930 | * @hide |
| 931 | */ |
| 932 | public long getAccessibilityShortcutKeyTimeout() { |
| 933 | return A11Y_SHORTCUT_KEY_TIMEOUT; |
| 934 | } |
| 935 | |
| 936 | /** |
Eugene Susla | 5f19cd3 | 2017-10-19 14:00:59 -0700 | [diff] [blame] | 937 | * @return The amount of time a user needs to press the relevant keys to activate the |
| 938 | * accessibility shortcut after it's confirmed that accessibility shortcut is used. |
| 939 | * @hide |
| 940 | */ |
| 941 | public long getAccessibilityShortcutKeyTimeoutAfterConfirmation() { |
| 942 | return A11Y_SHORTCUT_KEY_TIMEOUT_AFTER_CONFIRMATION; |
| 943 | } |
| 944 | |
| 945 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 946 | * The amount of friction applied to scrolls and flings. |
Daisuke Miyakawa | c19895f | 2012-04-03 12:25:26 -0700 | [diff] [blame] | 947 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 948 | * @return A scalar dimensionless value representing the coefficient of |
| 949 | * friction. |
| 950 | */ |
| 951 | public static float getScrollFriction() { |
| 952 | return SCROLL_FRICTION; |
| 953 | } |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 954 | |
| 955 | /** |
Abodunrinwa Toki | 9e21128 | 2015-06-05 02:46:57 +0100 | [diff] [blame] | 956 | * @return the default duration in milliseconds for {@link ActionMode#hide(long)}. |
Abodunrinwa Toki | fd3a3a1 | 2015-05-05 20:04:34 +0100 | [diff] [blame] | 957 | */ |
Abodunrinwa Toki | 9e21128 | 2015-06-05 02:46:57 +0100 | [diff] [blame] | 958 | public static long getDefaultActionModeHideDuration() { |
| 959 | return ACTION_MODE_HIDE_DURATION_DEFAULT; |
Abodunrinwa Toki | fd3a3a1 | 2015-05-05 20:04:34 +0100 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | /** |
Philip Quinn | 1687d42 | 2020-01-24 12:49:46 -0800 | [diff] [blame] | 963 | * The multiplication factor for inhibiting default gestures. |
Siarhei Vishniakou | 8b047dd | 2019-01-24 16:04:13 -0800 | [diff] [blame] | 964 | * |
Philip Quinn | 1687d42 | 2020-01-24 12:49:46 -0800 | [diff] [blame] | 965 | * If a MotionEvent has {@link android.view.MotionEvent#CLASSIFICATION_AMBIGUOUS_GESTURE} set, |
| 966 | * then certain actions, such as scrolling, will be inhibited. However, to account for the |
| 967 | * possibility of an incorrect classification, existing gesture thresholds (e.g. scrolling |
| 968 | * touch slop and the long-press timeout) should be scaled by this factor and remain in effect. |
| 969 | * |
| 970 | * @deprecated Use {@link #getScaledAmbiguousGestureMultiplier()}. |
Siarhei Vishniakou | 8b047dd | 2019-01-24 16:04:13 -0800 | [diff] [blame] | 971 | */ |
Philip Quinn | 1687d42 | 2020-01-24 12:49:46 -0800 | [diff] [blame] | 972 | @Deprecated |
Siarhei Vishniakou | 8b047dd | 2019-01-24 16:04:13 -0800 | [diff] [blame] | 973 | @FloatRange(from = 1.0) |
| 974 | public static float getAmbiguousGestureMultiplier() { |
| 975 | return AMBIGUOUS_GESTURE_MULTIPLIER; |
| 976 | } |
| 977 | |
| 978 | /** |
Philip Quinn | 1687d42 | 2020-01-24 12:49:46 -0800 | [diff] [blame] | 979 | * The multiplication factor for inhibiting default gestures. |
| 980 | * |
| 981 | * If a MotionEvent has {@link android.view.MotionEvent#CLASSIFICATION_AMBIGUOUS_GESTURE} set, |
| 982 | * then certain actions, such as scrolling, will be inhibited. However, to account for the |
| 983 | * possibility of an incorrect classification, existing gesture thresholds (e.g. scrolling |
| 984 | * touch slop and the long-press timeout) should be scaled by this factor and remain in effect. |
| 985 | */ |
| 986 | @FloatRange(from = 1.0) |
| 987 | public float getScaledAmbiguousGestureMultiplier() { |
| 988 | return mAmbiguousGestureMultiplier; |
| 989 | } |
| 990 | |
| 991 | /** |
Adam Powell | 8c47062 | 2011-06-30 18:19:51 -0700 | [diff] [blame] | 992 | * Report if the device has a permanent menu key available to the user. |
| 993 | * |
| 994 | * <p>As of Android 3.0, devices may not have a permanent menu key available. |
| 995 | * Apps should use the action bar to present menu options to users. |
| 996 | * However, there are some apps where the action bar is inappropriate |
| 997 | * or undesirable. This method may be used to detect if a menu key is present. |
| 998 | * If not, applications should provide another on-screen affordance to access |
| 999 | * functionality. |
| 1000 | * |
| 1001 | * @return true if a permanent menu key is present, false otherwise. |
| 1002 | */ |
| 1003 | public boolean hasPermanentMenuKey() { |
| 1004 | return sHasPermanentMenuKey; |
| 1005 | } |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 1006 | |
| 1007 | /** |
Vladislav Kaznacheev | a725df9 | 2018-02-26 16:22:34 -0800 | [diff] [blame] | 1008 | * Check if shortcuts should be displayed in menus. |
| 1009 | * |
| 1010 | * @return {@code True} if shortcuts should be displayed in menus. |
| 1011 | */ |
| 1012 | public boolean shouldShowMenuShortcutsWhenKeyboardPresent() { |
| 1013 | return mShowMenuShortcutsWhenKeyboardPresent; |
| 1014 | } |
| 1015 | |
| 1016 | /** |
shepshapard | ba6dbff | 2019-02-06 16:14:22 -0800 | [diff] [blame] | 1017 | * Retrieves the distance in pixels between touches that must be reached for a gesture to be |
| 1018 | * interpreted as scaling. |
| 1019 | * |
| 1020 | * In general, scaling shouldn't start until this distance has been met or surpassed, and |
| 1021 | * scaling should end when the distance in pixels between touches drops below this distance. |
| 1022 | * |
| 1023 | * @return The distance in pixels |
| 1024 | * @throws IllegalStateException if this method is called on a ViewConfiguration that was |
| 1025 | * instantiated using a constructor with no Context parameter. |
| 1026 | */ |
shepshapard | 192c635 | 2019-02-26 11:05:46 -0800 | [diff] [blame] | 1027 | public int getScaledMinimumScalingSpan() { |
shepshapard | ba6dbff | 2019-02-06 16:14:22 -0800 | [diff] [blame] | 1028 | if (!mConstructedWithContext) { |
| 1029 | throw new IllegalStateException("Min scaling span cannot be determined when this " |
| 1030 | + "method is called on a ViewConfiguration that was instantiated using a " |
| 1031 | + "constructor with no Context parameter"); |
| 1032 | } |
| 1033 | return mMinScalingSpan; |
| 1034 | } |
| 1035 | |
| 1036 | /** |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 1037 | * @hide |
| 1038 | * @return Whether or not marquee should use fading edges. |
| 1039 | */ |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 1040 | @UnsupportedAppUsage |
Romain Guy | 6805545 | 2011-08-02 16:33:02 -0700 | [diff] [blame] | 1041 | public boolean isFadingMarqueeEnabled() { |
| 1042 | return mFadingMarqueeEnabled; |
| 1043 | } |
Vladislav Kaznacheev | f847ee3 | 2016-11-21 14:11:00 -0800 | [diff] [blame] | 1044 | |
| 1045 | /** |
| 1046 | * @return the duration in milliseconds before an end of a long press causes a tooltip to be |
| 1047 | * hidden |
| 1048 | * @hide |
| 1049 | */ |
| 1050 | @TestApi |
| 1051 | public static int getLongPressTooltipHideTimeout() { |
| 1052 | return LONG_PRESS_TOOLTIP_HIDE_TIMEOUT; |
| 1053 | } |
| 1054 | |
| 1055 | /** |
| 1056 | * @return the duration in milliseconds before a hover event causes a tooltip to be shown |
| 1057 | * @hide |
| 1058 | */ |
| 1059 | @TestApi |
| 1060 | public static int getHoverTooltipShowTimeout() { |
| 1061 | return HOVER_TOOLTIP_SHOW_TIMEOUT; |
| 1062 | } |
| 1063 | |
| 1064 | /** |
| 1065 | * @return the duration in milliseconds before mouse inactivity causes a tooltip to be hidden |
| 1066 | * (default variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is not set). |
| 1067 | * @hide |
| 1068 | */ |
| 1069 | @TestApi |
| 1070 | public static int getHoverTooltipHideTimeout() { |
| 1071 | return HOVER_TOOLTIP_HIDE_TIMEOUT; |
| 1072 | } |
| 1073 | |
| 1074 | /** |
| 1075 | * @return the duration in milliseconds before mouse inactivity causes a tooltip to be hidden |
| 1076 | * (shorter variant to be used when {@link View#SYSTEM_UI_FLAG_LOW_PROFILE} is set). |
| 1077 | * @hide |
| 1078 | */ |
| 1079 | @TestApi |
| 1080 | public static int getHoverTooltipHideShortTimeout() { |
| 1081 | return HOVER_TOOLTIP_HIDE_SHORT_TIMEOUT; |
| 1082 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1083 | } |