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 | |
| 19 | import android.content.pm.ActivityInfo; |
| 20 | import android.graphics.PixelFormat; |
| 21 | import android.os.IBinder; |
| 22 | import android.os.Parcel; |
| 23 | import android.os.Parcelable; |
| 24 | import android.text.TextUtils; |
| 25 | import android.util.Log; |
| 26 | |
| 27 | |
| 28 | /** |
| 29 | * The interface that apps use to talk to the window manager. |
| 30 | * <p> |
| 31 | * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these. |
| 32 | * |
| 33 | * @see android.content.Context#getSystemService |
| 34 | * @see android.content.Context#WINDOW_SERVICE |
| 35 | */ |
| 36 | public interface WindowManager extends ViewManager { |
| 37 | /** |
| 38 | * Exception that is thrown when trying to add view whose |
| 39 | * {@link WindowManager.LayoutParams} {@link WindowManager.LayoutParams#token} |
| 40 | * is invalid. |
| 41 | */ |
| 42 | public static class BadTokenException extends RuntimeException { |
| 43 | public BadTokenException() { |
| 44 | } |
| 45 | |
| 46 | public BadTokenException(String name) { |
| 47 | super(name); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Use this method to get the default Display object. |
| 53 | * |
| 54 | * @return default Display object |
| 55 | */ |
| 56 | public Display getDefaultDisplay(); |
| 57 | |
| 58 | /** |
| 59 | * Special variation of {@link #removeView} that immediately invokes |
| 60 | * the given view hierarchy's {@link View#onDetachedFromWindow() |
| 61 | * View.onDetachedFromWindow()} methods before returning. This is not |
| 62 | * for normal applications; using it correctly requires great care. |
| 63 | * |
| 64 | * @param view The view to be removed. |
| 65 | */ |
| 66 | public void removeViewImmediate(View view); |
| 67 | |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 68 | /** |
| 69 | * Return true if this window manager is configured to request hardware |
| 70 | * accelerated windows. This does <em>not</em> guarantee that they will |
| 71 | * actually be accelerated, since that depends on the device supporting them. |
| 72 | * @hide |
| 73 | */ |
| 74 | public boolean isHardwareAccelerated(); |
| 75 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | public static class LayoutParams extends ViewGroup.LayoutParams |
| 77 | implements Parcelable { |
| 78 | /** |
| 79 | * X position for this window. With the default gravity it is ignored. |
| 80 | * When using {@link Gravity#LEFT} or {@link Gravity#RIGHT} it provides |
| 81 | * an offset from the given edge. |
| 82 | */ |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 83 | @ViewDebug.ExportedProperty |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | public int x; |
| 85 | |
| 86 | /** |
| 87 | * Y position for this window. With the default gravity it is ignored. |
| 88 | * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides |
| 89 | * an offset from the given edge. |
| 90 | */ |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 91 | @ViewDebug.ExportedProperty |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | public int y; |
| 93 | |
| 94 | /** |
| 95 | * Indicates how much of the extra space will be allocated horizontally |
| 96 | * to the view associated with these LayoutParams. Specify 0 if the view |
| 97 | * should not be stretched. Otherwise the extra pixels will be pro-rated |
| 98 | * among all views whose weight is greater than 0. |
| 99 | */ |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 100 | @ViewDebug.ExportedProperty |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 101 | public float horizontalWeight; |
| 102 | |
| 103 | /** |
| 104 | * Indicates how much of the extra space will be allocated vertically |
| 105 | * to the view associated with these LayoutParams. Specify 0 if the view |
| 106 | * should not be stretched. Otherwise the extra pixels will be pro-rated |
| 107 | * among all views whose weight is greater than 0. |
| 108 | */ |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 109 | @ViewDebug.ExportedProperty |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | public float verticalWeight; |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 111 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | /** |
| 113 | * The general type of window. There are three main classes of |
| 114 | * window types: |
| 115 | * <ul> |
| 116 | * <li> <strong>Application windows</strong> (ranging from |
| 117 | * {@link #FIRST_APPLICATION_WINDOW} to |
| 118 | * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application |
| 119 | * windows. For these types of windows, the {@link #token} must be |
| 120 | * set to the token of the activity they are a part of (this will |
| 121 | * normally be done for you if {@link #token} is null). |
| 122 | * <li> <strong>Sub-windows</strong> (ranging from |
| 123 | * {@link #FIRST_SUB_WINDOW} to |
| 124 | * {@link #LAST_SUB_WINDOW}) are associated with another top-level |
| 125 | * window. For these types of windows, the {@link #token} must be |
| 126 | * the token of the window it is attached to. |
| 127 | * <li> <strong>System windows</strong> (ranging from |
| 128 | * {@link #FIRST_SYSTEM_WINDOW} to |
| 129 | * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for |
| 130 | * use by the system for specific purposes. They should not normally |
| 131 | * be used by applications, and a special permission is required |
| 132 | * to use them. |
| 133 | * </ul> |
| 134 | * |
| 135 | * @see #TYPE_BASE_APPLICATION |
| 136 | * @see #TYPE_APPLICATION |
| 137 | * @see #TYPE_APPLICATION_STARTING |
| 138 | * @see #TYPE_APPLICATION_PANEL |
| 139 | * @see #TYPE_APPLICATION_MEDIA |
| 140 | * @see #TYPE_APPLICATION_SUB_PANEL |
| 141 | * @see #TYPE_APPLICATION_ATTACHED_DIALOG |
| 142 | * @see #TYPE_STATUS_BAR |
| 143 | * @see #TYPE_SEARCH_BAR |
| 144 | * @see #TYPE_PHONE |
| 145 | * @see #TYPE_SYSTEM_ALERT |
| 146 | * @see #TYPE_KEYGUARD |
| 147 | * @see #TYPE_TOAST |
| 148 | * @see #TYPE_SYSTEM_OVERLAY |
| 149 | * @see #TYPE_PRIORITY_PHONE |
| 150 | * @see #TYPE_STATUS_BAR_PANEL |
| 151 | * @see #TYPE_SYSTEM_DIALOG |
| 152 | * @see #TYPE_KEYGUARD_DIALOG |
| 153 | * @see #TYPE_SYSTEM_ERROR |
| 154 | * @see #TYPE_INPUT_METHOD |
| 155 | * @see #TYPE_INPUT_METHOD_DIALOG |
| 156 | */ |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 157 | @ViewDebug.ExportedProperty(mapping = { |
| 158 | @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"), |
| 159 | @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"), |
| 160 | @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"), |
| 161 | @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"), |
| 162 | @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"), |
| 163 | @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"), |
| 164 | @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"), |
| 165 | @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"), |
| 166 | @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"), |
| 167 | @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"), |
| 168 | @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"), |
| 169 | @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"), |
| 170 | @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"), |
| 171 | @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"), |
| 172 | @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"), |
| 173 | @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"), |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 174 | @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"), |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 175 | @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"), |
| 176 | @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"), |
| 177 | @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"), |
| 178 | @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"), |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 179 | @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"), |
| 180 | @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY") |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 181 | }) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 182 | public int type; |
| 183 | |
| 184 | /** |
| 185 | * Start of window types that represent normal application windows. |
| 186 | */ |
| 187 | public static final int FIRST_APPLICATION_WINDOW = 1; |
| 188 | |
| 189 | /** |
| 190 | * Window type: an application window that serves as the "base" window |
| 191 | * of the overall application; all other application windows will |
| 192 | * appear on top of it. |
| 193 | */ |
| 194 | public static final int TYPE_BASE_APPLICATION = 1; |
| 195 | |
| 196 | /** |
| 197 | * Window type: a normal application window. The {@link #token} must be |
| 198 | * an Activity token identifying who the window belongs to. |
| 199 | */ |
| 200 | public static final int TYPE_APPLICATION = 2; |
| 201 | |
| 202 | /** |
| 203 | * Window type: special application window that is displayed while the |
| 204 | * application is starting. Not for use by applications themselves; |
| 205 | * this is used by the system to display something until the |
| 206 | * application can show its own windows. |
| 207 | */ |
| 208 | public static final int TYPE_APPLICATION_STARTING = 3; |
| 209 | |
| 210 | /** |
| 211 | * End of types of application windows. |
| 212 | */ |
| 213 | public static final int LAST_APPLICATION_WINDOW = 99; |
| 214 | |
| 215 | /** |
| 216 | * Start of types of sub-windows. The {@link #token} of these windows |
| 217 | * must be set to the window they are attached to. These types of |
| 218 | * windows are kept next to their attached window in Z-order, and their |
| 219 | * coordinate space is relative to their attached window. |
| 220 | */ |
| 221 | public static final int FIRST_SUB_WINDOW = 1000; |
| 222 | |
| 223 | /** |
| 224 | * Window type: a panel on top of an application window. These windows |
| 225 | * appear on top of their attached window. |
| 226 | */ |
| 227 | public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; |
| 228 | |
| 229 | /** |
| 230 | * Window type: window for showing media (e.g. video). These windows |
| 231 | * are displayed behind their attached window. |
| 232 | */ |
| 233 | public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1; |
| 234 | |
| 235 | /** |
| 236 | * Window type: a sub-panel on top of an application window. These |
| 237 | * windows are displayed on top their attached window and any |
| 238 | * {@link #TYPE_APPLICATION_PANEL} panels. |
| 239 | */ |
| 240 | public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2; |
| 241 | |
| 242 | /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout |
| 243 | * of the window happens as that of a top-level window, <em>not</em> |
| 244 | * as a child of its container. |
| 245 | */ |
| 246 | public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3; |
| 247 | |
| 248 | /** |
Dianne Hackborn | c4d5d02 | 2009-05-21 17:32:42 -0700 | [diff] [blame] | 249 | * Window type: window for showing overlays on top of media windows. |
| 250 | * These windows are displayed between TYPE_APPLICATION_MEDIA and the |
| 251 | * application window. They should be translucent to be useful. This |
| 252 | * is a big ugly hack so: |
| 253 | * @hide |
| 254 | */ |
| 255 | public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4; |
| 256 | |
| 257 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 258 | * End of types of sub-windows. |
| 259 | */ |
| 260 | public static final int LAST_SUB_WINDOW = 1999; |
| 261 | |
| 262 | /** |
| 263 | * Start of system-specific window types. These are not normally |
| 264 | * created by applications. |
| 265 | */ |
| 266 | public static final int FIRST_SYSTEM_WINDOW = 2000; |
| 267 | |
| 268 | /** |
| 269 | * Window type: the status bar. There can be only one status bar |
| 270 | * window; it is placed at the top of the screen, and all other |
| 271 | * windows are shifted down so they are below it. |
| 272 | */ |
| 273 | public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; |
| 274 | |
| 275 | /** |
| 276 | * Window type: the search bar. There can be only one search bar |
| 277 | * window; it is placed at the top of the screen. |
| 278 | */ |
| 279 | public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; |
| 280 | |
| 281 | /** |
| 282 | * Window type: phone. These are non-application windows providing |
| 283 | * user interaction with the phone (in particular incoming calls). |
| 284 | * These windows are normally placed above all applications, but behind |
| 285 | * the status bar. |
| 286 | */ |
| 287 | public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; |
| 288 | |
| 289 | /** |
| 290 | * Window type: system window, such as low power alert. These windows |
| 291 | * are always on top of application windows. |
| 292 | */ |
| 293 | public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; |
| 294 | |
| 295 | /** |
| 296 | * Window type: keyguard window. |
| 297 | */ |
| 298 | public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; |
| 299 | |
| 300 | /** |
| 301 | * Window type: transient notifications. |
| 302 | */ |
| 303 | public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; |
| 304 | |
| 305 | /** |
| 306 | * Window type: system overlay windows, which need to be displayed |
| 307 | * on top of everything else. These windows must not take input |
| 308 | * focus, or they will interfere with the keyguard. |
| 309 | */ |
| 310 | public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; |
| 311 | |
| 312 | /** |
| 313 | * Window type: priority phone UI, which needs to be displayed even if |
| 314 | * the keyguard is active. These windows must not take input |
| 315 | * focus, or they will interfere with the keyguard. |
| 316 | */ |
| 317 | public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; |
| 318 | |
| 319 | /** |
| 320 | * Window type: panel that slides out from the status bar |
| 321 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 322 | public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; |
| 323 | |
| 324 | /** |
| 325 | * Window type: dialogs that the keyguard shows |
| 326 | */ |
| 327 | public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; |
| 328 | |
| 329 | /** |
| 330 | * Window type: internal system error windows, appear on top of |
| 331 | * everything they can. |
| 332 | */ |
| 333 | public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; |
| 334 | |
| 335 | /** |
| 336 | * Window type: internal input methods windows, which appear above |
| 337 | * the normal UI. Application windows may be resized or panned to keep |
| 338 | * the input focus visible while this window is displayed. |
| 339 | */ |
| 340 | public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; |
| 341 | |
| 342 | /** |
| 343 | * Window type: internal input methods dialog windows, which appear above |
| 344 | * the current input method window. |
| 345 | */ |
| 346 | public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; |
| 347 | |
| 348 | /** |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 349 | * Window type: wallpaper window, placed behind any window that wants |
| 350 | * to sit on top of the wallpaper. |
| 351 | */ |
| 352 | public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; |
| 353 | |
| 354 | /** |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 355 | * Window type: panel that slides out from over the status bar |
Dianne Hackborn | badc47e | 2009-11-08 17:37:07 -0800 | [diff] [blame] | 356 | */ |
| 357 | public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 358 | |
| 359 | /** |
| 360 | * Window type: secure system overlay windows, which need to be displayed |
| 361 | * on top of everything else. These windows must not take input |
| 362 | * focus, or they will interfere with the keyguard. |
| 363 | * |
| 364 | * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the |
| 365 | * system itself is allowed to create these overlays. Applications cannot |
| 366 | * obtain permission to create secure system overlays. |
| 367 | * @hide |
| 368 | */ |
| 369 | public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; |
| 370 | |
Dianne Hackborn | badc47e | 2009-11-08 17:37:07 -0800 | [diff] [blame] | 371 | /** |
Christopher Tate | a53146c | 2010-09-07 11:57:52 -0700 | [diff] [blame] | 372 | * Window type: the drag-and-drop pseudowindow. There is only one |
| 373 | * drag layer (at most), and it is placed on top of all other windows. |
| 374 | * @hide |
| 375 | */ |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 376 | public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; |
Christopher Tate | a53146c | 2010-09-07 11:57:52 -0700 | [diff] [blame] | 377 | |
| 378 | /** |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 379 | * Window type: panel that slides out from under the status bar |
Joe Onorato | a89e903 | 2010-11-24 11:13:44 -0800 | [diff] [blame] | 380 | * @hide |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 381 | */ |
| 382 | public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; |
| 383 | |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 384 | /** |
| 385 | * Window type: (mouse) pointer |
| 386 | * @hide |
| 387 | */ |
| 388 | public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 389 | |
| 390 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 391 | * End of types of system windows. |
| 392 | */ |
| 393 | public static final int LAST_SYSTEM_WINDOW = 2999; |
| 394 | |
| 395 | /** |
Mathias Agopian | d211230 | 2010-12-07 19:38:17 -0800 | [diff] [blame] | 396 | * @deprecated this is ignored |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 397 | */ |
Mathias Agopian | d211230 | 2010-12-07 19:38:17 -0800 | [diff] [blame] | 398 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | public int memoryType; |
| 400 | |
Mathias Agopian | d211230 | 2010-12-07 19:38:17 -0800 | [diff] [blame] | 401 | /** @deprecated this is ignored, this value is set automatically when needed. */ |
| 402 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 403 | public static final int MEMORY_TYPE_NORMAL = 0; |
Mathias Agopian | d211230 | 2010-12-07 19:38:17 -0800 | [diff] [blame] | 404 | /** @deprecated this is ignored, this value is set automatically when needed. */ |
Mathias Agopian | 317a628 | 2009-08-13 17:29:02 -0700 | [diff] [blame] | 405 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 406 | public static final int MEMORY_TYPE_HARDWARE = 1; |
Mathias Agopian | d211230 | 2010-12-07 19:38:17 -0800 | [diff] [blame] | 407 | /** @deprecated this is ignored, this value is set automatically when needed. */ |
Mathias Agopian | 317a628 | 2009-08-13 17:29:02 -0700 | [diff] [blame] | 408 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 409 | public static final int MEMORY_TYPE_GPU = 2; |
Mathias Agopian | d211230 | 2010-12-07 19:38:17 -0800 | [diff] [blame] | 410 | /** @deprecated this is ignored, this value is set automatically when needed. */ |
| 411 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 412 | public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; |
| 413 | |
| 414 | /** |
| 415 | * Various behavioral options/flags. Default is none. |
| 416 | * |
| 417 | * @see #FLAG_BLUR_BEHIND |
| 418 | * @see #FLAG_DIM_BEHIND |
| 419 | * @see #FLAG_NOT_FOCUSABLE |
| 420 | * @see #FLAG_NOT_TOUCHABLE |
| 421 | * @see #FLAG_NOT_TOUCH_MODAL |
| 422 | * @see #FLAG_LAYOUT_IN_SCREEN |
| 423 | * @see #FLAG_DITHER |
| 424 | * @see #FLAG_KEEP_SCREEN_ON |
| 425 | * @see #FLAG_FULLSCREEN |
| 426 | * @see #FLAG_FORCE_NOT_FULLSCREEN |
| 427 | * @see #FLAG_IGNORE_CHEEK_PRESSES |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 428 | * @see #FLAG_HARDWARE_ACCELERATED |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 429 | */ |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 430 | @ViewDebug.ExportedProperty(flagMapping = { |
| 431 | @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, |
| 432 | name = "FLAG_BLUR_BEHIND"), |
| 433 | @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, |
| 434 | name = "FLAG_DIM_BEHIND"), |
| 435 | @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, |
| 436 | name = "FLAG_NOT_FOCUSABLE"), |
| 437 | @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, |
| 438 | name = "FLAG_NOT_TOUCHABLE"), |
| 439 | @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, |
| 440 | name = "FLAG_NOT_TOUCH_MODAL"), |
| 441 | @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, |
| 442 | name = "FLAG_LAYOUT_IN_SCREEN"), |
| 443 | @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, |
| 444 | name = "FLAG_DITHER"), |
Daniel Sandler | 20e9271 | 2010-04-02 16:51:58 -0400 | [diff] [blame] | 445 | @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, |
| 446 | name = "FLAG_TURN_SCREEN_ON"), |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 447 | @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, |
| 448 | name = "FLAG_KEEP_SCREEN_ON"), |
Daniel Sandler | 20e9271 | 2010-04-02 16:51:58 -0400 | [diff] [blame] | 449 | @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, |
| 450 | name = "FLAG_SHOW_WHEN_LOCKED"), |
| 451 | @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, |
| 452 | name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"), |
| 453 | @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, |
| 454 | name = "FLAG_DISMISS_KEYGUARD"), |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 455 | @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, |
| 456 | name = "FLAG_FULLSCREEN"), |
| 457 | @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, |
| 458 | equals = FLAG_FORCE_NOT_FULLSCREEN, name = "FLAG_FORCE_NOT_FULLSCREEN"), |
| 459 | @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 460 | equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES"), |
| 461 | @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, |
| 462 | equals = FLAG_HARDWARE_ACCELERATED, name = "FLAG_HARDWARE_ACCELERATED") |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 463 | }) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 464 | public int flags; |
| 465 | |
Mike Lockwood | ef73162 | 2010-01-27 17:51:34 -0500 | [diff] [blame] | 466 | /** Window flag: as long as this window is visible to the user, allow |
| 467 | * the lock screen to activate while the screen is on. |
| 468 | * This can be used independently, or in combination with |
Christopher Tate | 95f7850 | 2010-01-29 15:57:34 -0800 | [diff] [blame] | 469 | * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ |
Mike Lockwood | ef73162 | 2010-01-27 17:51:34 -0500 | [diff] [blame] | 470 | public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; |
| 471 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 472 | /** Window flag: everything behind this window will be dimmed. |
| 473 | * Use {@link #dimAmount} to control the amount of dim. */ |
| 474 | public static final int FLAG_DIM_BEHIND = 0x00000002; |
| 475 | |
| 476 | /** Window flag: blur everything behind this window. */ |
| 477 | public static final int FLAG_BLUR_BEHIND = 0x00000004; |
| 478 | |
| 479 | /** Window flag: this window won't ever get key input focus, so the |
| 480 | * user can not send key or other button events to it. Those will |
| 481 | * instead go to whatever focusable window is behind it. This flag |
| 482 | * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that |
| 483 | * is explicitly set. |
| 484 | * |
| 485 | * <p>Setting this flag also implies that the window will not need to |
| 486 | * interact with |
| 487 | * a soft input method, so it will be Z-ordered and positioned |
| 488 | * independently of any active input method (typically this means it |
| 489 | * gets Z-ordered on top of the input method, so it can use the full |
| 490 | * screen for its content and cover the input method if needed. You |
| 491 | * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ |
| 492 | public static final int FLAG_NOT_FOCUSABLE = 0x00000008; |
| 493 | |
| 494 | /** Window flag: this window can never receive touch events. */ |
| 495 | public static final int FLAG_NOT_TOUCHABLE = 0x00000010; |
| 496 | |
| 497 | /** Window flag: Even when this window is focusable (its |
| 498 | * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events |
| 499 | * outside of the window to be sent to the windows behind it. Otherwise |
| 500 | * it will consume all pointer events itself, regardless of whether they |
| 501 | * are inside of the window. */ |
| 502 | public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; |
| 503 | |
| 504 | /** Window flag: When set, if the device is asleep when the touch |
| 505 | * screen is pressed, you will receive this first touch event. Usually |
| 506 | * the first touch event is consumed by the system since the user can |
| 507 | * not see what they are pressing on. |
| 508 | */ |
| 509 | public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; |
| 510 | |
| 511 | /** Window flag: as long as this window is visible to the user, keep |
| 512 | * the device's screen turned on and bright. */ |
| 513 | public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; |
| 514 | |
| 515 | /** Window flag: place the window within the entire screen, ignoring |
| 516 | * decorations around the border (a.k.a. the status bar). The |
| 517 | * window must correctly position its contents to take the screen |
| 518 | * decoration into account. This flag is normally set for you |
| 519 | * by Window as described in {@link Window#setFlags}. */ |
| 520 | public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; |
| 521 | |
| 522 | /** Window flag: allow window to extend outside of the screen. */ |
| 523 | public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; |
| 524 | |
| 525 | /** Window flag: Hide all screen decorations (e.g. status bar) while |
| 526 | * this window is displayed. This allows the window to use the entire |
| 527 | * display space for itself -- the status bar will be hidden when |
| 528 | * an app window with this flag set is on the top layer. */ |
| 529 | public static final int FLAG_FULLSCREEN = 0x00000400; |
| 530 | |
| 531 | /** Window flag: Override {@link #FLAG_FULLSCREEN and force the |
| 532 | * screen decorations (such as status bar) to be shown. */ |
| 533 | public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; |
| 534 | |
| 535 | /** Window flag: turn on dithering when compositing this window to |
| 536 | * the screen. */ |
| 537 | public static final int FLAG_DITHER = 0x00001000; |
| 538 | |
| 539 | /** Window flag: don't allow screen shots while this window is |
| 540 | * displayed. */ |
| 541 | public static final int FLAG_SECURE = 0x00002000; |
| 542 | |
| 543 | /** Window flag: a special mode where the layout parameters are used |
| 544 | * to perform scaling of the surface when it is composited to the |
| 545 | * screen. */ |
| 546 | public static final int FLAG_SCALED = 0x00004000; |
| 547 | |
| 548 | /** Window flag: intended for windows that will often be used when the user is |
| 549 | * holding the screen against their face, it will aggressively filter the event |
| 550 | * stream to prevent unintended presses in this situation that may not be |
| 551 | * desired for a particular window, when such an event stream is detected, the |
| 552 | * application will receive a CANCEL motion event to indicate this so applications |
| 553 | * can handle this accordingly by taking no action on the event |
| 554 | * until the finger is released. */ |
| 555 | public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; |
| 556 | |
| 557 | /** Window flag: a special option only for use in combination with |
| 558 | * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the |
| 559 | * screen your window may appear on top of or behind screen decorations |
| 560 | * such as the status bar. By also including this flag, the window |
| 561 | * manager will report the inset rectangle needed to ensure your |
| 562 | * content is not covered by screen decorations. This flag is normally |
| 563 | * set for you by Window as described in {@link Window#setFlags}.*/ |
| 564 | public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; |
| 565 | |
| 566 | /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with |
| 567 | * respect to how this window interacts with the current method. That |
| 568 | * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the |
| 569 | * window will behave as if it needs to interact with the input method |
| 570 | * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is |
| 571 | * not set and this flag is set, then the window will behave as if it |
| 572 | * doesn't need to interact with the input method and can be placed |
| 573 | * to use more space and cover the input method. |
| 574 | */ |
| 575 | public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; |
| 576 | |
| 577 | /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you |
| 578 | * can set this flag to receive a single special MotionEvent with |
| 579 | * the action |
| 580 | * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for |
| 581 | * touches that occur outside of your window. Note that you will not |
| 582 | * receive the full down/move/up gesture, only the location of the |
| 583 | * first down as an ACTION_OUTSIDE. |
| 584 | */ |
| 585 | public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; |
| 586 | |
Suchi Amalapurapu | d1a9337 | 2009-05-14 17:54:31 -0700 | [diff] [blame] | 587 | /** Window flag: special flag to let windows be shown when the screen |
| 588 | * is locked. This will let application windows take precedence over |
| 589 | * key guard or any other lock screens. Can be used with |
| 590 | * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 591 | * directly before showing the key guard window. Can be used with |
| 592 | * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss |
| 593 | * non-secure keyguards. This flag only applies to the top-most |
| 594 | * full-screen window. |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 595 | */ |
Suchi Amalapurapu | d1a9337 | 2009-05-14 17:54:31 -0700 | [diff] [blame] | 596 | public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; |
| 597 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 598 | /** Window flag: ask that the system wallpaper be shown behind |
| 599 | * your window. The window surface must be translucent to be able |
| 600 | * to actually see the wallpaper behind it; this flag just ensures |
| 601 | * that the wallpaper surface will be there if this window actually |
| 602 | * has translucent regions. |
| 603 | */ |
| 604 | public static final int FLAG_SHOW_WALLPAPER = 0x00100000; |
| 605 | |
Dianne Hackborn | 93e462b | 2009-09-15 22:50:40 -0700 | [diff] [blame] | 606 | /** Window flag: when set as a window is being added or made |
| 607 | * visible, once the window has been shown then the system will |
| 608 | * poke the power manager's user activity (as if the user had woken |
| 609 | * up the device) to turn the screen on. */ |
| 610 | public static final int FLAG_TURN_SCREEN_ON = 0x00200000; |
| 611 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 612 | /** Window flag: when set the window will cause the keyguard to |
| 613 | * be dismissed, only if it is not a secure lock keyguard. Because such |
| 614 | * a keyguard is not needed for security, it will never re-appear if |
| 615 | * the user navigates to another window (in contrast to |
| 616 | * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily |
| 617 | * hide both secure and non-secure keyguards but ensure they reappear |
| 618 | * when the user moves to another UI that doesn't hide them). |
| 619 | * If the keyguard is currently active and is secure (requires an |
| 620 | * unlock pattern) than the user will still need to confirm it before |
| 621 | * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has |
Daniel Sandler | ae069f7 | 2010-06-17 21:56:26 -0400 | [diff] [blame] | 622 | * also been set. |
| 623 | */ |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 624 | public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; |
Jeff Brown | 01ce2e9 | 2010-09-26 22:20:12 -0700 | [diff] [blame] | 625 | |
| 626 | /** Window flag: when set the window will accept for touch events |
| 627 | * outside of its bounds to be sent to other windows that also |
| 628 | * support split touch. When this flag is not set, the first pointer |
| 629 | * that goes down determines the window to which all subsequent touches |
| 630 | * go until all pointers go up. When this flag is set, each pointer |
| 631 | * (not necessarily the first) that goes down determines the window |
| 632 | * to which all subsequent touches of that pointer will go until that |
| 633 | * pointer goes up thereby enabling touches with multiple pointers |
| 634 | * to be split across multiple windows. |
Dianne Hackborn | d9b3b7e | 2010-11-16 18:22:49 -0800 | [diff] [blame] | 635 | */ |
Jeff Brown | 01ce2e9 | 2010-09-26 22:20:12 -0700 | [diff] [blame] | 636 | public static final int FLAG_SPLIT_TOUCH = 0x00800000; |
Dianne Hackborn | d9b3b7e | 2010-11-16 18:22:49 -0800 | [diff] [blame] | 637 | |
| 638 | /** |
Romain Guy | 72f0a27 | 2011-01-09 16:01:46 -0800 | [diff] [blame] | 639 | * <p>Indicates whether this window should be hardware accelerated. |
| 640 | * Requesting hardware acceleration does not guarantee it will happen.</p> |
| 641 | * |
| 642 | * <p>This flag can be controlled programmatically <em>only</em> to enable |
| 643 | * hardware acceleration. To enable hardware acceleration for a given |
| 644 | * window programmatically, do the following:</p> |
| 645 | * |
| 646 | * <pre> |
| 647 | * Window w = activity.getWindow(); // in Activity's onCreate() for instance |
| 648 | * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, |
| 649 | * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); |
| 650 | * </pre> |
| 651 | * |
| 652 | * <p>It is important to remember that this flag <strong>must</strong> |
| 653 | * be set before setting the content view of your activity or dialog.</p> |
| 654 | * |
| 655 | * <p>This flag cannot be used to disable hardware acceleration after it |
| 656 | * was enabled in your manifest using |
| 657 | * {@link android.R.attr#hardwareAccelerated}. If you need to selectively |
| 658 | * and programmatically disable hardware acceleration (for automated testing |
| 659 | * for instance), make sure it is turned off in your manifest and enable it |
| 660 | * on your activity or dialog when you need it instead, using the method |
| 661 | * described above.</p> |
| 662 | * |
| 663 | * <p>This flag is automatically set by the system if the |
| 664 | * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} |
| 665 | * XML attribute is set to true on an activity or on the application.</p> |
Dianne Hackborn | d9b3b7e | 2010-11-16 18:22:49 -0800 | [diff] [blame] | 666 | */ |
| 667 | public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000; |
Daniel Sandler | 611fae4 | 2010-06-17 10:45:00 -0400 | [diff] [blame] | 668 | |
Dianne Hackborn | d9b3b7e | 2010-11-16 18:22:49 -0800 | [diff] [blame] | 669 | // ----- HIDDEN FLAGS. |
| 670 | // These start at the high bit and go down. |
| 671 | |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 672 | /** |
| 673 | * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU} |
| 674 | * and therefore needs a Menu key. For devices where Menu is a physical button this flag is |
| 675 | * ignored, but on devices where the Menu key is drawn in software it may be hidden unless |
| 676 | * this flag is set. |
| 677 | * |
| 678 | * (Note that Action Bars, when available, are the preferred way to offer additional |
| 679 | * functions otherwise accessed via an options menu.) |
| 680 | * |
| 681 | * {@hide} |
| 682 | */ |
Dianne Hackborn | d9b3b7e | 2010-11-16 18:22:49 -0800 | [diff] [blame] | 683 | public static final int FLAG_NEEDS_MENU_KEY = 0x08000000; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 684 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 685 | /** Window flag: *sigh* The lock screen wants to continue running its |
| 686 | * animation while it is fading. A kind-of hack to allow this. Maybe |
| 687 | * in the future we just make this the default behavior. |
| 688 | * |
| 689 | * {@hide} */ |
| 690 | public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000; |
| 691 | |
Mitsuru Oshima | 1ecf5d2 | 2009-07-06 17:20:38 -0700 | [diff] [blame] | 692 | /** Window flag: special flag to limit the size of the window to be |
| 693 | * original size ([320x480] x density). Used to create window for applications |
| 694 | * running under compatibility mode. |
| 695 | * |
| 696 | * {@hide} */ |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 697 | public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000; |
Mitsuru Oshima | 1ecf5d2 | 2009-07-06 17:20:38 -0700 | [diff] [blame] | 698 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 699 | /** Window flag: a special option intended for system dialogs. When |
| 700 | * this flag is set, the window will demand focus unconditionally when |
| 701 | * it is created. |
| 702 | * {@hide} */ |
| 703 | public static final int FLAG_SYSTEM_ERROR = 0x40000000; |
| 704 | |
| 705 | /** |
| 706 | * Given a particular set of window manager flags, determine whether |
| 707 | * such a window may be a target for an input method when it has |
| 708 | * focus. In particular, this checks the |
| 709 | * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} |
| 710 | * flags and returns true if the combination of the two corresponds |
| 711 | * to a window that needs to be behind the input method so that the |
| 712 | * user can type into it. |
| 713 | * |
| 714 | * @param flags The current window manager flags. |
| 715 | * |
| 716 | * @return Returns true if such a window should be behind/interact |
| 717 | * with an input method, false if not. |
| 718 | */ |
| 719 | public static boolean mayUseInputMethod(int flags) { |
| 720 | switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { |
| 721 | case 0: |
| 722 | case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: |
| 723 | return true; |
| 724 | } |
| 725 | return false; |
| 726 | } |
| 727 | |
| 728 | /** |
| 729 | * Mask for {@link #softInputMode} of the bits that determine the |
| 730 | * desired visibility state of the soft input area for this window. |
| 731 | */ |
| 732 | public static final int SOFT_INPUT_MASK_STATE = 0x0f; |
| 733 | |
| 734 | /** |
| 735 | * Visibility state for {@link #softInputMode}: no state has been specified. |
| 736 | */ |
| 737 | public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; |
| 738 | |
| 739 | /** |
| 740 | * Visibility state for {@link #softInputMode}: please don't change the state of |
| 741 | * the soft input area. |
| 742 | */ |
| 743 | public static final int SOFT_INPUT_STATE_UNCHANGED = 1; |
| 744 | |
| 745 | /** |
| 746 | * Visibility state for {@link #softInputMode}: please hide any soft input |
| 747 | * area when normally appropriate (when the user is navigating |
| 748 | * forward to your window). |
| 749 | */ |
| 750 | public static final int SOFT_INPUT_STATE_HIDDEN = 2; |
| 751 | |
| 752 | /** |
| 753 | * Visibility state for {@link #softInputMode}: please always hide any |
| 754 | * soft input area when this window receives focus. |
| 755 | */ |
| 756 | public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; |
| 757 | |
| 758 | /** |
| 759 | * Visibility state for {@link #softInputMode}: please show the soft |
| 760 | * input area when normally appropriate (when the user is navigating |
| 761 | * forward to your window). |
| 762 | */ |
| 763 | public static final int SOFT_INPUT_STATE_VISIBLE = 4; |
| 764 | |
| 765 | /** |
| 766 | * Visibility state for {@link #softInputMode}: please always make the |
| 767 | * soft input area visible when this window receives input focus. |
| 768 | */ |
| 769 | public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; |
| 770 | |
| 771 | /** |
| 772 | * Mask for {@link #softInputMode} of the bits that determine the |
| 773 | * way that the window should be adjusted to accommodate the soft |
| 774 | * input window. |
| 775 | */ |
| 776 | public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; |
| 777 | |
| 778 | /** Adjustment option for {@link #softInputMode}: nothing specified. |
| 779 | * The system will try to pick one or |
| 780 | * the other depending on the contents of the window. |
| 781 | */ |
| 782 | public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; |
| 783 | |
| 784 | /** Adjustment option for {@link #softInputMode}: set to allow the |
| 785 | * window to be resized when an input |
| 786 | * method is shown, so that its contents are not covered by the input |
Scott Main | f10e633 | 2010-06-11 09:03:22 -0700 | [diff] [blame] | 787 | * method. This can <em>not</em> be combined with |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 788 | * {@link #SOFT_INPUT_ADJUST_PAN}; if |
| 789 | * neither of these are set, then the system will try to pick one or |
| 790 | * the other depending on the contents of the window. |
| 791 | */ |
| 792 | public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; |
| 793 | |
| 794 | /** Adjustment option for {@link #softInputMode}: set to have a window |
| 795 | * pan when an input method is |
| 796 | * shown, so it doesn't need to deal with resizing but just panned |
| 797 | * by the framework to ensure the current input focus is visible. This |
Scott Main | f10e633 | 2010-06-11 09:03:22 -0700 | [diff] [blame] | 798 | * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 799 | * neither of these are set, then the system will try to pick one or |
| 800 | * the other depending on the contents of the window. |
| 801 | */ |
| 802 | public static final int SOFT_INPUT_ADJUST_PAN = 0x20; |
| 803 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 804 | /** Adjustment option for {@link #softInputMode}: set to have a window |
| 805 | * not adjust for a shown input method. The window will not be resized, |
| 806 | * and it will not be panned to make its focus visible. |
| 807 | */ |
| 808 | public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; |
| 809 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 810 | /** |
| 811 | * Bit for {@link #softInputMode}: set when the user has navigated |
| 812 | * forward to the window. This is normally set automatically for |
| 813 | * you by the system, though you may want to set it in certain cases |
| 814 | * when you are displaying a window yourself. This flag will always |
| 815 | * be cleared automatically after the window is displayed. |
| 816 | */ |
| 817 | public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 818 | |
| 819 | /** |
Gilles Debunne | be2c4f9 | 2011-01-17 15:14:32 -0800 | [diff] [blame] | 820 | * Desired operating mode for any soft input area. May be any combination |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 821 | * of: |
| 822 | * |
| 823 | * <ul> |
| 824 | * <li> One of the visibility states |
| 825 | * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, |
| 826 | * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or |
| 827 | * {@link #SOFT_INPUT_STATE_VISIBLE}. |
| 828 | * <li> One of the adjustment options |
| 829 | * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, |
| 830 | * {@link #SOFT_INPUT_ADJUST_RESIZE}, or |
| 831 | * {@link #SOFT_INPUT_ADJUST_PAN}. |
| 832 | */ |
| 833 | public int softInputMode; |
| 834 | |
| 835 | /** |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 836 | * Placement of window within the screen as per {@link Gravity}. Both |
| 837 | * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, |
| 838 | * android.graphics.Rect) Gravity.apply} and |
| 839 | * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) |
| 840 | * Gravity.applyDisplay} are used during window layout, with this value |
| 841 | * given as the desired gravity. For example you can specify |
| 842 | * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and |
| 843 | * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here |
| 844 | * to control the behavior of |
| 845 | * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) |
| 846 | * Gravity.applyDisplay}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 847 | * |
| 848 | * @see Gravity |
| 849 | */ |
| 850 | public int gravity; |
| 851 | |
| 852 | /** |
| 853 | * The horizontal margin, as a percentage of the container's width, |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 854 | * between the container and the widget. See |
| 855 | * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, |
| 856 | * android.graphics.Rect) Gravity.apply} for how this is used. This |
| 857 | * field is added with {@link #x} to supply the <var>xAdj</var> parameter. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 858 | */ |
| 859 | public float horizontalMargin; |
| 860 | |
| 861 | /** |
| 862 | * The vertical margin, as a percentage of the container's height, |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 863 | * between the container and the widget. See |
| 864 | * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, |
| 865 | * android.graphics.Rect) Gravity.apply} for how this is used. This |
| 866 | * field is added with {@link #y} to supply the <var>yAdj</var> parameter. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 867 | */ |
| 868 | public float verticalMargin; |
| 869 | |
| 870 | /** |
| 871 | * The desired bitmap format. May be one of the constants in |
| 872 | * {@link android.graphics.PixelFormat}. Default is OPAQUE. |
| 873 | */ |
| 874 | public int format; |
| 875 | |
| 876 | /** |
| 877 | * A style resource defining the animations to use for this window. |
| 878 | * This must be a system resource; it can not be an application resource |
| 879 | * because the window manager does not have access to applications. |
| 880 | */ |
| 881 | public int windowAnimations; |
| 882 | |
| 883 | /** |
| 884 | * An alpha value to apply to this entire window. |
| 885 | * An alpha of 1.0 means fully opaque and 0.0 means fully transparent |
| 886 | */ |
| 887 | public float alpha = 1.0f; |
| 888 | |
| 889 | /** |
| 890 | * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming |
| 891 | * to apply. Range is from 1.0 for completely opaque to 0.0 for no |
| 892 | * dim. |
| 893 | */ |
| 894 | public float dimAmount = 1.0f; |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 895 | |
| 896 | /** |
| 897 | * Default value for {@link #screenBrightness} and {@link #buttonBrightness} |
| 898 | * indicating that the brightness value is not overridden for this window |
| 899 | * and normal brightness policy should be used. |
| 900 | */ |
| 901 | public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; |
| 902 | |
| 903 | /** |
| 904 | * Value for {@link #screenBrightness} and {@link #buttonBrightness} |
| 905 | * indicating that the screen or button backlight brightness should be set |
| 906 | * to the lowest value when this window is in front. |
| 907 | */ |
| 908 | public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; |
| 909 | |
| 910 | /** |
| 911 | * Value for {@link #screenBrightness} and {@link #buttonBrightness} |
| 912 | * indicating that the screen or button backlight brightness should be set |
| 913 | * to the hightest value when this window is in front. |
| 914 | */ |
| 915 | public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 916 | |
| 917 | /** |
| 918 | * This can be used to override the user's preferred brightness of |
| 919 | * the screen. A value of less than 0, the default, means to use the |
| 920 | * preferred screen brightness. 0 to 1 adjusts the brightness from |
| 921 | * dark to full bright. |
| 922 | */ |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 923 | public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 924 | |
| 925 | /** |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 926 | * This can be used to override the standard behavior of the button and |
| 927 | * keyboard backlights. A value of less than 0, the default, means to |
| 928 | * use the standard backlight behavior. 0 to 1 adjusts the brightness |
| 929 | * from dark to full bright. |
| 930 | */ |
| 931 | public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; |
| 932 | |
| 933 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 934 | * Identifier for this window. This will usually be filled in for |
| 935 | * you. |
| 936 | */ |
| 937 | public IBinder token = null; |
| 938 | |
| 939 | /** |
| 940 | * Name of the package owning this window. |
| 941 | */ |
| 942 | public String packageName = null; |
| 943 | |
| 944 | /** |
| 945 | * Specific orientation value for a window. |
| 946 | * May be any of the same values allowed |
| 947 | * for {@link android.content.pm.ActivityInfo#screenOrientation}. |
| 948 | * If not set, a default value of |
| 949 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} |
| 950 | * will be used. |
| 951 | */ |
| 952 | public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 953 | |
| 954 | /** |
| 955 | * Control the visibility of the status bar. |
Joe Onorato | 14782f7 | 2011-01-25 19:53:17 -0800 | [diff] [blame] | 956 | * |
| 957 | * @see View#STATUS_BAR_VISIBLE |
| 958 | * @see View#STATUS_BAR_HIDDEN |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 959 | */ |
| 960 | public int systemUiVisibility; |
| 961 | |
| 962 | /** |
Joe Onorato | 14782f7 | 2011-01-25 19:53:17 -0800 | [diff] [blame] | 963 | * @hide |
| 964 | * The ui visibility as requested by the views in this hierarchy. |
| 965 | * the combined value should be systemUiVisibility | subtreeSystemUiVisibility. |
| 966 | */ |
| 967 | public int subtreeSystemUiVisibility; |
| 968 | |
| 969 | /** |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 970 | * Get callbacks about the system ui visibility changing. |
| 971 | * |
| 972 | * TODO: Maybe there should be a bitfield of optional callbacks that we need. |
| 973 | * |
| 974 | * @hide |
| 975 | */ |
| 976 | public boolean hasSystemUiListeners; |
| 977 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 978 | public LayoutParams() { |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 979 | super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 980 | type = TYPE_APPLICATION; |
| 981 | format = PixelFormat.OPAQUE; |
| 982 | } |
| 983 | |
| 984 | public LayoutParams(int _type) { |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 985 | super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 986 | type = _type; |
| 987 | format = PixelFormat.OPAQUE; |
| 988 | } |
| 989 | |
| 990 | public LayoutParams(int _type, int _flags) { |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 991 | super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 992 | type = _type; |
| 993 | flags = _flags; |
| 994 | format = PixelFormat.OPAQUE; |
| 995 | } |
| 996 | |
| 997 | public LayoutParams(int _type, int _flags, int _format) { |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 998 | super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 999 | type = _type; |
| 1000 | flags = _flags; |
| 1001 | format = _format; |
| 1002 | } |
| 1003 | |
| 1004 | public LayoutParams(int w, int h, int _type, int _flags, int _format) { |
| 1005 | super(w, h); |
| 1006 | type = _type; |
| 1007 | flags = _flags; |
| 1008 | format = _format; |
| 1009 | } |
| 1010 | |
| 1011 | public LayoutParams(int w, int h, int xpos, int ypos, int _type, |
| 1012 | int _flags, int _format) { |
| 1013 | super(w, h); |
| 1014 | x = xpos; |
| 1015 | y = ypos; |
| 1016 | type = _type; |
| 1017 | flags = _flags; |
| 1018 | format = _format; |
| 1019 | } |
| 1020 | |
| 1021 | public final void setTitle(CharSequence title) { |
| 1022 | if (null == title) |
| 1023 | title = ""; |
| 1024 | |
| 1025 | mTitle = TextUtils.stringOrSpannedString(title); |
| 1026 | } |
| 1027 | |
| 1028 | public final CharSequence getTitle() { |
| 1029 | return mTitle; |
| 1030 | } |
| 1031 | |
| 1032 | public int describeContents() { |
| 1033 | return 0; |
| 1034 | } |
| 1035 | |
| 1036 | public void writeToParcel(Parcel out, int parcelableFlags) { |
| 1037 | out.writeInt(width); |
| 1038 | out.writeInt(height); |
| 1039 | out.writeInt(x); |
| 1040 | out.writeInt(y); |
| 1041 | out.writeInt(type); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1042 | out.writeInt(flags); |
| 1043 | out.writeInt(softInputMode); |
| 1044 | out.writeInt(gravity); |
| 1045 | out.writeFloat(horizontalMargin); |
| 1046 | out.writeFloat(verticalMargin); |
| 1047 | out.writeInt(format); |
| 1048 | out.writeInt(windowAnimations); |
| 1049 | out.writeFloat(alpha); |
| 1050 | out.writeFloat(dimAmount); |
| 1051 | out.writeFloat(screenBrightness); |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 1052 | out.writeFloat(buttonBrightness); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1053 | out.writeStrongBinder(token); |
| 1054 | out.writeString(packageName); |
| 1055 | TextUtils.writeToParcel(mTitle, out, parcelableFlags); |
| 1056 | out.writeInt(screenOrientation); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1057 | out.writeInt(systemUiVisibility); |
Joe Onorato | 14782f7 | 2011-01-25 19:53:17 -0800 | [diff] [blame] | 1058 | out.writeInt(subtreeSystemUiVisibility); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1059 | out.writeInt(hasSystemUiListeners ? 1 : 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | public static final Parcelable.Creator<LayoutParams> CREATOR |
| 1063 | = new Parcelable.Creator<LayoutParams>() { |
| 1064 | public LayoutParams createFromParcel(Parcel in) { |
| 1065 | return new LayoutParams(in); |
| 1066 | } |
| 1067 | |
| 1068 | public LayoutParams[] newArray(int size) { |
| 1069 | return new LayoutParams[size]; |
| 1070 | } |
| 1071 | }; |
| 1072 | |
| 1073 | |
| 1074 | public LayoutParams(Parcel in) { |
| 1075 | width = in.readInt(); |
| 1076 | height = in.readInt(); |
| 1077 | x = in.readInt(); |
| 1078 | y = in.readInt(); |
| 1079 | type = in.readInt(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1080 | flags = in.readInt(); |
| 1081 | softInputMode = in.readInt(); |
| 1082 | gravity = in.readInt(); |
| 1083 | horizontalMargin = in.readFloat(); |
| 1084 | verticalMargin = in.readFloat(); |
| 1085 | format = in.readInt(); |
| 1086 | windowAnimations = in.readInt(); |
| 1087 | alpha = in.readFloat(); |
| 1088 | dimAmount = in.readFloat(); |
| 1089 | screenBrightness = in.readFloat(); |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 1090 | buttonBrightness = in.readFloat(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1091 | token = in.readStrongBinder(); |
| 1092 | packageName = in.readString(); |
| 1093 | mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); |
| 1094 | screenOrientation = in.readInt(); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1095 | systemUiVisibility = in.readInt(); |
Joe Onorato | 14782f7 | 2011-01-25 19:53:17 -0800 | [diff] [blame] | 1096 | subtreeSystemUiVisibility = in.readInt(); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1097 | hasSystemUiListeners = in.readInt() != 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1098 | } |
| 1099 | |
Romain Guy | 7299807 | 2009-06-22 11:09:20 -0700 | [diff] [blame] | 1100 | @SuppressWarnings({"PointlessBitwiseExpression"}) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1101 | public static final int LAYOUT_CHANGED = 1<<0; |
| 1102 | public static final int TYPE_CHANGED = 1<<1; |
| 1103 | public static final int FLAGS_CHANGED = 1<<2; |
| 1104 | public static final int FORMAT_CHANGED = 1<<3; |
| 1105 | public static final int ANIMATION_CHANGED = 1<<4; |
| 1106 | public static final int DIM_AMOUNT_CHANGED = 1<<5; |
| 1107 | public static final int TITLE_CHANGED = 1<<6; |
| 1108 | public static final int ALPHA_CHANGED = 1<<7; |
| 1109 | public static final int MEMORY_TYPE_CHANGED = 1<<8; |
| 1110 | public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; |
| 1111 | public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; |
| 1112 | public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 1113 | /** {@hide} */ |
| 1114 | public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1115 | /** {@hide} */ |
| 1116 | public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<13; |
| 1117 | /** {@hide} */ |
| 1118 | public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1119 | |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1120 | // internal buffer to backup/restore parameters under compatibility mode. |
| 1121 | private int[] mCompatibilityParamsBackup = null; |
| 1122 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1123 | public final int copyFrom(LayoutParams o) { |
| 1124 | int changes = 0; |
| 1125 | |
| 1126 | if (width != o.width) { |
| 1127 | width = o.width; |
| 1128 | changes |= LAYOUT_CHANGED; |
| 1129 | } |
| 1130 | if (height != o.height) { |
| 1131 | height = o.height; |
| 1132 | changes |= LAYOUT_CHANGED; |
| 1133 | } |
| 1134 | if (x != o.x) { |
| 1135 | x = o.x; |
| 1136 | changes |= LAYOUT_CHANGED; |
| 1137 | } |
| 1138 | if (y != o.y) { |
| 1139 | y = o.y; |
| 1140 | changes |= LAYOUT_CHANGED; |
| 1141 | } |
| 1142 | if (horizontalWeight != o.horizontalWeight) { |
| 1143 | horizontalWeight = o.horizontalWeight; |
| 1144 | changes |= LAYOUT_CHANGED; |
| 1145 | } |
| 1146 | if (verticalWeight != o.verticalWeight) { |
| 1147 | verticalWeight = o.verticalWeight; |
| 1148 | changes |= LAYOUT_CHANGED; |
| 1149 | } |
| 1150 | if (horizontalMargin != o.horizontalMargin) { |
| 1151 | horizontalMargin = o.horizontalMargin; |
| 1152 | changes |= LAYOUT_CHANGED; |
| 1153 | } |
| 1154 | if (verticalMargin != o.verticalMargin) { |
| 1155 | verticalMargin = o.verticalMargin; |
| 1156 | changes |= LAYOUT_CHANGED; |
| 1157 | } |
| 1158 | if (type != o.type) { |
| 1159 | type = o.type; |
| 1160 | changes |= TYPE_CHANGED; |
| 1161 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1162 | if (flags != o.flags) { |
| 1163 | flags = o.flags; |
| 1164 | changes |= FLAGS_CHANGED; |
| 1165 | } |
| 1166 | if (softInputMode != o.softInputMode) { |
| 1167 | softInputMode = o.softInputMode; |
| 1168 | changes |= SOFT_INPUT_MODE_CHANGED; |
| 1169 | } |
| 1170 | if (gravity != o.gravity) { |
| 1171 | gravity = o.gravity; |
| 1172 | changes |= LAYOUT_CHANGED; |
| 1173 | } |
| 1174 | if (horizontalMargin != o.horizontalMargin) { |
| 1175 | horizontalMargin = o.horizontalMargin; |
| 1176 | changes |= LAYOUT_CHANGED; |
| 1177 | } |
| 1178 | if (verticalMargin != o.verticalMargin) { |
| 1179 | verticalMargin = o.verticalMargin; |
| 1180 | changes |= LAYOUT_CHANGED; |
| 1181 | } |
| 1182 | if (format != o.format) { |
| 1183 | format = o.format; |
| 1184 | changes |= FORMAT_CHANGED; |
| 1185 | } |
| 1186 | if (windowAnimations != o.windowAnimations) { |
| 1187 | windowAnimations = o.windowAnimations; |
| 1188 | changes |= ANIMATION_CHANGED; |
| 1189 | } |
| 1190 | if (token == null) { |
| 1191 | // NOTE: token only copied if the recipient doesn't |
| 1192 | // already have one. |
| 1193 | token = o.token; |
| 1194 | } |
| 1195 | if (packageName == null) { |
| 1196 | // NOTE: packageName only copied if the recipient doesn't |
| 1197 | // already have one. |
| 1198 | packageName = o.packageName; |
| 1199 | } |
| 1200 | if (!mTitle.equals(o.mTitle)) { |
| 1201 | mTitle = o.mTitle; |
| 1202 | changes |= TITLE_CHANGED; |
| 1203 | } |
| 1204 | if (alpha != o.alpha) { |
| 1205 | alpha = o.alpha; |
| 1206 | changes |= ALPHA_CHANGED; |
| 1207 | } |
| 1208 | if (dimAmount != o.dimAmount) { |
| 1209 | dimAmount = o.dimAmount; |
| 1210 | changes |= DIM_AMOUNT_CHANGED; |
| 1211 | } |
| 1212 | if (screenBrightness != o.screenBrightness) { |
| 1213 | screenBrightness = o.screenBrightness; |
| 1214 | changes |= SCREEN_BRIGHTNESS_CHANGED; |
| 1215 | } |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 1216 | if (buttonBrightness != o.buttonBrightness) { |
| 1217 | buttonBrightness = o.buttonBrightness; |
| 1218 | changes |= BUTTON_BRIGHTNESS_CHANGED; |
| 1219 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1220 | |
| 1221 | if (screenOrientation != o.screenOrientation) { |
| 1222 | screenOrientation = o.screenOrientation; |
| 1223 | changes |= SCREEN_ORIENTATION_CHANGED; |
| 1224 | } |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 1225 | |
Joe Onorato | 14782f7 | 2011-01-25 19:53:17 -0800 | [diff] [blame] | 1226 | if (systemUiVisibility != o.systemUiVisibility |
| 1227 | || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1228 | systemUiVisibility = o.systemUiVisibility; |
Joe Onorato | 14782f7 | 2011-01-25 19:53:17 -0800 | [diff] [blame] | 1229 | subtreeSystemUiVisibility = o.subtreeSystemUiVisibility; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1230 | changes |= SYSTEM_UI_VISIBILITY_CHANGED; |
| 1231 | } |
| 1232 | |
| 1233 | if (hasSystemUiListeners != o.hasSystemUiListeners) { |
| 1234 | hasSystemUiListeners = o.hasSystemUiListeners; |
| 1235 | changes |= SYSTEM_UI_LISTENER_CHANGED; |
| 1236 | } |
| 1237 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1238 | return changes; |
| 1239 | } |
| 1240 | |
| 1241 | @Override |
| 1242 | public String debug(String output) { |
| 1243 | output += "Contents of " + this + ":"; |
| 1244 | Log.d("Debug", output); |
| 1245 | output = super.debug(""); |
| 1246 | Log.d("Debug", output); |
| 1247 | Log.d("Debug", ""); |
| 1248 | Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); |
| 1249 | return ""; |
| 1250 | } |
| 1251 | |
| 1252 | @Override |
| 1253 | public String toString() { |
| 1254 | StringBuilder sb = new StringBuilder(256); |
| 1255 | sb.append("WM.LayoutParams{"); |
| 1256 | sb.append("("); |
| 1257 | sb.append(x); |
| 1258 | sb.append(','); |
| 1259 | sb.append(y); |
| 1260 | sb.append(")("); |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 1261 | sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width))); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1262 | sb.append('x'); |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 1263 | sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height))); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1264 | sb.append(")"); |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 1265 | if (horizontalMargin != 0) { |
| 1266 | sb.append(" hm="); |
| 1267 | sb.append(horizontalMargin); |
| 1268 | } |
| 1269 | if (verticalMargin != 0) { |
| 1270 | sb.append(" vm="); |
| 1271 | sb.append(verticalMargin); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1272 | } |
| 1273 | if (gravity != 0) { |
| 1274 | sb.append(" gr=#"); |
| 1275 | sb.append(Integer.toHexString(gravity)); |
| 1276 | } |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 1277 | if (softInputMode != 0) { |
| 1278 | sb.append(" sim=#"); |
| 1279 | sb.append(Integer.toHexString(softInputMode)); |
| 1280 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1281 | sb.append(" ty="); |
| 1282 | sb.append(type); |
| 1283 | sb.append(" fl=#"); |
| 1284 | sb.append(Integer.toHexString(flags)); |
| 1285 | sb.append(" fmt="); |
| 1286 | sb.append(format); |
| 1287 | if (windowAnimations != 0) { |
| 1288 | sb.append(" wanim=0x"); |
| 1289 | sb.append(Integer.toHexString(windowAnimations)); |
| 1290 | } |
| 1291 | if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { |
| 1292 | sb.append(" or="); |
| 1293 | sb.append(screenOrientation); |
| 1294 | } |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 1295 | if (alpha != 1.0f) { |
| 1296 | sb.append(" alpha="); |
| 1297 | sb.append(alpha); |
| 1298 | } |
| 1299 | if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { |
| 1300 | sb.append(" sbrt="); |
| 1301 | sb.append(screenBrightness); |
| 1302 | } |
| 1303 | if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { |
| 1304 | sb.append(" bbrt="); |
| 1305 | sb.append(buttonBrightness); |
| 1306 | } |
Mitsuru Oshima | 5a2b91d | 2009-07-16 16:30:02 -0700 | [diff] [blame] | 1307 | if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) { |
| 1308 | sb.append(" compatible=true"); |
| 1309 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1310 | if (systemUiVisibility != 0) { |
| 1311 | sb.append(" sysui=0x"); |
| 1312 | sb.append(Integer.toHexString(systemUiVisibility)); |
| 1313 | } |
Joe Onorato | 14782f7 | 2011-01-25 19:53:17 -0800 | [diff] [blame] | 1314 | if (subtreeSystemUiVisibility != 0) { |
| 1315 | sb.append(" vsysui=0x"); |
| 1316 | sb.append(Integer.toHexString(subtreeSystemUiVisibility)); |
| 1317 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1318 | if (hasSystemUiListeners) { |
| 1319 | sb.append(" sysuil="); |
| 1320 | sb.append(hasSystemUiListeners); |
| 1321 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1322 | sb.append('}'); |
| 1323 | return sb.toString(); |
| 1324 | } |
Mitsuru Oshima | 8d11267 | 2009-04-27 12:01:23 -0700 | [diff] [blame] | 1325 | |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1326 | /** |
| 1327 | * Scale the layout params' coordinates and size. |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame] | 1328 | * @hide |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1329 | */ |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame] | 1330 | public void scale(float scale) { |
Mitsuru Oshima | 61324e5 | 2009-07-21 15:40:36 -0700 | [diff] [blame] | 1331 | x = (int) (x * scale + 0.5f); |
| 1332 | y = (int) (y * scale + 0.5f); |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1333 | if (width > 0) { |
Mitsuru Oshima | 61324e5 | 2009-07-21 15:40:36 -0700 | [diff] [blame] | 1334 | width = (int) (width * scale + 0.5f); |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1335 | } |
| 1336 | if (height > 0) { |
Mitsuru Oshima | 61324e5 | 2009-07-21 15:40:36 -0700 | [diff] [blame] | 1337 | height = (int) (height * scale + 0.5f); |
Mitsuru Oshima | 8d11267 | 2009-04-27 12:01:23 -0700 | [diff] [blame] | 1338 | } |
| 1339 | } |
| 1340 | |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1341 | /** |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1342 | * Backup the layout parameters used in compatibility mode. |
| 1343 | * @see LayoutParams#restore() |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1344 | */ |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1345 | void backup() { |
| 1346 | int[] backup = mCompatibilityParamsBackup; |
| 1347 | if (backup == null) { |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame] | 1348 | // we backup 4 elements, x, y, width, height |
| 1349 | backup = mCompatibilityParamsBackup = new int[4]; |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1350 | } |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1351 | backup[0] = x; |
| 1352 | backup[1] = y; |
| 1353 | backup[2] = width; |
| 1354 | backup[3] = height; |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1355 | } |
| 1356 | |
| 1357 | /** |
| 1358 | * Restore the layout params' coordinates, size and gravity |
| 1359 | * @see LayoutParams#backup() |
| 1360 | */ |
| 1361 | void restore() { |
| 1362 | int[] backup = mCompatibilityParamsBackup; |
| 1363 | if (backup != null) { |
| 1364 | x = backup[0]; |
| 1365 | y = backup[1]; |
| 1366 | width = backup[2]; |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1367 | height = backup[3]; |
| 1368 | } |
| 1369 | } |
| 1370 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1371 | private CharSequence mTitle = ""; |
| 1372 | } |
| 1373 | } |