blob: 2534de76337a80518a3535f4094c2cecccf04b6c [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package android.view;
18
19import android.content.pm.ActivityInfo;
20import android.graphics.PixelFormat;
21import android.os.IBinder;
22import android.os.Parcel;
23import android.os.Parcelable;
24import android.text.TextUtils;
25import 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 */
36public 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 */
Joe Onorato8f2bd432010-03-25 11:45:28 -0700145 @ViewDebug.ExportedProperty(mapping = {
146 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"),
147 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"),
148 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"),
149 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"),
150 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"),
151 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"),
152 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"),
153 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"),
154 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"),
155 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"),
156 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"),
157 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"),
158 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"),
159 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"),
160 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"),
161 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"),
162 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"),
163 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"),
164 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"),
165 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"),
166 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG")
167 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800168 public int type;
169
170 /**
171 * Start of window types that represent normal application windows.
172 */
173 public static final int FIRST_APPLICATION_WINDOW = 1;
174
175 /**
176 * Window type: an application window that serves as the "base" window
177 * of the overall application; all other application windows will
178 * appear on top of it.
179 */
180 public static final int TYPE_BASE_APPLICATION = 1;
181
182 /**
183 * Window type: a normal application window. The {@link #token} must be
184 * an Activity token identifying who the window belongs to.
185 */
186 public static final int TYPE_APPLICATION = 2;
187
188 /**
189 * Window type: special application window that is displayed while the
190 * application is starting. Not for use by applications themselves;
191 * this is used by the system to display something until the
192 * application can show its own windows.
193 */
194 public static final int TYPE_APPLICATION_STARTING = 3;
195
196 /**
197 * End of types of application windows.
198 */
199 public static final int LAST_APPLICATION_WINDOW = 99;
200
201 /**
202 * Start of types of sub-windows. The {@link #token} of these windows
203 * must be set to the window they are attached to. These types of
204 * windows are kept next to their attached window in Z-order, and their
205 * coordinate space is relative to their attached window.
206 */
207 public static final int FIRST_SUB_WINDOW = 1000;
208
209 /**
210 * Window type: a panel on top of an application window. These windows
211 * appear on top of their attached window.
212 */
213 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
214
215 /**
216 * Window type: window for showing media (e.g. video). These windows
217 * are displayed behind their attached window.
218 */
219 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1;
220
221 /**
222 * Window type: a sub-panel on top of an application window. These
223 * windows are displayed on top their attached window and any
224 * {@link #TYPE_APPLICATION_PANEL} panels.
225 */
226 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2;
227
228 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
229 * of the window happens as that of a top-level window, <em>not</em>
230 * as a child of its container.
231 */
232 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3;
233
234 /**
Dianne Hackbornc4d5d022009-05-21 17:32:42 -0700235 * Window type: window for showing overlays on top of media windows.
236 * These windows are displayed between TYPE_APPLICATION_MEDIA and the
237 * application window. They should be translucent to be useful. This
238 * is a big ugly hack so:
239 * @hide
240 */
241 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4;
242
243 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800244 * End of types of sub-windows.
245 */
246 public static final int LAST_SUB_WINDOW = 1999;
247
248 /**
249 * Start of system-specific window types. These are not normally
250 * created by applications.
251 */
252 public static final int FIRST_SYSTEM_WINDOW = 2000;
253
254 /**
255 * Window type: the status bar. There can be only one status bar
256 * window; it is placed at the top of the screen, and all other
257 * windows are shifted down so they are below it.
258 */
259 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
260
261 /**
262 * Window type: the search bar. There can be only one search bar
263 * window; it is placed at the top of the screen.
264 */
265 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
266
267 /**
268 * Window type: phone. These are non-application windows providing
269 * user interaction with the phone (in particular incoming calls).
270 * These windows are normally placed above all applications, but behind
271 * the status bar.
272 */
273 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
274
275 /**
276 * Window type: system window, such as low power alert. These windows
277 * are always on top of application windows.
278 */
279 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
280
281 /**
282 * Window type: keyguard window.
283 */
284 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
285
286 /**
287 * Window type: transient notifications.
288 */
289 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
290
291 /**
292 * Window type: system overlay windows, which need to be displayed
293 * on top of everything else. These windows must not take input
294 * focus, or they will interfere with the keyguard.
295 */
296 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
297
298 /**
299 * Window type: priority phone UI, which needs to be displayed even if
300 * the keyguard is active. These windows must not take input
301 * focus, or they will interfere with the keyguard.
302 */
303 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
304
305 /**
306 * Window type: panel that slides out from the status bar
307 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800308 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
309
310 /**
311 * Window type: dialogs that the keyguard shows
312 */
313 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
314
315 /**
316 * Window type: internal system error windows, appear on top of
317 * everything they can.
318 */
319 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
320
321 /**
322 * Window type: internal input methods windows, which appear above
323 * the normal UI. Application windows may be resized or panned to keep
324 * the input focus visible while this window is displayed.
325 */
326 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
327
328 /**
329 * Window type: internal input methods dialog windows, which appear above
330 * the current input method window.
331 */
332 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
333
334 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700335 * Window type: wallpaper window, placed behind any window that wants
336 * to sit on top of the wallpaper.
337 */
338 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
339
340 /**
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800341 * Window type: panel that slides out from the status bar
342 */
343 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
344
345 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800346 * End of types of system windows.
347 */
348 public static final int LAST_SYSTEM_WINDOW = 2999;
349
350 /**
351 * Specifies what type of memory buffers should be used by this window.
352 * Default is normal.
353 *
354 * @see #MEMORY_TYPE_NORMAL
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800355 * @see #MEMORY_TYPE_PUSH_BUFFERS
356 */
357 public int memoryType;
358
359 /** Memory type: The window's surface is allocated in main memory. */
360 public static final int MEMORY_TYPE_NORMAL = 0;
361 /** Memory type: The window's surface is configured to be accessible
Mathias Agopian317a6282009-08-13 17:29:02 -0700362 * by DMA engines and hardware accelerators.
363 * @deprecated this is ignored, this value is set automatically when needed.
364 */
365 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800366 public static final int MEMORY_TYPE_HARDWARE = 1;
367 /** Memory type: The window's surface is configured to be accessible
Mathias Agopian317a6282009-08-13 17:29:02 -0700368 * by graphics accelerators.
369 * @deprecated this is ignored, this value is set automatically when needed.
370 */
371 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800372 public static final int MEMORY_TYPE_GPU = 2;
373 /** Memory type: The window's surface doesn't own its buffers and
374 * therefore cannot be locked. Instead the buffers are pushed to
375 * it through native binder calls. */
376 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
377
378 /**
379 * Various behavioral options/flags. Default is none.
380 *
381 * @see #FLAG_BLUR_BEHIND
382 * @see #FLAG_DIM_BEHIND
383 * @see #FLAG_NOT_FOCUSABLE
384 * @see #FLAG_NOT_TOUCHABLE
385 * @see #FLAG_NOT_TOUCH_MODAL
386 * @see #FLAG_LAYOUT_IN_SCREEN
387 * @see #FLAG_DITHER
388 * @see #FLAG_KEEP_SCREEN_ON
389 * @see #FLAG_FULLSCREEN
390 * @see #FLAG_FORCE_NOT_FULLSCREEN
391 * @see #FLAG_IGNORE_CHEEK_PRESSES
392 */
Joe Onorato8f2bd432010-03-25 11:45:28 -0700393 @ViewDebug.ExportedProperty(flagMapping = {
394 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
395 name = "FLAG_BLUR_BEHIND"),
396 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
397 name = "FLAG_DIM_BEHIND"),
398 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
399 name = "FLAG_NOT_FOCUSABLE"),
400 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
401 name = "FLAG_NOT_TOUCHABLE"),
402 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
403 name = "FLAG_NOT_TOUCH_MODAL"),
404 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
405 name = "FLAG_LAYOUT_IN_SCREEN"),
406 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
407 name = "FLAG_DITHER"),
Daniel Sandler20e92712010-04-02 16:51:58 -0400408 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
409 name = "FLAG_TURN_SCREEN_ON"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700410 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
411 name = "FLAG_KEEP_SCREEN_ON"),
Daniel Sandler20e92712010-04-02 16:51:58 -0400412 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
413 name = "FLAG_SHOW_WHEN_LOCKED"),
414 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
415 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
416 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
417 name = "FLAG_DISMISS_KEYGUARD"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700418 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
419 name = "FLAG_FULLSCREEN"),
420 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN,
421 equals = FLAG_FORCE_NOT_FULLSCREEN, name = "FLAG_FORCE_NOT_FULLSCREEN"),
422 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES,
423 equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES")
424 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800425 public int flags;
426
Mike Lockwoodef731622010-01-27 17:51:34 -0500427 /** Window flag: as long as this window is visible to the user, allow
428 * the lock screen to activate while the screen is on.
429 * This can be used independently, or in combination with
Christopher Tate95f78502010-01-29 15:57:34 -0800430 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
Mike Lockwoodef731622010-01-27 17:51:34 -0500431 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001;
432
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800433 /** Window flag: everything behind this window will be dimmed.
434 * Use {@link #dimAmount} to control the amount of dim. */
435 public static final int FLAG_DIM_BEHIND = 0x00000002;
436
437 /** Window flag: blur everything behind this window. */
438 public static final int FLAG_BLUR_BEHIND = 0x00000004;
439
440 /** Window flag: this window won't ever get key input focus, so the
441 * user can not send key or other button events to it. Those will
442 * instead go to whatever focusable window is behind it. This flag
443 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
444 * is explicitly set.
445 *
446 * <p>Setting this flag also implies that the window will not need to
447 * interact with
448 * a soft input method, so it will be Z-ordered and positioned
449 * independently of any active input method (typically this means it
450 * gets Z-ordered on top of the input method, so it can use the full
451 * screen for its content and cover the input method if needed. You
452 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
453 public static final int FLAG_NOT_FOCUSABLE = 0x00000008;
454
455 /** Window flag: this window can never receive touch events. */
456 public static final int FLAG_NOT_TOUCHABLE = 0x00000010;
457
458 /** Window flag: Even when this window is focusable (its
459 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events
460 * outside of the window to be sent to the windows behind it. Otherwise
461 * it will consume all pointer events itself, regardless of whether they
462 * are inside of the window. */
463 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020;
464
465 /** Window flag: When set, if the device is asleep when the touch
466 * screen is pressed, you will receive this first touch event. Usually
467 * the first touch event is consumed by the system since the user can
468 * not see what they are pressing on.
469 */
470 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
471
472 /** Window flag: as long as this window is visible to the user, keep
473 * the device's screen turned on and bright. */
474 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080;
475
476 /** Window flag: place the window within the entire screen, ignoring
477 * decorations around the border (a.k.a. the status bar). The
478 * window must correctly position its contents to take the screen
479 * decoration into account. This flag is normally set for you
480 * by Window as described in {@link Window#setFlags}. */
481 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100;
482
483 /** Window flag: allow window to extend outside of the screen. */
484 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200;
485
486 /** Window flag: Hide all screen decorations (e.g. status bar) while
487 * this window is displayed. This allows the window to use the entire
488 * display space for itself -- the status bar will be hidden when
489 * an app window with this flag set is on the top layer. */
490 public static final int FLAG_FULLSCREEN = 0x00000400;
491
492 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the
493 * screen decorations (such as status bar) to be shown. */
494 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800;
495
496 /** Window flag: turn on dithering when compositing this window to
497 * the screen. */
498 public static final int FLAG_DITHER = 0x00001000;
499
500 /** Window flag: don't allow screen shots while this window is
501 * displayed. */
502 public static final int FLAG_SECURE = 0x00002000;
503
504 /** Window flag: a special mode where the layout parameters are used
505 * to perform scaling of the surface when it is composited to the
506 * screen. */
507 public static final int FLAG_SCALED = 0x00004000;
508
509 /** Window flag: intended for windows that will often be used when the user is
510 * holding the screen against their face, it will aggressively filter the event
511 * stream to prevent unintended presses in this situation that may not be
512 * desired for a particular window, when such an event stream is detected, the
513 * application will receive a CANCEL motion event to indicate this so applications
514 * can handle this accordingly by taking no action on the event
515 * until the finger is released. */
516 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000;
517
518 /** Window flag: a special option only for use in combination with
519 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the
520 * screen your window may appear on top of or behind screen decorations
521 * such as the status bar. By also including this flag, the window
522 * manager will report the inset rectangle needed to ensure your
523 * content is not covered by screen decorations. This flag is normally
524 * set for you by Window as described in {@link Window#setFlags}.*/
525 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
526
527 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
528 * respect to how this window interacts with the current method. That
529 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
530 * window will behave as if it needs to interact with the input method
531 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
532 * not set and this flag is set, then the window will behave as if it
533 * doesn't need to interact with the input method and can be placed
534 * to use more space and cover the input method.
535 */
536 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
537
538 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
539 * can set this flag to receive a single special MotionEvent with
540 * the action
541 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
542 * touches that occur outside of your window. Note that you will not
543 * receive the full down/move/up gesture, only the location of the
544 * first down as an ACTION_OUTSIDE.
545 */
546 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
547
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700548 /** Window flag: special flag to let windows be shown when the screen
549 * is locked. This will let application windows take precedence over
550 * key guard or any other lock screens. Can be used with
551 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700552 * directly before showing the key guard window. Can be used with
553 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
554 * non-secure keyguards. This flag only applies to the top-most
555 * full-screen window.
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700556 */
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700557 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
558
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700559 /** Window flag: ask that the system wallpaper be shown behind
560 * your window. The window surface must be translucent to be able
561 * to actually see the wallpaper behind it; this flag just ensures
562 * that the wallpaper surface will be there if this window actually
563 * has translucent regions.
564 */
565 public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
566
Dianne Hackborn93e462b2009-09-15 22:50:40 -0700567 /** Window flag: when set as a window is being added or made
568 * visible, once the window has been shown then the system will
569 * poke the power manager's user activity (as if the user had woken
570 * up the device) to turn the screen on. */
571 public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
572
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700573 /** Window flag: when set the window will cause the keyguard to
574 * be dismissed, only if it is not a secure lock keyguard. Because such
575 * a keyguard is not needed for security, it will never re-appear if
576 * the user navigates to another window (in contrast to
577 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
578 * hide both secure and non-secure keyguards but ensure they reappear
579 * when the user moves to another UI that doesn't hide them).
580 * If the keyguard is currently active and is secure (requires an
581 * unlock pattern) than the user will still need to confirm it before
582 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has
583 * also been set. */
584 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
Daniel Sandler611fae42010-06-17 10:45:00 -0400585
586 /** Window flag: This window corresponds to an immersive activity
587 * that wishes not to be interrupted with notifications. In general,
588 * applications may simply hide the status bar with {@link
589 * FLAG_FULLSCREEN} to suppress most notifications, but will still be
590 * interrupted by those with
591 * {@link android.app.Notification.fullScreenIntent} set (example: an
592 * incoming call). Setting {@link FLAG_IMMERSIVE} will suppress the
593 * full-screen intent and show the status bar briefly for those
594 * important notifications instead. See also
595 * {@link android.app.Notification.FLAG_HIGH_PRIORITY}.
596 */
597 public static final int FLAG_IMMERSIVE = 0x00800000;
598
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700599 /** Window flag: *sigh* The lock screen wants to continue running its
600 * animation while it is fading. A kind-of hack to allow this. Maybe
601 * in the future we just make this the default behavior.
602 *
603 * {@hide} */
604 public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000;
605
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700606 /** Window flag: special flag to limit the size of the window to be
607 * original size ([320x480] x density). Used to create window for applications
608 * running under compatibility mode.
609 *
610 * {@hide} */
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700611 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000;
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700612
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800613 /** Window flag: a special option intended for system dialogs. When
614 * this flag is set, the window will demand focus unconditionally when
615 * it is created.
616 * {@hide} */
617 public static final int FLAG_SYSTEM_ERROR = 0x40000000;
618
619 /**
620 * Given a particular set of window manager flags, determine whether
621 * such a window may be a target for an input method when it has
622 * focus. In particular, this checks the
623 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
624 * flags and returns true if the combination of the two corresponds
625 * to a window that needs to be behind the input method so that the
626 * user can type into it.
627 *
628 * @param flags The current window manager flags.
629 *
630 * @return Returns true if such a window should be behind/interact
631 * with an input method, false if not.
632 */
633 public static boolean mayUseInputMethod(int flags) {
634 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
635 case 0:
636 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
637 return true;
638 }
639 return false;
640 }
641
642 /**
643 * Mask for {@link #softInputMode} of the bits that determine the
644 * desired visibility state of the soft input area for this window.
645 */
646 public static final int SOFT_INPUT_MASK_STATE = 0x0f;
647
648 /**
649 * Visibility state for {@link #softInputMode}: no state has been specified.
650 */
651 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
652
653 /**
654 * Visibility state for {@link #softInputMode}: please don't change the state of
655 * the soft input area.
656 */
657 public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
658
659 /**
660 * Visibility state for {@link #softInputMode}: please hide any soft input
661 * area when normally appropriate (when the user is navigating
662 * forward to your window).
663 */
664 public static final int SOFT_INPUT_STATE_HIDDEN = 2;
665
666 /**
667 * Visibility state for {@link #softInputMode}: please always hide any
668 * soft input area when this window receives focus.
669 */
670 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
671
672 /**
673 * Visibility state for {@link #softInputMode}: please show the soft
674 * input area when normally appropriate (when the user is navigating
675 * forward to your window).
676 */
677 public static final int SOFT_INPUT_STATE_VISIBLE = 4;
678
679 /**
680 * Visibility state for {@link #softInputMode}: please always make the
681 * soft input area visible when this window receives input focus.
682 */
683 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
684
685 /**
686 * Mask for {@link #softInputMode} of the bits that determine the
687 * way that the window should be adjusted to accommodate the soft
688 * input window.
689 */
690 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
691
692 /** Adjustment option for {@link #softInputMode}: nothing specified.
693 * The system will try to pick one or
694 * the other depending on the contents of the window.
695 */
696 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
697
698 /** Adjustment option for {@link #softInputMode}: set to allow the
699 * window to be resized when an input
700 * method is shown, so that its contents are not covered by the input
Scott Mainf10e6332010-06-11 09:03:22 -0700701 * method. This can <em>not</em> be combined with
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800702 * {@link #SOFT_INPUT_ADJUST_PAN}; if
703 * neither of these are set, then the system will try to pick one or
704 * the other depending on the contents of the window.
705 */
706 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
707
708 /** Adjustment option for {@link #softInputMode}: set to have a window
709 * pan when an input method is
710 * shown, so it doesn't need to deal with resizing but just panned
711 * by the framework to ensure the current input focus is visible. This
Scott Mainf10e6332010-06-11 09:03:22 -0700712 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800713 * neither of these are set, then the system will try to pick one or
714 * the other depending on the contents of the window.
715 */
716 public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
717
718 /**
719 * Bit for {@link #softInputMode}: set when the user has navigated
720 * forward to the window. This is normally set automatically for
721 * you by the system, though you may want to set it in certain cases
722 * when you are displaying a window yourself. This flag will always
723 * be cleared automatically after the window is displayed.
724 */
725 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500726
727 /**
728 * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
729 * indicating that the brightness value is not overridden for this window
730 * and normal brightness policy should be used.
731 */
732 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
733
734 /**
735 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
736 * indicating that the screen or button backlight brightness should be set
737 * to the lowest value when this window is in front.
738 */
739 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
740
741 /**
742 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
743 * indicating that the screen or button backlight brightness should be set
744 * to the hightest value when this window is in front.
745 */
746 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
747
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800748 /**
749 * Desired operating mode for any soft input area. May any combination
750 * of:
751 *
752 * <ul>
753 * <li> One of the visibility states
754 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
755 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
756 * {@link #SOFT_INPUT_STATE_VISIBLE}.
757 * <li> One of the adjustment options
758 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
759 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or
760 * {@link #SOFT_INPUT_ADJUST_PAN}.
761 */
762 public int softInputMode;
763
764 /**
765 * Placement of window within the screen as per {@link Gravity}
766 *
767 * @see Gravity
768 */
769 public int gravity;
770
771 /**
772 * The horizontal margin, as a percentage of the container's width,
773 * between the container and the widget.
774 */
775 public float horizontalMargin;
776
777 /**
778 * The vertical margin, as a percentage of the container's height,
779 * between the container and the widget.
780 */
781 public float verticalMargin;
782
783 /**
784 * The desired bitmap format. May be one of the constants in
785 * {@link android.graphics.PixelFormat}. Default is OPAQUE.
786 */
787 public int format;
788
789 /**
790 * A style resource defining the animations to use for this window.
791 * This must be a system resource; it can not be an application resource
792 * because the window manager does not have access to applications.
793 */
794 public int windowAnimations;
795
796 /**
797 * An alpha value to apply to this entire window.
798 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
799 */
800 public float alpha = 1.0f;
801
802 /**
803 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
804 * to apply. Range is from 1.0 for completely opaque to 0.0 for no
805 * dim.
806 */
807 public float dimAmount = 1.0f;
808
809 /**
810 * This can be used to override the user's preferred brightness of
811 * the screen. A value of less than 0, the default, means to use the
812 * preferred screen brightness. 0 to 1 adjusts the brightness from
813 * dark to full bright.
814 */
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500815 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800816
817 /**
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500818 * This can be used to override the standard behavior of the button and
819 * keyboard backlights. A value of less than 0, the default, means to
820 * use the standard backlight behavior. 0 to 1 adjusts the brightness
821 * from dark to full bright.
822 */
823 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
824
825 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800826 * Identifier for this window. This will usually be filled in for
827 * you.
828 */
829 public IBinder token = null;
830
831 /**
832 * Name of the package owning this window.
833 */
834 public String packageName = null;
835
836 /**
837 * Specific orientation value for a window.
838 * May be any of the same values allowed
839 * for {@link android.content.pm.ActivityInfo#screenOrientation}.
840 * If not set, a default value of
841 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
842 * will be used.
843 */
844 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
845
846
847 public LayoutParams() {
Romain Guy980a9382010-01-08 15:06:28 -0800848 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800849 type = TYPE_APPLICATION;
850 format = PixelFormat.OPAQUE;
851 }
852
853 public LayoutParams(int _type) {
Romain Guy980a9382010-01-08 15:06:28 -0800854 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800855 type = _type;
856 format = PixelFormat.OPAQUE;
857 }
858
859 public LayoutParams(int _type, int _flags) {
Romain Guy980a9382010-01-08 15:06:28 -0800860 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800861 type = _type;
862 flags = _flags;
863 format = PixelFormat.OPAQUE;
864 }
865
866 public LayoutParams(int _type, int _flags, int _format) {
Romain Guy980a9382010-01-08 15:06:28 -0800867 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800868 type = _type;
869 flags = _flags;
870 format = _format;
871 }
872
873 public LayoutParams(int w, int h, int _type, int _flags, int _format) {
874 super(w, h);
875 type = _type;
876 flags = _flags;
877 format = _format;
878 }
879
880 public LayoutParams(int w, int h, int xpos, int ypos, int _type,
881 int _flags, int _format) {
882 super(w, h);
883 x = xpos;
884 y = ypos;
885 type = _type;
886 flags = _flags;
887 format = _format;
888 }
889
890 public final void setTitle(CharSequence title) {
891 if (null == title)
892 title = "";
893
894 mTitle = TextUtils.stringOrSpannedString(title);
895 }
896
897 public final CharSequence getTitle() {
898 return mTitle;
899 }
900
901 public int describeContents() {
902 return 0;
903 }
904
905 public void writeToParcel(Parcel out, int parcelableFlags) {
906 out.writeInt(width);
907 out.writeInt(height);
908 out.writeInt(x);
909 out.writeInt(y);
910 out.writeInt(type);
911 out.writeInt(memoryType);
912 out.writeInt(flags);
913 out.writeInt(softInputMode);
914 out.writeInt(gravity);
915 out.writeFloat(horizontalMargin);
916 out.writeFloat(verticalMargin);
917 out.writeInt(format);
918 out.writeInt(windowAnimations);
919 out.writeFloat(alpha);
920 out.writeFloat(dimAmount);
921 out.writeFloat(screenBrightness);
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500922 out.writeFloat(buttonBrightness);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800923 out.writeStrongBinder(token);
924 out.writeString(packageName);
925 TextUtils.writeToParcel(mTitle, out, parcelableFlags);
926 out.writeInt(screenOrientation);
927 }
928
929 public static final Parcelable.Creator<LayoutParams> CREATOR
930 = new Parcelable.Creator<LayoutParams>() {
931 public LayoutParams createFromParcel(Parcel in) {
932 return new LayoutParams(in);
933 }
934
935 public LayoutParams[] newArray(int size) {
936 return new LayoutParams[size];
937 }
938 };
939
940
941 public LayoutParams(Parcel in) {
942 width = in.readInt();
943 height = in.readInt();
944 x = in.readInt();
945 y = in.readInt();
946 type = in.readInt();
947 memoryType = in.readInt();
948 flags = in.readInt();
949 softInputMode = in.readInt();
950 gravity = in.readInt();
951 horizontalMargin = in.readFloat();
952 verticalMargin = in.readFloat();
953 format = in.readInt();
954 windowAnimations = in.readInt();
955 alpha = in.readFloat();
956 dimAmount = in.readFloat();
957 screenBrightness = in.readFloat();
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500958 buttonBrightness = in.readFloat();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800959 token = in.readStrongBinder();
960 packageName = in.readString();
961 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
962 screenOrientation = in.readInt();
963 }
964
Romain Guy72998072009-06-22 11:09:20 -0700965 @SuppressWarnings({"PointlessBitwiseExpression"})
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800966 public static final int LAYOUT_CHANGED = 1<<0;
967 public static final int TYPE_CHANGED = 1<<1;
968 public static final int FLAGS_CHANGED = 1<<2;
969 public static final int FORMAT_CHANGED = 1<<3;
970 public static final int ANIMATION_CHANGED = 1<<4;
971 public static final int DIM_AMOUNT_CHANGED = 1<<5;
972 public static final int TITLE_CHANGED = 1<<6;
973 public static final int ALPHA_CHANGED = 1<<7;
974 public static final int MEMORY_TYPE_CHANGED = 1<<8;
975 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
976 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
977 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500978 /** {@hide} */
979 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800980
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700981 // internal buffer to backup/restore parameters under compatibility mode.
982 private int[] mCompatibilityParamsBackup = null;
983
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800984 public final int copyFrom(LayoutParams o) {
985 int changes = 0;
986
987 if (width != o.width) {
988 width = o.width;
989 changes |= LAYOUT_CHANGED;
990 }
991 if (height != o.height) {
992 height = o.height;
993 changes |= LAYOUT_CHANGED;
994 }
995 if (x != o.x) {
996 x = o.x;
997 changes |= LAYOUT_CHANGED;
998 }
999 if (y != o.y) {
1000 y = o.y;
1001 changes |= LAYOUT_CHANGED;
1002 }
1003 if (horizontalWeight != o.horizontalWeight) {
1004 horizontalWeight = o.horizontalWeight;
1005 changes |= LAYOUT_CHANGED;
1006 }
1007 if (verticalWeight != o.verticalWeight) {
1008 verticalWeight = o.verticalWeight;
1009 changes |= LAYOUT_CHANGED;
1010 }
1011 if (horizontalMargin != o.horizontalMargin) {
1012 horizontalMargin = o.horizontalMargin;
1013 changes |= LAYOUT_CHANGED;
1014 }
1015 if (verticalMargin != o.verticalMargin) {
1016 verticalMargin = o.verticalMargin;
1017 changes |= LAYOUT_CHANGED;
1018 }
1019 if (type != o.type) {
1020 type = o.type;
1021 changes |= TYPE_CHANGED;
1022 }
1023 if (memoryType != o.memoryType) {
1024 memoryType = o.memoryType;
1025 changes |= MEMORY_TYPE_CHANGED;
1026 }
1027 if (flags != o.flags) {
1028 flags = o.flags;
1029 changes |= FLAGS_CHANGED;
1030 }
1031 if (softInputMode != o.softInputMode) {
1032 softInputMode = o.softInputMode;
1033 changes |= SOFT_INPUT_MODE_CHANGED;
1034 }
1035 if (gravity != o.gravity) {
1036 gravity = o.gravity;
1037 changes |= LAYOUT_CHANGED;
1038 }
1039 if (horizontalMargin != o.horizontalMargin) {
1040 horizontalMargin = o.horizontalMargin;
1041 changes |= LAYOUT_CHANGED;
1042 }
1043 if (verticalMargin != o.verticalMargin) {
1044 verticalMargin = o.verticalMargin;
1045 changes |= LAYOUT_CHANGED;
1046 }
1047 if (format != o.format) {
1048 format = o.format;
1049 changes |= FORMAT_CHANGED;
1050 }
1051 if (windowAnimations != o.windowAnimations) {
1052 windowAnimations = o.windowAnimations;
1053 changes |= ANIMATION_CHANGED;
1054 }
1055 if (token == null) {
1056 // NOTE: token only copied if the recipient doesn't
1057 // already have one.
1058 token = o.token;
1059 }
1060 if (packageName == null) {
1061 // NOTE: packageName only copied if the recipient doesn't
1062 // already have one.
1063 packageName = o.packageName;
1064 }
1065 if (!mTitle.equals(o.mTitle)) {
1066 mTitle = o.mTitle;
1067 changes |= TITLE_CHANGED;
1068 }
1069 if (alpha != o.alpha) {
1070 alpha = o.alpha;
1071 changes |= ALPHA_CHANGED;
1072 }
1073 if (dimAmount != o.dimAmount) {
1074 dimAmount = o.dimAmount;
1075 changes |= DIM_AMOUNT_CHANGED;
1076 }
1077 if (screenBrightness != o.screenBrightness) {
1078 screenBrightness = o.screenBrightness;
1079 changes |= SCREEN_BRIGHTNESS_CHANGED;
1080 }
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001081 if (buttonBrightness != o.buttonBrightness) {
1082 buttonBrightness = o.buttonBrightness;
1083 changes |= BUTTON_BRIGHTNESS_CHANGED;
1084 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001085
1086 if (screenOrientation != o.screenOrientation) {
1087 screenOrientation = o.screenOrientation;
1088 changes |= SCREEN_ORIENTATION_CHANGED;
1089 }
1090 return changes;
1091 }
1092
1093 @Override
1094 public String debug(String output) {
1095 output += "Contents of " + this + ":";
1096 Log.d("Debug", output);
1097 output = super.debug("");
1098 Log.d("Debug", output);
1099 Log.d("Debug", "");
1100 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
1101 return "";
1102 }
1103
1104 @Override
1105 public String toString() {
1106 StringBuilder sb = new StringBuilder(256);
1107 sb.append("WM.LayoutParams{");
1108 sb.append("(");
1109 sb.append(x);
1110 sb.append(',');
1111 sb.append(y);
1112 sb.append(")(");
Romain Guy980a9382010-01-08 15:06:28 -08001113 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001114 sb.append('x');
Romain Guy980a9382010-01-08 15:06:28 -08001115 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001116 sb.append(")");
1117 if (softInputMode != 0) {
1118 sb.append(" sim=#");
1119 sb.append(Integer.toHexString(softInputMode));
1120 }
1121 if (gravity != 0) {
1122 sb.append(" gr=#");
1123 sb.append(Integer.toHexString(gravity));
1124 }
1125 sb.append(" ty=");
1126 sb.append(type);
1127 sb.append(" fl=#");
1128 sb.append(Integer.toHexString(flags));
1129 sb.append(" fmt=");
1130 sb.append(format);
1131 if (windowAnimations != 0) {
1132 sb.append(" wanim=0x");
1133 sb.append(Integer.toHexString(windowAnimations));
1134 }
1135 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
1136 sb.append(" or=");
1137 sb.append(screenOrientation);
1138 }
Mitsuru Oshima5a2b91d2009-07-16 16:30:02 -07001139 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) {
1140 sb.append(" compatible=true");
1141 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001142 sb.append('}');
1143 return sb.toString();
1144 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001145
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001146 /**
1147 * Scale the layout params' coordinates and size.
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001148 * @hide
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001149 */
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001150 public void scale(float scale) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001151 x = (int) (x * scale + 0.5f);
1152 y = (int) (y * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001153 if (width > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001154 width = (int) (width * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001155 }
1156 if (height > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001157 height = (int) (height * scale + 0.5f);
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001158 }
1159 }
1160
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001161 /**
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001162 * Backup the layout parameters used in compatibility mode.
1163 * @see LayoutParams#restore()
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001164 */
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001165 void backup() {
1166 int[] backup = mCompatibilityParamsBackup;
1167 if (backup == null) {
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001168 // we backup 4 elements, x, y, width, height
1169 backup = mCompatibilityParamsBackup = new int[4];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001170 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001171 backup[0] = x;
1172 backup[1] = y;
1173 backup[2] = width;
1174 backup[3] = height;
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001175 }
1176
1177 /**
1178 * Restore the layout params' coordinates, size and gravity
1179 * @see LayoutParams#backup()
1180 */
1181 void restore() {
1182 int[] backup = mCompatibilityParamsBackup;
1183 if (backup != null) {
1184 x = backup[0];
1185 y = backup[1];
1186 width = backup[2];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001187 height = backup[3];
1188 }
1189 }
1190
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001191 private CharSequence mTitle = "";
1192 }
1193}