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 |
| 380 | */ |
| 381 | public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; |
| 382 | |
| 383 | |
| 384 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 385 | * End of types of system windows. |
| 386 | */ |
| 387 | public static final int LAST_SYSTEM_WINDOW = 2999; |
| 388 | |
| 389 | /** |
| 390 | * Specifies what type of memory buffers should be used by this window. |
| 391 | * Default is normal. |
| 392 | * |
| 393 | * @see #MEMORY_TYPE_NORMAL |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 394 | * @see #MEMORY_TYPE_PUSH_BUFFERS |
| 395 | */ |
| 396 | public int memoryType; |
| 397 | |
| 398 | /** Memory type: The window's surface is allocated in main memory. */ |
| 399 | public static final int MEMORY_TYPE_NORMAL = 0; |
| 400 | /** Memory type: The window's surface is configured to be accessible |
Mathias Agopian | 317a628 | 2009-08-13 17:29:02 -0700 | [diff] [blame] | 401 | * by DMA engines and hardware accelerators. |
| 402 | * @deprecated this is ignored, this value is set automatically when needed. |
| 403 | */ |
| 404 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 405 | public static final int MEMORY_TYPE_HARDWARE = 1; |
| 406 | /** Memory type: The window's surface is configured to be accessible |
Mathias Agopian | 317a628 | 2009-08-13 17:29:02 -0700 | [diff] [blame] | 407 | * by graphics accelerators. |
| 408 | * @deprecated this is ignored, this value is set automatically when needed. |
| 409 | */ |
| 410 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 411 | public static final int MEMORY_TYPE_GPU = 2; |
| 412 | /** Memory type: The window's surface doesn't own its buffers and |
| 413 | * therefore cannot be locked. Instead the buffers are pushed to |
| 414 | * it through native binder calls. */ |
| 415 | public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; |
| 416 | |
| 417 | /** |
| 418 | * Various behavioral options/flags. Default is none. |
| 419 | * |
| 420 | * @see #FLAG_BLUR_BEHIND |
| 421 | * @see #FLAG_DIM_BEHIND |
| 422 | * @see #FLAG_NOT_FOCUSABLE |
| 423 | * @see #FLAG_NOT_TOUCHABLE |
| 424 | * @see #FLAG_NOT_TOUCH_MODAL |
| 425 | * @see #FLAG_LAYOUT_IN_SCREEN |
| 426 | * @see #FLAG_DITHER |
| 427 | * @see #FLAG_KEEP_SCREEN_ON |
| 428 | * @see #FLAG_FULLSCREEN |
| 429 | * @see #FLAG_FORCE_NOT_FULLSCREEN |
| 430 | * @see #FLAG_IGNORE_CHEEK_PRESSES |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 431 | * @see #FLAG_HARDWARE_ACCELERATED |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 432 | */ |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 433 | @ViewDebug.ExportedProperty(flagMapping = { |
| 434 | @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, |
| 435 | name = "FLAG_BLUR_BEHIND"), |
| 436 | @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, |
| 437 | name = "FLAG_DIM_BEHIND"), |
| 438 | @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, |
| 439 | name = "FLAG_NOT_FOCUSABLE"), |
| 440 | @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, |
| 441 | name = "FLAG_NOT_TOUCHABLE"), |
| 442 | @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, |
| 443 | name = "FLAG_NOT_TOUCH_MODAL"), |
| 444 | @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, |
| 445 | name = "FLAG_LAYOUT_IN_SCREEN"), |
| 446 | @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, |
| 447 | name = "FLAG_DITHER"), |
Daniel Sandler | 20e9271 | 2010-04-02 16:51:58 -0400 | [diff] [blame] | 448 | @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, |
| 449 | name = "FLAG_TURN_SCREEN_ON"), |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 450 | @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, |
| 451 | name = "FLAG_KEEP_SCREEN_ON"), |
Daniel Sandler | 20e9271 | 2010-04-02 16:51:58 -0400 | [diff] [blame] | 452 | @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, |
| 453 | name = "FLAG_SHOW_WHEN_LOCKED"), |
| 454 | @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, |
| 455 | name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"), |
| 456 | @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, |
| 457 | name = "FLAG_DISMISS_KEYGUARD"), |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 458 | @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, |
| 459 | name = "FLAG_FULLSCREEN"), |
| 460 | @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, |
| 461 | equals = FLAG_FORCE_NOT_FULLSCREEN, name = "FLAG_FORCE_NOT_FULLSCREEN"), |
| 462 | @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 463 | equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES"), |
| 464 | @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, |
| 465 | equals = FLAG_HARDWARE_ACCELERATED, name = "FLAG_HARDWARE_ACCELERATED") |
Joe Onorato | 8f2bd43 | 2010-03-25 11:45:28 -0700 | [diff] [blame] | 466 | }) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 467 | public int flags; |
| 468 | |
Mike Lockwood | ef73162 | 2010-01-27 17:51:34 -0500 | [diff] [blame] | 469 | /** Window flag: as long as this window is visible to the user, allow |
| 470 | * the lock screen to activate while the screen is on. |
| 471 | * This can be used independently, or in combination with |
Christopher Tate | 95f7850 | 2010-01-29 15:57:34 -0800 | [diff] [blame] | 472 | * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ |
Mike Lockwood | ef73162 | 2010-01-27 17:51:34 -0500 | [diff] [blame] | 473 | public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; |
| 474 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 475 | /** Window flag: everything behind this window will be dimmed. |
| 476 | * Use {@link #dimAmount} to control the amount of dim. */ |
| 477 | public static final int FLAG_DIM_BEHIND = 0x00000002; |
| 478 | |
| 479 | /** Window flag: blur everything behind this window. */ |
| 480 | public static final int FLAG_BLUR_BEHIND = 0x00000004; |
| 481 | |
| 482 | /** Window flag: this window won't ever get key input focus, so the |
| 483 | * user can not send key or other button events to it. Those will |
| 484 | * instead go to whatever focusable window is behind it. This flag |
| 485 | * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that |
| 486 | * is explicitly set. |
| 487 | * |
| 488 | * <p>Setting this flag also implies that the window will not need to |
| 489 | * interact with |
| 490 | * a soft input method, so it will be Z-ordered and positioned |
| 491 | * independently of any active input method (typically this means it |
| 492 | * gets Z-ordered on top of the input method, so it can use the full |
| 493 | * screen for its content and cover the input method if needed. You |
| 494 | * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ |
| 495 | public static final int FLAG_NOT_FOCUSABLE = 0x00000008; |
| 496 | |
| 497 | /** Window flag: this window can never receive touch events. */ |
| 498 | public static final int FLAG_NOT_TOUCHABLE = 0x00000010; |
| 499 | |
| 500 | /** Window flag: Even when this window is focusable (its |
| 501 | * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events |
| 502 | * outside of the window to be sent to the windows behind it. Otherwise |
| 503 | * it will consume all pointer events itself, regardless of whether they |
| 504 | * are inside of the window. */ |
| 505 | public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; |
| 506 | |
| 507 | /** Window flag: When set, if the device is asleep when the touch |
| 508 | * screen is pressed, you will receive this first touch event. Usually |
| 509 | * the first touch event is consumed by the system since the user can |
| 510 | * not see what they are pressing on. |
| 511 | */ |
| 512 | public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; |
| 513 | |
| 514 | /** Window flag: as long as this window is visible to the user, keep |
| 515 | * the device's screen turned on and bright. */ |
| 516 | public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; |
| 517 | |
| 518 | /** Window flag: place the window within the entire screen, ignoring |
| 519 | * decorations around the border (a.k.a. the status bar). The |
| 520 | * window must correctly position its contents to take the screen |
| 521 | * decoration into account. This flag is normally set for you |
| 522 | * by Window as described in {@link Window#setFlags}. */ |
| 523 | public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; |
| 524 | |
| 525 | /** Window flag: allow window to extend outside of the screen. */ |
| 526 | public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; |
| 527 | |
| 528 | /** Window flag: Hide all screen decorations (e.g. status bar) while |
| 529 | * this window is displayed. This allows the window to use the entire |
| 530 | * display space for itself -- the status bar will be hidden when |
| 531 | * an app window with this flag set is on the top layer. */ |
| 532 | public static final int FLAG_FULLSCREEN = 0x00000400; |
| 533 | |
| 534 | /** Window flag: Override {@link #FLAG_FULLSCREEN and force the |
| 535 | * screen decorations (such as status bar) to be shown. */ |
| 536 | public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; |
| 537 | |
| 538 | /** Window flag: turn on dithering when compositing this window to |
| 539 | * the screen. */ |
| 540 | public static final int FLAG_DITHER = 0x00001000; |
| 541 | |
| 542 | /** Window flag: don't allow screen shots while this window is |
| 543 | * displayed. */ |
| 544 | public static final int FLAG_SECURE = 0x00002000; |
| 545 | |
| 546 | /** Window flag: a special mode where the layout parameters are used |
| 547 | * to perform scaling of the surface when it is composited to the |
| 548 | * screen. */ |
| 549 | public static final int FLAG_SCALED = 0x00004000; |
| 550 | |
| 551 | /** Window flag: intended for windows that will often be used when the user is |
| 552 | * holding the screen against their face, it will aggressively filter the event |
| 553 | * stream to prevent unintended presses in this situation that may not be |
| 554 | * desired for a particular window, when such an event stream is detected, the |
| 555 | * application will receive a CANCEL motion event to indicate this so applications |
| 556 | * can handle this accordingly by taking no action on the event |
| 557 | * until the finger is released. */ |
| 558 | public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; |
| 559 | |
| 560 | /** Window flag: a special option only for use in combination with |
| 561 | * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the |
| 562 | * screen your window may appear on top of or behind screen decorations |
| 563 | * such as the status bar. By also including this flag, the window |
| 564 | * manager will report the inset rectangle needed to ensure your |
| 565 | * content is not covered by screen decorations. This flag is normally |
| 566 | * set for you by Window as described in {@link Window#setFlags}.*/ |
| 567 | public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; |
| 568 | |
| 569 | /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with |
| 570 | * respect to how this window interacts with the current method. That |
| 571 | * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the |
| 572 | * window will behave as if it needs to interact with the input method |
| 573 | * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is |
| 574 | * not set and this flag is set, then the window will behave as if it |
| 575 | * doesn't need to interact with the input method and can be placed |
| 576 | * to use more space and cover the input method. |
| 577 | */ |
| 578 | public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; |
| 579 | |
| 580 | /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you |
| 581 | * can set this flag to receive a single special MotionEvent with |
| 582 | * the action |
| 583 | * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for |
| 584 | * touches that occur outside of your window. Note that you will not |
| 585 | * receive the full down/move/up gesture, only the location of the |
| 586 | * first down as an ACTION_OUTSIDE. |
| 587 | */ |
| 588 | public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; |
| 589 | |
Suchi Amalapurapu | d1a9337 | 2009-05-14 17:54:31 -0700 | [diff] [blame] | 590 | /** Window flag: special flag to let windows be shown when the screen |
| 591 | * is locked. This will let application windows take precedence over |
| 592 | * key guard or any other lock screens. Can be used with |
| 593 | * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 594 | * directly before showing the key guard window. Can be used with |
| 595 | * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss |
| 596 | * non-secure keyguards. This flag only applies to the top-most |
| 597 | * full-screen window. |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 598 | */ |
Suchi Amalapurapu | d1a9337 | 2009-05-14 17:54:31 -0700 | [diff] [blame] | 599 | public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; |
| 600 | |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 601 | /** Window flag: ask that the system wallpaper be shown behind |
| 602 | * your window. The window surface must be translucent to be able |
| 603 | * to actually see the wallpaper behind it; this flag just ensures |
| 604 | * that the wallpaper surface will be there if this window actually |
| 605 | * has translucent regions. |
| 606 | */ |
| 607 | public static final int FLAG_SHOW_WALLPAPER = 0x00100000; |
| 608 | |
Dianne Hackborn | 93e462b | 2009-09-15 22:50:40 -0700 | [diff] [blame] | 609 | /** Window flag: when set as a window is being added or made |
| 610 | * visible, once the window has been shown then the system will |
| 611 | * poke the power manager's user activity (as if the user had woken |
| 612 | * up the device) to turn the screen on. */ |
| 613 | public static final int FLAG_TURN_SCREEN_ON = 0x00200000; |
| 614 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 615 | /** Window flag: when set the window will cause the keyguard to |
| 616 | * be dismissed, only if it is not a secure lock keyguard. Because such |
| 617 | * a keyguard is not needed for security, it will never re-appear if |
| 618 | * the user navigates to another window (in contrast to |
| 619 | * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily |
| 620 | * hide both secure and non-secure keyguards but ensure they reappear |
| 621 | * when the user moves to another UI that doesn't hide them). |
| 622 | * If the keyguard is currently active and is secure (requires an |
| 623 | * unlock pattern) than the user will still need to confirm it before |
| 624 | * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has |
Daniel Sandler | ae069f7 | 2010-06-17 21:56:26 -0400 | [diff] [blame] | 625 | * also been set. |
| 626 | */ |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 627 | public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; |
Jeff Brown | 01ce2e9 | 2010-09-26 22:20:12 -0700 | [diff] [blame] | 628 | |
| 629 | /** Window flag: when set the window will accept for touch events |
| 630 | * outside of its bounds to be sent to other windows that also |
| 631 | * support split touch. When this flag is not set, the first pointer |
| 632 | * that goes down determines the window to which all subsequent touches |
| 633 | * go until all pointers go up. When this flag is set, each pointer |
| 634 | * (not necessarily the first) that goes down determines the window |
| 635 | * to which all subsequent touches of that pointer will go until that |
| 636 | * pointer goes up thereby enabling touches with multiple pointers |
| 637 | * to be split across multiple windows. |
Dianne Hackborn | d9b3b7e | 2010-11-16 18:22:49 -0800 | [diff] [blame] | 638 | */ |
Jeff Brown | 01ce2e9 | 2010-09-26 22:20:12 -0700 | [diff] [blame] | 639 | public static final int FLAG_SPLIT_TOUCH = 0x00800000; |
Dianne Hackborn | d9b3b7e | 2010-11-16 18:22:49 -0800 | [diff] [blame] | 640 | |
| 641 | /** |
| 642 | * Indicates whether this window should be hardware accelerated. |
| 643 | * Requesting hardware acceleration does not guarantee it will happen. |
| 644 | */ |
| 645 | public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000; |
Daniel Sandler | 611fae4 | 2010-06-17 10:45:00 -0400 | [diff] [blame] | 646 | |
Dianne Hackborn | d9b3b7e | 2010-11-16 18:22:49 -0800 | [diff] [blame] | 647 | // ----- HIDDEN FLAGS. |
| 648 | // These start at the high bit and go down. |
| 649 | |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 650 | /** |
| 651 | * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU} |
| 652 | * and therefore needs a Menu key. For devices where Menu is a physical button this flag is |
| 653 | * ignored, but on devices where the Menu key is drawn in software it may be hidden unless |
| 654 | * this flag is set. |
| 655 | * |
| 656 | * (Note that Action Bars, when available, are the preferred way to offer additional |
| 657 | * functions otherwise accessed via an options menu.) |
| 658 | * |
| 659 | * {@hide} |
| 660 | */ |
Dianne Hackborn | d9b3b7e | 2010-11-16 18:22:49 -0800 | [diff] [blame] | 661 | public static final int FLAG_NEEDS_MENU_KEY = 0x08000000; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 662 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 663 | /** Window flag: *sigh* The lock screen wants to continue running its |
| 664 | * animation while it is fading. A kind-of hack to allow this. Maybe |
| 665 | * in the future we just make this the default behavior. |
| 666 | * |
| 667 | * {@hide} */ |
| 668 | public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000; |
| 669 | |
Mitsuru Oshima | 1ecf5d2 | 2009-07-06 17:20:38 -0700 | [diff] [blame] | 670 | /** Window flag: special flag to limit the size of the window to be |
| 671 | * original size ([320x480] x density). Used to create window for applications |
| 672 | * running under compatibility mode. |
| 673 | * |
| 674 | * {@hide} */ |
Dianne Hackborn | 4c62fc0 | 2009-08-08 20:40:27 -0700 | [diff] [blame] | 675 | public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000; |
Mitsuru Oshima | 1ecf5d2 | 2009-07-06 17:20:38 -0700 | [diff] [blame] | 676 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 677 | /** Window flag: a special option intended for system dialogs. When |
| 678 | * this flag is set, the window will demand focus unconditionally when |
| 679 | * it is created. |
| 680 | * {@hide} */ |
| 681 | public static final int FLAG_SYSTEM_ERROR = 0x40000000; |
| 682 | |
| 683 | /** |
| 684 | * Given a particular set of window manager flags, determine whether |
| 685 | * such a window may be a target for an input method when it has |
| 686 | * focus. In particular, this checks the |
| 687 | * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} |
| 688 | * flags and returns true if the combination of the two corresponds |
| 689 | * to a window that needs to be behind the input method so that the |
| 690 | * user can type into it. |
| 691 | * |
| 692 | * @param flags The current window manager flags. |
| 693 | * |
| 694 | * @return Returns true if such a window should be behind/interact |
| 695 | * with an input method, false if not. |
| 696 | */ |
| 697 | public static boolean mayUseInputMethod(int flags) { |
| 698 | switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { |
| 699 | case 0: |
| 700 | case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: |
| 701 | return true; |
| 702 | } |
| 703 | return false; |
| 704 | } |
| 705 | |
| 706 | /** |
| 707 | * Mask for {@link #softInputMode} of the bits that determine the |
| 708 | * desired visibility state of the soft input area for this window. |
| 709 | */ |
| 710 | public static final int SOFT_INPUT_MASK_STATE = 0x0f; |
| 711 | |
| 712 | /** |
| 713 | * Visibility state for {@link #softInputMode}: no state has been specified. |
| 714 | */ |
| 715 | public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; |
| 716 | |
| 717 | /** |
| 718 | * Visibility state for {@link #softInputMode}: please don't change the state of |
| 719 | * the soft input area. |
| 720 | */ |
| 721 | public static final int SOFT_INPUT_STATE_UNCHANGED = 1; |
| 722 | |
| 723 | /** |
| 724 | * Visibility state for {@link #softInputMode}: please hide any soft input |
| 725 | * area when normally appropriate (when the user is navigating |
| 726 | * forward to your window). |
| 727 | */ |
| 728 | public static final int SOFT_INPUT_STATE_HIDDEN = 2; |
| 729 | |
| 730 | /** |
| 731 | * Visibility state for {@link #softInputMode}: please always hide any |
| 732 | * soft input area when this window receives focus. |
| 733 | */ |
| 734 | public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; |
| 735 | |
| 736 | /** |
| 737 | * Visibility state for {@link #softInputMode}: please show the soft |
| 738 | * input area when normally appropriate (when the user is navigating |
| 739 | * forward to your window). |
| 740 | */ |
| 741 | public static final int SOFT_INPUT_STATE_VISIBLE = 4; |
| 742 | |
| 743 | /** |
| 744 | * Visibility state for {@link #softInputMode}: please always make the |
| 745 | * soft input area visible when this window receives input focus. |
| 746 | */ |
| 747 | public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; |
| 748 | |
| 749 | /** |
| 750 | * Mask for {@link #softInputMode} of the bits that determine the |
| 751 | * way that the window should be adjusted to accommodate the soft |
| 752 | * input window. |
| 753 | */ |
| 754 | public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; |
| 755 | |
| 756 | /** Adjustment option for {@link #softInputMode}: nothing specified. |
| 757 | * The system will try to pick one or |
| 758 | * the other depending on the contents of the window. |
| 759 | */ |
| 760 | public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; |
| 761 | |
| 762 | /** Adjustment option for {@link #softInputMode}: set to allow the |
| 763 | * window to be resized when an input |
| 764 | * 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] | 765 | * method. This can <em>not</em> be combined with |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 766 | * {@link #SOFT_INPUT_ADJUST_PAN}; if |
| 767 | * neither of these are set, then the system will try to pick one or |
| 768 | * the other depending on the contents of the window. |
| 769 | */ |
| 770 | public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; |
| 771 | |
| 772 | /** Adjustment option for {@link #softInputMode}: set to have a window |
| 773 | * pan when an input method is |
| 774 | * shown, so it doesn't need to deal with resizing but just panned |
| 775 | * by the framework to ensure the current input focus is visible. This |
Scott Main | f10e633 | 2010-06-11 09:03:22 -0700 | [diff] [blame] | 776 | * 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] | 777 | * neither of these are set, then the system will try to pick one or |
| 778 | * the other depending on the contents of the window. |
| 779 | */ |
| 780 | public static final int SOFT_INPUT_ADJUST_PAN = 0x20; |
| 781 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 782 | /** Adjustment option for {@link #softInputMode}: set to have a window |
| 783 | * not adjust for a shown input method. The window will not be resized, |
| 784 | * and it will not be panned to make its focus visible. |
| 785 | */ |
| 786 | public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; |
| 787 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 788 | /** |
| 789 | * Bit for {@link #softInputMode}: set when the user has navigated |
| 790 | * forward to the window. This is normally set automatically for |
| 791 | * you by the system, though you may want to set it in certain cases |
| 792 | * when you are displaying a window yourself. This flag will always |
| 793 | * be cleared automatically after the window is displayed. |
| 794 | */ |
| 795 | public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 796 | |
| 797 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 798 | * Desired operating mode for any soft input area. May any combination |
| 799 | * of: |
| 800 | * |
| 801 | * <ul> |
| 802 | * <li> One of the visibility states |
| 803 | * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, |
| 804 | * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or |
| 805 | * {@link #SOFT_INPUT_STATE_VISIBLE}. |
| 806 | * <li> One of the adjustment options |
| 807 | * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, |
| 808 | * {@link #SOFT_INPUT_ADJUST_RESIZE}, or |
| 809 | * {@link #SOFT_INPUT_ADJUST_PAN}. |
| 810 | */ |
| 811 | public int softInputMode; |
| 812 | |
| 813 | /** |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 814 | * Placement of window within the screen as per {@link Gravity}. Both |
| 815 | * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, |
| 816 | * android.graphics.Rect) Gravity.apply} and |
| 817 | * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) |
| 818 | * Gravity.applyDisplay} are used during window layout, with this value |
| 819 | * given as the desired gravity. For example you can specify |
| 820 | * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and |
| 821 | * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here |
| 822 | * to control the behavior of |
| 823 | * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) |
| 824 | * Gravity.applyDisplay}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 825 | * |
| 826 | * @see Gravity |
| 827 | */ |
| 828 | public int gravity; |
| 829 | |
| 830 | /** |
| 831 | * The horizontal margin, as a percentage of the container's width, |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 832 | * between the container and the widget. See |
| 833 | * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, |
| 834 | * android.graphics.Rect) Gravity.apply} for how this is used. This |
| 835 | * 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] | 836 | */ |
| 837 | public float horizontalMargin; |
| 838 | |
| 839 | /** |
| 840 | * The vertical margin, as a percentage of the container's height, |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 841 | * between the container and the widget. See |
| 842 | * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, |
| 843 | * android.graphics.Rect) Gravity.apply} for how this is used. This |
| 844 | * 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] | 845 | */ |
| 846 | public float verticalMargin; |
| 847 | |
| 848 | /** |
| 849 | * The desired bitmap format. May be one of the constants in |
| 850 | * {@link android.graphics.PixelFormat}. Default is OPAQUE. |
| 851 | */ |
| 852 | public int format; |
| 853 | |
| 854 | /** |
| 855 | * A style resource defining the animations to use for this window. |
| 856 | * This must be a system resource; it can not be an application resource |
| 857 | * because the window manager does not have access to applications. |
| 858 | */ |
| 859 | public int windowAnimations; |
| 860 | |
| 861 | /** |
| 862 | * An alpha value to apply to this entire window. |
| 863 | * An alpha of 1.0 means fully opaque and 0.0 means fully transparent |
| 864 | */ |
| 865 | public float alpha = 1.0f; |
| 866 | |
| 867 | /** |
| 868 | * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming |
| 869 | * to apply. Range is from 1.0 for completely opaque to 0.0 for no |
| 870 | * dim. |
| 871 | */ |
| 872 | public float dimAmount = 1.0f; |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 873 | |
| 874 | /** |
| 875 | * Default value for {@link #screenBrightness} and {@link #buttonBrightness} |
| 876 | * indicating that the brightness value is not overridden for this window |
| 877 | * and normal brightness policy should be used. |
| 878 | */ |
| 879 | public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; |
| 880 | |
| 881 | /** |
| 882 | * Value for {@link #screenBrightness} and {@link #buttonBrightness} |
| 883 | * indicating that the screen or button backlight brightness should be set |
| 884 | * to the lowest value when this window is in front. |
| 885 | */ |
| 886 | public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; |
| 887 | |
| 888 | /** |
| 889 | * Value for {@link #screenBrightness} and {@link #buttonBrightness} |
| 890 | * indicating that the screen or button backlight brightness should be set |
| 891 | * to the hightest value when this window is in front. |
| 892 | */ |
| 893 | public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 894 | |
| 895 | /** |
| 896 | * This can be used to override the user's preferred brightness of |
| 897 | * the screen. A value of less than 0, the default, means to use the |
| 898 | * preferred screen brightness. 0 to 1 adjusts the brightness from |
| 899 | * dark to full bright. |
| 900 | */ |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 901 | public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 902 | |
| 903 | /** |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 904 | * This can be used to override the standard behavior of the button and |
| 905 | * keyboard backlights. A value of less than 0, the default, means to |
| 906 | * use the standard backlight behavior. 0 to 1 adjusts the brightness |
| 907 | * from dark to full bright. |
| 908 | */ |
| 909 | public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; |
| 910 | |
| 911 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 912 | * Identifier for this window. This will usually be filled in for |
| 913 | * you. |
| 914 | */ |
| 915 | public IBinder token = null; |
| 916 | |
| 917 | /** |
| 918 | * Name of the package owning this window. |
| 919 | */ |
| 920 | public String packageName = null; |
| 921 | |
| 922 | /** |
| 923 | * Specific orientation value for a window. |
| 924 | * May be any of the same values allowed |
| 925 | * for {@link android.content.pm.ActivityInfo#screenOrientation}. |
| 926 | * If not set, a default value of |
| 927 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} |
| 928 | * will be used. |
| 929 | */ |
| 930 | public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
| 931 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 932 | public LayoutParams() { |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 933 | super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 934 | type = TYPE_APPLICATION; |
| 935 | format = PixelFormat.OPAQUE; |
| 936 | } |
| 937 | |
| 938 | public LayoutParams(int _type) { |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 939 | super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 940 | type = _type; |
| 941 | format = PixelFormat.OPAQUE; |
| 942 | } |
| 943 | |
| 944 | public LayoutParams(int _type, int _flags) { |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 945 | super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 946 | type = _type; |
| 947 | flags = _flags; |
| 948 | format = PixelFormat.OPAQUE; |
| 949 | } |
| 950 | |
| 951 | public LayoutParams(int _type, int _flags, int _format) { |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 952 | super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 953 | type = _type; |
| 954 | flags = _flags; |
| 955 | format = _format; |
| 956 | } |
| 957 | |
| 958 | public LayoutParams(int w, int h, int _type, int _flags, int _format) { |
| 959 | super(w, h); |
| 960 | type = _type; |
| 961 | flags = _flags; |
| 962 | format = _format; |
| 963 | } |
| 964 | |
| 965 | public LayoutParams(int w, int h, int xpos, int ypos, int _type, |
| 966 | int _flags, int _format) { |
| 967 | super(w, h); |
| 968 | x = xpos; |
| 969 | y = ypos; |
| 970 | type = _type; |
| 971 | flags = _flags; |
| 972 | format = _format; |
| 973 | } |
| 974 | |
| 975 | public final void setTitle(CharSequence title) { |
| 976 | if (null == title) |
| 977 | title = ""; |
| 978 | |
| 979 | mTitle = TextUtils.stringOrSpannedString(title); |
| 980 | } |
| 981 | |
| 982 | public final CharSequence getTitle() { |
| 983 | return mTitle; |
| 984 | } |
| 985 | |
| 986 | public int describeContents() { |
| 987 | return 0; |
| 988 | } |
| 989 | |
| 990 | public void writeToParcel(Parcel out, int parcelableFlags) { |
| 991 | out.writeInt(width); |
| 992 | out.writeInt(height); |
| 993 | out.writeInt(x); |
| 994 | out.writeInt(y); |
| 995 | out.writeInt(type); |
| 996 | out.writeInt(memoryType); |
| 997 | out.writeInt(flags); |
| 998 | out.writeInt(softInputMode); |
| 999 | out.writeInt(gravity); |
| 1000 | out.writeFloat(horizontalMargin); |
| 1001 | out.writeFloat(verticalMargin); |
| 1002 | out.writeInt(format); |
| 1003 | out.writeInt(windowAnimations); |
| 1004 | out.writeFloat(alpha); |
| 1005 | out.writeFloat(dimAmount); |
| 1006 | out.writeFloat(screenBrightness); |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 1007 | out.writeFloat(buttonBrightness); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1008 | out.writeStrongBinder(token); |
| 1009 | out.writeString(packageName); |
| 1010 | TextUtils.writeToParcel(mTitle, out, parcelableFlags); |
| 1011 | out.writeInt(screenOrientation); |
| 1012 | } |
| 1013 | |
| 1014 | public static final Parcelable.Creator<LayoutParams> CREATOR |
| 1015 | = new Parcelable.Creator<LayoutParams>() { |
| 1016 | public LayoutParams createFromParcel(Parcel in) { |
| 1017 | return new LayoutParams(in); |
| 1018 | } |
| 1019 | |
| 1020 | public LayoutParams[] newArray(int size) { |
| 1021 | return new LayoutParams[size]; |
| 1022 | } |
| 1023 | }; |
| 1024 | |
| 1025 | |
| 1026 | public LayoutParams(Parcel in) { |
| 1027 | width = in.readInt(); |
| 1028 | height = in.readInt(); |
| 1029 | x = in.readInt(); |
| 1030 | y = in.readInt(); |
| 1031 | type = in.readInt(); |
| 1032 | memoryType = in.readInt(); |
| 1033 | flags = in.readInt(); |
| 1034 | softInputMode = in.readInt(); |
| 1035 | gravity = in.readInt(); |
| 1036 | horizontalMargin = in.readFloat(); |
| 1037 | verticalMargin = in.readFloat(); |
| 1038 | format = in.readInt(); |
| 1039 | windowAnimations = in.readInt(); |
| 1040 | alpha = in.readFloat(); |
| 1041 | dimAmount = in.readFloat(); |
| 1042 | screenBrightness = in.readFloat(); |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 1043 | buttonBrightness = in.readFloat(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1044 | token = in.readStrongBinder(); |
| 1045 | packageName = in.readString(); |
| 1046 | mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); |
| 1047 | screenOrientation = in.readInt(); |
| 1048 | } |
| 1049 | |
Romain Guy | 7299807 | 2009-06-22 11:09:20 -0700 | [diff] [blame] | 1050 | @SuppressWarnings({"PointlessBitwiseExpression"}) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1051 | public static final int LAYOUT_CHANGED = 1<<0; |
| 1052 | public static final int TYPE_CHANGED = 1<<1; |
| 1053 | public static final int FLAGS_CHANGED = 1<<2; |
| 1054 | public static final int FORMAT_CHANGED = 1<<3; |
| 1055 | public static final int ANIMATION_CHANGED = 1<<4; |
| 1056 | public static final int DIM_AMOUNT_CHANGED = 1<<5; |
| 1057 | public static final int TITLE_CHANGED = 1<<6; |
| 1058 | public static final int ALPHA_CHANGED = 1<<7; |
| 1059 | public static final int MEMORY_TYPE_CHANGED = 1<<8; |
| 1060 | public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; |
| 1061 | public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; |
| 1062 | public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 1063 | /** {@hide} */ |
| 1064 | public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1065 | |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1066 | // internal buffer to backup/restore parameters under compatibility mode. |
| 1067 | private int[] mCompatibilityParamsBackup = null; |
| 1068 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1069 | public final int copyFrom(LayoutParams o) { |
| 1070 | int changes = 0; |
| 1071 | |
| 1072 | if (width != o.width) { |
| 1073 | width = o.width; |
| 1074 | changes |= LAYOUT_CHANGED; |
| 1075 | } |
| 1076 | if (height != o.height) { |
| 1077 | height = o.height; |
| 1078 | changes |= LAYOUT_CHANGED; |
| 1079 | } |
| 1080 | if (x != o.x) { |
| 1081 | x = o.x; |
| 1082 | changes |= LAYOUT_CHANGED; |
| 1083 | } |
| 1084 | if (y != o.y) { |
| 1085 | y = o.y; |
| 1086 | changes |= LAYOUT_CHANGED; |
| 1087 | } |
| 1088 | if (horizontalWeight != o.horizontalWeight) { |
| 1089 | horizontalWeight = o.horizontalWeight; |
| 1090 | changes |= LAYOUT_CHANGED; |
| 1091 | } |
| 1092 | if (verticalWeight != o.verticalWeight) { |
| 1093 | verticalWeight = o.verticalWeight; |
| 1094 | changes |= LAYOUT_CHANGED; |
| 1095 | } |
| 1096 | if (horizontalMargin != o.horizontalMargin) { |
| 1097 | horizontalMargin = o.horizontalMargin; |
| 1098 | changes |= LAYOUT_CHANGED; |
| 1099 | } |
| 1100 | if (verticalMargin != o.verticalMargin) { |
| 1101 | verticalMargin = o.verticalMargin; |
| 1102 | changes |= LAYOUT_CHANGED; |
| 1103 | } |
| 1104 | if (type != o.type) { |
| 1105 | type = o.type; |
| 1106 | changes |= TYPE_CHANGED; |
| 1107 | } |
| 1108 | if (memoryType != o.memoryType) { |
| 1109 | memoryType = o.memoryType; |
| 1110 | changes |= MEMORY_TYPE_CHANGED; |
| 1111 | } |
| 1112 | if (flags != o.flags) { |
| 1113 | flags = o.flags; |
| 1114 | changes |= FLAGS_CHANGED; |
| 1115 | } |
| 1116 | if (softInputMode != o.softInputMode) { |
| 1117 | softInputMode = o.softInputMode; |
| 1118 | changes |= SOFT_INPUT_MODE_CHANGED; |
| 1119 | } |
| 1120 | if (gravity != o.gravity) { |
| 1121 | gravity = o.gravity; |
| 1122 | changes |= LAYOUT_CHANGED; |
| 1123 | } |
| 1124 | if (horizontalMargin != o.horizontalMargin) { |
| 1125 | horizontalMargin = o.horizontalMargin; |
| 1126 | changes |= LAYOUT_CHANGED; |
| 1127 | } |
| 1128 | if (verticalMargin != o.verticalMargin) { |
| 1129 | verticalMargin = o.verticalMargin; |
| 1130 | changes |= LAYOUT_CHANGED; |
| 1131 | } |
| 1132 | if (format != o.format) { |
| 1133 | format = o.format; |
| 1134 | changes |= FORMAT_CHANGED; |
| 1135 | } |
| 1136 | if (windowAnimations != o.windowAnimations) { |
| 1137 | windowAnimations = o.windowAnimations; |
| 1138 | changes |= ANIMATION_CHANGED; |
| 1139 | } |
| 1140 | if (token == null) { |
| 1141 | // NOTE: token only copied if the recipient doesn't |
| 1142 | // already have one. |
| 1143 | token = o.token; |
| 1144 | } |
| 1145 | if (packageName == null) { |
| 1146 | // NOTE: packageName only copied if the recipient doesn't |
| 1147 | // already have one. |
| 1148 | packageName = o.packageName; |
| 1149 | } |
| 1150 | if (!mTitle.equals(o.mTitle)) { |
| 1151 | mTitle = o.mTitle; |
| 1152 | changes |= TITLE_CHANGED; |
| 1153 | } |
| 1154 | if (alpha != o.alpha) { |
| 1155 | alpha = o.alpha; |
| 1156 | changes |= ALPHA_CHANGED; |
| 1157 | } |
| 1158 | if (dimAmount != o.dimAmount) { |
| 1159 | dimAmount = o.dimAmount; |
| 1160 | changes |= DIM_AMOUNT_CHANGED; |
| 1161 | } |
| 1162 | if (screenBrightness != o.screenBrightness) { |
| 1163 | screenBrightness = o.screenBrightness; |
| 1164 | changes |= SCREEN_BRIGHTNESS_CHANGED; |
| 1165 | } |
Mike Lockwood | fb73f79 | 2009-11-20 11:31:18 -0500 | [diff] [blame] | 1166 | if (buttonBrightness != o.buttonBrightness) { |
| 1167 | buttonBrightness = o.buttonBrightness; |
| 1168 | changes |= BUTTON_BRIGHTNESS_CHANGED; |
| 1169 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1170 | |
| 1171 | if (screenOrientation != o.screenOrientation) { |
| 1172 | screenOrientation = o.screenOrientation; |
| 1173 | changes |= SCREEN_ORIENTATION_CHANGED; |
| 1174 | } |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 1175 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1176 | return changes; |
| 1177 | } |
| 1178 | |
| 1179 | @Override |
| 1180 | public String debug(String output) { |
| 1181 | output += "Contents of " + this + ":"; |
| 1182 | Log.d("Debug", output); |
| 1183 | output = super.debug(""); |
| 1184 | Log.d("Debug", output); |
| 1185 | Log.d("Debug", ""); |
| 1186 | Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); |
| 1187 | return ""; |
| 1188 | } |
| 1189 | |
| 1190 | @Override |
| 1191 | public String toString() { |
| 1192 | StringBuilder sb = new StringBuilder(256); |
| 1193 | sb.append("WM.LayoutParams{"); |
| 1194 | sb.append("("); |
| 1195 | sb.append(x); |
| 1196 | sb.append(','); |
| 1197 | sb.append(y); |
| 1198 | sb.append(")("); |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 1199 | 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] | 1200 | sb.append('x'); |
Romain Guy | 980a938 | 2010-01-08 15:06:28 -0800 | [diff] [blame] | 1201 | 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] | 1202 | sb.append(")"); |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 1203 | if (horizontalMargin != 0) { |
| 1204 | sb.append(" hm="); |
| 1205 | sb.append(horizontalMargin); |
| 1206 | } |
| 1207 | if (verticalMargin != 0) { |
| 1208 | sb.append(" vm="); |
| 1209 | sb.append(verticalMargin); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1210 | } |
| 1211 | if (gravity != 0) { |
| 1212 | sb.append(" gr=#"); |
| 1213 | sb.append(Integer.toHexString(gravity)); |
| 1214 | } |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 1215 | if (softInputMode != 0) { |
| 1216 | sb.append(" sim=#"); |
| 1217 | sb.append(Integer.toHexString(softInputMode)); |
| 1218 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1219 | sb.append(" ty="); |
| 1220 | sb.append(type); |
| 1221 | sb.append(" fl=#"); |
| 1222 | sb.append(Integer.toHexString(flags)); |
| 1223 | sb.append(" fmt="); |
| 1224 | sb.append(format); |
| 1225 | if (windowAnimations != 0) { |
| 1226 | sb.append(" wanim=0x"); |
| 1227 | sb.append(Integer.toHexString(windowAnimations)); |
| 1228 | } |
| 1229 | if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { |
| 1230 | sb.append(" or="); |
| 1231 | sb.append(screenOrientation); |
| 1232 | } |
Dianne Hackborn | 8eb2e24 | 2010-11-01 12:31:24 -0700 | [diff] [blame] | 1233 | if (alpha != 1.0f) { |
| 1234 | sb.append(" alpha="); |
| 1235 | sb.append(alpha); |
| 1236 | } |
| 1237 | if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { |
| 1238 | sb.append(" sbrt="); |
| 1239 | sb.append(screenBrightness); |
| 1240 | } |
| 1241 | if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { |
| 1242 | sb.append(" bbrt="); |
| 1243 | sb.append(buttonBrightness); |
| 1244 | } |
Mitsuru Oshima | 5a2b91d | 2009-07-16 16:30:02 -0700 | [diff] [blame] | 1245 | if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) { |
| 1246 | sb.append(" compatible=true"); |
| 1247 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1248 | sb.append('}'); |
| 1249 | return sb.toString(); |
| 1250 | } |
Mitsuru Oshima | 8d11267 | 2009-04-27 12:01:23 -0700 | [diff] [blame] | 1251 | |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1252 | /** |
| 1253 | * Scale the layout params' coordinates and size. |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame] | 1254 | * @hide |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1255 | */ |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame] | 1256 | public void scale(float scale) { |
Mitsuru Oshima | 61324e5 | 2009-07-21 15:40:36 -0700 | [diff] [blame] | 1257 | x = (int) (x * scale + 0.5f); |
| 1258 | y = (int) (y * scale + 0.5f); |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1259 | if (width > 0) { |
Mitsuru Oshima | 61324e5 | 2009-07-21 15:40:36 -0700 | [diff] [blame] | 1260 | width = (int) (width * scale + 0.5f); |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1261 | } |
| 1262 | if (height > 0) { |
Mitsuru Oshima | 61324e5 | 2009-07-21 15:40:36 -0700 | [diff] [blame] | 1263 | height = (int) (height * scale + 0.5f); |
Mitsuru Oshima | 8d11267 | 2009-04-27 12:01:23 -0700 | [diff] [blame] | 1264 | } |
| 1265 | } |
| 1266 | |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1267 | /** |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1268 | * Backup the layout parameters used in compatibility mode. |
| 1269 | * @see LayoutParams#restore() |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1270 | */ |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1271 | void backup() { |
| 1272 | int[] backup = mCompatibilityParamsBackup; |
| 1273 | if (backup == null) { |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame] | 1274 | // we backup 4 elements, x, y, width, height |
| 1275 | backup = mCompatibilityParamsBackup = new int[4]; |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1276 | } |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1277 | backup[0] = x; |
| 1278 | backup[1] = y; |
| 1279 | backup[2] = width; |
| 1280 | backup[3] = height; |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1281 | } |
| 1282 | |
| 1283 | /** |
| 1284 | * Restore the layout params' coordinates, size and gravity |
| 1285 | * @see LayoutParams#backup() |
| 1286 | */ |
| 1287 | void restore() { |
| 1288 | int[] backup = mCompatibilityParamsBackup; |
| 1289 | if (backup != null) { |
| 1290 | x = backup[0]; |
| 1291 | y = backup[1]; |
| 1292 | width = backup[2]; |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1293 | height = backup[3]; |
| 1294 | } |
| 1295 | } |
| 1296 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1297 | private CharSequence mTitle = ""; |
| 1298 | } |
| 1299 | } |