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