blob: e5f4b087e6fe87e73c900bcfa63bed758d63637e [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 */
Romain Guy529b60a2010-08-03 18:05:47 -070075 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 public int x;
77
78 /**
79 * Y position for this window. With the default gravity it is ignored.
80 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
81 * an offset from the given edge.
82 */
Romain Guy529b60a2010-08-03 18:05:47 -070083 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080084 public int y;
85
86 /**
87 * Indicates how much of the extra space will be allocated horizontally
88 * to the view associated with these LayoutParams. Specify 0 if the view
89 * should not be stretched. Otherwise the extra pixels will be pro-rated
90 * among all views whose weight is greater than 0.
91 */
Romain Guy529b60a2010-08-03 18:05:47 -070092 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093 public float horizontalWeight;
94
95 /**
96 * Indicates how much of the extra space will be allocated vertically
97 * to the view associated with these LayoutParams. Specify 0 if the view
98 * should not be stretched. Otherwise the extra pixels will be pro-rated
99 * among all views whose weight is greater than 0.
100 */
Romain Guy529b60a2010-08-03 18:05:47 -0700101 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102 public float verticalWeight;
Romain Guy529b60a2010-08-03 18:05:47 -0700103
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104 /**
105 * The general type of window. There are three main classes of
106 * window types:
107 * <ul>
108 * <li> <strong>Application windows</strong> (ranging from
109 * {@link #FIRST_APPLICATION_WINDOW} to
110 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
111 * windows. For these types of windows, the {@link #token} must be
112 * set to the token of the activity they are a part of (this will
113 * normally be done for you if {@link #token} is null).
114 * <li> <strong>Sub-windows</strong> (ranging from
115 * {@link #FIRST_SUB_WINDOW} to
116 * {@link #LAST_SUB_WINDOW}) are associated with another top-level
117 * window. For these types of windows, the {@link #token} must be
118 * the token of the window it is attached to.
119 * <li> <strong>System windows</strong> (ranging from
120 * {@link #FIRST_SYSTEM_WINDOW} to
121 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
122 * use by the system for specific purposes. They should not normally
123 * be used by applications, and a special permission is required
124 * to use them.
125 * </ul>
126 *
127 * @see #TYPE_BASE_APPLICATION
128 * @see #TYPE_APPLICATION
129 * @see #TYPE_APPLICATION_STARTING
130 * @see #TYPE_APPLICATION_PANEL
131 * @see #TYPE_APPLICATION_MEDIA
132 * @see #TYPE_APPLICATION_SUB_PANEL
133 * @see #TYPE_APPLICATION_ATTACHED_DIALOG
134 * @see #TYPE_STATUS_BAR
135 * @see #TYPE_SEARCH_BAR
136 * @see #TYPE_PHONE
137 * @see #TYPE_SYSTEM_ALERT
138 * @see #TYPE_KEYGUARD
139 * @see #TYPE_TOAST
140 * @see #TYPE_SYSTEM_OVERLAY
141 * @see #TYPE_PRIORITY_PHONE
142 * @see #TYPE_STATUS_BAR_PANEL
143 * @see #TYPE_SYSTEM_DIALOG
144 * @see #TYPE_KEYGUARD_DIALOG
145 * @see #TYPE_SYSTEM_ERROR
146 * @see #TYPE_INPUT_METHOD
147 * @see #TYPE_INPUT_METHOD_DIALOG
148 */
Joe Onorato8f2bd432010-03-25 11:45:28 -0700149 @ViewDebug.ExportedProperty(mapping = {
150 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"),
151 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"),
152 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"),
153 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"),
154 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"),
155 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"),
156 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"),
157 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"),
158 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"),
159 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"),
160 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"),
161 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"),
162 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"),
163 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"),
164 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"),
165 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"),
166 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"),
167 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"),
168 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"),
169 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"),
Jeff Brown3b2b3542010-10-15 00:54:27 -0700170 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"),
171 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY")
Joe Onorato8f2bd432010-03-25 11:45:28 -0700172 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800173 public int type;
174
175 /**
176 * Start of window types that represent normal application windows.
177 */
178 public static final int FIRST_APPLICATION_WINDOW = 1;
179
180 /**
181 * Window type: an application window that serves as the "base" window
182 * of the overall application; all other application windows will
183 * appear on top of it.
184 */
185 public static final int TYPE_BASE_APPLICATION = 1;
186
187 /**
188 * Window type: a normal application window. The {@link #token} must be
189 * an Activity token identifying who the window belongs to.
190 */
191 public static final int TYPE_APPLICATION = 2;
192
193 /**
194 * Window type: special application window that is displayed while the
195 * application is starting. Not for use by applications themselves;
196 * this is used by the system to display something until the
197 * application can show its own windows.
198 */
199 public static final int TYPE_APPLICATION_STARTING = 3;
200
201 /**
202 * End of types of application windows.
203 */
204 public static final int LAST_APPLICATION_WINDOW = 99;
205
206 /**
207 * Start of types of sub-windows. The {@link #token} of these windows
208 * must be set to the window they are attached to. These types of
209 * windows are kept next to their attached window in Z-order, and their
210 * coordinate space is relative to their attached window.
211 */
212 public static final int FIRST_SUB_WINDOW = 1000;
213
214 /**
215 * Window type: a panel on top of an application window. These windows
216 * appear on top of their attached window.
217 */
218 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
219
220 /**
221 * Window type: window for showing media (e.g. video). These windows
222 * are displayed behind their attached window.
223 */
224 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1;
225
226 /**
227 * Window type: a sub-panel on top of an application window. These
228 * windows are displayed on top their attached window and any
229 * {@link #TYPE_APPLICATION_PANEL} panels.
230 */
231 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2;
232
233 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
234 * of the window happens as that of a top-level window, <em>not</em>
235 * as a child of its container.
236 */
237 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3;
238
239 /**
Dianne Hackbornc4d5d022009-05-21 17:32:42 -0700240 * Window type: window for showing overlays on top of media windows.
241 * These windows are displayed between TYPE_APPLICATION_MEDIA and the
242 * application window. They should be translucent to be useful. This
243 * is a big ugly hack so:
244 * @hide
245 */
246 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4;
247
248 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249 * End of types of sub-windows.
250 */
251 public static final int LAST_SUB_WINDOW = 1999;
252
253 /**
254 * Start of system-specific window types. These are not normally
255 * created by applications.
256 */
257 public static final int FIRST_SYSTEM_WINDOW = 2000;
258
259 /**
260 * Window type: the status bar. There can be only one status bar
261 * window; it is placed at the top of the screen, and all other
262 * windows are shifted down so they are below it.
263 */
264 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
265
266 /**
267 * Window type: the search bar. There can be only one search bar
268 * window; it is placed at the top of the screen.
269 */
270 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
271
272 /**
273 * Window type: phone. These are non-application windows providing
274 * user interaction with the phone (in particular incoming calls).
275 * These windows are normally placed above all applications, but behind
276 * the status bar.
277 */
278 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
279
280 /**
281 * Window type: system window, such as low power alert. These windows
282 * are always on top of application windows.
283 */
284 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
285
286 /**
287 * Window type: keyguard window.
288 */
289 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
290
291 /**
292 * Window type: transient notifications.
293 */
294 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
295
296 /**
297 * Window type: system overlay windows, which need to be displayed
298 * on top of everything else. These windows must not take input
299 * focus, or they will interfere with the keyguard.
300 */
301 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
302
303 /**
304 * Window type: priority phone UI, which needs to be displayed even if
305 * the keyguard is active. These windows must not take input
306 * focus, or they will interfere with the keyguard.
307 */
308 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
309
310 /**
311 * Window type: panel that slides out from the status bar
312 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800313 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
314
315 /**
316 * Window type: dialogs that the keyguard shows
317 */
318 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
319
320 /**
321 * Window type: internal system error windows, appear on top of
322 * everything they can.
323 */
324 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
325
326 /**
327 * Window type: internal input methods windows, which appear above
328 * the normal UI. Application windows may be resized or panned to keep
329 * the input focus visible while this window is displayed.
330 */
331 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
332
333 /**
334 * Window type: internal input methods dialog windows, which appear above
335 * the current input method window.
336 */
337 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
338
339 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700340 * Window type: wallpaper window, placed behind any window that wants
341 * to sit on top of the wallpaper.
342 */
343 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
344
345 /**
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800346 * Window type: panel that slides out from the status bar
347 */
348 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
Jeff Brown3b2b3542010-10-15 00:54:27 -0700349
350 /**
351 * Window type: secure system overlay windows, which need to be displayed
352 * on top of everything else. These windows must not take input
353 * focus, or they will interfere with the keyguard.
354 *
355 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
356 * system itself is allowed to create these overlays. Applications cannot
357 * obtain permission to create secure system overlays.
358 * @hide
359 */
360 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
361
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800362 /**
Christopher Tatea53146c2010-09-07 11:57:52 -0700363 * Window type: the drag-and-drop pseudowindow. There is only one
364 * drag layer (at most), and it is placed on top of all other windows.
365 * @hide
366 */
Jeff Brown3b2b3542010-10-15 00:54:27 -0700367 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16;
Christopher Tatea53146c2010-09-07 11:57:52 -0700368
369 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800370 * End of types of system windows.
371 */
372 public static final int LAST_SYSTEM_WINDOW = 2999;
373
374 /**
375 * Specifies what type of memory buffers should be used by this window.
376 * Default is normal.
377 *
378 * @see #MEMORY_TYPE_NORMAL
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800379 * @see #MEMORY_TYPE_PUSH_BUFFERS
380 */
381 public int memoryType;
382
383 /** Memory type: The window's surface is allocated in main memory. */
384 public static final int MEMORY_TYPE_NORMAL = 0;
385 /** Memory type: The window's surface is configured to be accessible
Mathias Agopian317a6282009-08-13 17:29:02 -0700386 * by DMA engines and hardware accelerators.
387 * @deprecated this is ignored, this value is set automatically when needed.
388 */
389 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800390 public static final int MEMORY_TYPE_HARDWARE = 1;
391 /** Memory type: The window's surface is configured to be accessible
Mathias Agopian317a6282009-08-13 17:29:02 -0700392 * by graphics accelerators.
393 * @deprecated this is ignored, this value is set automatically when needed.
394 */
395 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800396 public static final int MEMORY_TYPE_GPU = 2;
397 /** Memory type: The window's surface doesn't own its buffers and
398 * therefore cannot be locked. Instead the buffers are pushed to
399 * it through native binder calls. */
400 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
401
402 /**
403 * Various behavioral options/flags. Default is none.
404 *
405 * @see #FLAG_BLUR_BEHIND
406 * @see #FLAG_DIM_BEHIND
407 * @see #FLAG_NOT_FOCUSABLE
408 * @see #FLAG_NOT_TOUCHABLE
409 * @see #FLAG_NOT_TOUCH_MODAL
410 * @see #FLAG_LAYOUT_IN_SCREEN
411 * @see #FLAG_DITHER
412 * @see #FLAG_KEEP_SCREEN_ON
413 * @see #FLAG_FULLSCREEN
414 * @see #FLAG_FORCE_NOT_FULLSCREEN
415 * @see #FLAG_IGNORE_CHEEK_PRESSES
Romain Guy529b60a2010-08-03 18:05:47 -0700416 * @see #FLAG_HARDWARE_ACCELERATED
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800417 */
Joe Onorato8f2bd432010-03-25 11:45:28 -0700418 @ViewDebug.ExportedProperty(flagMapping = {
419 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
420 name = "FLAG_BLUR_BEHIND"),
421 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
422 name = "FLAG_DIM_BEHIND"),
423 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
424 name = "FLAG_NOT_FOCUSABLE"),
425 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
426 name = "FLAG_NOT_TOUCHABLE"),
427 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
428 name = "FLAG_NOT_TOUCH_MODAL"),
429 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
430 name = "FLAG_LAYOUT_IN_SCREEN"),
431 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
432 name = "FLAG_DITHER"),
Daniel Sandler20e92712010-04-02 16:51:58 -0400433 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
434 name = "FLAG_TURN_SCREEN_ON"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700435 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
436 name = "FLAG_KEEP_SCREEN_ON"),
Daniel Sandler20e92712010-04-02 16:51:58 -0400437 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
438 name = "FLAG_SHOW_WHEN_LOCKED"),
439 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
440 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
441 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
442 name = "FLAG_DISMISS_KEYGUARD"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700443 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
444 name = "FLAG_FULLSCREEN"),
445 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN,
446 equals = FLAG_FORCE_NOT_FULLSCREEN, name = "FLAG_FORCE_NOT_FULLSCREEN"),
447 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES,
Romain Guy529b60a2010-08-03 18:05:47 -0700448 equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES"),
449 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED,
450 equals = FLAG_HARDWARE_ACCELERATED, name = "FLAG_HARDWARE_ACCELERATED")
Joe Onorato8f2bd432010-03-25 11:45:28 -0700451 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800452 public int flags;
453
Mike Lockwoodef731622010-01-27 17:51:34 -0500454 /** Window flag: as long as this window is visible to the user, allow
455 * the lock screen to activate while the screen is on.
456 * This can be used independently, or in combination with
Christopher Tate95f78502010-01-29 15:57:34 -0800457 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
Mike Lockwoodef731622010-01-27 17:51:34 -0500458 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001;
459
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800460 /** Window flag: everything behind this window will be dimmed.
461 * Use {@link #dimAmount} to control the amount of dim. */
462 public static final int FLAG_DIM_BEHIND = 0x00000002;
463
464 /** Window flag: blur everything behind this window. */
465 public static final int FLAG_BLUR_BEHIND = 0x00000004;
466
467 /** Window flag: this window won't ever get key input focus, so the
468 * user can not send key or other button events to it. Those will
469 * instead go to whatever focusable window is behind it. This flag
470 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
471 * is explicitly set.
472 *
473 * <p>Setting this flag also implies that the window will not need to
474 * interact with
475 * a soft input method, so it will be Z-ordered and positioned
476 * independently of any active input method (typically this means it
477 * gets Z-ordered on top of the input method, so it can use the full
478 * screen for its content and cover the input method if needed. You
479 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
480 public static final int FLAG_NOT_FOCUSABLE = 0x00000008;
481
482 /** Window flag: this window can never receive touch events. */
483 public static final int FLAG_NOT_TOUCHABLE = 0x00000010;
484
485 /** Window flag: Even when this window is focusable (its
486 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events
487 * outside of the window to be sent to the windows behind it. Otherwise
488 * it will consume all pointer events itself, regardless of whether they
489 * are inside of the window. */
490 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020;
491
492 /** Window flag: When set, if the device is asleep when the touch
493 * screen is pressed, you will receive this first touch event. Usually
494 * the first touch event is consumed by the system since the user can
495 * not see what they are pressing on.
496 */
497 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
498
499 /** Window flag: as long as this window is visible to the user, keep
500 * the device's screen turned on and bright. */
501 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080;
502
503 /** Window flag: place the window within the entire screen, ignoring
504 * decorations around the border (a.k.a. the status bar). The
505 * window must correctly position its contents to take the screen
506 * decoration into account. This flag is normally set for you
507 * by Window as described in {@link Window#setFlags}. */
508 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100;
509
510 /** Window flag: allow window to extend outside of the screen. */
511 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200;
512
513 /** Window flag: Hide all screen decorations (e.g. status bar) while
514 * this window is displayed. This allows the window to use the entire
515 * display space for itself -- the status bar will be hidden when
516 * an app window with this flag set is on the top layer. */
517 public static final int FLAG_FULLSCREEN = 0x00000400;
518
519 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the
520 * screen decorations (such as status bar) to be shown. */
521 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800;
522
523 /** Window flag: turn on dithering when compositing this window to
524 * the screen. */
525 public static final int FLAG_DITHER = 0x00001000;
526
527 /** Window flag: don't allow screen shots while this window is
528 * displayed. */
529 public static final int FLAG_SECURE = 0x00002000;
530
531 /** Window flag: a special mode where the layout parameters are used
532 * to perform scaling of the surface when it is composited to the
533 * screen. */
534 public static final int FLAG_SCALED = 0x00004000;
535
536 /** Window flag: intended for windows that will often be used when the user is
537 * holding the screen against their face, it will aggressively filter the event
538 * stream to prevent unintended presses in this situation that may not be
539 * desired for a particular window, when such an event stream is detected, the
540 * application will receive a CANCEL motion event to indicate this so applications
541 * can handle this accordingly by taking no action on the event
542 * until the finger is released. */
543 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000;
544
545 /** Window flag: a special option only for use in combination with
546 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the
547 * screen your window may appear on top of or behind screen decorations
548 * such as the status bar. By also including this flag, the window
549 * manager will report the inset rectangle needed to ensure your
550 * content is not covered by screen decorations. This flag is normally
551 * set for you by Window as described in {@link Window#setFlags}.*/
552 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
553
554 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
555 * respect to how this window interacts with the current method. That
556 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
557 * window will behave as if it needs to interact with the input method
558 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
559 * not set and this flag is set, then the window will behave as if it
560 * doesn't need to interact with the input method and can be placed
561 * to use more space and cover the input method.
562 */
563 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
564
565 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
566 * can set this flag to receive a single special MotionEvent with
567 * the action
568 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
569 * touches that occur outside of your window. Note that you will not
570 * receive the full down/move/up gesture, only the location of the
571 * first down as an ACTION_OUTSIDE.
572 */
573 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
574
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700575 /** Window flag: special flag to let windows be shown when the screen
576 * is locked. This will let application windows take precedence over
577 * key guard or any other lock screens. Can be used with
578 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700579 * directly before showing the key guard window. Can be used with
580 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
581 * non-secure keyguards. This flag only applies to the top-most
582 * full-screen window.
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700583 */
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700584 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
585
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700586 /** Window flag: ask that the system wallpaper be shown behind
587 * your window. The window surface must be translucent to be able
588 * to actually see the wallpaper behind it; this flag just ensures
589 * that the wallpaper surface will be there if this window actually
590 * has translucent regions.
591 */
592 public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
593
Dianne Hackborn93e462b2009-09-15 22:50:40 -0700594 /** Window flag: when set as a window is being added or made
595 * visible, once the window has been shown then the system will
596 * poke the power manager's user activity (as if the user had woken
597 * up the device) to turn the screen on. */
598 public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
599
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700600 /** Window flag: when set the window will cause the keyguard to
601 * be dismissed, only if it is not a secure lock keyguard. Because such
602 * a keyguard is not needed for security, it will never re-appear if
603 * the user navigates to another window (in contrast to
604 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
605 * hide both secure and non-secure keyguards but ensure they reappear
606 * when the user moves to another UI that doesn't hide them).
607 * If the keyguard is currently active and is secure (requires an
608 * unlock pattern) than the user will still need to confirm it before
609 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has
Daniel Sandlerae069f72010-06-17 21:56:26 -0400610 * also been set.
611 */
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700612 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
Jeff Brown01ce2e92010-09-26 22:20:12 -0700613
614 /** Window flag: when set the window will accept for touch events
615 * outside of its bounds to be sent to other windows that also
616 * support split touch. When this flag is not set, the first pointer
617 * that goes down determines the window to which all subsequent touches
618 * go until all pointers go up. When this flag is set, each pointer
619 * (not necessarily the first) that goes down determines the window
620 * to which all subsequent touches of that pointer will go until that
621 * pointer goes up thereby enabling touches with multiple pointers
622 * to be split across multiple windows.
623 *
624 * {@hide} */
625 public static final int FLAG_SPLIT_TOUCH = 0x00800000;
Daniel Sandler611fae42010-06-17 10:45:00 -0400626
Daniel Sandlere02d8082010-10-08 15:13:22 -0400627 /**
628 * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU}
629 * and therefore needs a Menu key. For devices where Menu is a physical button this flag is
630 * ignored, but on devices where the Menu key is drawn in software it may be hidden unless
631 * this flag is set.
632 *
633 * (Note that Action Bars, when available, are the preferred way to offer additional
634 * functions otherwise accessed via an options menu.)
635 *
636 * {@hide}
637 */
638 public static final int FLAG_NEEDS_MENU_KEY = 0x01000000;
639
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700640 /** Window flag: *sigh* The lock screen wants to continue running its
641 * animation while it is fading. A kind-of hack to allow this. Maybe
642 * in the future we just make this the default behavior.
643 *
644 * {@hide} */
645 public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000;
646
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700647 /** Window flag: special flag to limit the size of the window to be
648 * original size ([320x480] x density). Used to create window for applications
649 * running under compatibility mode.
650 *
651 * {@hide} */
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700652 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000;
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700653
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800654 /** Window flag: a special option intended for system dialogs. When
655 * this flag is set, the window will demand focus unconditionally when
656 * it is created.
657 * {@hide} */
658 public static final int FLAG_SYSTEM_ERROR = 0x40000000;
Romain Guy529b60a2010-08-03 18:05:47 -0700659
660 /**
661 * Indicates whether this window should be hardware accelerated.
662 * Requesting hardware acceleration does not guarantee it will happen.
663 */
664 public static final int FLAG_HARDWARE_ACCELERATED = 0x80000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800665
666 /**
667 * Given a particular set of window manager flags, determine whether
668 * such a window may be a target for an input method when it has
669 * focus. In particular, this checks the
670 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
671 * flags and returns true if the combination of the two corresponds
672 * to a window that needs to be behind the input method so that the
673 * user can type into it.
674 *
675 * @param flags The current window manager flags.
676 *
677 * @return Returns true if such a window should be behind/interact
678 * with an input method, false if not.
679 */
680 public static boolean mayUseInputMethod(int flags) {
681 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
682 case 0:
683 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
684 return true;
685 }
686 return false;
687 }
688
689 /**
690 * Mask for {@link #softInputMode} of the bits that determine the
691 * desired visibility state of the soft input area for this window.
692 */
693 public static final int SOFT_INPUT_MASK_STATE = 0x0f;
694
695 /**
696 * Visibility state for {@link #softInputMode}: no state has been specified.
697 */
698 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
699
700 /**
701 * Visibility state for {@link #softInputMode}: please don't change the state of
702 * the soft input area.
703 */
704 public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
705
706 /**
707 * Visibility state for {@link #softInputMode}: please hide any soft input
708 * area when normally appropriate (when the user is navigating
709 * forward to your window).
710 */
711 public static final int SOFT_INPUT_STATE_HIDDEN = 2;
712
713 /**
714 * Visibility state for {@link #softInputMode}: please always hide any
715 * soft input area when this window receives focus.
716 */
717 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
718
719 /**
720 * Visibility state for {@link #softInputMode}: please show the soft
721 * input area when normally appropriate (when the user is navigating
722 * forward to your window).
723 */
724 public static final int SOFT_INPUT_STATE_VISIBLE = 4;
725
726 /**
727 * Visibility state for {@link #softInputMode}: please always make the
728 * soft input area visible when this window receives input focus.
729 */
730 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
731
732 /**
733 * Mask for {@link #softInputMode} of the bits that determine the
734 * way that the window should be adjusted to accommodate the soft
735 * input window.
736 */
737 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
738
739 /** Adjustment option for {@link #softInputMode}: nothing specified.
740 * The system will try to pick one or
741 * the other depending on the contents of the window.
742 */
743 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
744
745 /** Adjustment option for {@link #softInputMode}: set to allow the
746 * window to be resized when an input
747 * method is shown, so that its contents are not covered by the input
Scott Mainf10e6332010-06-11 09:03:22 -0700748 * method. This can <em>not</em> be combined with
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800749 * {@link #SOFT_INPUT_ADJUST_PAN}; if
750 * neither of these are set, then the system will try to pick one or
751 * the other depending on the contents of the window.
752 */
753 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
754
755 /** Adjustment option for {@link #softInputMode}: set to have a window
756 * pan when an input method is
757 * shown, so it doesn't need to deal with resizing but just panned
758 * by the framework to ensure the current input focus is visible. This
Scott Mainf10e6332010-06-11 09:03:22 -0700759 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800760 * neither of these are set, then the system will try to pick one or
761 * the other depending on the contents of the window.
762 */
763 public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
764
Dianne Hackborndea3ef72010-10-28 14:24:22 -0700765 /** Adjustment option for {@link #softInputMode}: set to have a window
766 * not adjust for a shown input method. The window will not be resized,
767 * and it will not be panned to make its focus visible.
768 */
769 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
770
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800771 /**
772 * Bit for {@link #softInputMode}: set when the user has navigated
773 * forward to the window. This is normally set automatically for
774 * you by the system, though you may want to set it in certain cases
775 * when you are displaying a window yourself. This flag will always
776 * be cleared automatically after the window is displayed.
777 */
778 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500779
780 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800781 * Desired operating mode for any soft input area. May any combination
782 * of:
783 *
784 * <ul>
785 * <li> One of the visibility states
786 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
787 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
788 * {@link #SOFT_INPUT_STATE_VISIBLE}.
789 * <li> One of the adjustment options
790 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
791 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or
792 * {@link #SOFT_INPUT_ADJUST_PAN}.
793 */
794 public int softInputMode;
795
796 /**
797 * Placement of window within the screen as per {@link Gravity}
798 *
799 * @see Gravity
800 */
801 public int gravity;
802
803 /**
804 * The horizontal margin, as a percentage of the container's width,
805 * between the container and the widget.
806 */
807 public float horizontalMargin;
808
809 /**
810 * The vertical margin, as a percentage of the container's height,
811 * between the container and the widget.
812 */
813 public float verticalMargin;
814
815 /**
816 * The desired bitmap format. May be one of the constants in
817 * {@link android.graphics.PixelFormat}. Default is OPAQUE.
818 */
819 public int format;
820
821 /**
822 * A style resource defining the animations to use for this window.
823 * This must be a system resource; it can not be an application resource
824 * because the window manager does not have access to applications.
825 */
826 public int windowAnimations;
827
828 /**
829 * An alpha value to apply to this entire window.
830 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
831 */
832 public float alpha = 1.0f;
833
834 /**
835 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
836 * to apply. Range is from 1.0 for completely opaque to 0.0 for no
837 * dim.
838 */
839 public float dimAmount = 1.0f;
Dianne Hackborndea3ef72010-10-28 14:24:22 -0700840
841 /**
842 * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
843 * indicating that the brightness value is not overridden for this window
844 * and normal brightness policy should be used.
845 */
846 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
847
848 /**
849 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
850 * indicating that the screen or button backlight brightness should be set
851 * to the lowest value when this window is in front.
852 */
853 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
854
855 /**
856 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
857 * indicating that the screen or button backlight brightness should be set
858 * to the hightest value when this window is in front.
859 */
860 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800861
862 /**
863 * This can be used to override the user's preferred brightness of
864 * the screen. A value of less than 0, the default, means to use the
865 * preferred screen brightness. 0 to 1 adjusts the brightness from
866 * dark to full bright.
867 */
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500868 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800869
870 /**
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500871 * This can be used to override the standard behavior of the button and
872 * keyboard backlights. A value of less than 0, the default, means to
873 * use the standard backlight behavior. 0 to 1 adjusts the brightness
874 * from dark to full bright.
875 */
876 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
877
878 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800879 * Identifier for this window. This will usually be filled in for
880 * you.
881 */
882 public IBinder token = null;
883
884 /**
885 * Name of the package owning this window.
886 */
887 public String packageName = null;
888
889 /**
890 * Specific orientation value for a window.
891 * May be any of the same values allowed
892 * for {@link android.content.pm.ActivityInfo#screenOrientation}.
893 * If not set, a default value of
894 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
895 * will be used.
896 */
897 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
898
899
900 public LayoutParams() {
Romain Guy980a9382010-01-08 15:06:28 -0800901 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800902 type = TYPE_APPLICATION;
903 format = PixelFormat.OPAQUE;
904 }
905
906 public LayoutParams(int _type) {
Romain Guy980a9382010-01-08 15:06:28 -0800907 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800908 type = _type;
909 format = PixelFormat.OPAQUE;
910 }
911
912 public LayoutParams(int _type, int _flags) {
Romain Guy980a9382010-01-08 15:06:28 -0800913 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800914 type = _type;
915 flags = _flags;
916 format = PixelFormat.OPAQUE;
917 }
918
919 public LayoutParams(int _type, int _flags, int _format) {
Romain Guy980a9382010-01-08 15:06:28 -0800920 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800921 type = _type;
922 flags = _flags;
923 format = _format;
924 }
925
926 public LayoutParams(int w, int h, int _type, int _flags, int _format) {
927 super(w, h);
928 type = _type;
929 flags = _flags;
930 format = _format;
931 }
932
933 public LayoutParams(int w, int h, int xpos, int ypos, int _type,
934 int _flags, int _format) {
935 super(w, h);
936 x = xpos;
937 y = ypos;
938 type = _type;
939 flags = _flags;
940 format = _format;
941 }
942
943 public final void setTitle(CharSequence title) {
944 if (null == title)
945 title = "";
946
947 mTitle = TextUtils.stringOrSpannedString(title);
948 }
949
950 public final CharSequence getTitle() {
951 return mTitle;
952 }
953
954 public int describeContents() {
955 return 0;
956 }
957
958 public void writeToParcel(Parcel out, int parcelableFlags) {
959 out.writeInt(width);
960 out.writeInt(height);
961 out.writeInt(x);
962 out.writeInt(y);
963 out.writeInt(type);
964 out.writeInt(memoryType);
965 out.writeInt(flags);
966 out.writeInt(softInputMode);
967 out.writeInt(gravity);
968 out.writeFloat(horizontalMargin);
969 out.writeFloat(verticalMargin);
970 out.writeInt(format);
971 out.writeInt(windowAnimations);
972 out.writeFloat(alpha);
973 out.writeFloat(dimAmount);
974 out.writeFloat(screenBrightness);
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500975 out.writeFloat(buttonBrightness);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800976 out.writeStrongBinder(token);
977 out.writeString(packageName);
978 TextUtils.writeToParcel(mTitle, out, parcelableFlags);
979 out.writeInt(screenOrientation);
980 }
981
982 public static final Parcelable.Creator<LayoutParams> CREATOR
983 = new Parcelable.Creator<LayoutParams>() {
984 public LayoutParams createFromParcel(Parcel in) {
985 return new LayoutParams(in);
986 }
987
988 public LayoutParams[] newArray(int size) {
989 return new LayoutParams[size];
990 }
991 };
992
993
994 public LayoutParams(Parcel in) {
995 width = in.readInt();
996 height = in.readInt();
997 x = in.readInt();
998 y = in.readInt();
999 type = in.readInt();
1000 memoryType = in.readInt();
1001 flags = in.readInt();
1002 softInputMode = in.readInt();
1003 gravity = in.readInt();
1004 horizontalMargin = in.readFloat();
1005 verticalMargin = in.readFloat();
1006 format = in.readInt();
1007 windowAnimations = in.readInt();
1008 alpha = in.readFloat();
1009 dimAmount = in.readFloat();
1010 screenBrightness = in.readFloat();
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001011 buttonBrightness = in.readFloat();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001012 token = in.readStrongBinder();
1013 packageName = in.readString();
1014 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
1015 screenOrientation = in.readInt();
1016 }
1017
Romain Guy72998072009-06-22 11:09:20 -07001018 @SuppressWarnings({"PointlessBitwiseExpression"})
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001019 public static final int LAYOUT_CHANGED = 1<<0;
1020 public static final int TYPE_CHANGED = 1<<1;
1021 public static final int FLAGS_CHANGED = 1<<2;
1022 public static final int FORMAT_CHANGED = 1<<3;
1023 public static final int ANIMATION_CHANGED = 1<<4;
1024 public static final int DIM_AMOUNT_CHANGED = 1<<5;
1025 public static final int TITLE_CHANGED = 1<<6;
1026 public static final int ALPHA_CHANGED = 1<<7;
1027 public static final int MEMORY_TYPE_CHANGED = 1<<8;
1028 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
1029 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
1030 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001031 /** {@hide} */
1032 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001033
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001034 // internal buffer to backup/restore parameters under compatibility mode.
1035 private int[] mCompatibilityParamsBackup = null;
1036
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001037 public final int copyFrom(LayoutParams o) {
1038 int changes = 0;
1039
1040 if (width != o.width) {
1041 width = o.width;
1042 changes |= LAYOUT_CHANGED;
1043 }
1044 if (height != o.height) {
1045 height = o.height;
1046 changes |= LAYOUT_CHANGED;
1047 }
1048 if (x != o.x) {
1049 x = o.x;
1050 changes |= LAYOUT_CHANGED;
1051 }
1052 if (y != o.y) {
1053 y = o.y;
1054 changes |= LAYOUT_CHANGED;
1055 }
1056 if (horizontalWeight != o.horizontalWeight) {
1057 horizontalWeight = o.horizontalWeight;
1058 changes |= LAYOUT_CHANGED;
1059 }
1060 if (verticalWeight != o.verticalWeight) {
1061 verticalWeight = o.verticalWeight;
1062 changes |= LAYOUT_CHANGED;
1063 }
1064 if (horizontalMargin != o.horizontalMargin) {
1065 horizontalMargin = o.horizontalMargin;
1066 changes |= LAYOUT_CHANGED;
1067 }
1068 if (verticalMargin != o.verticalMargin) {
1069 verticalMargin = o.verticalMargin;
1070 changes |= LAYOUT_CHANGED;
1071 }
1072 if (type != o.type) {
1073 type = o.type;
1074 changes |= TYPE_CHANGED;
1075 }
1076 if (memoryType != o.memoryType) {
1077 memoryType = o.memoryType;
1078 changes |= MEMORY_TYPE_CHANGED;
1079 }
1080 if (flags != o.flags) {
1081 flags = o.flags;
1082 changes |= FLAGS_CHANGED;
1083 }
1084 if (softInputMode != o.softInputMode) {
1085 softInputMode = o.softInputMode;
1086 changes |= SOFT_INPUT_MODE_CHANGED;
1087 }
1088 if (gravity != o.gravity) {
1089 gravity = o.gravity;
1090 changes |= LAYOUT_CHANGED;
1091 }
1092 if (horizontalMargin != o.horizontalMargin) {
1093 horizontalMargin = o.horizontalMargin;
1094 changes |= LAYOUT_CHANGED;
1095 }
1096 if (verticalMargin != o.verticalMargin) {
1097 verticalMargin = o.verticalMargin;
1098 changes |= LAYOUT_CHANGED;
1099 }
1100 if (format != o.format) {
1101 format = o.format;
1102 changes |= FORMAT_CHANGED;
1103 }
1104 if (windowAnimations != o.windowAnimations) {
1105 windowAnimations = o.windowAnimations;
1106 changes |= ANIMATION_CHANGED;
1107 }
1108 if (token == null) {
1109 // NOTE: token only copied if the recipient doesn't
1110 // already have one.
1111 token = o.token;
1112 }
1113 if (packageName == null) {
1114 // NOTE: packageName only copied if the recipient doesn't
1115 // already have one.
1116 packageName = o.packageName;
1117 }
1118 if (!mTitle.equals(o.mTitle)) {
1119 mTitle = o.mTitle;
1120 changes |= TITLE_CHANGED;
1121 }
1122 if (alpha != o.alpha) {
1123 alpha = o.alpha;
1124 changes |= ALPHA_CHANGED;
1125 }
1126 if (dimAmount != o.dimAmount) {
1127 dimAmount = o.dimAmount;
1128 changes |= DIM_AMOUNT_CHANGED;
1129 }
1130 if (screenBrightness != o.screenBrightness) {
1131 screenBrightness = o.screenBrightness;
1132 changes |= SCREEN_BRIGHTNESS_CHANGED;
1133 }
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001134 if (buttonBrightness != o.buttonBrightness) {
1135 buttonBrightness = o.buttonBrightness;
1136 changes |= BUTTON_BRIGHTNESS_CHANGED;
1137 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001138
1139 if (screenOrientation != o.screenOrientation) {
1140 screenOrientation = o.screenOrientation;
1141 changes |= SCREEN_ORIENTATION_CHANGED;
1142 }
Romain Guy529b60a2010-08-03 18:05:47 -07001143
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001144 return changes;
1145 }
1146
1147 @Override
1148 public String debug(String output) {
1149 output += "Contents of " + this + ":";
1150 Log.d("Debug", output);
1151 output = super.debug("");
1152 Log.d("Debug", output);
1153 Log.d("Debug", "");
1154 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
1155 return "";
1156 }
1157
1158 @Override
1159 public String toString() {
1160 StringBuilder sb = new StringBuilder(256);
1161 sb.append("WM.LayoutParams{");
1162 sb.append("(");
1163 sb.append(x);
1164 sb.append(',');
1165 sb.append(y);
1166 sb.append(")(");
Romain Guy980a9382010-01-08 15:06:28 -08001167 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001168 sb.append('x');
Romain Guy980a9382010-01-08 15:06:28 -08001169 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001170 sb.append(")");
1171 if (softInputMode != 0) {
1172 sb.append(" sim=#");
1173 sb.append(Integer.toHexString(softInputMode));
1174 }
1175 if (gravity != 0) {
1176 sb.append(" gr=#");
1177 sb.append(Integer.toHexString(gravity));
1178 }
1179 sb.append(" ty=");
1180 sb.append(type);
1181 sb.append(" fl=#");
1182 sb.append(Integer.toHexString(flags));
1183 sb.append(" fmt=");
1184 sb.append(format);
1185 if (windowAnimations != 0) {
1186 sb.append(" wanim=0x");
1187 sb.append(Integer.toHexString(windowAnimations));
1188 }
1189 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
1190 sb.append(" or=");
1191 sb.append(screenOrientation);
1192 }
Mitsuru Oshima5a2b91d2009-07-16 16:30:02 -07001193 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) {
1194 sb.append(" compatible=true");
1195 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001196 sb.append('}');
1197 return sb.toString();
1198 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001199
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001200 /**
1201 * Scale the layout params' coordinates and size.
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001202 * @hide
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001203 */
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001204 public void scale(float scale) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001205 x = (int) (x * scale + 0.5f);
1206 y = (int) (y * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001207 if (width > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001208 width = (int) (width * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001209 }
1210 if (height > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001211 height = (int) (height * scale + 0.5f);
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001212 }
1213 }
1214
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001215 /**
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001216 * Backup the layout parameters used in compatibility mode.
1217 * @see LayoutParams#restore()
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001218 */
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001219 void backup() {
1220 int[] backup = mCompatibilityParamsBackup;
1221 if (backup == null) {
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001222 // we backup 4 elements, x, y, width, height
1223 backup = mCompatibilityParamsBackup = new int[4];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001224 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001225 backup[0] = x;
1226 backup[1] = y;
1227 backup[2] = width;
1228 backup[3] = height;
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001229 }
1230
1231 /**
1232 * Restore the layout params' coordinates, size and gravity
1233 * @see LayoutParams#backup()
1234 */
1235 void restore() {
1236 int[] backup = mCompatibilityParamsBackup;
1237 if (backup != null) {
1238 x = backup[0];
1239 y = backup[1];
1240 width = backup[2];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001241 height = backup[3];
1242 }
1243 }
1244
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001245 private CharSequence mTitle = "";
1246 }
1247}