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 | |
| 68 | public static class LayoutParams extends ViewGroup.LayoutParams |
| 69 | implements Parcelable { |
| 70 | /** |
| 71 | * X position for this window. With the default gravity it is ignored. |
| 72 | * When using {@link Gravity#LEFT} or {@link Gravity#RIGHT} it provides |
| 73 | * an offset from the given edge. |
| 74 | */ |
| 75 | public int x; |
| 76 | |
| 77 | /** |
| 78 | * Y position for this window. With the default gravity it is ignored. |
| 79 | * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides |
| 80 | * an offset from the given edge. |
| 81 | */ |
| 82 | public int y; |
| 83 | |
| 84 | /** |
| 85 | * Indicates how much of the extra space will be allocated horizontally |
| 86 | * to the view associated with these LayoutParams. Specify 0 if the view |
| 87 | * should not be stretched. Otherwise the extra pixels will be pro-rated |
| 88 | * among all views whose weight is greater than 0. |
| 89 | */ |
| 90 | public float horizontalWeight; |
| 91 | |
| 92 | /** |
| 93 | * Indicates how much of the extra space will be allocated vertically |
| 94 | * to the view associated with these LayoutParams. Specify 0 if the view |
| 95 | * should not be stretched. Otherwise the extra pixels will be pro-rated |
| 96 | * among all views whose weight is greater than 0. |
| 97 | */ |
| 98 | public float verticalWeight; |
| 99 | |
| 100 | /** |
| 101 | * The general type of window. There are three main classes of |
| 102 | * window types: |
| 103 | * <ul> |
| 104 | * <li> <strong>Application windows</strong> (ranging from |
| 105 | * {@link #FIRST_APPLICATION_WINDOW} to |
| 106 | * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application |
| 107 | * windows. For these types of windows, the {@link #token} must be |
| 108 | * set to the token of the activity they are a part of (this will |
| 109 | * normally be done for you if {@link #token} is null). |
| 110 | * <li> <strong>Sub-windows</strong> (ranging from |
| 111 | * {@link #FIRST_SUB_WINDOW} to |
| 112 | * {@link #LAST_SUB_WINDOW}) are associated with another top-level |
| 113 | * window. For these types of windows, the {@link #token} must be |
| 114 | * the token of the window it is attached to. |
| 115 | * <li> <strong>System windows</strong> (ranging from |
| 116 | * {@link #FIRST_SYSTEM_WINDOW} to |
| 117 | * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for |
| 118 | * use by the system for specific purposes. They should not normally |
| 119 | * be used by applications, and a special permission is required |
| 120 | * to use them. |
| 121 | * </ul> |
| 122 | * |
| 123 | * @see #TYPE_BASE_APPLICATION |
| 124 | * @see #TYPE_APPLICATION |
| 125 | * @see #TYPE_APPLICATION_STARTING |
| 126 | * @see #TYPE_APPLICATION_PANEL |
| 127 | * @see #TYPE_APPLICATION_MEDIA |
| 128 | * @see #TYPE_APPLICATION_SUB_PANEL |
| 129 | * @see #TYPE_APPLICATION_ATTACHED_DIALOG |
| 130 | * @see #TYPE_STATUS_BAR |
| 131 | * @see #TYPE_SEARCH_BAR |
| 132 | * @see #TYPE_PHONE |
| 133 | * @see #TYPE_SYSTEM_ALERT |
| 134 | * @see #TYPE_KEYGUARD |
| 135 | * @see #TYPE_TOAST |
| 136 | * @see #TYPE_SYSTEM_OVERLAY |
| 137 | * @see #TYPE_PRIORITY_PHONE |
| 138 | * @see #TYPE_STATUS_BAR_PANEL |
| 139 | * @see #TYPE_SYSTEM_DIALOG |
| 140 | * @see #TYPE_KEYGUARD_DIALOG |
| 141 | * @see #TYPE_SYSTEM_ERROR |
| 142 | * @see #TYPE_INPUT_METHOD |
| 143 | * @see #TYPE_INPUT_METHOD_DIALOG |
| 144 | */ |
| 145 | public int type; |
| 146 | |
| 147 | /** |
| 148 | * Start of window types that represent normal application windows. |
| 149 | */ |
| 150 | public static final int FIRST_APPLICATION_WINDOW = 1; |
| 151 | |
| 152 | /** |
| 153 | * Window type: an application window that serves as the "base" window |
| 154 | * of the overall application; all other application windows will |
| 155 | * appear on top of it. |
| 156 | */ |
| 157 | public static final int TYPE_BASE_APPLICATION = 1; |
| 158 | |
| 159 | /** |
| 160 | * Window type: a normal application window. The {@link #token} must be |
| 161 | * an Activity token identifying who the window belongs to. |
| 162 | */ |
| 163 | public static final int TYPE_APPLICATION = 2; |
| 164 | |
| 165 | /** |
| 166 | * Window type: special application window that is displayed while the |
| 167 | * application is starting. Not for use by applications themselves; |
| 168 | * this is used by the system to display something until the |
| 169 | * application can show its own windows. |
| 170 | */ |
| 171 | public static final int TYPE_APPLICATION_STARTING = 3; |
| 172 | |
| 173 | /** |
| 174 | * End of types of application windows. |
| 175 | */ |
| 176 | public static final int LAST_APPLICATION_WINDOW = 99; |
| 177 | |
| 178 | /** |
| 179 | * Start of types of sub-windows. The {@link #token} of these windows |
| 180 | * must be set to the window they are attached to. These types of |
| 181 | * windows are kept next to their attached window in Z-order, and their |
| 182 | * coordinate space is relative to their attached window. |
| 183 | */ |
| 184 | public static final int FIRST_SUB_WINDOW = 1000; |
| 185 | |
| 186 | /** |
| 187 | * Window type: a panel on top of an application window. These windows |
| 188 | * appear on top of their attached window. |
| 189 | */ |
| 190 | public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; |
| 191 | |
| 192 | /** |
| 193 | * Window type: window for showing media (e.g. video). These windows |
| 194 | * are displayed behind their attached window. |
| 195 | */ |
| 196 | public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1; |
| 197 | |
| 198 | /** |
| 199 | * Window type: a sub-panel on top of an application window. These |
| 200 | * windows are displayed on top their attached window and any |
| 201 | * {@link #TYPE_APPLICATION_PANEL} panels. |
| 202 | */ |
| 203 | public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2; |
| 204 | |
| 205 | /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout |
| 206 | * of the window happens as that of a top-level window, <em>not</em> |
| 207 | * as a child of its container. |
| 208 | */ |
| 209 | public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3; |
| 210 | |
| 211 | /** |
Dianne Hackborn | c4d5d02 | 2009-05-21 17:32:42 -0700 | [diff] [blame] | 212 | * Window type: window for showing overlays on top of media windows. |
| 213 | * These windows are displayed between TYPE_APPLICATION_MEDIA and the |
| 214 | * application window. They should be translucent to be useful. This |
| 215 | * is a big ugly hack so: |
| 216 | * @hide |
| 217 | */ |
| 218 | public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4; |
| 219 | |
| 220 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 221 | * End of types of sub-windows. |
| 222 | */ |
| 223 | public static final int LAST_SUB_WINDOW = 1999; |
| 224 | |
| 225 | /** |
| 226 | * Start of system-specific window types. These are not normally |
| 227 | * created by applications. |
| 228 | */ |
| 229 | public static final int FIRST_SYSTEM_WINDOW = 2000; |
| 230 | |
| 231 | /** |
| 232 | * Window type: the status bar. There can be only one status bar |
| 233 | * window; it is placed at the top of the screen, and all other |
| 234 | * windows are shifted down so they are below it. |
| 235 | */ |
| 236 | public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; |
| 237 | |
| 238 | /** |
| 239 | * Window type: the search bar. There can be only one search bar |
| 240 | * window; it is placed at the top of the screen. |
| 241 | */ |
| 242 | public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; |
| 243 | |
| 244 | /** |
| 245 | * Window type: phone. These are non-application windows providing |
| 246 | * user interaction with the phone (in particular incoming calls). |
| 247 | * These windows are normally placed above all applications, but behind |
| 248 | * the status bar. |
| 249 | */ |
| 250 | public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; |
| 251 | |
| 252 | /** |
| 253 | * Window type: system window, such as low power alert. These windows |
| 254 | * are always on top of application windows. |
| 255 | */ |
| 256 | public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; |
| 257 | |
| 258 | /** |
| 259 | * Window type: keyguard window. |
| 260 | */ |
| 261 | public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; |
| 262 | |
| 263 | /** |
| 264 | * Window type: transient notifications. |
| 265 | */ |
| 266 | public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; |
| 267 | |
| 268 | /** |
| 269 | * Window type: system overlay windows, which need to be displayed |
| 270 | * on top of everything else. These windows must not take input |
| 271 | * focus, or they will interfere with the keyguard. |
| 272 | */ |
| 273 | public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; |
| 274 | |
| 275 | /** |
| 276 | * Window type: priority phone UI, which needs to be displayed even if |
| 277 | * the keyguard is active. These windows must not take input |
| 278 | * focus, or they will interfere with the keyguard. |
| 279 | */ |
| 280 | public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; |
| 281 | |
| 282 | /** |
| 283 | * Window type: panel that slides out from the status bar |
| 284 | */ |
| 285 | public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+8; |
| 286 | |
| 287 | /** |
| 288 | * Window type: panel that slides out from the status bar |
| 289 | */ |
| 290 | public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; |
| 291 | |
| 292 | /** |
| 293 | * Window type: dialogs that the keyguard shows |
| 294 | */ |
| 295 | public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; |
| 296 | |
| 297 | /** |
| 298 | * Window type: internal system error windows, appear on top of |
| 299 | * everything they can. |
| 300 | */ |
| 301 | public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; |
| 302 | |
| 303 | /** |
| 304 | * Window type: internal input methods windows, which appear above |
| 305 | * the normal UI. Application windows may be resized or panned to keep |
| 306 | * the input focus visible while this window is displayed. |
| 307 | */ |
| 308 | public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; |
| 309 | |
| 310 | /** |
| 311 | * Window type: internal input methods dialog windows, which appear above |
| 312 | * the current input method window. |
| 313 | */ |
| 314 | public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; |
| 315 | |
| 316 | /** |
| 317 | * End of types of system windows. |
| 318 | */ |
| 319 | public static final int LAST_SYSTEM_WINDOW = 2999; |
| 320 | |
| 321 | /** |
| 322 | * Specifies what type of memory buffers should be used by this window. |
| 323 | * Default is normal. |
| 324 | * |
| 325 | * @see #MEMORY_TYPE_NORMAL |
| 326 | * @see #MEMORY_TYPE_HARDWARE |
| 327 | * @see #MEMORY_TYPE_GPU |
| 328 | * @see #MEMORY_TYPE_PUSH_BUFFERS |
| 329 | */ |
| 330 | public int memoryType; |
| 331 | |
| 332 | /** Memory type: The window's surface is allocated in main memory. */ |
| 333 | public static final int MEMORY_TYPE_NORMAL = 0; |
| 334 | /** Memory type: The window's surface is configured to be accessible |
| 335 | * by DMA engines and hardware accelerators. */ |
| 336 | public static final int MEMORY_TYPE_HARDWARE = 1; |
| 337 | /** Memory type: The window's surface is configured to be accessible |
| 338 | * by graphics accelerators. */ |
| 339 | public static final int MEMORY_TYPE_GPU = 2; |
| 340 | /** Memory type: The window's surface doesn't own its buffers and |
| 341 | * therefore cannot be locked. Instead the buffers are pushed to |
| 342 | * it through native binder calls. */ |
| 343 | public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; |
| 344 | |
| 345 | /** |
| 346 | * Various behavioral options/flags. Default is none. |
| 347 | * |
| 348 | * @see #FLAG_BLUR_BEHIND |
| 349 | * @see #FLAG_DIM_BEHIND |
| 350 | * @see #FLAG_NOT_FOCUSABLE |
| 351 | * @see #FLAG_NOT_TOUCHABLE |
| 352 | * @see #FLAG_NOT_TOUCH_MODAL |
| 353 | * @see #FLAG_LAYOUT_IN_SCREEN |
| 354 | * @see #FLAG_DITHER |
| 355 | * @see #FLAG_KEEP_SCREEN_ON |
| 356 | * @see #FLAG_FULLSCREEN |
| 357 | * @see #FLAG_FORCE_NOT_FULLSCREEN |
| 358 | * @see #FLAG_IGNORE_CHEEK_PRESSES |
| 359 | */ |
| 360 | public int flags; |
| 361 | |
| 362 | /** Window flag: everything behind this window will be dimmed. |
| 363 | * Use {@link #dimAmount} to control the amount of dim. */ |
| 364 | public static final int FLAG_DIM_BEHIND = 0x00000002; |
| 365 | |
| 366 | /** Window flag: blur everything behind this window. */ |
| 367 | public static final int FLAG_BLUR_BEHIND = 0x00000004; |
| 368 | |
| 369 | /** Window flag: this window won't ever get key input focus, so the |
| 370 | * user can not send key or other button events to it. Those will |
| 371 | * instead go to whatever focusable window is behind it. This flag |
| 372 | * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that |
| 373 | * is explicitly set. |
| 374 | * |
| 375 | * <p>Setting this flag also implies that the window will not need to |
| 376 | * interact with |
| 377 | * a soft input method, so it will be Z-ordered and positioned |
| 378 | * independently of any active input method (typically this means it |
| 379 | * gets Z-ordered on top of the input method, so it can use the full |
| 380 | * screen for its content and cover the input method if needed. You |
| 381 | * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ |
| 382 | public static final int FLAG_NOT_FOCUSABLE = 0x00000008; |
| 383 | |
| 384 | /** Window flag: this window can never receive touch events. */ |
| 385 | public static final int FLAG_NOT_TOUCHABLE = 0x00000010; |
| 386 | |
| 387 | /** Window flag: Even when this window is focusable (its |
| 388 | * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events |
| 389 | * outside of the window to be sent to the windows behind it. Otherwise |
| 390 | * it will consume all pointer events itself, regardless of whether they |
| 391 | * are inside of the window. */ |
| 392 | public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; |
| 393 | |
| 394 | /** Window flag: When set, if the device is asleep when the touch |
| 395 | * screen is pressed, you will receive this first touch event. Usually |
| 396 | * the first touch event is consumed by the system since the user can |
| 397 | * not see what they are pressing on. |
| 398 | */ |
| 399 | public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; |
| 400 | |
| 401 | /** Window flag: as long as this window is visible to the user, keep |
| 402 | * the device's screen turned on and bright. */ |
| 403 | public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; |
| 404 | |
| 405 | /** Window flag: place the window within the entire screen, ignoring |
| 406 | * decorations around the border (a.k.a. the status bar). The |
| 407 | * window must correctly position its contents to take the screen |
| 408 | * decoration into account. This flag is normally set for you |
| 409 | * by Window as described in {@link Window#setFlags}. */ |
| 410 | public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; |
| 411 | |
| 412 | /** Window flag: allow window to extend outside of the screen. */ |
| 413 | public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; |
| 414 | |
| 415 | /** Window flag: Hide all screen decorations (e.g. status bar) while |
| 416 | * this window is displayed. This allows the window to use the entire |
| 417 | * display space for itself -- the status bar will be hidden when |
| 418 | * an app window with this flag set is on the top layer. */ |
| 419 | public static final int FLAG_FULLSCREEN = 0x00000400; |
| 420 | |
| 421 | /** Window flag: Override {@link #FLAG_FULLSCREEN and force the |
| 422 | * screen decorations (such as status bar) to be shown. */ |
| 423 | public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; |
| 424 | |
| 425 | /** Window flag: turn on dithering when compositing this window to |
| 426 | * the screen. */ |
| 427 | public static final int FLAG_DITHER = 0x00001000; |
| 428 | |
| 429 | /** Window flag: don't allow screen shots while this window is |
| 430 | * displayed. */ |
| 431 | public static final int FLAG_SECURE = 0x00002000; |
| 432 | |
| 433 | /** Window flag: a special mode where the layout parameters are used |
| 434 | * to perform scaling of the surface when it is composited to the |
| 435 | * screen. */ |
| 436 | public static final int FLAG_SCALED = 0x00004000; |
| 437 | |
| 438 | /** Window flag: intended for windows that will often be used when the user is |
| 439 | * holding the screen against their face, it will aggressively filter the event |
| 440 | * stream to prevent unintended presses in this situation that may not be |
| 441 | * desired for a particular window, when such an event stream is detected, the |
| 442 | * application will receive a CANCEL motion event to indicate this so applications |
| 443 | * can handle this accordingly by taking no action on the event |
| 444 | * until the finger is released. */ |
| 445 | public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; |
| 446 | |
| 447 | /** Window flag: a special option only for use in combination with |
| 448 | * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the |
| 449 | * screen your window may appear on top of or behind screen decorations |
| 450 | * such as the status bar. By also including this flag, the window |
| 451 | * manager will report the inset rectangle needed to ensure your |
| 452 | * content is not covered by screen decorations. This flag is normally |
| 453 | * set for you by Window as described in {@link Window#setFlags}.*/ |
| 454 | public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; |
| 455 | |
| 456 | /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with |
| 457 | * respect to how this window interacts with the current method. That |
| 458 | * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the |
| 459 | * window will behave as if it needs to interact with the input method |
| 460 | * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is |
| 461 | * not set and this flag is set, then the window will behave as if it |
| 462 | * doesn't need to interact with the input method and can be placed |
| 463 | * to use more space and cover the input method. |
| 464 | */ |
| 465 | public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; |
| 466 | |
| 467 | /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you |
| 468 | * can set this flag to receive a single special MotionEvent with |
| 469 | * the action |
| 470 | * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for |
| 471 | * touches that occur outside of your window. Note that you will not |
| 472 | * receive the full down/move/up gesture, only the location of the |
| 473 | * first down as an ACTION_OUTSIDE. |
| 474 | */ |
| 475 | public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; |
| 476 | |
Suchi Amalapurapu | d1a9337 | 2009-05-14 17:54:31 -0700 | [diff] [blame] | 477 | /** Window flag: special flag to let windows be shown when the screen |
| 478 | * is locked. This will let application windows take precedence over |
| 479 | * key guard or any other lock screens. Can be used with |
| 480 | * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows |
| 481 | * directly before showing the key guard window |
| 482 | * |
| 483 | * {@hide} */ |
| 484 | public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; |
| 485 | |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame^] | 486 | /** Window flag: special flag to let a window ignore the compatibility scaling. |
| 487 | * This is used by SurfaceView to create a window that does not scale the content. |
| 488 | * |
| 489 | * {@hide} */ |
| 490 | public static final int FLAG_NO_COMPATIBILITY_SCALING = 0x00100000; |
| 491 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 492 | /** Window flag: a special option intended for system dialogs. When |
| 493 | * this flag is set, the window will demand focus unconditionally when |
| 494 | * it is created. |
| 495 | * {@hide} */ |
| 496 | public static final int FLAG_SYSTEM_ERROR = 0x40000000; |
| 497 | |
| 498 | /** |
| 499 | * Given a particular set of window manager flags, determine whether |
| 500 | * such a window may be a target for an input method when it has |
| 501 | * focus. In particular, this checks the |
| 502 | * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} |
| 503 | * flags and returns true if the combination of the two corresponds |
| 504 | * to a window that needs to be behind the input method so that the |
| 505 | * user can type into it. |
| 506 | * |
| 507 | * @param flags The current window manager flags. |
| 508 | * |
| 509 | * @return Returns true if such a window should be behind/interact |
| 510 | * with an input method, false if not. |
| 511 | */ |
| 512 | public static boolean mayUseInputMethod(int flags) { |
| 513 | switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { |
| 514 | case 0: |
| 515 | case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: |
| 516 | return true; |
| 517 | } |
| 518 | return false; |
| 519 | } |
| 520 | |
| 521 | /** |
| 522 | * Mask for {@link #softInputMode} of the bits that determine the |
| 523 | * desired visibility state of the soft input area for this window. |
| 524 | */ |
| 525 | public static final int SOFT_INPUT_MASK_STATE = 0x0f; |
| 526 | |
| 527 | /** |
| 528 | * Visibility state for {@link #softInputMode}: no state has been specified. |
| 529 | */ |
| 530 | public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; |
| 531 | |
| 532 | /** |
| 533 | * Visibility state for {@link #softInputMode}: please don't change the state of |
| 534 | * the soft input area. |
| 535 | */ |
| 536 | public static final int SOFT_INPUT_STATE_UNCHANGED = 1; |
| 537 | |
| 538 | /** |
| 539 | * Visibility state for {@link #softInputMode}: please hide any soft input |
| 540 | * area when normally appropriate (when the user is navigating |
| 541 | * forward to your window). |
| 542 | */ |
| 543 | public static final int SOFT_INPUT_STATE_HIDDEN = 2; |
| 544 | |
| 545 | /** |
| 546 | * Visibility state for {@link #softInputMode}: please always hide any |
| 547 | * soft input area when this window receives focus. |
| 548 | */ |
| 549 | public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; |
| 550 | |
| 551 | /** |
| 552 | * Visibility state for {@link #softInputMode}: please show the soft |
| 553 | * input area when normally appropriate (when the user is navigating |
| 554 | * forward to your window). |
| 555 | */ |
| 556 | public static final int SOFT_INPUT_STATE_VISIBLE = 4; |
| 557 | |
| 558 | /** |
| 559 | * Visibility state for {@link #softInputMode}: please always make the |
| 560 | * soft input area visible when this window receives input focus. |
| 561 | */ |
| 562 | public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; |
| 563 | |
| 564 | /** |
| 565 | * Mask for {@link #softInputMode} of the bits that determine the |
| 566 | * way that the window should be adjusted to accommodate the soft |
| 567 | * input window. |
| 568 | */ |
| 569 | public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; |
| 570 | |
| 571 | /** Adjustment option for {@link #softInputMode}: nothing specified. |
| 572 | * The system will try to pick one or |
| 573 | * the other depending on the contents of the window. |
| 574 | */ |
| 575 | public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; |
| 576 | |
| 577 | /** Adjustment option for {@link #softInputMode}: set to allow the |
| 578 | * window to be resized when an input |
| 579 | * method is shown, so that its contents are not covered by the input |
| 580 | * method. This can <em>not<em> be combined with |
| 581 | * {@link #SOFT_INPUT_ADJUST_PAN}; if |
| 582 | * neither of these are set, then the system will try to pick one or |
| 583 | * the other depending on the contents of the window. |
| 584 | */ |
| 585 | public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; |
| 586 | |
| 587 | /** Adjustment option for {@link #softInputMode}: set to have a window |
| 588 | * pan when an input method is |
| 589 | * shown, so it doesn't need to deal with resizing but just panned |
| 590 | * by the framework to ensure the current input focus is visible. This |
| 591 | * can <em>not<em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if |
| 592 | * neither of these are set, then the system will try to pick one or |
| 593 | * the other depending on the contents of the window. |
| 594 | */ |
| 595 | public static final int SOFT_INPUT_ADJUST_PAN = 0x20; |
| 596 | |
| 597 | /** |
| 598 | * Bit for {@link #softInputMode}: set when the user has navigated |
| 599 | * forward to the window. This is normally set automatically for |
| 600 | * you by the system, though you may want to set it in certain cases |
| 601 | * when you are displaying a window yourself. This flag will always |
| 602 | * be cleared automatically after the window is displayed. |
| 603 | */ |
| 604 | public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; |
| 605 | |
| 606 | /** |
| 607 | * Desired operating mode for any soft input area. May any combination |
| 608 | * of: |
| 609 | * |
| 610 | * <ul> |
| 611 | * <li> One of the visibility states |
| 612 | * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, |
| 613 | * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or |
| 614 | * {@link #SOFT_INPUT_STATE_VISIBLE}. |
| 615 | * <li> One of the adjustment options |
| 616 | * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, |
| 617 | * {@link #SOFT_INPUT_ADJUST_RESIZE}, or |
| 618 | * {@link #SOFT_INPUT_ADJUST_PAN}. |
| 619 | */ |
| 620 | public int softInputMode; |
| 621 | |
| 622 | /** |
| 623 | * Placement of window within the screen as per {@link Gravity} |
| 624 | * |
| 625 | * @see Gravity |
| 626 | */ |
| 627 | public int gravity; |
| 628 | |
| 629 | /** |
| 630 | * The horizontal margin, as a percentage of the container's width, |
| 631 | * between the container and the widget. |
| 632 | */ |
| 633 | public float horizontalMargin; |
| 634 | |
| 635 | /** |
| 636 | * The vertical margin, as a percentage of the container's height, |
| 637 | * between the container and the widget. |
| 638 | */ |
| 639 | public float verticalMargin; |
| 640 | |
| 641 | /** |
| 642 | * The desired bitmap format. May be one of the constants in |
| 643 | * {@link android.graphics.PixelFormat}. Default is OPAQUE. |
| 644 | */ |
| 645 | public int format; |
| 646 | |
| 647 | /** |
| 648 | * A style resource defining the animations to use for this window. |
| 649 | * This must be a system resource; it can not be an application resource |
| 650 | * because the window manager does not have access to applications. |
| 651 | */ |
| 652 | public int windowAnimations; |
| 653 | |
| 654 | /** |
| 655 | * An alpha value to apply to this entire window. |
| 656 | * An alpha of 1.0 means fully opaque and 0.0 means fully transparent |
| 657 | */ |
| 658 | public float alpha = 1.0f; |
| 659 | |
| 660 | /** |
| 661 | * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming |
| 662 | * to apply. Range is from 1.0 for completely opaque to 0.0 for no |
| 663 | * dim. |
| 664 | */ |
| 665 | public float dimAmount = 1.0f; |
| 666 | |
| 667 | /** |
| 668 | * This can be used to override the user's preferred brightness of |
| 669 | * the screen. A value of less than 0, the default, means to use the |
| 670 | * preferred screen brightness. 0 to 1 adjusts the brightness from |
| 671 | * dark to full bright. |
| 672 | */ |
| 673 | public float screenBrightness = -1.0f; |
| 674 | |
| 675 | /** |
| 676 | * Identifier for this window. This will usually be filled in for |
| 677 | * you. |
| 678 | */ |
| 679 | public IBinder token = null; |
| 680 | |
| 681 | /** |
| 682 | * Name of the package owning this window. |
| 683 | */ |
| 684 | public String packageName = null; |
| 685 | |
| 686 | /** |
| 687 | * Specific orientation value for a window. |
| 688 | * May be any of the same values allowed |
| 689 | * for {@link android.content.pm.ActivityInfo#screenOrientation}. |
| 690 | * If not set, a default value of |
| 691 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} |
| 692 | * will be used. |
| 693 | */ |
| 694 | public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
| 695 | |
| 696 | |
| 697 | public LayoutParams() { |
| 698 | super(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); |
| 699 | type = TYPE_APPLICATION; |
| 700 | format = PixelFormat.OPAQUE; |
| 701 | } |
| 702 | |
| 703 | public LayoutParams(int _type) { |
| 704 | super(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); |
| 705 | type = _type; |
| 706 | format = PixelFormat.OPAQUE; |
| 707 | } |
| 708 | |
| 709 | public LayoutParams(int _type, int _flags) { |
| 710 | super(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); |
| 711 | type = _type; |
| 712 | flags = _flags; |
| 713 | format = PixelFormat.OPAQUE; |
| 714 | } |
| 715 | |
| 716 | public LayoutParams(int _type, int _flags, int _format) { |
| 717 | super(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); |
| 718 | type = _type; |
| 719 | flags = _flags; |
| 720 | format = _format; |
| 721 | } |
| 722 | |
| 723 | public LayoutParams(int w, int h, int _type, int _flags, int _format) { |
| 724 | super(w, h); |
| 725 | type = _type; |
| 726 | flags = _flags; |
| 727 | format = _format; |
| 728 | } |
| 729 | |
| 730 | public LayoutParams(int w, int h, int xpos, int ypos, int _type, |
| 731 | int _flags, int _format) { |
| 732 | super(w, h); |
| 733 | x = xpos; |
| 734 | y = ypos; |
| 735 | type = _type; |
| 736 | flags = _flags; |
| 737 | format = _format; |
| 738 | } |
| 739 | |
| 740 | public final void setTitle(CharSequence title) { |
| 741 | if (null == title) |
| 742 | title = ""; |
| 743 | |
| 744 | mTitle = TextUtils.stringOrSpannedString(title); |
| 745 | } |
| 746 | |
| 747 | public final CharSequence getTitle() { |
| 748 | return mTitle; |
| 749 | } |
| 750 | |
| 751 | public int describeContents() { |
| 752 | return 0; |
| 753 | } |
| 754 | |
| 755 | public void writeToParcel(Parcel out, int parcelableFlags) { |
| 756 | out.writeInt(width); |
| 757 | out.writeInt(height); |
| 758 | out.writeInt(x); |
| 759 | out.writeInt(y); |
| 760 | out.writeInt(type); |
| 761 | out.writeInt(memoryType); |
| 762 | out.writeInt(flags); |
| 763 | out.writeInt(softInputMode); |
| 764 | out.writeInt(gravity); |
| 765 | out.writeFloat(horizontalMargin); |
| 766 | out.writeFloat(verticalMargin); |
| 767 | out.writeInt(format); |
| 768 | out.writeInt(windowAnimations); |
| 769 | out.writeFloat(alpha); |
| 770 | out.writeFloat(dimAmount); |
| 771 | out.writeFloat(screenBrightness); |
| 772 | out.writeStrongBinder(token); |
| 773 | out.writeString(packageName); |
| 774 | TextUtils.writeToParcel(mTitle, out, parcelableFlags); |
| 775 | out.writeInt(screenOrientation); |
| 776 | } |
| 777 | |
| 778 | public static final Parcelable.Creator<LayoutParams> CREATOR |
| 779 | = new Parcelable.Creator<LayoutParams>() { |
| 780 | public LayoutParams createFromParcel(Parcel in) { |
| 781 | return new LayoutParams(in); |
| 782 | } |
| 783 | |
| 784 | public LayoutParams[] newArray(int size) { |
| 785 | return new LayoutParams[size]; |
| 786 | } |
| 787 | }; |
| 788 | |
| 789 | |
| 790 | public LayoutParams(Parcel in) { |
| 791 | width = in.readInt(); |
| 792 | height = in.readInt(); |
| 793 | x = in.readInt(); |
| 794 | y = in.readInt(); |
| 795 | type = in.readInt(); |
| 796 | memoryType = in.readInt(); |
| 797 | flags = in.readInt(); |
| 798 | softInputMode = in.readInt(); |
| 799 | gravity = in.readInt(); |
| 800 | horizontalMargin = in.readFloat(); |
| 801 | verticalMargin = in.readFloat(); |
| 802 | format = in.readInt(); |
| 803 | windowAnimations = in.readInt(); |
| 804 | alpha = in.readFloat(); |
| 805 | dimAmount = in.readFloat(); |
| 806 | screenBrightness = in.readFloat(); |
| 807 | token = in.readStrongBinder(); |
| 808 | packageName = in.readString(); |
| 809 | mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); |
| 810 | screenOrientation = in.readInt(); |
| 811 | } |
| 812 | |
Romain Guy | 7299807 | 2009-06-22 11:09:20 -0700 | [diff] [blame] | 813 | @SuppressWarnings({"PointlessBitwiseExpression"}) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 814 | public static final int LAYOUT_CHANGED = 1<<0; |
| 815 | public static final int TYPE_CHANGED = 1<<1; |
| 816 | public static final int FLAGS_CHANGED = 1<<2; |
| 817 | public static final int FORMAT_CHANGED = 1<<3; |
| 818 | public static final int ANIMATION_CHANGED = 1<<4; |
| 819 | public static final int DIM_AMOUNT_CHANGED = 1<<5; |
| 820 | public static final int TITLE_CHANGED = 1<<6; |
| 821 | public static final int ALPHA_CHANGED = 1<<7; |
| 822 | public static final int MEMORY_TYPE_CHANGED = 1<<8; |
| 823 | public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; |
| 824 | public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; |
| 825 | public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; |
| 826 | |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 827 | // internal buffer to backup/restore parameters under compatibility mode. |
| 828 | private int[] mCompatibilityParamsBackup = null; |
| 829 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 830 | public final int copyFrom(LayoutParams o) { |
| 831 | int changes = 0; |
| 832 | |
| 833 | if (width != o.width) { |
| 834 | width = o.width; |
| 835 | changes |= LAYOUT_CHANGED; |
| 836 | } |
| 837 | if (height != o.height) { |
| 838 | height = o.height; |
| 839 | changes |= LAYOUT_CHANGED; |
| 840 | } |
| 841 | if (x != o.x) { |
| 842 | x = o.x; |
| 843 | changes |= LAYOUT_CHANGED; |
| 844 | } |
| 845 | if (y != o.y) { |
| 846 | y = o.y; |
| 847 | changes |= LAYOUT_CHANGED; |
| 848 | } |
| 849 | if (horizontalWeight != o.horizontalWeight) { |
| 850 | horizontalWeight = o.horizontalWeight; |
| 851 | changes |= LAYOUT_CHANGED; |
| 852 | } |
| 853 | if (verticalWeight != o.verticalWeight) { |
| 854 | verticalWeight = o.verticalWeight; |
| 855 | changes |= LAYOUT_CHANGED; |
| 856 | } |
| 857 | if (horizontalMargin != o.horizontalMargin) { |
| 858 | horizontalMargin = o.horizontalMargin; |
| 859 | changes |= LAYOUT_CHANGED; |
| 860 | } |
| 861 | if (verticalMargin != o.verticalMargin) { |
| 862 | verticalMargin = o.verticalMargin; |
| 863 | changes |= LAYOUT_CHANGED; |
| 864 | } |
| 865 | if (type != o.type) { |
| 866 | type = o.type; |
| 867 | changes |= TYPE_CHANGED; |
| 868 | } |
| 869 | if (memoryType != o.memoryType) { |
| 870 | memoryType = o.memoryType; |
| 871 | changes |= MEMORY_TYPE_CHANGED; |
| 872 | } |
| 873 | if (flags != o.flags) { |
| 874 | flags = o.flags; |
| 875 | changes |= FLAGS_CHANGED; |
| 876 | } |
| 877 | if (softInputMode != o.softInputMode) { |
| 878 | softInputMode = o.softInputMode; |
| 879 | changes |= SOFT_INPUT_MODE_CHANGED; |
| 880 | } |
| 881 | if (gravity != o.gravity) { |
| 882 | gravity = o.gravity; |
| 883 | changes |= LAYOUT_CHANGED; |
| 884 | } |
| 885 | if (horizontalMargin != o.horizontalMargin) { |
| 886 | horizontalMargin = o.horizontalMargin; |
| 887 | changes |= LAYOUT_CHANGED; |
| 888 | } |
| 889 | if (verticalMargin != o.verticalMargin) { |
| 890 | verticalMargin = o.verticalMargin; |
| 891 | changes |= LAYOUT_CHANGED; |
| 892 | } |
| 893 | if (format != o.format) { |
| 894 | format = o.format; |
| 895 | changes |= FORMAT_CHANGED; |
| 896 | } |
| 897 | if (windowAnimations != o.windowAnimations) { |
| 898 | windowAnimations = o.windowAnimations; |
| 899 | changes |= ANIMATION_CHANGED; |
| 900 | } |
| 901 | if (token == null) { |
| 902 | // NOTE: token only copied if the recipient doesn't |
| 903 | // already have one. |
| 904 | token = o.token; |
| 905 | } |
| 906 | if (packageName == null) { |
| 907 | // NOTE: packageName only copied if the recipient doesn't |
| 908 | // already have one. |
| 909 | packageName = o.packageName; |
| 910 | } |
| 911 | if (!mTitle.equals(o.mTitle)) { |
| 912 | mTitle = o.mTitle; |
| 913 | changes |= TITLE_CHANGED; |
| 914 | } |
| 915 | if (alpha != o.alpha) { |
| 916 | alpha = o.alpha; |
| 917 | changes |= ALPHA_CHANGED; |
| 918 | } |
| 919 | if (dimAmount != o.dimAmount) { |
| 920 | dimAmount = o.dimAmount; |
| 921 | changes |= DIM_AMOUNT_CHANGED; |
| 922 | } |
| 923 | if (screenBrightness != o.screenBrightness) { |
| 924 | screenBrightness = o.screenBrightness; |
| 925 | changes |= SCREEN_BRIGHTNESS_CHANGED; |
| 926 | } |
| 927 | |
| 928 | if (screenOrientation != o.screenOrientation) { |
| 929 | screenOrientation = o.screenOrientation; |
| 930 | changes |= SCREEN_ORIENTATION_CHANGED; |
| 931 | } |
| 932 | return changes; |
| 933 | } |
| 934 | |
| 935 | @Override |
| 936 | public String debug(String output) { |
| 937 | output += "Contents of " + this + ":"; |
| 938 | Log.d("Debug", output); |
| 939 | output = super.debug(""); |
| 940 | Log.d("Debug", output); |
| 941 | Log.d("Debug", ""); |
| 942 | Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); |
| 943 | return ""; |
| 944 | } |
| 945 | |
| 946 | @Override |
| 947 | public String toString() { |
| 948 | StringBuilder sb = new StringBuilder(256); |
| 949 | sb.append("WM.LayoutParams{"); |
| 950 | sb.append("("); |
| 951 | sb.append(x); |
| 952 | sb.append(','); |
| 953 | sb.append(y); |
| 954 | sb.append(")("); |
| 955 | sb.append((width==FILL_PARENT?"fill":(width==WRAP_CONTENT?"wrap":width))); |
| 956 | sb.append('x'); |
| 957 | sb.append((height==FILL_PARENT?"fill":(height==WRAP_CONTENT?"wrap":height))); |
| 958 | sb.append(")"); |
| 959 | if (softInputMode != 0) { |
| 960 | sb.append(" sim=#"); |
| 961 | sb.append(Integer.toHexString(softInputMode)); |
| 962 | } |
| 963 | if (gravity != 0) { |
| 964 | sb.append(" gr=#"); |
| 965 | sb.append(Integer.toHexString(gravity)); |
| 966 | } |
| 967 | sb.append(" ty="); |
| 968 | sb.append(type); |
| 969 | sb.append(" fl=#"); |
| 970 | sb.append(Integer.toHexString(flags)); |
| 971 | sb.append(" fmt="); |
| 972 | sb.append(format); |
| 973 | if (windowAnimations != 0) { |
| 974 | sb.append(" wanim=0x"); |
| 975 | sb.append(Integer.toHexString(windowAnimations)); |
| 976 | } |
| 977 | if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { |
| 978 | sb.append(" or="); |
| 979 | sb.append(screenOrientation); |
| 980 | } |
| 981 | sb.append('}'); |
| 982 | return sb.toString(); |
| 983 | } |
Mitsuru Oshima | 8d11267 | 2009-04-27 12:01:23 -0700 | [diff] [blame] | 984 | |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 985 | /** |
| 986 | * Scale the layout params' coordinates and size. |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame^] | 987 | * @hide |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 988 | */ |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame^] | 989 | public void scale(float scale) { |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 990 | x *= scale; |
| 991 | y *= scale; |
| 992 | if (width > 0) { |
| 993 | width *= scale; |
| 994 | } |
| 995 | if (height > 0) { |
| 996 | height *= scale; |
Mitsuru Oshima | 8d11267 | 2009-04-27 12:01:23 -0700 | [diff] [blame] | 997 | } |
| 998 | } |
| 999 | |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1000 | /** |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1001 | * Backup the layout parameters used in compatibility mode. |
| 1002 | * @see LayoutParams#restore() |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1003 | */ |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1004 | void backup() { |
| 1005 | int[] backup = mCompatibilityParamsBackup; |
| 1006 | if (backup == null) { |
Mitsuru Oshima | 64f5934 | 2009-06-21 00:03:11 -0700 | [diff] [blame^] | 1007 | // we backup 4 elements, x, y, width, height |
| 1008 | backup = mCompatibilityParamsBackup = new int[4]; |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1009 | } |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1010 | backup[0] = x; |
| 1011 | backup[1] = y; |
| 1012 | backup[2] = width; |
| 1013 | backup[3] = height; |
Mitsuru Oshima | e5fb328 | 2009-06-09 21:16:08 -0700 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | /** |
| 1017 | * Restore the layout params' coordinates, size and gravity |
| 1018 | * @see LayoutParams#backup() |
| 1019 | */ |
| 1020 | void restore() { |
| 1021 | int[] backup = mCompatibilityParamsBackup; |
| 1022 | if (backup != null) { |
| 1023 | x = backup[0]; |
| 1024 | y = backup[1]; |
| 1025 | width = backup[2]; |
Mitsuru Oshima | 3d91492 | 2009-05-13 22:29:15 -0700 | [diff] [blame] | 1026 | height = backup[3]; |
| 1027 | } |
| 1028 | } |
| 1029 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1030 | private CharSequence mTitle = ""; |
| 1031 | } |
| 1032 | } |