blob: 99acb3fc0cc1f2deeaa182cbe80467215c44ebb2 [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.
Fabrice Di Meglio9e3b0022011-06-06 16:30:29 -070080 * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or
81 * {@link Gravity#END} it provides an offset from the given edge.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080082 */
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"),
Jeff Brownbfcb60a2011-09-08 18:51:14 -0700180 @ViewDebug.IntToString(from = TYPE_WALLPAPER, to = "TYPE_WALLPAPER"),
181 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"),
Dianne Hackborn29aae6f2011-08-18 18:30:09 -0700182 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"),
Jeff Brownbfcb60a2011-09-08 18:51:14 -0700183 @ViewDebug.IntToString(from = TYPE_DRAG, to = "TYPE_DRAG"),
184 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"),
185 @ViewDebug.IntToString(from = TYPE_POINTER, to = "TYPE_POINTER"),
186 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, to = "TYPE_NAVIGATION_BAR"),
187 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, to = "TYPE_VOLUME_OVERLAY"),
Dianne Hackborn29aae6f2011-08-18 18:30:09 -0700188 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS")
Joe Onorato8f2bd432010-03-25 11:45:28 -0700189 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800190 public int type;
191
192 /**
193 * Start of window types that represent normal application windows.
194 */
195 public static final int FIRST_APPLICATION_WINDOW = 1;
196
197 /**
198 * Window type: an application window that serves as the "base" window
199 * of the overall application; all other application windows will
200 * appear on top of it.
201 */
202 public static final int TYPE_BASE_APPLICATION = 1;
203
204 /**
205 * Window type: a normal application window. The {@link #token} must be
206 * an Activity token identifying who the window belongs to.
207 */
208 public static final int TYPE_APPLICATION = 2;
209
210 /**
211 * Window type: special application window that is displayed while the
212 * application is starting. Not for use by applications themselves;
213 * this is used by the system to display something until the
214 * application can show its own windows.
215 */
216 public static final int TYPE_APPLICATION_STARTING = 3;
217
218 /**
219 * End of types of application windows.
220 */
221 public static final int LAST_APPLICATION_WINDOW = 99;
222
223 /**
224 * Start of types of sub-windows. The {@link #token} of these windows
225 * must be set to the window they are attached to. These types of
226 * windows are kept next to their attached window in Z-order, and their
227 * coordinate space is relative to their attached window.
228 */
229 public static final int FIRST_SUB_WINDOW = 1000;
230
231 /**
232 * Window type: a panel on top of an application window. These windows
233 * appear on top of their attached window.
234 */
235 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
236
237 /**
238 * Window type: window for showing media (e.g. video). These windows
239 * are displayed behind their attached window.
240 */
241 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1;
242
243 /**
244 * Window type: a sub-panel on top of an application window. These
245 * windows are displayed on top their attached window and any
246 * {@link #TYPE_APPLICATION_PANEL} panels.
247 */
248 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2;
249
250 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
251 * of the window happens as that of a top-level window, <em>not</em>
252 * as a child of its container.
253 */
254 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3;
255
256 /**
Dianne Hackbornc4d5d022009-05-21 17:32:42 -0700257 * Window type: window for showing overlays on top of media windows.
258 * These windows are displayed between TYPE_APPLICATION_MEDIA and the
259 * application window. They should be translucent to be useful. This
260 * is a big ugly hack so:
261 * @hide
262 */
263 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4;
264
265 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800266 * End of types of sub-windows.
267 */
268 public static final int LAST_SUB_WINDOW = 1999;
269
270 /**
271 * Start of system-specific window types. These are not normally
272 * created by applications.
273 */
274 public static final int FIRST_SYSTEM_WINDOW = 2000;
275
276 /**
277 * Window type: the status bar. There can be only one status bar
278 * window; it is placed at the top of the screen, and all other
279 * windows are shifted down so they are below it.
280 */
281 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
282
283 /**
284 * Window type: the search bar. There can be only one search bar
285 * window; it is placed at the top of the screen.
286 */
287 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
288
289 /**
290 * Window type: phone. These are non-application windows providing
291 * user interaction with the phone (in particular incoming calls).
292 * These windows are normally placed above all applications, but behind
293 * the status bar.
294 */
295 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
296
297 /**
298 * Window type: system window, such as low power alert. These windows
299 * are always on top of application windows.
300 */
301 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
302
303 /**
304 * Window type: keyguard window.
305 */
306 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
307
308 /**
309 * Window type: transient notifications.
310 */
311 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
312
313 /**
314 * Window type: system overlay windows, which need to be displayed
315 * on top of everything else. These windows must not take input
316 * focus, or they will interfere with the keyguard.
317 */
318 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
319
320 /**
321 * Window type: priority phone UI, which needs to be displayed even if
322 * the keyguard is active. These windows must not take input
323 * focus, or they will interfere with the keyguard.
324 */
325 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
326
327 /**
328 * Window type: panel that slides out from the status bar
329 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
331
332 /**
333 * Window type: dialogs that the keyguard shows
334 */
335 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
336
337 /**
338 * Window type: internal system error windows, appear on top of
339 * everything they can.
340 */
341 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
342
343 /**
344 * Window type: internal input methods windows, which appear above
345 * the normal UI. Application windows may be resized or panned to keep
346 * the input focus visible while this window is displayed.
347 */
348 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
349
350 /**
351 * Window type: internal input methods dialog windows, which appear above
352 * the current input method window.
353 */
354 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
355
356 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700357 * Window type: wallpaper window, placed behind any window that wants
358 * to sit on top of the wallpaper.
359 */
360 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
361
362 /**
Joe Onorato29fc2c92010-11-24 10:26:50 -0800363 * Window type: panel that slides out from over the status bar
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800364 */
365 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
Jeff Brown3b2b3542010-10-15 00:54:27 -0700366
367 /**
368 * Window type: secure system overlay windows, which need to be displayed
369 * on top of everything else. These windows must not take input
370 * focus, or they will interfere with the keyguard.
371 *
372 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
373 * system itself is allowed to create these overlays. Applications cannot
374 * obtain permission to create secure system overlays.
375 * @hide
376 */
377 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
378
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800379 /**
Christopher Tatea53146c2010-09-07 11:57:52 -0700380 * Window type: the drag-and-drop pseudowindow. There is only one
381 * drag layer (at most), and it is placed on top of all other windows.
382 * @hide
383 */
Jeff Brown3b2b3542010-10-15 00:54:27 -0700384 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16;
Christopher Tatea53146c2010-09-07 11:57:52 -0700385
386 /**
Joe Onorato29fc2c92010-11-24 10:26:50 -0800387 * Window type: panel that slides out from under the status bar
Joe Onoratoa89e9032010-11-24 11:13:44 -0800388 * @hide
Joe Onorato29fc2c92010-11-24 10:26:50 -0800389 */
390 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
391
Jeff Brown83c09682010-12-23 17:50:18 -0800392 /**
393 * Window type: (mouse) pointer
394 * @hide
395 */
396 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
Joe Onorato29fc2c92010-11-24 10:26:50 -0800397
398 /**
Daniel Sandler8956dbb2011-04-22 07:55:02 -0400399 * Window type: Navigation bar (when distinct from status bar)
400 * @hide
401 */
402 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
403
404 /**
Dianne Hackborne8ecde12011-08-03 18:55:19 -0700405 * Window type: The volume level overlay/dialog shown when the user
406 * changes the system volume.
407 * @hide
408 */
409 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
410
411 /**
Dianne Hackborn29aae6f2011-08-18 18:30:09 -0700412 * Window type: The boot progress dialog, goes on top of everything
413 * in the world.
414 * @hide
415 */
416 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
417
418 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800419 * End of types of system windows.
420 */
421 public static final int LAST_SYSTEM_WINDOW = 2999;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422
Mathias Agopiand2112302010-12-07 19:38:17 -0800423 /** @deprecated this is ignored, this value is set automatically when needed. */
424 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800425 public static final int MEMORY_TYPE_NORMAL = 0;
Mathias Agopiand2112302010-12-07 19:38:17 -0800426 /** @deprecated this is ignored, this value is set automatically when needed. */
Mathias Agopian317a6282009-08-13 17:29:02 -0700427 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800428 public static final int MEMORY_TYPE_HARDWARE = 1;
Mathias Agopiand2112302010-12-07 19:38:17 -0800429 /** @deprecated this is ignored, this value is set automatically when needed. */
Mathias Agopian317a6282009-08-13 17:29:02 -0700430 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800431 public static final int MEMORY_TYPE_GPU = 2;
Mathias Agopiand2112302010-12-07 19:38:17 -0800432 /** @deprecated this is ignored, this value is set automatically when needed. */
433 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800434 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700435
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800436 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700437 * @deprecated this is ignored
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438 */
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700439 @Deprecated
440 public int memoryType;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800441
Mike Lockwoodef731622010-01-27 17:51:34 -0500442 /** Window flag: as long as this window is visible to the user, allow
443 * the lock screen to activate while the screen is on.
444 * This can be used independently, or in combination with
Christopher Tate95f78502010-01-29 15:57:34 -0800445 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
Mike Lockwoodef731622010-01-27 17:51:34 -0500446 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001;
447
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800448 /** Window flag: everything behind this window will be dimmed.
449 * Use {@link #dimAmount} to control the amount of dim. */
450 public static final int FLAG_DIM_BEHIND = 0x00000002;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700451
452 /** Window flag: blur everything behind this window.
453 * @deprecated Blurring is no longer supported. */
454 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455 public static final int FLAG_BLUR_BEHIND = 0x00000004;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700456
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800457 /** Window flag: this window won't ever get key input focus, so the
458 * user can not send key or other button events to it. Those will
459 * instead go to whatever focusable window is behind it. This flag
460 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
461 * is explicitly set.
462 *
463 * <p>Setting this flag also implies that the window will not need to
464 * interact with
465 * a soft input method, so it will be Z-ordered and positioned
466 * independently of any active input method (typically this means it
467 * gets Z-ordered on top of the input method, so it can use the full
468 * screen for its content and cover the input method if needed. You
469 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
470 public static final int FLAG_NOT_FOCUSABLE = 0x00000008;
471
472 /** Window flag: this window can never receive touch events. */
473 public static final int FLAG_NOT_TOUCHABLE = 0x00000010;
474
475 /** Window flag: Even when this window is focusable (its
476 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events
477 * outside of the window to be sent to the windows behind it. Otherwise
478 * it will consume all pointer events itself, regardless of whether they
479 * are inside of the window. */
480 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020;
481
482 /** Window flag: When set, if the device is asleep when the touch
483 * screen is pressed, you will receive this first touch event. Usually
484 * the first touch event is consumed by the system since the user can
485 * not see what they are pressing on.
486 */
487 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
488
489 /** Window flag: as long as this window is visible to the user, keep
490 * the device's screen turned on and bright. */
491 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080;
492
493 /** Window flag: place the window within the entire screen, ignoring
494 * decorations around the border (a.k.a. the status bar). The
495 * window must correctly position its contents to take the screen
496 * decoration into account. This flag is normally set for you
497 * by Window as described in {@link Window#setFlags}. */
498 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100;
499
500 /** Window flag: allow window to extend outside of the screen. */
501 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200;
502
503 /** Window flag: Hide all screen decorations (e.g. status bar) while
504 * this window is displayed. This allows the window to use the entire
505 * display space for itself -- the status bar will be hidden when
506 * an app window with this flag set is on the top layer. */
507 public static final int FLAG_FULLSCREEN = 0x00000400;
508
509 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the
510 * screen decorations (such as status bar) to be shown. */
511 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800;
512
513 /** Window flag: turn on dithering when compositing this window to
514 * the screen. */
515 public static final int FLAG_DITHER = 0x00001000;
516
517 /** Window flag: don't allow screen shots while this window is
Glenn Kastend6f5bde2011-01-19 15:27:27 -0800518 * displayed. Maps to Surface.SECURE. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519 public static final int FLAG_SECURE = 0x00002000;
520
521 /** Window flag: a special mode where the layout parameters are used
522 * to perform scaling of the surface when it is composited to the
523 * screen. */
524 public static final int FLAG_SCALED = 0x00004000;
525
526 /** Window flag: intended for windows that will often be used when the user is
527 * holding the screen against their face, it will aggressively filter the event
528 * stream to prevent unintended presses in this situation that may not be
529 * desired for a particular window, when such an event stream is detected, the
530 * application will receive a CANCEL motion event to indicate this so applications
531 * can handle this accordingly by taking no action on the event
532 * until the finger is released. */
533 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000;
534
535 /** Window flag: a special option only for use in combination with
536 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the
537 * screen your window may appear on top of or behind screen decorations
538 * such as the status bar. By also including this flag, the window
539 * manager will report the inset rectangle needed to ensure your
540 * content is not covered by screen decorations. This flag is normally
541 * set for you by Window as described in {@link Window#setFlags}.*/
542 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
543
544 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
545 * respect to how this window interacts with the current method. That
546 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
547 * window will behave as if it needs to interact with the input method
548 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
549 * not set and this flag is set, then the window will behave as if it
550 * doesn't need to interact with the input method and can be placed
551 * to use more space and cover the input method.
552 */
553 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
554
555 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
556 * can set this flag to receive a single special MotionEvent with
557 * the action
558 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
559 * touches that occur outside of your window. Note that you will not
560 * receive the full down/move/up gesture, only the location of the
561 * first down as an ACTION_OUTSIDE.
562 */
563 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
564
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700565 /** Window flag: special flag to let windows be shown when the screen
566 * is locked. This will let application windows take precedence over
567 * key guard or any other lock screens. Can be used with
568 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700569 * directly before showing the key guard window. Can be used with
570 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
571 * non-secure keyguards. This flag only applies to the top-most
572 * full-screen window.
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700573 */
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700574 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
575
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700576 /** Window flag: ask that the system wallpaper be shown behind
577 * your window. The window surface must be translucent to be able
578 * to actually see the wallpaper behind it; this flag just ensures
579 * that the wallpaper surface will be there if this window actually
580 * has translucent regions.
581 */
582 public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
583
Dianne Hackborn93e462b2009-09-15 22:50:40 -0700584 /** Window flag: when set as a window is being added or made
585 * visible, once the window has been shown then the system will
586 * poke the power manager's user activity (as if the user had woken
587 * up the device) to turn the screen on. */
588 public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
589
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700590 /** Window flag: when set the window will cause the keyguard to
591 * be dismissed, only if it is not a secure lock keyguard. Because such
592 * a keyguard is not needed for security, it will never re-appear if
593 * the user navigates to another window (in contrast to
594 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
595 * hide both secure and non-secure keyguards but ensure they reappear
596 * when the user moves to another UI that doesn't hide them).
597 * If the keyguard is currently active and is secure (requires an
598 * unlock pattern) than the user will still need to confirm it before
599 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has
Daniel Sandlerae069f72010-06-17 21:56:26 -0400600 * also been set.
601 */
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700602 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
Jeff Brown01ce2e92010-09-26 22:20:12 -0700603
604 /** Window flag: when set the window will accept for touch events
605 * outside of its bounds to be sent to other windows that also
606 * support split touch. When this flag is not set, the first pointer
607 * that goes down determines the window to which all subsequent touches
608 * go until all pointers go up. When this flag is set, each pointer
609 * (not necessarily the first) that goes down determines the window
610 * to which all subsequent touches of that pointer will go until that
611 * pointer goes up thereby enabling touches with multiple pointers
612 * to be split across multiple windows.
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800613 */
Jeff Brown01ce2e92010-09-26 22:20:12 -0700614 public static final int FLAG_SPLIT_TOUCH = 0x00800000;
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800615
616 /**
Romain Guy72f0a272011-01-09 16:01:46 -0800617 * <p>Indicates whether this window should be hardware accelerated.
618 * Requesting hardware acceleration does not guarantee it will happen.</p>
619 *
620 * <p>This flag can be controlled programmatically <em>only</em> to enable
621 * hardware acceleration. To enable hardware acceleration for a given
622 * window programmatically, do the following:</p>
623 *
624 * <pre>
625 * Window w = activity.getWindow(); // in Activity's onCreate() for instance
626 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
627 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
628 * </pre>
629 *
630 * <p>It is important to remember that this flag <strong>must</strong>
631 * be set before setting the content view of your activity or dialog.</p>
632 *
633 * <p>This flag cannot be used to disable hardware acceleration after it
634 * was enabled in your manifest using
635 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively
636 * and programmatically disable hardware acceleration (for automated testing
637 * for instance), make sure it is turned off in your manifest and enable it
638 * on your activity or dialog when you need it instead, using the method
639 * described above.</p>
640 *
641 * <p>This flag is automatically set by the system if the
642 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
643 * XML attribute is set to true on an activity or on the application.</p>
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800644 */
645 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
Daniel Sandler611fae42010-06-17 10:45:00 -0400646
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800647 // ----- HIDDEN FLAGS.
648 // These start at the high bit and go down.
Jeff Brown98db5fa2011-06-08 15:37:10 -0700649
650 /** Window flag: Enable touches to slide out of a window into neighboring
651 * windows in mid-gesture instead of being captured for the duration of
652 * the gesture.
653 *
654 * This flag changes the behavior of touch focus for this window only.
655 * Touches can slide out of the window but they cannot necessarily slide
656 * back in (unless the other window with touch focus permits it).
657 *
658 * {@hide}
659 */
660 public static final int FLAG_SLIPPERY = 0x04000000;
661
Daniel Sandlere02d8082010-10-08 15:13:22 -0400662 /**
663 * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU}
664 * and therefore needs a Menu key. For devices where Menu is a physical button this flag is
665 * ignored, but on devices where the Menu key is drawn in software it may be hidden unless
666 * this flag is set.
667 *
668 * (Note that Action Bars, when available, are the preferred way to offer additional
669 * functions otherwise accessed via an options menu.)
670 *
671 * {@hide}
672 */
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800673 public static final int FLAG_NEEDS_MENU_KEY = 0x08000000;
Daniel Sandlere02d8082010-10-08 15:13:22 -0400674
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700675 /** Window flag: *sigh* The lock screen wants to continue running its
676 * animation while it is fading. A kind-of hack to allow this. Maybe
677 * in the future we just make this the default behavior.
678 *
679 * {@hide} */
680 public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000;
681
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700682 /** Window flag: special flag to limit the size of the window to be
683 * original size ([320x480] x density). Used to create window for applications
684 * running under compatibility mode.
685 *
686 * {@hide} */
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700687 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000;
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700688
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800689 /** Window flag: a special option intended for system dialogs. When
690 * this flag is set, the window will demand focus unconditionally when
691 * it is created.
692 * {@hide} */
693 public static final int FLAG_SYSTEM_ERROR = 0x40000000;
694
695 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700696 * Various behavioral options/flags. Default is none.
697 *
698 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
699 * @see #FLAG_DIM_BEHIND
700 * @see #FLAG_NOT_FOCUSABLE
701 * @see #FLAG_NOT_TOUCHABLE
702 * @see #FLAG_NOT_TOUCH_MODAL
703 * @see #FLAG_TOUCHABLE_WHEN_WAKING
704 * @see #FLAG_KEEP_SCREEN_ON
705 * @see #FLAG_LAYOUT_IN_SCREEN
706 * @see #FLAG_LAYOUT_NO_LIMITS
707 * @see #FLAG_FULLSCREEN
708 * @see #FLAG_FORCE_NOT_FULLSCREEN
709 * @see #FLAG_DITHER
710 * @see #FLAG_SECURE
711 * @see #FLAG_SCALED
712 * @see #FLAG_IGNORE_CHEEK_PRESSES
713 * @see #FLAG_LAYOUT_INSET_DECOR
714 * @see #FLAG_ALT_FOCUSABLE_IM
715 * @see #FLAG_WATCH_OUTSIDE_TOUCH
716 * @see #FLAG_SHOW_WHEN_LOCKED
717 * @see #FLAG_SHOW_WALLPAPER
718 * @see #FLAG_TURN_SCREEN_ON
719 * @see #FLAG_DISMISS_KEYGUARD
720 * @see #FLAG_SPLIT_TOUCH
721 * @see #FLAG_HARDWARE_ACCELERATED
722 */
723 @ViewDebug.ExportedProperty(flagMapping = {
724 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
725 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
726 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
727 name = "FLAG_DIM_BEHIND"),
728 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
729 name = "FLAG_BLUR_BEHIND"),
730 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
731 name = "FLAG_NOT_FOCUSABLE"),
732 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
733 name = "FLAG_NOT_TOUCHABLE"),
734 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
735 name = "FLAG_NOT_TOUCH_MODAL"),
736 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
737 name = "FLAG_TOUCHABLE_WHEN_WAKING"),
738 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
739 name = "FLAG_KEEP_SCREEN_ON"),
740 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
741 name = "FLAG_LAYOUT_IN_SCREEN"),
742 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
743 name = "FLAG_LAYOUT_NO_LIMITS"),
744 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
745 name = "FLAG_FULLSCREEN"),
746 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
747 name = "FLAG_FORCE_NOT_FULLSCREEN"),
748 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
749 name = "FLAG_DITHER"),
750 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
751 name = "FLAG_SECURE"),
752 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
753 name = "FLAG_SCALED"),
754 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
755 name = "FLAG_IGNORE_CHEEK_PRESSES"),
756 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
757 name = "FLAG_LAYOUT_INSET_DECOR"),
758 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
759 name = "FLAG_ALT_FOCUSABLE_IM"),
760 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
761 name = "FLAG_WATCH_OUTSIDE_TOUCH"),
762 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
763 name = "FLAG_SHOW_WHEN_LOCKED"),
764 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
765 name = "FLAG_SHOW_WALLPAPER"),
766 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
767 name = "FLAG_TURN_SCREEN_ON"),
768 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
769 name = "FLAG_DISMISS_KEYGUARD"),
770 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
771 name = "FLAG_SPLIT_TOUCH"),
772 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
773 name = "FLAG_HARDWARE_ACCELERATED")
774 })
775 public int flags;
776
777 /**
778 * If the window has requested hardware acceleration, but this is not
779 * allowed in the process it is in, then still render it as if it is
780 * hardware accelerated. This is used for the starting preview windows
781 * in the system process, which don't need to have the overhead of
782 * hardware acceleration (they are just a static rendering), but should
783 * be rendered as much to match the actual window of the app even if it
784 * is hardware accelerated.
785 * Even if the window isn't hardware accelerated, still do its rendering
786 * as if it is.
787 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
788 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
789 * is generally disabled. This flag must be specified in addition to
790 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
791 * windows.
792 *
793 * @hide
794 */
795 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
796
797 /**
798 * In the system process, we globally do not use hardware acceleration
799 * because there are many threads doing UI there and they an conflict.
800 * If certain parts of the UI that really do want to use hardware
801 * acceleration, this flag can be set to force it. This is basically
802 * for the lock screen. Anyone else using it, you are probably wrong.
803 *
804 * @hide
805 */
806 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
807
808 /**
809 * Control flags that are private to the platform.
810 * @hide
811 */
812 public int privateFlags;
813
814 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800815 * Given a particular set of window manager flags, determine whether
816 * such a window may be a target for an input method when it has
817 * focus. In particular, this checks the
818 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
819 * flags and returns true if the combination of the two corresponds
820 * to a window that needs to be behind the input method so that the
821 * user can type into it.
822 *
823 * @param flags The current window manager flags.
824 *
825 * @return Returns true if such a window should be behind/interact
826 * with an input method, false if not.
827 */
828 public static boolean mayUseInputMethod(int flags) {
829 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
830 case 0:
831 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
832 return true;
833 }
834 return false;
835 }
836
837 /**
838 * Mask for {@link #softInputMode} of the bits that determine the
839 * desired visibility state of the soft input area for this window.
840 */
841 public static final int SOFT_INPUT_MASK_STATE = 0x0f;
842
843 /**
844 * Visibility state for {@link #softInputMode}: no state has been specified.
845 */
846 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
847
848 /**
849 * Visibility state for {@link #softInputMode}: please don't change the state of
850 * the soft input area.
851 */
852 public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
853
854 /**
855 * Visibility state for {@link #softInputMode}: please hide any soft input
856 * area when normally appropriate (when the user is navigating
857 * forward to your window).
858 */
859 public static final int SOFT_INPUT_STATE_HIDDEN = 2;
860
861 /**
862 * Visibility state for {@link #softInputMode}: please always hide any
863 * soft input area when this window receives focus.
864 */
865 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
866
867 /**
868 * Visibility state for {@link #softInputMode}: please show the soft
869 * input area when normally appropriate (when the user is navigating
870 * forward to your window).
871 */
872 public static final int SOFT_INPUT_STATE_VISIBLE = 4;
873
874 /**
875 * Visibility state for {@link #softInputMode}: please always make the
876 * soft input area visible when this window receives input focus.
877 */
878 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
879
880 /**
881 * Mask for {@link #softInputMode} of the bits that determine the
882 * way that the window should be adjusted to accommodate the soft
883 * input window.
884 */
885 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
886
887 /** Adjustment option for {@link #softInputMode}: nothing specified.
888 * The system will try to pick one or
889 * the other depending on the contents of the window.
890 */
891 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
892
893 /** Adjustment option for {@link #softInputMode}: set to allow the
894 * window to be resized when an input
895 * method is shown, so that its contents are not covered by the input
Scott Mainf10e6332010-06-11 09:03:22 -0700896 * method. This can <em>not</em> be combined with
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800897 * {@link #SOFT_INPUT_ADJUST_PAN}; if
898 * neither of these are set, then the system will try to pick one or
899 * the other depending on the contents of the window.
900 */
901 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
902
903 /** Adjustment option for {@link #softInputMode}: set to have a window
904 * pan when an input method is
905 * shown, so it doesn't need to deal with resizing but just panned
906 * by the framework to ensure the current input focus is visible. This
Scott Mainf10e6332010-06-11 09:03:22 -0700907 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800908 * neither of these are set, then the system will try to pick one or
909 * the other depending on the contents of the window.
910 */
911 public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
912
Dianne Hackborndea3ef72010-10-28 14:24:22 -0700913 /** Adjustment option for {@link #softInputMode}: set to have a window
914 * not adjust for a shown input method. The window will not be resized,
915 * and it will not be panned to make its focus visible.
916 */
917 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
918
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800919 /**
920 * Bit for {@link #softInputMode}: set when the user has navigated
921 * forward to the window. This is normally set automatically for
922 * you by the system, though you may want to set it in certain cases
923 * when you are displaying a window yourself. This flag will always
924 * be cleared automatically after the window is displayed.
925 */
926 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500927
928 /**
Gilles Debunnebe2c4f92011-01-17 15:14:32 -0800929 * Desired operating mode for any soft input area. May be any combination
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800930 * of:
931 *
932 * <ul>
933 * <li> One of the visibility states
934 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
935 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
936 * {@link #SOFT_INPUT_STATE_VISIBLE}.
937 * <li> One of the adjustment options
938 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
939 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or
940 * {@link #SOFT_INPUT_ADJUST_PAN}.
941 */
942 public int softInputMode;
943
944 /**
Dianne Hackborn8eb2e242010-11-01 12:31:24 -0700945 * Placement of window within the screen as per {@link Gravity}. Both
946 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
947 * android.graphics.Rect) Gravity.apply} and
948 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
949 * Gravity.applyDisplay} are used during window layout, with this value
950 * given as the desired gravity. For example you can specify
951 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and
952 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here
953 * to control the behavior of
954 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
955 * Gravity.applyDisplay}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800956 *
957 * @see Gravity
958 */
959 public int gravity;
960
961 /**
962 * The horizontal margin, as a percentage of the container's width,
Dianne Hackborn8eb2e242010-11-01 12:31:24 -0700963 * between the container and the widget. See
964 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
965 * android.graphics.Rect) Gravity.apply} for how this is used. This
966 * field is added with {@link #x} to supply the <var>xAdj</var> parameter.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800967 */
968 public float horizontalMargin;
969
970 /**
971 * The vertical margin, as a percentage of the container's height,
Dianne Hackborn8eb2e242010-11-01 12:31:24 -0700972 * between the container and the widget. See
973 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
974 * android.graphics.Rect) Gravity.apply} for how this is used. This
975 * field is added with {@link #y} to supply the <var>yAdj</var> parameter.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800976 */
977 public float verticalMargin;
978
979 /**
980 * The desired bitmap format. May be one of the constants in
981 * {@link android.graphics.PixelFormat}. Default is OPAQUE.
982 */
983 public int format;
984
985 /**
986 * A style resource defining the animations to use for this window.
987 * This must be a system resource; it can not be an application resource
988 * because the window manager does not have access to applications.
989 */
990 public int windowAnimations;
991
992 /**
993 * An alpha value to apply to this entire window.
994 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
995 */
996 public float alpha = 1.0f;
997
998 /**
999 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
1000 * to apply. Range is from 1.0 for completely opaque to 0.0 for no
1001 * dim.
1002 */
1003 public float dimAmount = 1.0f;
Dianne Hackborndea3ef72010-10-28 14:24:22 -07001004
1005 /**
1006 * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
1007 * indicating that the brightness value is not overridden for this window
1008 * and normal brightness policy should be used.
1009 */
1010 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
1011
1012 /**
1013 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
1014 * indicating that the screen or button backlight brightness should be set
1015 * to the lowest value when this window is in front.
1016 */
1017 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
1018
1019 /**
1020 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
1021 * indicating that the screen or button backlight brightness should be set
1022 * to the hightest value when this window is in front.
1023 */
1024 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001025
1026 /**
1027 * This can be used to override the user's preferred brightness of
1028 * the screen. A value of less than 0, the default, means to use the
1029 * preferred screen brightness. 0 to 1 adjusts the brightness from
1030 * dark to full bright.
1031 */
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001032 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001033
1034 /**
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001035 * This can be used to override the standard behavior of the button and
1036 * keyboard backlights. A value of less than 0, the default, means to
1037 * use the standard backlight behavior. 0 to 1 adjusts the brightness
1038 * from dark to full bright.
1039 */
1040 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
1041
1042 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001043 * Identifier for this window. This will usually be filled in for
1044 * you.
1045 */
1046 public IBinder token = null;
1047
1048 /**
1049 * Name of the package owning this window.
1050 */
1051 public String packageName = null;
1052
1053 /**
1054 * Specific orientation value for a window.
1055 * May be any of the same values allowed
1056 * for {@link android.content.pm.ActivityInfo#screenOrientation}.
1057 * If not set, a default value of
1058 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
1059 * will be used.
1060 */
1061 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Joe Onorato664644d2011-01-23 17:53:23 -08001062
1063 /**
1064 * Control the visibility of the status bar.
Joe Onorato14782f72011-01-25 19:53:17 -08001065 *
1066 * @see View#STATUS_BAR_VISIBLE
1067 * @see View#STATUS_BAR_HIDDEN
Joe Onorato664644d2011-01-23 17:53:23 -08001068 */
1069 public int systemUiVisibility;
1070
1071 /**
Joe Onorato14782f72011-01-25 19:53:17 -08001072 * @hide
1073 * The ui visibility as requested by the views in this hierarchy.
1074 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility.
1075 */
1076 public int subtreeSystemUiVisibility;
1077
1078 /**
Joe Onorato664644d2011-01-23 17:53:23 -08001079 * Get callbacks about the system ui visibility changing.
1080 *
1081 * TODO: Maybe there should be a bitfield of optional callbacks that we need.
1082 *
1083 * @hide
1084 */
1085 public boolean hasSystemUiListeners;
1086
Jeff Brown474dcb52011-06-14 20:22:50 -07001087 /**
1088 * When this window has focus, disable touch pad pointer gesture processing.
1089 * The window will receive raw position updates from the touch pad instead
1090 * of pointer movements and synthetic touch events.
1091 *
1092 * @hide
1093 */
1094 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001;
1095
1096 /**
Jeff Browncc4f7db2011-08-30 20:34:48 -07001097 * Does not construct an input channel for this window. The channel will therefore
1098 * be incapable of receiving input.
1099 *
1100 * @hide
1101 */
1102 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
1103
1104 /**
Jeff Brown474dcb52011-06-14 20:22:50 -07001105 * Control special features of the input subsystem.
1106 *
1107 * @see #INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES
Jeff Browncc4f7db2011-08-30 20:34:48 -07001108 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL
Jeff Brown474dcb52011-06-14 20:22:50 -07001109 * @hide
1110 */
1111 public int inputFeatures;
1112
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001113 public LayoutParams() {
Romain Guy980a9382010-01-08 15:06:28 -08001114 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001115 type = TYPE_APPLICATION;
1116 format = PixelFormat.OPAQUE;
1117 }
1118
1119 public LayoutParams(int _type) {
Romain Guy980a9382010-01-08 15:06:28 -08001120 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001121 type = _type;
1122 format = PixelFormat.OPAQUE;
1123 }
1124
1125 public LayoutParams(int _type, int _flags) {
Romain Guy980a9382010-01-08 15:06:28 -08001126 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001127 type = _type;
1128 flags = _flags;
1129 format = PixelFormat.OPAQUE;
1130 }
1131
1132 public LayoutParams(int _type, int _flags, int _format) {
Romain Guy980a9382010-01-08 15:06:28 -08001133 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001134 type = _type;
1135 flags = _flags;
1136 format = _format;
1137 }
1138
1139 public LayoutParams(int w, int h, int _type, int _flags, int _format) {
1140 super(w, h);
1141 type = _type;
1142 flags = _flags;
1143 format = _format;
1144 }
1145
1146 public LayoutParams(int w, int h, int xpos, int ypos, int _type,
1147 int _flags, int _format) {
1148 super(w, h);
1149 x = xpos;
1150 y = ypos;
1151 type = _type;
1152 flags = _flags;
1153 format = _format;
1154 }
1155
1156 public final void setTitle(CharSequence title) {
1157 if (null == title)
1158 title = "";
1159
1160 mTitle = TextUtils.stringOrSpannedString(title);
1161 }
1162
1163 public final CharSequence getTitle() {
1164 return mTitle;
1165 }
1166
1167 public int describeContents() {
1168 return 0;
1169 }
1170
1171 public void writeToParcel(Parcel out, int parcelableFlags) {
1172 out.writeInt(width);
1173 out.writeInt(height);
1174 out.writeInt(x);
1175 out.writeInt(y);
1176 out.writeInt(type);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001177 out.writeInt(flags);
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001178 out.writeInt(privateFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001179 out.writeInt(softInputMode);
1180 out.writeInt(gravity);
1181 out.writeFloat(horizontalMargin);
1182 out.writeFloat(verticalMargin);
1183 out.writeInt(format);
1184 out.writeInt(windowAnimations);
1185 out.writeFloat(alpha);
1186 out.writeFloat(dimAmount);
1187 out.writeFloat(screenBrightness);
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001188 out.writeFloat(buttonBrightness);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 out.writeStrongBinder(token);
1190 out.writeString(packageName);
1191 TextUtils.writeToParcel(mTitle, out, parcelableFlags);
1192 out.writeInt(screenOrientation);
Joe Onorato664644d2011-01-23 17:53:23 -08001193 out.writeInt(systemUiVisibility);
Joe Onorato14782f72011-01-25 19:53:17 -08001194 out.writeInt(subtreeSystemUiVisibility);
Joe Onorato664644d2011-01-23 17:53:23 -08001195 out.writeInt(hasSystemUiListeners ? 1 : 0);
Jeff Brown474dcb52011-06-14 20:22:50 -07001196 out.writeInt(inputFeatures);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001197 }
1198
1199 public static final Parcelable.Creator<LayoutParams> CREATOR
1200 = new Parcelable.Creator<LayoutParams>() {
1201 public LayoutParams createFromParcel(Parcel in) {
1202 return new LayoutParams(in);
1203 }
1204
1205 public LayoutParams[] newArray(int size) {
1206 return new LayoutParams[size];
1207 }
1208 };
1209
1210
1211 public LayoutParams(Parcel in) {
1212 width = in.readInt();
1213 height = in.readInt();
1214 x = in.readInt();
1215 y = in.readInt();
1216 type = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001217 flags = in.readInt();
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001218 privateFlags = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001219 softInputMode = in.readInt();
1220 gravity = in.readInt();
1221 horizontalMargin = in.readFloat();
1222 verticalMargin = in.readFloat();
1223 format = in.readInt();
1224 windowAnimations = in.readInt();
1225 alpha = in.readFloat();
1226 dimAmount = in.readFloat();
1227 screenBrightness = in.readFloat();
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001228 buttonBrightness = in.readFloat();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001229 token = in.readStrongBinder();
1230 packageName = in.readString();
1231 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
1232 screenOrientation = in.readInt();
Joe Onorato664644d2011-01-23 17:53:23 -08001233 systemUiVisibility = in.readInt();
Joe Onorato14782f72011-01-25 19:53:17 -08001234 subtreeSystemUiVisibility = in.readInt();
Joe Onorato664644d2011-01-23 17:53:23 -08001235 hasSystemUiListeners = in.readInt() != 0;
Jeff Brown474dcb52011-06-14 20:22:50 -07001236 inputFeatures = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001237 }
1238
Romain Guy72998072009-06-22 11:09:20 -07001239 @SuppressWarnings({"PointlessBitwiseExpression"})
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001240 public static final int LAYOUT_CHANGED = 1<<0;
1241 public static final int TYPE_CHANGED = 1<<1;
1242 public static final int FLAGS_CHANGED = 1<<2;
1243 public static final int FORMAT_CHANGED = 1<<3;
1244 public static final int ANIMATION_CHANGED = 1<<4;
1245 public static final int DIM_AMOUNT_CHANGED = 1<<5;
1246 public static final int TITLE_CHANGED = 1<<6;
1247 public static final int ALPHA_CHANGED = 1<<7;
1248 public static final int MEMORY_TYPE_CHANGED = 1<<8;
1249 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
1250 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
1251 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001252 /** {@hide} */
1253 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12;
Joe Onorato664644d2011-01-23 17:53:23 -08001254 /** {@hide} */
1255 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<13;
1256 /** {@hide} */
1257 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14;
Jeff Brown474dcb52011-06-14 20:22:50 -07001258 /** {@hide} */
1259 public static final int INPUT_FEATURES_CHANGED = 1<<15;
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001260 /** {@hide} */
1261 public static final int PRIVATE_FLAGS_CHANGED = 1<<16;
Romain Guyf21c9b02011-09-06 16:56:54 -07001262 /** {@hide} */
Romain Guyf21c9b02011-09-06 16:56:54 -07001263 public static final int EVERYTHING_CHANGED = 0xffffffff;
1264
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001265 // internal buffer to backup/restore parameters under compatibility mode.
1266 private int[] mCompatibilityParamsBackup = null;
1267
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001268 public final int copyFrom(LayoutParams o) {
1269 int changes = 0;
1270
1271 if (width != o.width) {
1272 width = o.width;
Chet Haase40e03832011-10-06 08:34:13 -07001273 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001274 }
1275 if (height != o.height) {
1276 height = o.height;
Chet Haase40e03832011-10-06 08:34:13 -07001277 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001278 }
1279 if (x != o.x) {
1280 x = o.x;
1281 changes |= LAYOUT_CHANGED;
1282 }
1283 if (y != o.y) {
1284 y = o.y;
1285 changes |= LAYOUT_CHANGED;
1286 }
1287 if (horizontalWeight != o.horizontalWeight) {
1288 horizontalWeight = o.horizontalWeight;
Chet Haase40e03832011-10-06 08:34:13 -07001289 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001290 }
1291 if (verticalWeight != o.verticalWeight) {
1292 verticalWeight = o.verticalWeight;
Chet Haase40e03832011-10-06 08:34:13 -07001293 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001294 }
1295 if (horizontalMargin != o.horizontalMargin) {
1296 horizontalMargin = o.horizontalMargin;
Chet Haase40e03832011-10-06 08:34:13 -07001297 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001298 }
1299 if (verticalMargin != o.verticalMargin) {
1300 verticalMargin = o.verticalMargin;
Chet Haase40e03832011-10-06 08:34:13 -07001301 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001302 }
1303 if (type != o.type) {
1304 type = o.type;
1305 changes |= TYPE_CHANGED;
1306 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001307 if (flags != o.flags) {
1308 flags = o.flags;
Chet Haase40e03832011-10-06 08:34:13 -07001309 changes |= FLAGS_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001310 }
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001311 if (privateFlags != o.privateFlags) {
1312 privateFlags = o.privateFlags;
1313 changes |= PRIVATE_FLAGS_CHANGED;
1314 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001315 if (softInputMode != o.softInputMode) {
1316 softInputMode = o.softInputMode;
1317 changes |= SOFT_INPUT_MODE_CHANGED;
1318 }
1319 if (gravity != o.gravity) {
1320 gravity = o.gravity;
Chet Haase40e03832011-10-06 08:34:13 -07001321 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001322 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001323 if (format != o.format) {
1324 format = o.format;
Chet Haase40e03832011-10-06 08:34:13 -07001325 changes |= FORMAT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001326 }
1327 if (windowAnimations != o.windowAnimations) {
1328 windowAnimations = o.windowAnimations;
1329 changes |= ANIMATION_CHANGED;
1330 }
1331 if (token == null) {
1332 // NOTE: token only copied if the recipient doesn't
1333 // already have one.
1334 token = o.token;
1335 }
1336 if (packageName == null) {
1337 // NOTE: packageName only copied if the recipient doesn't
1338 // already have one.
1339 packageName = o.packageName;
1340 }
1341 if (!mTitle.equals(o.mTitle)) {
1342 mTitle = o.mTitle;
1343 changes |= TITLE_CHANGED;
1344 }
1345 if (alpha != o.alpha) {
1346 alpha = o.alpha;
1347 changes |= ALPHA_CHANGED;
1348 }
1349 if (dimAmount != o.dimAmount) {
1350 dimAmount = o.dimAmount;
1351 changes |= DIM_AMOUNT_CHANGED;
1352 }
1353 if (screenBrightness != o.screenBrightness) {
1354 screenBrightness = o.screenBrightness;
1355 changes |= SCREEN_BRIGHTNESS_CHANGED;
1356 }
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001357 if (buttonBrightness != o.buttonBrightness) {
1358 buttonBrightness = o.buttonBrightness;
1359 changes |= BUTTON_BRIGHTNESS_CHANGED;
1360 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001361
1362 if (screenOrientation != o.screenOrientation) {
1363 screenOrientation = o.screenOrientation;
Chet Haase40e03832011-10-06 08:34:13 -07001364 changes |= SCREEN_ORIENTATION_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001365 }
Romain Guy529b60a2010-08-03 18:05:47 -07001366
Joe Onorato14782f72011-01-25 19:53:17 -08001367 if (systemUiVisibility != o.systemUiVisibility
1368 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
Joe Onorato664644d2011-01-23 17:53:23 -08001369 systemUiVisibility = o.systemUiVisibility;
Joe Onorato14782f72011-01-25 19:53:17 -08001370 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
Joe Onorato664644d2011-01-23 17:53:23 -08001371 changes |= SYSTEM_UI_VISIBILITY_CHANGED;
1372 }
1373
1374 if (hasSystemUiListeners != o.hasSystemUiListeners) {
1375 hasSystemUiListeners = o.hasSystemUiListeners;
1376 changes |= SYSTEM_UI_LISTENER_CHANGED;
1377 }
1378
Jeff Brown474dcb52011-06-14 20:22:50 -07001379 if (inputFeatures != o.inputFeatures) {
1380 inputFeatures = o.inputFeatures;
1381 changes |= INPUT_FEATURES_CHANGED;
1382 }
1383
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001384 return changes;
1385 }
1386
1387 @Override
1388 public String debug(String output) {
1389 output += "Contents of " + this + ":";
1390 Log.d("Debug", output);
1391 output = super.debug("");
1392 Log.d("Debug", output);
1393 Log.d("Debug", "");
1394 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
1395 return "";
1396 }
1397
1398 @Override
1399 public String toString() {
1400 StringBuilder sb = new StringBuilder(256);
1401 sb.append("WM.LayoutParams{");
1402 sb.append("(");
1403 sb.append(x);
1404 sb.append(',');
1405 sb.append(y);
1406 sb.append(")(");
Romain Guy980a9382010-01-08 15:06:28 -08001407 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001408 sb.append('x');
Romain Guy980a9382010-01-08 15:06:28 -08001409 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001410 sb.append(")");
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001411 if (horizontalMargin != 0) {
1412 sb.append(" hm=");
1413 sb.append(horizontalMargin);
1414 }
1415 if (verticalMargin != 0) {
1416 sb.append(" vm=");
1417 sb.append(verticalMargin);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001418 }
1419 if (gravity != 0) {
1420 sb.append(" gr=#");
1421 sb.append(Integer.toHexString(gravity));
1422 }
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001423 if (softInputMode != 0) {
1424 sb.append(" sim=#");
1425 sb.append(Integer.toHexString(softInputMode));
1426 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001427 sb.append(" ty=");
1428 sb.append(type);
1429 sb.append(" fl=#");
1430 sb.append(Integer.toHexString(flags));
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001431 if (privateFlags != 0) {
1432 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags));
1433 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001434 if (format != PixelFormat.OPAQUE) {
1435 sb.append(" fmt=");
1436 sb.append(format);
1437 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001438 if (windowAnimations != 0) {
1439 sb.append(" wanim=0x");
1440 sb.append(Integer.toHexString(windowAnimations));
1441 }
1442 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
1443 sb.append(" or=");
1444 sb.append(screenOrientation);
1445 }
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001446 if (alpha != 1.0f) {
1447 sb.append(" alpha=");
1448 sb.append(alpha);
1449 }
1450 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) {
1451 sb.append(" sbrt=");
1452 sb.append(screenBrightness);
1453 }
1454 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) {
1455 sb.append(" bbrt=");
1456 sb.append(buttonBrightness);
1457 }
Mitsuru Oshima5a2b91d2009-07-16 16:30:02 -07001458 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) {
1459 sb.append(" compatible=true");
1460 }
Joe Onorato664644d2011-01-23 17:53:23 -08001461 if (systemUiVisibility != 0) {
1462 sb.append(" sysui=0x");
1463 sb.append(Integer.toHexString(systemUiVisibility));
1464 }
Joe Onorato14782f72011-01-25 19:53:17 -08001465 if (subtreeSystemUiVisibility != 0) {
1466 sb.append(" vsysui=0x");
1467 sb.append(Integer.toHexString(subtreeSystemUiVisibility));
1468 }
Joe Onorato664644d2011-01-23 17:53:23 -08001469 if (hasSystemUiListeners) {
1470 sb.append(" sysuil=");
1471 sb.append(hasSystemUiListeners);
1472 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001473 if (inputFeatures != 0) {
1474 sb.append(" if=0x").append(Integer.toHexString(inputFeatures));
1475 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001476 sb.append('}');
1477 return sb.toString();
1478 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001479
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001480 /**
1481 * Scale the layout params' coordinates and size.
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001482 * @hide
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001483 */
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001484 public void scale(float scale) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001485 x = (int) (x * scale + 0.5f);
1486 y = (int) (y * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001487 if (width > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001488 width = (int) (width * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001489 }
1490 if (height > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001491 height = (int) (height * scale + 0.5f);
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001492 }
1493 }
1494
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001495 /**
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001496 * Backup the layout parameters used in compatibility mode.
1497 * @see LayoutParams#restore()
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001498 */
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001499 void backup() {
1500 int[] backup = mCompatibilityParamsBackup;
1501 if (backup == null) {
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001502 // we backup 4 elements, x, y, width, height
1503 backup = mCompatibilityParamsBackup = new int[4];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001504 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001505 backup[0] = x;
1506 backup[1] = y;
1507 backup[2] = width;
1508 backup[3] = height;
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001509 }
1510
1511 /**
1512 * Restore the layout params' coordinates, size and gravity
1513 * @see LayoutParams#backup()
1514 */
1515 void restore() {
1516 int[] backup = mCompatibilityParamsBackup;
1517 if (backup != null) {
1518 x = backup[0];
1519 y = backup[1];
1520 width = backup[2];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001521 height = backup[3];
1522 }
1523 }
1524
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001525 private CharSequence mTitle = "";
1526 }
1527}