blob: fa2d4e8ee7bf11e413ca79803dfde66dd68a0162 [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
Jeff Browna492c3a2012-08-23 19:48:44 -070019import android.app.Presentation;
20import android.content.Context;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.pm.ActivityInfo;
22import android.graphics.PixelFormat;
23import android.os.IBinder;
24import android.os.Parcel;
25import android.os.Parcelable;
26import android.text.TextUtils;
27import android.util.Log;
28
29
30/**
31 * The interface that apps use to talk to the window manager.
32 * <p>
33 * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these.
Jeff Browna492c3a2012-08-23 19:48:44 -070034 * </p><p>
35 * Each window manager instance is bound to a particular {@link Display}.
36 * To obtain a {@link WindowManager} for a different display, use
37 * {@link Context#createDisplayContext} to obtain a {@link Context} for that
38 * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code>
39 * to get the WindowManager.
40 * </p><p>
41 * The simplest way to show a window on another display is to create a
42 * {@link Presentation}. The presentation will automatically obtain a
43 * {@link WindowManager} and {@link Context} for that display.
44 * </p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045 *
46 * @see android.content.Context#getSystemService
47 * @see android.content.Context#WINDOW_SERVICE
48 */
49public interface WindowManager extends ViewManager {
50 /**
51 * Exception that is thrown when trying to add view whose
52 * {@link WindowManager.LayoutParams} {@link WindowManager.LayoutParams#token}
53 * is invalid.
54 */
55 public static class BadTokenException extends RuntimeException {
56 public BadTokenException() {
57 }
58
59 public BadTokenException(String name) {
60 super(name);
61 }
62 }
63
64 /**
Jeff Browna492c3a2012-08-23 19:48:44 -070065 * Returns the {@link Display} upon which this {@link WindowManager} instance
66 * will create new windows.
67 * <p>
68 * Despite the name of this method, the display that is returned is not
69 * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}).
70 * The returned display could instead be a secondary display that this
71 * window manager instance is managing. Think of it as the display that
72 * this {@link WindowManager} instance uses by default.
73 * </p><p>
74 * To create windows on a different display, you need to obtain a
75 * {@link WindowManager} for that {@link Display}. (See the {@link WindowManager}
76 * class documentation for more information.)
77 * </p>
78 *
79 * @return The display that this window manager is managing.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080 */
81 public Display getDefaultDisplay();
Jeff Browna492c3a2012-08-23 19:48:44 -070082
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 /**
84 * Special variation of {@link #removeView} that immediately invokes
85 * the given view hierarchy's {@link View#onDetachedFromWindow()
86 * View.onDetachedFromWindow()} methods before returning. This is not
87 * for normal applications; using it correctly requires great care.
88 *
89 * @param view The view to be removed.
90 */
91 public void removeViewImmediate(View view);
Jeff Brownd32460c2012-07-20 16:15:36 -070092
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093 public static class LayoutParams extends ViewGroup.LayoutParams
94 implements Parcelable {
95 /**
96 * X position for this window. With the default gravity it is ignored.
Fabrice Di Meglio9e3b0022011-06-06 16:30:29 -070097 * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or
98 * {@link Gravity#END} it provides an offset from the given edge.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 */
Romain Guy529b60a2010-08-03 18:05:47 -0700100 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 public int x;
102
103 /**
104 * Y position for this window. With the default gravity it is ignored.
105 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
106 * an offset from the given edge.
107 */
Romain Guy529b60a2010-08-03 18:05:47 -0700108 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109 public int y;
110
111 /**
112 * Indicates how much of the extra space will be allocated horizontally
113 * to the view associated with these LayoutParams. Specify 0 if the view
114 * should not be stretched. Otherwise the extra pixels will be pro-rated
115 * among all views whose weight is greater than 0.
116 */
Romain Guy529b60a2010-08-03 18:05:47 -0700117 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 public float horizontalWeight;
119
120 /**
121 * Indicates how much of the extra space will be allocated vertically
122 * to the view associated with these LayoutParams. Specify 0 if the view
123 * should not be stretched. Otherwise the extra pixels will be pro-rated
124 * among all views whose weight is greater than 0.
125 */
Romain Guy529b60a2010-08-03 18:05:47 -0700126 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800127 public float verticalWeight;
Romain Guy529b60a2010-08-03 18:05:47 -0700128
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129 /**
130 * The general type of window. There are three main classes of
131 * window types:
132 * <ul>
133 * <li> <strong>Application windows</strong> (ranging from
134 * {@link #FIRST_APPLICATION_WINDOW} to
135 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
136 * windows. For these types of windows, the {@link #token} must be
137 * set to the token of the activity they are a part of (this will
138 * normally be done for you if {@link #token} is null).
139 * <li> <strong>Sub-windows</strong> (ranging from
140 * {@link #FIRST_SUB_WINDOW} to
141 * {@link #LAST_SUB_WINDOW}) are associated with another top-level
142 * window. For these types of windows, the {@link #token} must be
143 * the token of the window it is attached to.
144 * <li> <strong>System windows</strong> (ranging from
145 * {@link #FIRST_SYSTEM_WINDOW} to
146 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
147 * use by the system for specific purposes. They should not normally
148 * be used by applications, and a special permission is required
149 * to use them.
150 * </ul>
151 *
152 * @see #TYPE_BASE_APPLICATION
153 * @see #TYPE_APPLICATION
154 * @see #TYPE_APPLICATION_STARTING
155 * @see #TYPE_APPLICATION_PANEL
156 * @see #TYPE_APPLICATION_MEDIA
157 * @see #TYPE_APPLICATION_SUB_PANEL
158 * @see #TYPE_APPLICATION_ATTACHED_DIALOG
159 * @see #TYPE_STATUS_BAR
160 * @see #TYPE_SEARCH_BAR
161 * @see #TYPE_PHONE
162 * @see #TYPE_SYSTEM_ALERT
163 * @see #TYPE_KEYGUARD
164 * @see #TYPE_TOAST
165 * @see #TYPE_SYSTEM_OVERLAY
166 * @see #TYPE_PRIORITY_PHONE
167 * @see #TYPE_STATUS_BAR_PANEL
168 * @see #TYPE_SYSTEM_DIALOG
169 * @see #TYPE_KEYGUARD_DIALOG
170 * @see #TYPE_SYSTEM_ERROR
171 * @see #TYPE_INPUT_METHOD
172 * @see #TYPE_INPUT_METHOD_DIALOG
173 */
Joe Onorato8f2bd432010-03-25 11:45:28 -0700174 @ViewDebug.ExportedProperty(mapping = {
175 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"),
176 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"),
177 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"),
178 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"),
179 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"),
180 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"),
181 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"),
Scott Andersonaeb77232012-05-31 18:55:54 -0700182 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY, to = "TYPE_APPLICATION_MEDIA_OVERLAY"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700183 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"),
184 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"),
185 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"),
186 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"),
187 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"),
188 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"),
189 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"),
190 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700191 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"),
192 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"),
193 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"),
194 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"),
Jeff Brown3b2b3542010-10-15 00:54:27 -0700195 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"),
Jeff Brownbfcb60a2011-09-08 18:51:14 -0700196 @ViewDebug.IntToString(from = TYPE_WALLPAPER, to = "TYPE_WALLPAPER"),
197 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"),
Dianne Hackborn29aae6f2011-08-18 18:30:09 -0700198 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"),
Jeff Brownbfcb60a2011-09-08 18:51:14 -0700199 @ViewDebug.IntToString(from = TYPE_DRAG, to = "TYPE_DRAG"),
200 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"),
201 @ViewDebug.IntToString(from = TYPE_POINTER, to = "TYPE_POINTER"),
202 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, to = "TYPE_NAVIGATION_BAR"),
203 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, to = "TYPE_VOLUME_OVERLAY"),
Scott Andersonaeb77232012-05-31 18:55:54 -0700204 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS"),
205 @ViewDebug.IntToString(from = TYPE_HIDDEN_NAV_CONSUMER, to = "TYPE_HIDDEN_NAV_CONSUMER"),
206 @ViewDebug.IntToString(from = TYPE_DREAM, to = "TYPE_DREAM"),
Jeff Brownbd6e1502012-08-28 03:27:37 -0700207 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL, to = "TYPE_NAVIGATION_BAR_PANEL"),
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700208 @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY, to = "TYPE_DISPLAY_OVERLAY"),
209 @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY, to = "TYPE_MAGNIFICATION_OVERLAY")
Joe Onorato8f2bd432010-03-25 11:45:28 -0700210 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 public int type;
212
213 /**
214 * Start of window types that represent normal application windows.
215 */
216 public static final int FIRST_APPLICATION_WINDOW = 1;
217
218 /**
219 * Window type: an application window that serves as the "base" window
220 * of the overall application; all other application windows will
221 * appear on top of it.
222 */
223 public static final int TYPE_BASE_APPLICATION = 1;
224
225 /**
226 * Window type: a normal application window. The {@link #token} must be
227 * an Activity token identifying who the window belongs to.
228 */
229 public static final int TYPE_APPLICATION = 2;
230
231 /**
232 * Window type: special application window that is displayed while the
233 * application is starting. Not for use by applications themselves;
234 * this is used by the system to display something until the
235 * application can show its own windows.
236 */
237 public static final int TYPE_APPLICATION_STARTING = 3;
238
239 /**
240 * End of types of application windows.
241 */
242 public static final int LAST_APPLICATION_WINDOW = 99;
243
244 /**
245 * Start of types of sub-windows. The {@link #token} of these windows
246 * must be set to the window they are attached to. These types of
247 * windows are kept next to their attached window in Z-order, and their
248 * coordinate space is relative to their attached window.
249 */
250 public static final int FIRST_SUB_WINDOW = 1000;
251
252 /**
253 * Window type: a panel on top of an application window. These windows
254 * appear on top of their attached window.
255 */
256 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
257
258 /**
259 * Window type: window for showing media (e.g. video). These windows
260 * are displayed behind their attached window.
261 */
262 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1;
263
264 /**
265 * Window type: a sub-panel on top of an application window. These
266 * windows are displayed on top their attached window and any
267 * {@link #TYPE_APPLICATION_PANEL} panels.
268 */
269 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2;
270
271 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
272 * of the window happens as that of a top-level window, <em>not</em>
273 * as a child of its container.
274 */
275 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3;
276
277 /**
Dianne Hackbornc4d5d022009-05-21 17:32:42 -0700278 * Window type: window for showing overlays on top of media windows.
279 * These windows are displayed between TYPE_APPLICATION_MEDIA and the
280 * application window. They should be translucent to be useful. This
281 * is a big ugly hack so:
282 * @hide
283 */
284 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4;
285
286 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287 * End of types of sub-windows.
288 */
289 public static final int LAST_SUB_WINDOW = 1999;
290
291 /**
292 * Start of system-specific window types. These are not normally
293 * created by applications.
294 */
295 public static final int FIRST_SYSTEM_WINDOW = 2000;
296
297 /**
298 * Window type: the status bar. There can be only one status bar
299 * window; it is placed at the top of the screen, and all other
300 * windows are shifted down so they are below it.
301 */
302 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
303
304 /**
305 * Window type: the search bar. There can be only one search bar
306 * window; it is placed at the top of the screen.
307 */
308 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
309
310 /**
311 * Window type: phone. These are non-application windows providing
312 * user interaction with the phone (in particular incoming calls).
313 * These windows are normally placed above all applications, but behind
314 * the status bar.
315 */
316 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
317
318 /**
319 * Window type: system window, such as low power alert. These windows
320 * are always on top of application windows.
321 */
322 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
323
324 /**
325 * Window type: keyguard window.
326 */
327 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
328
329 /**
330 * Window type: transient notifications.
331 */
332 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
333
334 /**
335 * Window type: system overlay windows, which need to be displayed
336 * on top of everything else. These windows must not take input
337 * focus, or they will interfere with the keyguard.
338 */
339 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
340
341 /**
342 * Window type: priority phone UI, which needs to be displayed even if
343 * the keyguard is active. These windows must not take input
344 * focus, or they will interfere with the keyguard.
345 */
346 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
347
348 /**
349 * Window type: panel that slides out from the status bar
350 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800351 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
352
353 /**
354 * Window type: dialogs that the keyguard shows
355 */
356 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
357
358 /**
359 * Window type: internal system error windows, appear on top of
360 * everything they can.
361 */
362 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
363
364 /**
365 * Window type: internal input methods windows, which appear above
366 * the normal UI. Application windows may be resized or panned to keep
367 * the input focus visible while this window is displayed.
368 */
369 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
370
371 /**
372 * Window type: internal input methods dialog windows, which appear above
373 * the current input method window.
374 */
375 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
376
377 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700378 * Window type: wallpaper window, placed behind any window that wants
379 * to sit on top of the wallpaper.
380 */
381 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
382
383 /**
Joe Onorato29fc2c92010-11-24 10:26:50 -0800384 * Window type: panel that slides out from over the status bar
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800385 */
386 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
Jeff Brown3b2b3542010-10-15 00:54:27 -0700387
388 /**
389 * Window type: secure system overlay windows, which need to be displayed
390 * on top of everything else. These windows must not take input
391 * focus, or they will interfere with the keyguard.
392 *
393 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
394 * system itself is allowed to create these overlays. Applications cannot
395 * obtain permission to create secure system overlays.
396 * @hide
397 */
398 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
399
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800400 /**
Christopher Tatea53146c2010-09-07 11:57:52 -0700401 * Window type: the drag-and-drop pseudowindow. There is only one
402 * drag layer (at most), and it is placed on top of all other windows.
403 * @hide
404 */
Jeff Brown3b2b3542010-10-15 00:54:27 -0700405 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16;
Christopher Tatea53146c2010-09-07 11:57:52 -0700406
407 /**
Joe Onorato29fc2c92010-11-24 10:26:50 -0800408 * Window type: panel that slides out from under the status bar
Joe Onoratoa89e9032010-11-24 11:13:44 -0800409 * @hide
Joe Onorato29fc2c92010-11-24 10:26:50 -0800410 */
411 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
412
Jeff Brown83c09682010-12-23 17:50:18 -0800413 /**
414 * Window type: (mouse) pointer
415 * @hide
416 */
417 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
Joe Onorato29fc2c92010-11-24 10:26:50 -0800418
419 /**
Daniel Sandler8956dbb2011-04-22 07:55:02 -0400420 * Window type: Navigation bar (when distinct from status bar)
421 * @hide
422 */
423 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
424
425 /**
Dianne Hackborne8ecde12011-08-03 18:55:19 -0700426 * Window type: The volume level overlay/dialog shown when the user
427 * changes the system volume.
428 * @hide
429 */
430 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
431
432 /**
Dianne Hackborn29aae6f2011-08-18 18:30:09 -0700433 * Window type: The boot progress dialog, goes on top of everything
434 * in the world.
435 * @hide
436 */
437 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
438
439 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -0700440 * Window type: Fake window to consume touch events when the navigation
441 * bar is hidden.
442 * @hide
443 */
444 public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22;
445
446 /**
Daniel Sandler7d276c32012-01-30 14:33:52 -0500447 * Window type: Dreams (screen saver) window, just above keyguard.
448 * @hide
449 */
450 public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
451
452 /**
Jim Millere898ac52012-04-06 17:10:57 -0700453 * Window type: Navigation bar panel (when navigation bar is distinct from status bar)
454 * @hide
455 */
456 public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
457
458 /**
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700459 * Window type: Behind the universe of the real windows.
460 * @hide
461 */
462 public static final int TYPE_UNIVERSE_BACKGROUND = FIRST_SYSTEM_WINDOW+25;
463
464 /**
Jeff Brownbd6e1502012-08-28 03:27:37 -0700465 * Window type: Display overlay window. Used to simulate secondary display devices.
466 * @hide
467 */
468 public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26;
469
470 /**
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -0700471 * Window type: Magnification overlay window. Used to highlight the magnified
472 * portion of a display when accessibility magnification is enabled.
473 * @hide
474 */
475 public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27;
476
477 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800478 * End of types of system windows.
479 */
480 public static final int LAST_SYSTEM_WINDOW = 2999;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800481
Mathias Agopiand2112302010-12-07 19:38:17 -0800482 /** @deprecated this is ignored, this value is set automatically when needed. */
483 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800484 public static final int MEMORY_TYPE_NORMAL = 0;
Mathias Agopiand2112302010-12-07 19:38:17 -0800485 /** @deprecated this is ignored, this value is set automatically when needed. */
Mathias Agopian317a6282009-08-13 17:29:02 -0700486 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800487 public static final int MEMORY_TYPE_HARDWARE = 1;
Mathias Agopiand2112302010-12-07 19:38:17 -0800488 /** @deprecated this is ignored, this value is set automatically when needed. */
Mathias Agopian317a6282009-08-13 17:29:02 -0700489 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800490 public static final int MEMORY_TYPE_GPU = 2;
Mathias Agopiand2112302010-12-07 19:38:17 -0800491 /** @deprecated this is ignored, this value is set automatically when needed. */
492 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800493 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700494
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800495 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700496 * @deprecated this is ignored
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800497 */
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700498 @Deprecated
499 public int memoryType;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800500
Mike Lockwoodef731622010-01-27 17:51:34 -0500501 /** Window flag: as long as this window is visible to the user, allow
502 * the lock screen to activate while the screen is on.
503 * This can be used independently, or in combination with
Christopher Tate95f78502010-01-29 15:57:34 -0800504 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
Mike Lockwoodef731622010-01-27 17:51:34 -0500505 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001;
506
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800507 /** Window flag: everything behind this window will be dimmed.
508 * Use {@link #dimAmount} to control the amount of dim. */
509 public static final int FLAG_DIM_BEHIND = 0x00000002;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700510
511 /** Window flag: blur everything behind this window.
512 * @deprecated Blurring is no longer supported. */
513 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800514 public static final int FLAG_BLUR_BEHIND = 0x00000004;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700515
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800516 /** Window flag: this window won't ever get key input focus, so the
517 * user can not send key or other button events to it. Those will
518 * instead go to whatever focusable window is behind it. This flag
519 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
520 * is explicitly set.
521 *
522 * <p>Setting this flag also implies that the window will not need to
523 * interact with
524 * a soft input method, so it will be Z-ordered and positioned
525 * independently of any active input method (typically this means it
526 * gets Z-ordered on top of the input method, so it can use the full
527 * screen for its content and cover the input method if needed. You
528 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
529 public static final int FLAG_NOT_FOCUSABLE = 0x00000008;
530
531 /** Window flag: this window can never receive touch events. */
532 public static final int FLAG_NOT_TOUCHABLE = 0x00000010;
533
534 /** Window flag: Even when this window is focusable (its
535 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events
536 * outside of the window to be sent to the windows behind it. Otherwise
537 * it will consume all pointer events itself, regardless of whether they
538 * are inside of the window. */
539 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020;
540
541 /** Window flag: When set, if the device is asleep when the touch
542 * screen is pressed, you will receive this first touch event. Usually
543 * the first touch event is consumed by the system since the user can
544 * not see what they are pressing on.
545 */
546 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
547
548 /** Window flag: as long as this window is visible to the user, keep
549 * the device's screen turned on and bright. */
550 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080;
551
552 /** Window flag: place the window within the entire screen, ignoring
553 * decorations around the border (a.k.a. the status bar). The
554 * window must correctly position its contents to take the screen
555 * decoration into account. This flag is normally set for you
556 * by Window as described in {@link Window#setFlags}. */
557 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100;
558
559 /** Window flag: allow window to extend outside of the screen. */
560 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200;
561
562 /** Window flag: Hide all screen decorations (e.g. status bar) while
563 * this window is displayed. This allows the window to use the entire
564 * display space for itself -- the status bar will be hidden when
565 * an app window with this flag set is on the top layer. */
566 public static final int FLAG_FULLSCREEN = 0x00000400;
567
568 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the
569 * screen decorations (such as status bar) to be shown. */
570 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800;
571
572 /** Window flag: turn on dithering when compositing this window to
Jeff Brown3cc321e2012-07-16 16:04:23 -0700573 * the screen.
574 * @deprecated This flag is no longer used. */
575 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800576 public static final int FLAG_DITHER = 0x00001000;
577
578 /** Window flag: don't allow screen shots while this window is
Glenn Kastend6f5bde2011-01-19 15:27:27 -0800579 * displayed. Maps to Surface.SECURE. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800580 public static final int FLAG_SECURE = 0x00002000;
581
582 /** Window flag: a special mode where the layout parameters are used
583 * to perform scaling of the surface when it is composited to the
584 * screen. */
585 public static final int FLAG_SCALED = 0x00004000;
586
587 /** Window flag: intended for windows that will often be used when the user is
588 * holding the screen against their face, it will aggressively filter the event
589 * stream to prevent unintended presses in this situation that may not be
590 * desired for a particular window, when such an event stream is detected, the
591 * application will receive a CANCEL motion event to indicate this so applications
592 * can handle this accordingly by taking no action on the event
593 * until the finger is released. */
594 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000;
595
596 /** Window flag: a special option only for use in combination with
597 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the
598 * screen your window may appear on top of or behind screen decorations
599 * such as the status bar. By also including this flag, the window
600 * manager will report the inset rectangle needed to ensure your
601 * content is not covered by screen decorations. This flag is normally
602 * set for you by Window as described in {@link Window#setFlags}.*/
603 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
604
605 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
606 * respect to how this window interacts with the current method. That
607 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
608 * window will behave as if it needs to interact with the input method
609 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
610 * not set and this flag is set, then the window will behave as if it
611 * doesn't need to interact with the input method and can be placed
612 * to use more space and cover the input method.
613 */
614 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
615
616 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
617 * can set this flag to receive a single special MotionEvent with
618 * the action
619 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
620 * touches that occur outside of your window. Note that you will not
621 * receive the full down/move/up gesture, only the location of the
622 * first down as an ACTION_OUTSIDE.
623 */
624 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
625
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700626 /** Window flag: special flag to let windows be shown when the screen
627 * is locked. This will let application windows take precedence over
628 * key guard or any other lock screens. Can be used with
629 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700630 * directly before showing the key guard window. Can be used with
631 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
632 * non-secure keyguards. This flag only applies to the top-most
633 * full-screen window.
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700634 */
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700635 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
636
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700637 /** Window flag: ask that the system wallpaper be shown behind
638 * your window. The window surface must be translucent to be able
639 * to actually see the wallpaper behind it; this flag just ensures
640 * that the wallpaper surface will be there if this window actually
641 * has translucent regions.
642 */
643 public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
644
Dianne Hackborn93e462b2009-09-15 22:50:40 -0700645 /** Window flag: when set as a window is being added or made
646 * visible, once the window has been shown then the system will
647 * poke the power manager's user activity (as if the user had woken
648 * up the device) to turn the screen on. */
649 public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
650
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700651 /** Window flag: when set the window will cause the keyguard to
652 * be dismissed, only if it is not a secure lock keyguard. Because such
653 * a keyguard is not needed for security, it will never re-appear if
654 * the user navigates to another window (in contrast to
655 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
656 * hide both secure and non-secure keyguards but ensure they reappear
657 * when the user moves to another UI that doesn't hide them).
658 * If the keyguard is currently active and is secure (requires an
659 * unlock pattern) than the user will still need to confirm it before
660 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has
Daniel Sandlerae069f72010-06-17 21:56:26 -0400661 * also been set.
662 */
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700663 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
Jeff Brown01ce2e92010-09-26 22:20:12 -0700664
665 /** Window flag: when set the window will accept for touch events
666 * outside of its bounds to be sent to other windows that also
667 * support split touch. When this flag is not set, the first pointer
668 * that goes down determines the window to which all subsequent touches
669 * go until all pointers go up. When this flag is set, each pointer
670 * (not necessarily the first) that goes down determines the window
671 * to which all subsequent touches of that pointer will go until that
672 * pointer goes up thereby enabling touches with multiple pointers
673 * to be split across multiple windows.
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800674 */
Jeff Brown01ce2e92010-09-26 22:20:12 -0700675 public static final int FLAG_SPLIT_TOUCH = 0x00800000;
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800676
677 /**
Romain Guy72f0a272011-01-09 16:01:46 -0800678 * <p>Indicates whether this window should be hardware accelerated.
679 * Requesting hardware acceleration does not guarantee it will happen.</p>
680 *
681 * <p>This flag can be controlled programmatically <em>only</em> to enable
682 * hardware acceleration. To enable hardware acceleration for a given
683 * window programmatically, do the following:</p>
684 *
685 * <pre>
686 * Window w = activity.getWindow(); // in Activity's onCreate() for instance
687 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
688 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
689 * </pre>
690 *
691 * <p>It is important to remember that this flag <strong>must</strong>
692 * be set before setting the content view of your activity or dialog.</p>
693 *
694 * <p>This flag cannot be used to disable hardware acceleration after it
695 * was enabled in your manifest using
696 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively
697 * and programmatically disable hardware acceleration (for automated testing
698 * for instance), make sure it is turned off in your manifest and enable it
699 * on your activity or dialog when you need it instead, using the method
700 * described above.</p>
701 *
702 * <p>This flag is automatically set by the system if the
703 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
704 * XML attribute is set to true on an activity or on the application.</p>
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800705 */
706 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
Daniel Sandler611fae42010-06-17 10:45:00 -0400707
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800708 // ----- HIDDEN FLAGS.
709 // These start at the high bit and go down.
Jeff Brown98db5fa2011-06-08 15:37:10 -0700710
711 /** Window flag: Enable touches to slide out of a window into neighboring
712 * windows in mid-gesture instead of being captured for the duration of
713 * the gesture.
714 *
715 * This flag changes the behavior of touch focus for this window only.
716 * Touches can slide out of the window but they cannot necessarily slide
717 * back in (unless the other window with touch focus permits it).
718 *
719 * {@hide}
720 */
721 public static final int FLAG_SLIPPERY = 0x04000000;
722
Daniel Sandlere02d8082010-10-08 15:13:22 -0400723 /**
724 * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU}
725 * and therefore needs a Menu key. For devices where Menu is a physical button this flag is
726 * ignored, but on devices where the Menu key is drawn in software it may be hidden unless
727 * this flag is set.
728 *
729 * (Note that Action Bars, when available, are the preferred way to offer additional
730 * functions otherwise accessed via an options menu.)
731 *
732 * {@hide}
733 */
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800734 public static final int FLAG_NEEDS_MENU_KEY = 0x08000000;
Daniel Sandlere02d8082010-10-08 15:13:22 -0400735
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700736 /** Window flag: special flag to limit the size of the window to be
737 * original size ([320x480] x density). Used to create window for applications
738 * running under compatibility mode.
739 *
740 * {@hide} */
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700741 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000;
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700742
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800743 /** Window flag: a special option intended for system dialogs. When
744 * this flag is set, the window will demand focus unconditionally when
745 * it is created.
746 * {@hide} */
747 public static final int FLAG_SYSTEM_ERROR = 0x40000000;
748
749 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700750 * Various behavioral options/flags. Default is none.
751 *
752 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
753 * @see #FLAG_DIM_BEHIND
754 * @see #FLAG_NOT_FOCUSABLE
755 * @see #FLAG_NOT_TOUCHABLE
756 * @see #FLAG_NOT_TOUCH_MODAL
757 * @see #FLAG_TOUCHABLE_WHEN_WAKING
758 * @see #FLAG_KEEP_SCREEN_ON
759 * @see #FLAG_LAYOUT_IN_SCREEN
760 * @see #FLAG_LAYOUT_NO_LIMITS
761 * @see #FLAG_FULLSCREEN
762 * @see #FLAG_FORCE_NOT_FULLSCREEN
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700763 * @see #FLAG_SECURE
764 * @see #FLAG_SCALED
765 * @see #FLAG_IGNORE_CHEEK_PRESSES
766 * @see #FLAG_LAYOUT_INSET_DECOR
767 * @see #FLAG_ALT_FOCUSABLE_IM
768 * @see #FLAG_WATCH_OUTSIDE_TOUCH
769 * @see #FLAG_SHOW_WHEN_LOCKED
770 * @see #FLAG_SHOW_WALLPAPER
771 * @see #FLAG_TURN_SCREEN_ON
772 * @see #FLAG_DISMISS_KEYGUARD
773 * @see #FLAG_SPLIT_TOUCH
774 * @see #FLAG_HARDWARE_ACCELERATED
775 */
776 @ViewDebug.ExportedProperty(flagMapping = {
777 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
778 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
779 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
780 name = "FLAG_DIM_BEHIND"),
781 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
782 name = "FLAG_BLUR_BEHIND"),
783 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
784 name = "FLAG_NOT_FOCUSABLE"),
785 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
786 name = "FLAG_NOT_TOUCHABLE"),
787 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
788 name = "FLAG_NOT_TOUCH_MODAL"),
789 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
790 name = "FLAG_TOUCHABLE_WHEN_WAKING"),
791 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
792 name = "FLAG_KEEP_SCREEN_ON"),
793 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
794 name = "FLAG_LAYOUT_IN_SCREEN"),
795 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
796 name = "FLAG_LAYOUT_NO_LIMITS"),
797 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
798 name = "FLAG_FULLSCREEN"),
799 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
800 name = "FLAG_FORCE_NOT_FULLSCREEN"),
801 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
802 name = "FLAG_DITHER"),
803 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
804 name = "FLAG_SECURE"),
805 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
806 name = "FLAG_SCALED"),
807 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
808 name = "FLAG_IGNORE_CHEEK_PRESSES"),
809 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
810 name = "FLAG_LAYOUT_INSET_DECOR"),
811 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
812 name = "FLAG_ALT_FOCUSABLE_IM"),
813 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
814 name = "FLAG_WATCH_OUTSIDE_TOUCH"),
815 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
816 name = "FLAG_SHOW_WHEN_LOCKED"),
817 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
818 name = "FLAG_SHOW_WALLPAPER"),
819 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
820 name = "FLAG_TURN_SCREEN_ON"),
821 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
822 name = "FLAG_DISMISS_KEYGUARD"),
823 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
824 name = "FLAG_SPLIT_TOUCH"),
825 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
826 name = "FLAG_HARDWARE_ACCELERATED")
827 })
828 public int flags;
829
830 /**
831 * If the window has requested hardware acceleration, but this is not
832 * allowed in the process it is in, then still render it as if it is
833 * hardware accelerated. This is used for the starting preview windows
834 * in the system process, which don't need to have the overhead of
835 * hardware acceleration (they are just a static rendering), but should
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900836 * be rendered as such to match the actual window of the app even if it
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700837 * is hardware accelerated.
838 * Even if the window isn't hardware accelerated, still do its rendering
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900839 * as if it was.
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700840 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
841 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
842 * is generally disabled. This flag must be specified in addition to
843 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
844 * windows.
845 *
846 * @hide
847 */
848 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
849
850 /**
851 * In the system process, we globally do not use hardware acceleration
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900852 * because there are many threads doing UI there and they conflict.
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700853 * If certain parts of the UI that really do want to use hardware
854 * acceleration, this flag can be set to force it. This is basically
855 * for the lock screen. Anyone else using it, you are probably wrong.
856 *
857 * @hide
858 */
859 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
860
861 /**
Chet Haasea8e5a2b2011-10-28 13:18:16 -0700862 * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900863 * may elect to skip these notifications if they are not doing anything productive with
Chet Haasea8e5a2b2011-10-28 13:18:16 -0700864 * them (they do not affect the wallpaper scrolling operation) by calling
865 * {@link
866 * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}.
867 *
868 * @hide
869 */
870 public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004;
871
872 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800873 * This is set for a window that has explicitly specified its
874 * FLAG_NEEDS_MENU_KEY, so we know the value on this window is the
875 * appropriate one to use. If this is not set, we should look at
876 * windows behind it to determine the appropriate value.
877 *
878 * @hide
879 */
880 public static final int PRIVATE_FLAG_SET_NEEDS_MENU_KEY = 0x00000008;
881
882 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700883 * Control flags that are private to the platform.
884 * @hide
885 */
886 public int privateFlags;
887
888 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800889 * Given a particular set of window manager flags, determine whether
890 * such a window may be a target for an input method when it has
891 * focus. In particular, this checks the
892 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
893 * flags and returns true if the combination of the two corresponds
894 * to a window that needs to be behind the input method so that the
895 * user can type into it.
896 *
897 * @param flags The current window manager flags.
898 *
899 * @return Returns true if such a window should be behind/interact
900 * with an input method, false if not.
901 */
902 public static boolean mayUseInputMethod(int flags) {
903 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
904 case 0:
905 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
906 return true;
907 }
908 return false;
909 }
910
911 /**
912 * Mask for {@link #softInputMode} of the bits that determine the
913 * desired visibility state of the soft input area for this window.
914 */
915 public static final int SOFT_INPUT_MASK_STATE = 0x0f;
916
917 /**
918 * Visibility state for {@link #softInputMode}: no state has been specified.
919 */
920 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
921
922 /**
923 * Visibility state for {@link #softInputMode}: please don't change the state of
924 * the soft input area.
925 */
926 public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
927
928 /**
929 * Visibility state for {@link #softInputMode}: please hide any soft input
930 * area when normally appropriate (when the user is navigating
931 * forward to your window).
932 */
933 public static final int SOFT_INPUT_STATE_HIDDEN = 2;
934
935 /**
936 * Visibility state for {@link #softInputMode}: please always hide any
937 * soft input area when this window receives focus.
938 */
939 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
940
941 /**
942 * Visibility state for {@link #softInputMode}: please show the soft
943 * input area when normally appropriate (when the user is navigating
944 * forward to your window).
945 */
946 public static final int SOFT_INPUT_STATE_VISIBLE = 4;
947
948 /**
949 * Visibility state for {@link #softInputMode}: please always make the
950 * soft input area visible when this window receives input focus.
951 */
952 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
953
954 /**
955 * Mask for {@link #softInputMode} of the bits that determine the
956 * way that the window should be adjusted to accommodate the soft
957 * input window.
958 */
959 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
960
961 /** Adjustment option for {@link #softInputMode}: nothing specified.
962 * The system will try to pick one or
963 * the other depending on the contents of the window.
964 */
965 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
966
967 /** Adjustment option for {@link #softInputMode}: set to allow the
968 * window to be resized when an input
969 * method is shown, so that its contents are not covered by the input
Scott Mainf10e6332010-06-11 09:03:22 -0700970 * method. This can <em>not</em> be combined with
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800971 * {@link #SOFT_INPUT_ADJUST_PAN}; if
972 * neither of these are set, then the system will try to pick one or
973 * the other depending on the contents of the window.
974 */
975 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
976
977 /** Adjustment option for {@link #softInputMode}: set to have a window
978 * pan when an input method is
979 * shown, so it doesn't need to deal with resizing but just panned
980 * by the framework to ensure the current input focus is visible. This
Scott Mainf10e6332010-06-11 09:03:22 -0700981 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800982 * neither of these are set, then the system will try to pick one or
983 * the other depending on the contents of the window.
984 */
985 public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
986
Dianne Hackborndea3ef72010-10-28 14:24:22 -0700987 /** Adjustment option for {@link #softInputMode}: set to have a window
988 * not adjust for a shown input method. The window will not be resized,
989 * and it will not be panned to make its focus visible.
990 */
991 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
992
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800993 /**
994 * Bit for {@link #softInputMode}: set when the user has navigated
995 * forward to the window. This is normally set automatically for
996 * you by the system, though you may want to set it in certain cases
997 * when you are displaying a window yourself. This flag will always
998 * be cleared automatically after the window is displayed.
999 */
1000 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001001
1002 /**
Gilles Debunnebe2c4f92011-01-17 15:14:32 -08001003 * Desired operating mode for any soft input area. May be any combination
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001004 * of:
1005 *
1006 * <ul>
1007 * <li> One of the visibility states
1008 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
1009 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
1010 * {@link #SOFT_INPUT_STATE_VISIBLE}.
1011 * <li> One of the adjustment options
1012 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
1013 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or
1014 * {@link #SOFT_INPUT_ADJUST_PAN}.
1015 */
1016 public int softInputMode;
1017
1018 /**
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001019 * Placement of window within the screen as per {@link Gravity}. Both
1020 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1021 * android.graphics.Rect) Gravity.apply} and
1022 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
1023 * Gravity.applyDisplay} are used during window layout, with this value
1024 * given as the desired gravity. For example you can specify
1025 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and
1026 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here
1027 * to control the behavior of
1028 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
1029 * Gravity.applyDisplay}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001030 *
1031 * @see Gravity
1032 */
1033 public int gravity;
1034
1035 /**
1036 * The horizontal margin, as a percentage of the container's width,
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001037 * between the container and the widget. See
1038 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1039 * android.graphics.Rect) Gravity.apply} for how this is used. This
1040 * field is added with {@link #x} to supply the <var>xAdj</var> parameter.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001041 */
1042 public float horizontalMargin;
1043
1044 /**
1045 * The vertical margin, as a percentage of the container's height,
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001046 * between the container and the widget. See
1047 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1048 * android.graphics.Rect) Gravity.apply} for how this is used. This
1049 * field is added with {@link #y} to supply the <var>yAdj</var> parameter.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001050 */
1051 public float verticalMargin;
1052
1053 /**
1054 * The desired bitmap format. May be one of the constants in
1055 * {@link android.graphics.PixelFormat}. Default is OPAQUE.
1056 */
1057 public int format;
1058
1059 /**
1060 * A style resource defining the animations to use for this window.
1061 * This must be a system resource; it can not be an application resource
1062 * because the window manager does not have access to applications.
1063 */
1064 public int windowAnimations;
1065
1066 /**
1067 * An alpha value to apply to this entire window.
1068 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
1069 */
1070 public float alpha = 1.0f;
1071
1072 /**
1073 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
1074 * to apply. Range is from 1.0 for completely opaque to 0.0 for no
1075 * dim.
1076 */
1077 public float dimAmount = 1.0f;
Dianne Hackborndea3ef72010-10-28 14:24:22 -07001078
1079 /**
1080 * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
1081 * indicating that the brightness value is not overridden for this window
1082 * and normal brightness policy should be used.
1083 */
1084 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
1085
1086 /**
1087 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
1088 * indicating that the screen or button backlight brightness should be set
1089 * to the lowest value when this window is in front.
1090 */
1091 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
1092
1093 /**
1094 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
1095 * indicating that the screen or button backlight brightness should be set
1096 * to the hightest value when this window is in front.
1097 */
1098 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001099
1100 /**
1101 * This can be used to override the user's preferred brightness of
1102 * the screen. A value of less than 0, the default, means to use the
1103 * preferred screen brightness. 0 to 1 adjusts the brightness from
1104 * dark to full bright.
1105 */
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001106 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001107
1108 /**
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001109 * This can be used to override the standard behavior of the button and
1110 * keyboard backlights. A value of less than 0, the default, means to
1111 * use the standard backlight behavior. 0 to 1 adjusts the brightness
1112 * from dark to full bright.
1113 */
1114 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
1115
1116 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001117 * Identifier for this window. This will usually be filled in for
1118 * you.
1119 */
1120 public IBinder token = null;
1121
1122 /**
1123 * Name of the package owning this window.
1124 */
1125 public String packageName = null;
1126
1127 /**
1128 * Specific orientation value for a window.
1129 * May be any of the same values allowed
1130 * for {@link android.content.pm.ActivityInfo#screenOrientation}.
1131 * If not set, a default value of
1132 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
1133 * will be used.
1134 */
1135 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Joe Onorato664644d2011-01-23 17:53:23 -08001136
1137 /**
1138 * Control the visibility of the status bar.
Joe Onorato14782f72011-01-25 19:53:17 -08001139 *
1140 * @see View#STATUS_BAR_VISIBLE
1141 * @see View#STATUS_BAR_HIDDEN
Joe Onorato664644d2011-01-23 17:53:23 -08001142 */
1143 public int systemUiVisibility;
1144
1145 /**
Joe Onorato14782f72011-01-25 19:53:17 -08001146 * @hide
1147 * The ui visibility as requested by the views in this hierarchy.
1148 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility.
1149 */
1150 public int subtreeSystemUiVisibility;
1151
1152 /**
Joe Onorato664644d2011-01-23 17:53:23 -08001153 * Get callbacks about the system ui visibility changing.
1154 *
1155 * TODO: Maybe there should be a bitfield of optional callbacks that we need.
1156 *
1157 * @hide
1158 */
1159 public boolean hasSystemUiListeners;
1160
Jeff Brown474dcb52011-06-14 20:22:50 -07001161 /**
1162 * When this window has focus, disable touch pad pointer gesture processing.
1163 * The window will receive raw position updates from the touch pad instead
1164 * of pointer movements and synthetic touch events.
1165 *
1166 * @hide
1167 */
1168 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001;
1169
1170 /**
Jeff Browncc4f7db2011-08-30 20:34:48 -07001171 * Does not construct an input channel for this window. The channel will therefore
1172 * be incapable of receiving input.
1173 *
1174 * @hide
1175 */
1176 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
1177
1178 /**
Jeff Brown474dcb52011-06-14 20:22:50 -07001179 * Control special features of the input subsystem.
1180 *
1181 * @see #INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES
Jeff Browncc4f7db2011-08-30 20:34:48 -07001182 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL
Jeff Brown474dcb52011-06-14 20:22:50 -07001183 * @hide
1184 */
1185 public int inputFeatures;
1186
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001187 public LayoutParams() {
Romain Guy980a9382010-01-08 15:06:28 -08001188 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 type = TYPE_APPLICATION;
1190 format = PixelFormat.OPAQUE;
1191 }
1192
1193 public LayoutParams(int _type) {
Romain Guy980a9382010-01-08 15:06:28 -08001194 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001195 type = _type;
1196 format = PixelFormat.OPAQUE;
1197 }
1198
1199 public LayoutParams(int _type, int _flags) {
Romain Guy980a9382010-01-08 15:06:28 -08001200 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001201 type = _type;
1202 flags = _flags;
1203 format = PixelFormat.OPAQUE;
1204 }
1205
1206 public LayoutParams(int _type, int _flags, int _format) {
Romain Guy980a9382010-01-08 15:06:28 -08001207 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001208 type = _type;
1209 flags = _flags;
1210 format = _format;
1211 }
1212
1213 public LayoutParams(int w, int h, int _type, int _flags, int _format) {
1214 super(w, h);
1215 type = _type;
1216 flags = _flags;
1217 format = _format;
1218 }
1219
1220 public LayoutParams(int w, int h, int xpos, int ypos, int _type,
1221 int _flags, int _format) {
1222 super(w, h);
1223 x = xpos;
1224 y = ypos;
1225 type = _type;
1226 flags = _flags;
1227 format = _format;
1228 }
1229
1230 public final void setTitle(CharSequence title) {
1231 if (null == title)
1232 title = "";
1233
1234 mTitle = TextUtils.stringOrSpannedString(title);
1235 }
1236
1237 public final CharSequence getTitle() {
1238 return mTitle;
1239 }
1240
1241 public int describeContents() {
1242 return 0;
1243 }
1244
1245 public void writeToParcel(Parcel out, int parcelableFlags) {
1246 out.writeInt(width);
1247 out.writeInt(height);
1248 out.writeInt(x);
1249 out.writeInt(y);
1250 out.writeInt(type);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001251 out.writeInt(flags);
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001252 out.writeInt(privateFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001253 out.writeInt(softInputMode);
1254 out.writeInt(gravity);
1255 out.writeFloat(horizontalMargin);
1256 out.writeFloat(verticalMargin);
1257 out.writeInt(format);
1258 out.writeInt(windowAnimations);
1259 out.writeFloat(alpha);
1260 out.writeFloat(dimAmount);
1261 out.writeFloat(screenBrightness);
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001262 out.writeFloat(buttonBrightness);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001263 out.writeStrongBinder(token);
1264 out.writeString(packageName);
1265 TextUtils.writeToParcel(mTitle, out, parcelableFlags);
1266 out.writeInt(screenOrientation);
Joe Onorato664644d2011-01-23 17:53:23 -08001267 out.writeInt(systemUiVisibility);
Joe Onorato14782f72011-01-25 19:53:17 -08001268 out.writeInt(subtreeSystemUiVisibility);
Joe Onorato664644d2011-01-23 17:53:23 -08001269 out.writeInt(hasSystemUiListeners ? 1 : 0);
Jeff Brown474dcb52011-06-14 20:22:50 -07001270 out.writeInt(inputFeatures);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001271 }
1272
1273 public static final Parcelable.Creator<LayoutParams> CREATOR
1274 = new Parcelable.Creator<LayoutParams>() {
1275 public LayoutParams createFromParcel(Parcel in) {
1276 return new LayoutParams(in);
1277 }
1278
1279 public LayoutParams[] newArray(int size) {
1280 return new LayoutParams[size];
1281 }
1282 };
1283
1284
1285 public LayoutParams(Parcel in) {
1286 width = in.readInt();
1287 height = in.readInt();
1288 x = in.readInt();
1289 y = in.readInt();
1290 type = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001291 flags = in.readInt();
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001292 privateFlags = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001293 softInputMode = in.readInt();
1294 gravity = in.readInt();
1295 horizontalMargin = in.readFloat();
1296 verticalMargin = in.readFloat();
1297 format = in.readInt();
1298 windowAnimations = in.readInt();
1299 alpha = in.readFloat();
1300 dimAmount = in.readFloat();
1301 screenBrightness = in.readFloat();
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001302 buttonBrightness = in.readFloat();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001303 token = in.readStrongBinder();
1304 packageName = in.readString();
1305 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
1306 screenOrientation = in.readInt();
Joe Onorato664644d2011-01-23 17:53:23 -08001307 systemUiVisibility = in.readInt();
Joe Onorato14782f72011-01-25 19:53:17 -08001308 subtreeSystemUiVisibility = in.readInt();
Joe Onorato664644d2011-01-23 17:53:23 -08001309 hasSystemUiListeners = in.readInt() != 0;
Jeff Brown474dcb52011-06-14 20:22:50 -07001310 inputFeatures = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001311 }
1312
Romain Guy72998072009-06-22 11:09:20 -07001313 @SuppressWarnings({"PointlessBitwiseExpression"})
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001314 public static final int LAYOUT_CHANGED = 1<<0;
1315 public static final int TYPE_CHANGED = 1<<1;
1316 public static final int FLAGS_CHANGED = 1<<2;
1317 public static final int FORMAT_CHANGED = 1<<3;
1318 public static final int ANIMATION_CHANGED = 1<<4;
1319 public static final int DIM_AMOUNT_CHANGED = 1<<5;
1320 public static final int TITLE_CHANGED = 1<<6;
1321 public static final int ALPHA_CHANGED = 1<<7;
1322 public static final int MEMORY_TYPE_CHANGED = 1<<8;
1323 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
1324 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
1325 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001326 /** {@hide} */
1327 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12;
Joe Onorato664644d2011-01-23 17:53:23 -08001328 /** {@hide} */
1329 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<13;
1330 /** {@hide} */
1331 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14;
Jeff Brown474dcb52011-06-14 20:22:50 -07001332 /** {@hide} */
1333 public static final int INPUT_FEATURES_CHANGED = 1<<15;
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001334 /** {@hide} */
1335 public static final int PRIVATE_FLAGS_CHANGED = 1<<16;
Romain Guyf21c9b02011-09-06 16:56:54 -07001336 /** {@hide} */
Romain Guyf21c9b02011-09-06 16:56:54 -07001337 public static final int EVERYTHING_CHANGED = 0xffffffff;
1338
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001339 // internal buffer to backup/restore parameters under compatibility mode.
1340 private int[] mCompatibilityParamsBackup = null;
1341
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001342 public final int copyFrom(LayoutParams o) {
1343 int changes = 0;
1344
1345 if (width != o.width) {
1346 width = o.width;
Chet Haase40e03832011-10-06 08:34:13 -07001347 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001348 }
1349 if (height != o.height) {
1350 height = o.height;
Chet Haase40e03832011-10-06 08:34:13 -07001351 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001352 }
1353 if (x != o.x) {
1354 x = o.x;
1355 changes |= LAYOUT_CHANGED;
1356 }
1357 if (y != o.y) {
1358 y = o.y;
1359 changes |= LAYOUT_CHANGED;
1360 }
1361 if (horizontalWeight != o.horizontalWeight) {
1362 horizontalWeight = o.horizontalWeight;
Chet Haase40e03832011-10-06 08:34:13 -07001363 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001364 }
1365 if (verticalWeight != o.verticalWeight) {
1366 verticalWeight = o.verticalWeight;
Chet Haase40e03832011-10-06 08:34:13 -07001367 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001368 }
1369 if (horizontalMargin != o.horizontalMargin) {
1370 horizontalMargin = o.horizontalMargin;
Chet Haase40e03832011-10-06 08:34:13 -07001371 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001372 }
1373 if (verticalMargin != o.verticalMargin) {
1374 verticalMargin = o.verticalMargin;
Chet Haase40e03832011-10-06 08:34:13 -07001375 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001376 }
1377 if (type != o.type) {
1378 type = o.type;
1379 changes |= TYPE_CHANGED;
1380 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001381 if (flags != o.flags) {
1382 flags = o.flags;
Chet Haase40e03832011-10-06 08:34:13 -07001383 changes |= FLAGS_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001384 }
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001385 if (privateFlags != o.privateFlags) {
1386 privateFlags = o.privateFlags;
1387 changes |= PRIVATE_FLAGS_CHANGED;
1388 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001389 if (softInputMode != o.softInputMode) {
1390 softInputMode = o.softInputMode;
1391 changes |= SOFT_INPUT_MODE_CHANGED;
1392 }
1393 if (gravity != o.gravity) {
1394 gravity = o.gravity;
Chet Haase40e03832011-10-06 08:34:13 -07001395 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001396 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001397 if (format != o.format) {
1398 format = o.format;
Chet Haase40e03832011-10-06 08:34:13 -07001399 changes |= FORMAT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001400 }
1401 if (windowAnimations != o.windowAnimations) {
1402 windowAnimations = o.windowAnimations;
1403 changes |= ANIMATION_CHANGED;
1404 }
1405 if (token == null) {
1406 // NOTE: token only copied if the recipient doesn't
1407 // already have one.
1408 token = o.token;
1409 }
1410 if (packageName == null) {
1411 // NOTE: packageName only copied if the recipient doesn't
1412 // already have one.
1413 packageName = o.packageName;
1414 }
1415 if (!mTitle.equals(o.mTitle)) {
1416 mTitle = o.mTitle;
1417 changes |= TITLE_CHANGED;
1418 }
1419 if (alpha != o.alpha) {
1420 alpha = o.alpha;
1421 changes |= ALPHA_CHANGED;
1422 }
1423 if (dimAmount != o.dimAmount) {
1424 dimAmount = o.dimAmount;
1425 changes |= DIM_AMOUNT_CHANGED;
1426 }
1427 if (screenBrightness != o.screenBrightness) {
1428 screenBrightness = o.screenBrightness;
1429 changes |= SCREEN_BRIGHTNESS_CHANGED;
1430 }
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001431 if (buttonBrightness != o.buttonBrightness) {
1432 buttonBrightness = o.buttonBrightness;
1433 changes |= BUTTON_BRIGHTNESS_CHANGED;
1434 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001435
1436 if (screenOrientation != o.screenOrientation) {
1437 screenOrientation = o.screenOrientation;
Chet Haase40e03832011-10-06 08:34:13 -07001438 changes |= SCREEN_ORIENTATION_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001439 }
Romain Guy529b60a2010-08-03 18:05:47 -07001440
Joe Onorato14782f72011-01-25 19:53:17 -08001441 if (systemUiVisibility != o.systemUiVisibility
1442 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
Joe Onorato664644d2011-01-23 17:53:23 -08001443 systemUiVisibility = o.systemUiVisibility;
Joe Onorato14782f72011-01-25 19:53:17 -08001444 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
Joe Onorato664644d2011-01-23 17:53:23 -08001445 changes |= SYSTEM_UI_VISIBILITY_CHANGED;
1446 }
1447
1448 if (hasSystemUiListeners != o.hasSystemUiListeners) {
1449 hasSystemUiListeners = o.hasSystemUiListeners;
1450 changes |= SYSTEM_UI_LISTENER_CHANGED;
1451 }
1452
Jeff Brown474dcb52011-06-14 20:22:50 -07001453 if (inputFeatures != o.inputFeatures) {
1454 inputFeatures = o.inputFeatures;
1455 changes |= INPUT_FEATURES_CHANGED;
1456 }
1457
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001458 return changes;
1459 }
1460
1461 @Override
1462 public String debug(String output) {
1463 output += "Contents of " + this + ":";
1464 Log.d("Debug", output);
1465 output = super.debug("");
1466 Log.d("Debug", output);
1467 Log.d("Debug", "");
1468 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
1469 return "";
1470 }
1471
1472 @Override
1473 public String toString() {
1474 StringBuilder sb = new StringBuilder(256);
1475 sb.append("WM.LayoutParams{");
1476 sb.append("(");
1477 sb.append(x);
1478 sb.append(',');
1479 sb.append(y);
1480 sb.append(")(");
Romain Guy980a9382010-01-08 15:06:28 -08001481 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001482 sb.append('x');
Romain Guy980a9382010-01-08 15:06:28 -08001483 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001484 sb.append(")");
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001485 if (horizontalMargin != 0) {
1486 sb.append(" hm=");
1487 sb.append(horizontalMargin);
1488 }
1489 if (verticalMargin != 0) {
1490 sb.append(" vm=");
1491 sb.append(verticalMargin);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001492 }
1493 if (gravity != 0) {
1494 sb.append(" gr=#");
1495 sb.append(Integer.toHexString(gravity));
1496 }
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001497 if (softInputMode != 0) {
1498 sb.append(" sim=#");
1499 sb.append(Integer.toHexString(softInputMode));
1500 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001501 sb.append(" ty=");
1502 sb.append(type);
1503 sb.append(" fl=#");
1504 sb.append(Integer.toHexString(flags));
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001505 if (privateFlags != 0) {
1506 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags));
1507 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001508 if (format != PixelFormat.OPAQUE) {
1509 sb.append(" fmt=");
1510 sb.append(format);
1511 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001512 if (windowAnimations != 0) {
1513 sb.append(" wanim=0x");
1514 sb.append(Integer.toHexString(windowAnimations));
1515 }
1516 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
1517 sb.append(" or=");
1518 sb.append(screenOrientation);
1519 }
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001520 if (alpha != 1.0f) {
1521 sb.append(" alpha=");
1522 sb.append(alpha);
1523 }
1524 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) {
1525 sb.append(" sbrt=");
1526 sb.append(screenBrightness);
1527 }
1528 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) {
1529 sb.append(" bbrt=");
1530 sb.append(buttonBrightness);
1531 }
Mitsuru Oshima5a2b91d2009-07-16 16:30:02 -07001532 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) {
1533 sb.append(" compatible=true");
1534 }
Joe Onorato664644d2011-01-23 17:53:23 -08001535 if (systemUiVisibility != 0) {
1536 sb.append(" sysui=0x");
1537 sb.append(Integer.toHexString(systemUiVisibility));
1538 }
Joe Onorato14782f72011-01-25 19:53:17 -08001539 if (subtreeSystemUiVisibility != 0) {
1540 sb.append(" vsysui=0x");
1541 sb.append(Integer.toHexString(subtreeSystemUiVisibility));
1542 }
Joe Onorato664644d2011-01-23 17:53:23 -08001543 if (hasSystemUiListeners) {
1544 sb.append(" sysuil=");
1545 sb.append(hasSystemUiListeners);
1546 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001547 if (inputFeatures != 0) {
1548 sb.append(" if=0x").append(Integer.toHexString(inputFeatures));
1549 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001550 sb.append('}');
1551 return sb.toString();
1552 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001553
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001554 /**
1555 * Scale the layout params' coordinates and size.
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001556 * @hide
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001557 */
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001558 public void scale(float scale) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001559 x = (int) (x * scale + 0.5f);
1560 y = (int) (y * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001561 if (width > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001562 width = (int) (width * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001563 }
1564 if (height > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001565 height = (int) (height * scale + 0.5f);
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001566 }
1567 }
1568
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001569 /**
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001570 * Backup the layout parameters used in compatibility mode.
1571 * @see LayoutParams#restore()
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001572 */
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001573 void backup() {
1574 int[] backup = mCompatibilityParamsBackup;
1575 if (backup == null) {
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001576 // we backup 4 elements, x, y, width, height
1577 backup = mCompatibilityParamsBackup = new int[4];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001578 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001579 backup[0] = x;
1580 backup[1] = y;
1581 backup[2] = width;
1582 backup[3] = height;
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001583 }
1584
1585 /**
1586 * Restore the layout params' coordinates, size and gravity
1587 * @see LayoutParams#backup()
1588 */
1589 void restore() {
1590 int[] backup = mCompatibilityParamsBackup;
1591 if (backup != null) {
1592 x = backup[0];
1593 y = backup[1];
1594 width = backup[2];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001595 height = backup[3];
1596 }
1597 }
1598
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001599 private CharSequence mTitle = "";
1600 }
1601}