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