blob: e6a29eaf6423b890c2ff05b3a24f8484264c5f3f [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"),
Scott Andersonaeb77232012-05-31 18:55:54 -0700165 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY, to = "TYPE_APPLICATION_MEDIA_OVERLAY"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700166 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"),
167 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"),
168 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"),
169 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"),
170 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"),
171 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"),
172 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"),
173 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700174 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"),
175 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"),
176 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"),
177 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"),
Jeff Brown3b2b3542010-10-15 00:54:27 -0700178 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"),
Jeff Brownbfcb60a2011-09-08 18:51:14 -0700179 @ViewDebug.IntToString(from = TYPE_WALLPAPER, to = "TYPE_WALLPAPER"),
180 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"),
Dianne Hackborn29aae6f2011-08-18 18:30:09 -0700181 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"),
Jeff Brownbfcb60a2011-09-08 18:51:14 -0700182 @ViewDebug.IntToString(from = TYPE_DRAG, to = "TYPE_DRAG"),
183 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"),
184 @ViewDebug.IntToString(from = TYPE_POINTER, to = "TYPE_POINTER"),
185 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, to = "TYPE_NAVIGATION_BAR"),
186 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, to = "TYPE_VOLUME_OVERLAY"),
Scott Andersonaeb77232012-05-31 18:55:54 -0700187 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS"),
188 @ViewDebug.IntToString(from = TYPE_HIDDEN_NAV_CONSUMER, to = "TYPE_HIDDEN_NAV_CONSUMER"),
189 @ViewDebug.IntToString(from = TYPE_DREAM, to = "TYPE_DREAM"),
190 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL, to = "TYPE_NAVIGATION_BAR_PANEL")
Joe Onorato8f2bd432010-03-25 11:45:28 -0700191 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800192 public int type;
193
194 /**
195 * Start of window types that represent normal application windows.
196 */
197 public static final int FIRST_APPLICATION_WINDOW = 1;
198
199 /**
200 * Window type: an application window that serves as the "base" window
201 * of the overall application; all other application windows will
202 * appear on top of it.
203 */
204 public static final int TYPE_BASE_APPLICATION = 1;
205
206 /**
207 * Window type: a normal application window. The {@link #token} must be
208 * an Activity token identifying who the window belongs to.
209 */
210 public static final int TYPE_APPLICATION = 2;
211
212 /**
213 * Window type: special application window that is displayed while the
214 * application is starting. Not for use by applications themselves;
215 * this is used by the system to display something until the
216 * application can show its own windows.
217 */
218 public static final int TYPE_APPLICATION_STARTING = 3;
219
220 /**
221 * End of types of application windows.
222 */
223 public static final int LAST_APPLICATION_WINDOW = 99;
224
225 /**
226 * Start of types of sub-windows. The {@link #token} of these windows
227 * must be set to the window they are attached to. These types of
228 * windows are kept next to their attached window in Z-order, and their
229 * coordinate space is relative to their attached window.
230 */
231 public static final int FIRST_SUB_WINDOW = 1000;
232
233 /**
234 * Window type: a panel on top of an application window. These windows
235 * appear on top of their attached window.
236 */
237 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
238
239 /**
240 * Window type: window for showing media (e.g. video). These windows
241 * are displayed behind their attached window.
242 */
243 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1;
244
245 /**
246 * Window type: a sub-panel on top of an application window. These
247 * windows are displayed on top their attached window and any
248 * {@link #TYPE_APPLICATION_PANEL} panels.
249 */
250 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2;
251
252 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
253 * of the window happens as that of a top-level window, <em>not</em>
254 * as a child of its container.
255 */
256 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3;
257
258 /**
Dianne Hackbornc4d5d022009-05-21 17:32:42 -0700259 * Window type: window for showing overlays on top of media windows.
260 * These windows are displayed between TYPE_APPLICATION_MEDIA and the
261 * application window. They should be translucent to be useful. This
262 * is a big ugly hack so:
263 * @hide
264 */
265 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4;
266
267 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800268 * End of types of sub-windows.
269 */
270 public static final int LAST_SUB_WINDOW = 1999;
271
272 /**
273 * Start of system-specific window types. These are not normally
274 * created by applications.
275 */
276 public static final int FIRST_SYSTEM_WINDOW = 2000;
277
278 /**
279 * Window type: the status bar. There can be only one status bar
280 * window; it is placed at the top of the screen, and all other
281 * windows are shifted down so they are below it.
282 */
283 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
284
285 /**
286 * Window type: the search bar. There can be only one search bar
287 * window; it is placed at the top of the screen.
288 */
289 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
290
291 /**
292 * Window type: phone. These are non-application windows providing
293 * user interaction with the phone (in particular incoming calls).
294 * These windows are normally placed above all applications, but behind
295 * the status bar.
296 */
297 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
298
299 /**
300 * Window type: system window, such as low power alert. These windows
301 * are always on top of application windows.
302 */
303 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
304
305 /**
306 * Window type: keyguard window.
307 */
308 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
309
310 /**
311 * Window type: transient notifications.
312 */
313 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
314
315 /**
316 * Window type: system overlay windows, which need to be displayed
317 * on top of everything else. These windows must not take input
318 * focus, or they will interfere with the keyguard.
319 */
320 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
321
322 /**
323 * Window type: priority phone UI, which needs to be displayed even if
324 * the keyguard is active. These windows must not take input
325 * focus, or they will interfere with the keyguard.
326 */
327 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
328
329 /**
330 * Window type: panel that slides out from the status bar
331 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800332 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
333
334 /**
335 * Window type: dialogs that the keyguard shows
336 */
337 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
338
339 /**
340 * Window type: internal system error windows, appear on top of
341 * everything they can.
342 */
343 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
344
345 /**
346 * Window type: internal input methods windows, which appear above
347 * the normal UI. Application windows may be resized or panned to keep
348 * the input focus visible while this window is displayed.
349 */
350 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
351
352 /**
353 * Window type: internal input methods dialog windows, which appear above
354 * the current input method window.
355 */
356 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
357
358 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700359 * Window type: wallpaper window, placed behind any window that wants
360 * to sit on top of the wallpaper.
361 */
362 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
363
364 /**
Joe Onorato29fc2c92010-11-24 10:26:50 -0800365 * Window type: panel that slides out from over the status bar
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800366 */
367 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
Jeff Brown3b2b3542010-10-15 00:54:27 -0700368
369 /**
370 * Window type: secure system overlay windows, which need to be displayed
371 * on top of everything else. These windows must not take input
372 * focus, or they will interfere with the keyguard.
373 *
374 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
375 * system itself is allowed to create these overlays. Applications cannot
376 * obtain permission to create secure system overlays.
377 * @hide
378 */
379 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
380
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800381 /**
Christopher Tatea53146c2010-09-07 11:57:52 -0700382 * Window type: the drag-and-drop pseudowindow. There is only one
383 * drag layer (at most), and it is placed on top of all other windows.
384 * @hide
385 */
Jeff Brown3b2b3542010-10-15 00:54:27 -0700386 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16;
Christopher Tatea53146c2010-09-07 11:57:52 -0700387
388 /**
Joe Onorato29fc2c92010-11-24 10:26:50 -0800389 * Window type: panel that slides out from under the status bar
Joe Onoratoa89e9032010-11-24 11:13:44 -0800390 * @hide
Joe Onorato29fc2c92010-11-24 10:26:50 -0800391 */
392 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
393
Jeff Brown83c09682010-12-23 17:50:18 -0800394 /**
395 * Window type: (mouse) pointer
396 * @hide
397 */
398 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
Joe Onorato29fc2c92010-11-24 10:26:50 -0800399
400 /**
Daniel Sandler8956dbb2011-04-22 07:55:02 -0400401 * Window type: Navigation bar (when distinct from status bar)
402 * @hide
403 */
404 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
405
406 /**
Dianne Hackborne8ecde12011-08-03 18:55:19 -0700407 * Window type: The volume level overlay/dialog shown when the user
408 * changes the system volume.
409 * @hide
410 */
411 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
412
413 /**
Dianne Hackborn29aae6f2011-08-18 18:30:09 -0700414 * Window type: The boot progress dialog, goes on top of everything
415 * in the world.
416 * @hide
417 */
418 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
419
420 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -0700421 * Window type: Fake window to consume touch events when the navigation
422 * bar is hidden.
423 * @hide
424 */
425 public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22;
426
427 /**
Daniel Sandler7d276c32012-01-30 14:33:52 -0500428 * Window type: Dreams (screen saver) window, just above keyguard.
429 * @hide
430 */
431 public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
432
433 /**
Jim Millere898ac52012-04-06 17:10:57 -0700434 * Window type: Navigation bar panel (when navigation bar is distinct from status bar)
435 * @hide
436 */
437 public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
438
439 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 * End of types of system windows.
441 */
442 public static final int LAST_SYSTEM_WINDOW = 2999;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800443
Mathias Agopiand2112302010-12-07 19:38:17 -0800444 /** @deprecated this is ignored, this value is set automatically when needed. */
445 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 public static final int MEMORY_TYPE_NORMAL = 0;
Mathias Agopiand2112302010-12-07 19:38:17 -0800447 /** @deprecated this is ignored, this value is set automatically when needed. */
Mathias Agopian317a6282009-08-13 17:29:02 -0700448 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800449 public static final int MEMORY_TYPE_HARDWARE = 1;
Mathias Agopiand2112302010-12-07 19:38:17 -0800450 /** @deprecated this is ignored, this value is set automatically when needed. */
Mathias Agopian317a6282009-08-13 17:29:02 -0700451 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800452 public static final int MEMORY_TYPE_GPU = 2;
Mathias Agopiand2112302010-12-07 19:38:17 -0800453 /** @deprecated this is ignored, this value is set automatically when needed. */
454 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700456
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800457 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700458 * @deprecated this is ignored
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800459 */
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700460 @Deprecated
461 public int memoryType;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800462
Mike Lockwoodef731622010-01-27 17:51:34 -0500463 /** Window flag: as long as this window is visible to the user, allow
464 * the lock screen to activate while the screen is on.
465 * This can be used independently, or in combination with
Christopher Tate95f78502010-01-29 15:57:34 -0800466 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
Mike Lockwoodef731622010-01-27 17:51:34 -0500467 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001;
468
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800469 /** Window flag: everything behind this window will be dimmed.
470 * Use {@link #dimAmount} to control the amount of dim. */
471 public static final int FLAG_DIM_BEHIND = 0x00000002;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700472
473 /** Window flag: blur everything behind this window.
474 * @deprecated Blurring is no longer supported. */
475 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800476 public static final int FLAG_BLUR_BEHIND = 0x00000004;
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700477
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800478 /** Window flag: this window won't ever get key input focus, so the
479 * user can not send key or other button events to it. Those will
480 * instead go to whatever focusable window is behind it. This flag
481 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
482 * is explicitly set.
483 *
484 * <p>Setting this flag also implies that the window will not need to
485 * interact with
486 * a soft input method, so it will be Z-ordered and positioned
487 * independently of any active input method (typically this means it
488 * gets Z-ordered on top of the input method, so it can use the full
489 * screen for its content and cover the input method if needed. You
490 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
491 public static final int FLAG_NOT_FOCUSABLE = 0x00000008;
492
493 /** Window flag: this window can never receive touch events. */
494 public static final int FLAG_NOT_TOUCHABLE = 0x00000010;
495
496 /** Window flag: Even when this window is focusable (its
497 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events
498 * outside of the window to be sent to the windows behind it. Otherwise
499 * it will consume all pointer events itself, regardless of whether they
500 * are inside of the window. */
501 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020;
502
503 /** Window flag: When set, if the device is asleep when the touch
504 * screen is pressed, you will receive this first touch event. Usually
505 * the first touch event is consumed by the system since the user can
506 * not see what they are pressing on.
507 */
508 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
509
510 /** Window flag: as long as this window is visible to the user, keep
511 * the device's screen turned on and bright. */
512 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080;
513
514 /** Window flag: place the window within the entire screen, ignoring
515 * decorations around the border (a.k.a. the status bar). The
516 * window must correctly position its contents to take the screen
517 * decoration into account. This flag is normally set for you
518 * by Window as described in {@link Window#setFlags}. */
519 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100;
520
521 /** Window flag: allow window to extend outside of the screen. */
522 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200;
523
524 /** Window flag: Hide all screen decorations (e.g. status bar) while
525 * this window is displayed. This allows the window to use the entire
526 * display space for itself -- the status bar will be hidden when
527 * an app window with this flag set is on the top layer. */
528 public static final int FLAG_FULLSCREEN = 0x00000400;
529
530 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the
531 * screen decorations (such as status bar) to be shown. */
532 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800;
533
534 /** Window flag: turn on dithering when compositing this window to
535 * the screen. */
536 public static final int FLAG_DITHER = 0x00001000;
537
538 /** Window flag: don't allow screen shots while this window is
Glenn Kastend6f5bde2011-01-19 15:27:27 -0800539 * displayed. Maps to Surface.SECURE. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800540 public static final int FLAG_SECURE = 0x00002000;
541
542 /** Window flag: a special mode where the layout parameters are used
543 * to perform scaling of the surface when it is composited to the
544 * screen. */
545 public static final int FLAG_SCALED = 0x00004000;
546
547 /** Window flag: intended for windows that will often be used when the user is
548 * holding the screen against their face, it will aggressively filter the event
549 * stream to prevent unintended presses in this situation that may not be
550 * desired for a particular window, when such an event stream is detected, the
551 * application will receive a CANCEL motion event to indicate this so applications
552 * can handle this accordingly by taking no action on the event
553 * until the finger is released. */
554 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000;
555
556 /** Window flag: a special option only for use in combination with
557 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the
558 * screen your window may appear on top of or behind screen decorations
559 * such as the status bar. By also including this flag, the window
560 * manager will report the inset rectangle needed to ensure your
561 * content is not covered by screen decorations. This flag is normally
562 * set for you by Window as described in {@link Window#setFlags}.*/
563 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
564
565 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
566 * respect to how this window interacts with the current method. That
567 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
568 * window will behave as if it needs to interact with the input method
569 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
570 * not set and this flag is set, then the window will behave as if it
571 * doesn't need to interact with the input method and can be placed
572 * to use more space and cover the input method.
573 */
574 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
575
576 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
577 * can set this flag to receive a single special MotionEvent with
578 * the action
579 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
580 * touches that occur outside of your window. Note that you will not
581 * receive the full down/move/up gesture, only the location of the
582 * first down as an ACTION_OUTSIDE.
583 */
584 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
585
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700586 /** Window flag: special flag to let windows be shown when the screen
587 * is locked. This will let application windows take precedence over
588 * key guard or any other lock screens. Can be used with
589 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700590 * directly before showing the key guard window. Can be used with
591 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
592 * non-secure keyguards. This flag only applies to the top-most
593 * full-screen window.
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700594 */
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700595 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
596
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700597 /** Window flag: ask that the system wallpaper be shown behind
598 * your window. The window surface must be translucent to be able
599 * to actually see the wallpaper behind it; this flag just ensures
600 * that the wallpaper surface will be there if this window actually
601 * has translucent regions.
602 */
603 public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
604
Dianne Hackborn93e462b2009-09-15 22:50:40 -0700605 /** Window flag: when set as a window is being added or made
606 * visible, once the window has been shown then the system will
607 * poke the power manager's user activity (as if the user had woken
608 * up the device) to turn the screen on. */
609 public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
610
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700611 /** Window flag: when set the window will cause the keyguard to
612 * be dismissed, only if it is not a secure lock keyguard. Because such
613 * a keyguard is not needed for security, it will never re-appear if
614 * the user navigates to another window (in contrast to
615 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
616 * hide both secure and non-secure keyguards but ensure they reappear
617 * when the user moves to another UI that doesn't hide them).
618 * If the keyguard is currently active and is secure (requires an
619 * unlock pattern) than the user will still need to confirm it before
620 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has
Daniel Sandlerae069f72010-06-17 21:56:26 -0400621 * also been set.
622 */
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700623 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
Jeff Brown01ce2e92010-09-26 22:20:12 -0700624
625 /** Window flag: when set the window will accept for touch events
626 * outside of its bounds to be sent to other windows that also
627 * support split touch. When this flag is not set, the first pointer
628 * that goes down determines the window to which all subsequent touches
629 * go until all pointers go up. When this flag is set, each pointer
630 * (not necessarily the first) that goes down determines the window
631 * to which all subsequent touches of that pointer will go until that
632 * pointer goes up thereby enabling touches with multiple pointers
633 * to be split across multiple windows.
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800634 */
Jeff Brown01ce2e92010-09-26 22:20:12 -0700635 public static final int FLAG_SPLIT_TOUCH = 0x00800000;
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800636
637 /**
Romain Guy72f0a272011-01-09 16:01:46 -0800638 * <p>Indicates whether this window should be hardware accelerated.
639 * Requesting hardware acceleration does not guarantee it will happen.</p>
640 *
641 * <p>This flag can be controlled programmatically <em>only</em> to enable
642 * hardware acceleration. To enable hardware acceleration for a given
643 * window programmatically, do the following:</p>
644 *
645 * <pre>
646 * Window w = activity.getWindow(); // in Activity's onCreate() for instance
647 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
648 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
649 * </pre>
650 *
651 * <p>It is important to remember that this flag <strong>must</strong>
652 * be set before setting the content view of your activity or dialog.</p>
653 *
654 * <p>This flag cannot be used to disable hardware acceleration after it
655 * was enabled in your manifest using
656 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively
657 * and programmatically disable hardware acceleration (for automated testing
658 * for instance), make sure it is turned off in your manifest and enable it
659 * on your activity or dialog when you need it instead, using the method
660 * described above.</p>
661 *
662 * <p>This flag is automatically set by the system if the
663 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
664 * XML attribute is set to true on an activity or on the application.</p>
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800665 */
666 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
Daniel Sandler611fae42010-06-17 10:45:00 -0400667
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800668 // ----- HIDDEN FLAGS.
669 // These start at the high bit and go down.
Jeff Brown98db5fa2011-06-08 15:37:10 -0700670
671 /** Window flag: Enable touches to slide out of a window into neighboring
672 * windows in mid-gesture instead of being captured for the duration of
673 * the gesture.
674 *
675 * This flag changes the behavior of touch focus for this window only.
676 * Touches can slide out of the window but they cannot necessarily slide
677 * back in (unless the other window with touch focus permits it).
678 *
679 * {@hide}
680 */
681 public static final int FLAG_SLIPPERY = 0x04000000;
682
Daniel Sandlere02d8082010-10-08 15:13:22 -0400683 /**
684 * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU}
685 * and therefore needs a Menu key. For devices where Menu is a physical button this flag is
686 * ignored, but on devices where the Menu key is drawn in software it may be hidden unless
687 * this flag is set.
688 *
689 * (Note that Action Bars, when available, are the preferred way to offer additional
690 * functions otherwise accessed via an options menu.)
691 *
692 * {@hide}
693 */
Dianne Hackbornd9b3b7e2010-11-16 18:22:49 -0800694 public static final int FLAG_NEEDS_MENU_KEY = 0x08000000;
Daniel Sandlere02d8082010-10-08 15:13:22 -0400695
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700696 /** Window flag: special flag to limit the size of the window to be
697 * original size ([320x480] x density). Used to create window for applications
698 * running under compatibility mode.
699 *
700 * {@hide} */
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700701 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000;
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700702
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800703 /** Window flag: a special option intended for system dialogs. When
704 * this flag is set, the window will demand focus unconditionally when
705 * it is created.
706 * {@hide} */
707 public static final int FLAG_SYSTEM_ERROR = 0x40000000;
708
709 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700710 * Various behavioral options/flags. Default is none.
711 *
712 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
713 * @see #FLAG_DIM_BEHIND
714 * @see #FLAG_NOT_FOCUSABLE
715 * @see #FLAG_NOT_TOUCHABLE
716 * @see #FLAG_NOT_TOUCH_MODAL
717 * @see #FLAG_TOUCHABLE_WHEN_WAKING
718 * @see #FLAG_KEEP_SCREEN_ON
719 * @see #FLAG_LAYOUT_IN_SCREEN
720 * @see #FLAG_LAYOUT_NO_LIMITS
721 * @see #FLAG_FULLSCREEN
722 * @see #FLAG_FORCE_NOT_FULLSCREEN
723 * @see #FLAG_DITHER
724 * @see #FLAG_SECURE
725 * @see #FLAG_SCALED
726 * @see #FLAG_IGNORE_CHEEK_PRESSES
727 * @see #FLAG_LAYOUT_INSET_DECOR
728 * @see #FLAG_ALT_FOCUSABLE_IM
729 * @see #FLAG_WATCH_OUTSIDE_TOUCH
730 * @see #FLAG_SHOW_WHEN_LOCKED
731 * @see #FLAG_SHOW_WALLPAPER
732 * @see #FLAG_TURN_SCREEN_ON
733 * @see #FLAG_DISMISS_KEYGUARD
734 * @see #FLAG_SPLIT_TOUCH
735 * @see #FLAG_HARDWARE_ACCELERATED
736 */
737 @ViewDebug.ExportedProperty(flagMapping = {
738 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
739 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
740 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
741 name = "FLAG_DIM_BEHIND"),
742 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
743 name = "FLAG_BLUR_BEHIND"),
744 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
745 name = "FLAG_NOT_FOCUSABLE"),
746 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
747 name = "FLAG_NOT_TOUCHABLE"),
748 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
749 name = "FLAG_NOT_TOUCH_MODAL"),
750 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
751 name = "FLAG_TOUCHABLE_WHEN_WAKING"),
752 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
753 name = "FLAG_KEEP_SCREEN_ON"),
754 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
755 name = "FLAG_LAYOUT_IN_SCREEN"),
756 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
757 name = "FLAG_LAYOUT_NO_LIMITS"),
758 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
759 name = "FLAG_FULLSCREEN"),
760 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
761 name = "FLAG_FORCE_NOT_FULLSCREEN"),
762 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
763 name = "FLAG_DITHER"),
764 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
765 name = "FLAG_SECURE"),
766 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
767 name = "FLAG_SCALED"),
768 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
769 name = "FLAG_IGNORE_CHEEK_PRESSES"),
770 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
771 name = "FLAG_LAYOUT_INSET_DECOR"),
772 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
773 name = "FLAG_ALT_FOCUSABLE_IM"),
774 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
775 name = "FLAG_WATCH_OUTSIDE_TOUCH"),
776 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
777 name = "FLAG_SHOW_WHEN_LOCKED"),
778 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
779 name = "FLAG_SHOW_WALLPAPER"),
780 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
781 name = "FLAG_TURN_SCREEN_ON"),
782 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
783 name = "FLAG_DISMISS_KEYGUARD"),
784 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
785 name = "FLAG_SPLIT_TOUCH"),
786 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
787 name = "FLAG_HARDWARE_ACCELERATED")
788 })
789 public int flags;
790
791 /**
792 * If the window has requested hardware acceleration, but this is not
793 * allowed in the process it is in, then still render it as if it is
794 * hardware accelerated. This is used for the starting preview windows
795 * in the system process, which don't need to have the overhead of
796 * hardware acceleration (they are just a static rendering), but should
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900797 * be rendered as such to match the actual window of the app even if it
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700798 * is hardware accelerated.
799 * Even if the window isn't hardware accelerated, still do its rendering
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900800 * as if it was.
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700801 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
802 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
803 * is generally disabled. This flag must be specified in addition to
804 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
805 * windows.
806 *
807 * @hide
808 */
809 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
810
811 /**
812 * In the system process, we globally do not use hardware acceleration
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900813 * because there are many threads doing UI there and they conflict.
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700814 * If certain parts of the UI that really do want to use hardware
815 * acceleration, this flag can be set to force it. This is basically
816 * for the lock screen. Anyone else using it, you are probably wrong.
817 *
818 * @hide
819 */
820 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
821
822 /**
Chet Haasea8e5a2b2011-10-28 13:18:16 -0700823 * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900824 * may elect to skip these notifications if they are not doing anything productive with
Chet Haasea8e5a2b2011-10-28 13:18:16 -0700825 * them (they do not affect the wallpaper scrolling operation) by calling
826 * {@link
827 * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}.
828 *
829 * @hide
830 */
831 public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004;
832
833 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800834 * This is set for a window that has explicitly specified its
835 * FLAG_NEEDS_MENU_KEY, so we know the value on this window is the
836 * appropriate one to use. If this is not set, we should look at
837 * windows behind it to determine the appropriate value.
838 *
839 * @hide
840 */
841 public static final int PRIVATE_FLAG_SET_NEEDS_MENU_KEY = 0x00000008;
842
843 /**
Dianne Hackborn5d927c22011-09-02 12:22:18 -0700844 * Control flags that are private to the platform.
845 * @hide
846 */
847 public int privateFlags;
848
849 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800850 * Given a particular set of window manager flags, determine whether
851 * such a window may be a target for an input method when it has
852 * focus. In particular, this checks the
853 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
854 * flags and returns true if the combination of the two corresponds
855 * to a window that needs to be behind the input method so that the
856 * user can type into it.
857 *
858 * @param flags The current window manager flags.
859 *
860 * @return Returns true if such a window should be behind/interact
861 * with an input method, false if not.
862 */
863 public static boolean mayUseInputMethod(int flags) {
864 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
865 case 0:
866 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
867 return true;
868 }
869 return false;
870 }
871
872 /**
873 * Mask for {@link #softInputMode} of the bits that determine the
874 * desired visibility state of the soft input area for this window.
875 */
876 public static final int SOFT_INPUT_MASK_STATE = 0x0f;
877
878 /**
879 * Visibility state for {@link #softInputMode}: no state has been specified.
880 */
881 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
882
883 /**
884 * Visibility state for {@link #softInputMode}: please don't change the state of
885 * the soft input area.
886 */
887 public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
888
889 /**
890 * Visibility state for {@link #softInputMode}: please hide any soft input
891 * area when normally appropriate (when the user is navigating
892 * forward to your window).
893 */
894 public static final int SOFT_INPUT_STATE_HIDDEN = 2;
895
896 /**
897 * Visibility state for {@link #softInputMode}: please always hide any
898 * soft input area when this window receives focus.
899 */
900 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
901
902 /**
903 * Visibility state for {@link #softInputMode}: please show the soft
904 * input area when normally appropriate (when the user is navigating
905 * forward to your window).
906 */
907 public static final int SOFT_INPUT_STATE_VISIBLE = 4;
908
909 /**
910 * Visibility state for {@link #softInputMode}: please always make the
911 * soft input area visible when this window receives input focus.
912 */
913 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
914
915 /**
916 * Mask for {@link #softInputMode} of the bits that determine the
917 * way that the window should be adjusted to accommodate the soft
918 * input window.
919 */
920 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
921
922 /** Adjustment option for {@link #softInputMode}: nothing specified.
923 * The system will try to pick one or
924 * the other depending on the contents of the window.
925 */
926 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
927
928 /** Adjustment option for {@link #softInputMode}: set to allow the
929 * window to be resized when an input
930 * method is shown, so that its contents are not covered by the input
Scott Mainf10e6332010-06-11 09:03:22 -0700931 * method. This can <em>not</em> be combined with
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800932 * {@link #SOFT_INPUT_ADJUST_PAN}; if
933 * neither of these are set, then the system will try to pick one or
934 * the other depending on the contents of the window.
935 */
936 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
937
938 /** Adjustment option for {@link #softInputMode}: set to have a window
939 * pan when an input method is
940 * shown, so it doesn't need to deal with resizing but just panned
941 * by the framework to ensure the current input focus is visible. This
Scott Mainf10e6332010-06-11 09:03:22 -0700942 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800943 * neither of these are set, then the system will try to pick one or
944 * the other depending on the contents of the window.
945 */
946 public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
947
Dianne Hackborndea3ef72010-10-28 14:24:22 -0700948 /** Adjustment option for {@link #softInputMode}: set to have a window
949 * not adjust for a shown input method. The window will not be resized,
950 * and it will not be panned to make its focus visible.
951 */
952 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
953
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800954 /**
955 * Bit for {@link #softInputMode}: set when the user has navigated
956 * forward to the window. This is normally set automatically for
957 * you by the system, though you may want to set it in certain cases
958 * when you are displaying a window yourself. This flag will always
959 * be cleared automatically after the window is displayed.
960 */
961 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500962
963 /**
Gilles Debunnebe2c4f92011-01-17 15:14:32 -0800964 * Desired operating mode for any soft input area. May be any combination
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800965 * of:
966 *
967 * <ul>
968 * <li> One of the visibility states
969 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
970 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
971 * {@link #SOFT_INPUT_STATE_VISIBLE}.
972 * <li> One of the adjustment options
973 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
974 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or
975 * {@link #SOFT_INPUT_ADJUST_PAN}.
976 */
977 public int softInputMode;
978
979 /**
Dianne Hackborn8eb2e242010-11-01 12:31:24 -0700980 * Placement of window within the screen as per {@link Gravity}. Both
981 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
982 * android.graphics.Rect) Gravity.apply} and
983 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
984 * Gravity.applyDisplay} are used during window layout, with this value
985 * given as the desired gravity. For example you can specify
986 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and
987 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here
988 * to control the behavior of
989 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
990 * Gravity.applyDisplay}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800991 *
992 * @see Gravity
993 */
994 public int gravity;
995
996 /**
997 * The horizontal margin, as a percentage of the container's width,
Dianne Hackborn8eb2e242010-11-01 12:31:24 -0700998 * between the container and the widget. See
999 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1000 * android.graphics.Rect) Gravity.apply} for how this is used. This
1001 * field is added with {@link #x} to supply the <var>xAdj</var> parameter.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001002 */
1003 public float horizontalMargin;
1004
1005 /**
1006 * The vertical margin, as a percentage of the container's height,
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001007 * between the container and the widget. See
1008 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1009 * android.graphics.Rect) Gravity.apply} for how this is used. This
1010 * field is added with {@link #y} to supply the <var>yAdj</var> parameter.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001011 */
1012 public float verticalMargin;
1013
1014 /**
1015 * The desired bitmap format. May be one of the constants in
1016 * {@link android.graphics.PixelFormat}. Default is OPAQUE.
1017 */
1018 public int format;
1019
1020 /**
1021 * A style resource defining the animations to use for this window.
1022 * This must be a system resource; it can not be an application resource
1023 * because the window manager does not have access to applications.
1024 */
1025 public int windowAnimations;
1026
1027 /**
1028 * An alpha value to apply to this entire window.
1029 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
1030 */
1031 public float alpha = 1.0f;
1032
1033 /**
1034 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
1035 * to apply. Range is from 1.0 for completely opaque to 0.0 for no
1036 * dim.
1037 */
1038 public float dimAmount = 1.0f;
Dianne Hackborndea3ef72010-10-28 14:24:22 -07001039
1040 /**
1041 * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
1042 * indicating that the brightness value is not overridden for this window
1043 * and normal brightness policy should be used.
1044 */
1045 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
1046
1047 /**
1048 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
1049 * indicating that the screen or button backlight brightness should be set
1050 * to the lowest value when this window is in front.
1051 */
1052 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
1053
1054 /**
1055 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
1056 * indicating that the screen or button backlight brightness should be set
1057 * to the hightest value when this window is in front.
1058 */
1059 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001060
1061 /**
1062 * This can be used to override the user's preferred brightness of
1063 * the screen. A value of less than 0, the default, means to use the
1064 * preferred screen brightness. 0 to 1 adjusts the brightness from
1065 * dark to full bright.
1066 */
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001067 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001068
1069 /**
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001070 * This can be used to override the standard behavior of the button and
1071 * keyboard backlights. A value of less than 0, the default, means to
1072 * use the standard backlight behavior. 0 to 1 adjusts the brightness
1073 * from dark to full bright.
1074 */
1075 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
1076
1077 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001078 * Identifier for this window. This will usually be filled in for
1079 * you.
1080 */
1081 public IBinder token = null;
1082
1083 /**
1084 * Name of the package owning this window.
1085 */
1086 public String packageName = null;
1087
1088 /**
1089 * Specific orientation value for a window.
1090 * May be any of the same values allowed
1091 * for {@link android.content.pm.ActivityInfo#screenOrientation}.
1092 * If not set, a default value of
1093 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
1094 * will be used.
1095 */
1096 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
Joe Onorato664644d2011-01-23 17:53:23 -08001097
1098 /**
1099 * Control the visibility of the status bar.
Joe Onorato14782f72011-01-25 19:53:17 -08001100 *
1101 * @see View#STATUS_BAR_VISIBLE
1102 * @see View#STATUS_BAR_HIDDEN
Joe Onorato664644d2011-01-23 17:53:23 -08001103 */
1104 public int systemUiVisibility;
1105
1106 /**
Joe Onorato14782f72011-01-25 19:53:17 -08001107 * @hide
1108 * The ui visibility as requested by the views in this hierarchy.
1109 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility.
1110 */
1111 public int subtreeSystemUiVisibility;
1112
1113 /**
Joe Onorato664644d2011-01-23 17:53:23 -08001114 * Get callbacks about the system ui visibility changing.
1115 *
1116 * TODO: Maybe there should be a bitfield of optional callbacks that we need.
1117 *
1118 * @hide
1119 */
1120 public boolean hasSystemUiListeners;
1121
Jeff Brown474dcb52011-06-14 20:22:50 -07001122 /**
1123 * When this window has focus, disable touch pad pointer gesture processing.
1124 * The window will receive raw position updates from the touch pad instead
1125 * of pointer movements and synthetic touch events.
1126 *
1127 * @hide
1128 */
1129 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001;
1130
1131 /**
Jeff Browncc4f7db2011-08-30 20:34:48 -07001132 * Does not construct an input channel for this window. The channel will therefore
1133 * be incapable of receiving input.
1134 *
1135 * @hide
1136 */
1137 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
1138
1139 /**
Jeff Brown474dcb52011-06-14 20:22:50 -07001140 * Control special features of the input subsystem.
1141 *
1142 * @see #INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES
Jeff Browncc4f7db2011-08-30 20:34:48 -07001143 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL
Jeff Brown474dcb52011-06-14 20:22:50 -07001144 * @hide
1145 */
1146 public int inputFeatures;
1147
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001148 public LayoutParams() {
Romain Guy980a9382010-01-08 15:06:28 -08001149 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001150 type = TYPE_APPLICATION;
1151 format = PixelFormat.OPAQUE;
1152 }
1153
1154 public LayoutParams(int _type) {
Romain Guy980a9382010-01-08 15:06:28 -08001155 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001156 type = _type;
1157 format = PixelFormat.OPAQUE;
1158 }
1159
1160 public LayoutParams(int _type, int _flags) {
Romain Guy980a9382010-01-08 15:06:28 -08001161 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001162 type = _type;
1163 flags = _flags;
1164 format = PixelFormat.OPAQUE;
1165 }
1166
1167 public LayoutParams(int _type, int _flags, int _format) {
Romain Guy980a9382010-01-08 15:06:28 -08001168 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001169 type = _type;
1170 flags = _flags;
1171 format = _format;
1172 }
1173
1174 public LayoutParams(int w, int h, int _type, int _flags, int _format) {
1175 super(w, h);
1176 type = _type;
1177 flags = _flags;
1178 format = _format;
1179 }
1180
1181 public LayoutParams(int w, int h, int xpos, int ypos, int _type,
1182 int _flags, int _format) {
1183 super(w, h);
1184 x = xpos;
1185 y = ypos;
1186 type = _type;
1187 flags = _flags;
1188 format = _format;
1189 }
1190
1191 public final void setTitle(CharSequence title) {
1192 if (null == title)
1193 title = "";
1194
1195 mTitle = TextUtils.stringOrSpannedString(title);
1196 }
1197
1198 public final CharSequence getTitle() {
1199 return mTitle;
1200 }
1201
1202 public int describeContents() {
1203 return 0;
1204 }
1205
1206 public void writeToParcel(Parcel out, int parcelableFlags) {
1207 out.writeInt(width);
1208 out.writeInt(height);
1209 out.writeInt(x);
1210 out.writeInt(y);
1211 out.writeInt(type);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001212 out.writeInt(flags);
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001213 out.writeInt(privateFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001214 out.writeInt(softInputMode);
1215 out.writeInt(gravity);
1216 out.writeFloat(horizontalMargin);
1217 out.writeFloat(verticalMargin);
1218 out.writeInt(format);
1219 out.writeInt(windowAnimations);
1220 out.writeFloat(alpha);
1221 out.writeFloat(dimAmount);
1222 out.writeFloat(screenBrightness);
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001223 out.writeFloat(buttonBrightness);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001224 out.writeStrongBinder(token);
1225 out.writeString(packageName);
1226 TextUtils.writeToParcel(mTitle, out, parcelableFlags);
1227 out.writeInt(screenOrientation);
Joe Onorato664644d2011-01-23 17:53:23 -08001228 out.writeInt(systemUiVisibility);
Joe Onorato14782f72011-01-25 19:53:17 -08001229 out.writeInt(subtreeSystemUiVisibility);
Joe Onorato664644d2011-01-23 17:53:23 -08001230 out.writeInt(hasSystemUiListeners ? 1 : 0);
Jeff Brown474dcb52011-06-14 20:22:50 -07001231 out.writeInt(inputFeatures);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001232 }
1233
1234 public static final Parcelable.Creator<LayoutParams> CREATOR
1235 = new Parcelable.Creator<LayoutParams>() {
1236 public LayoutParams createFromParcel(Parcel in) {
1237 return new LayoutParams(in);
1238 }
1239
1240 public LayoutParams[] newArray(int size) {
1241 return new LayoutParams[size];
1242 }
1243 };
1244
1245
1246 public LayoutParams(Parcel in) {
1247 width = in.readInt();
1248 height = in.readInt();
1249 x = in.readInt();
1250 y = in.readInt();
1251 type = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001252 flags = in.readInt();
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001253 privateFlags = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001254 softInputMode = in.readInt();
1255 gravity = in.readInt();
1256 horizontalMargin = in.readFloat();
1257 verticalMargin = in.readFloat();
1258 format = in.readInt();
1259 windowAnimations = in.readInt();
1260 alpha = in.readFloat();
1261 dimAmount = in.readFloat();
1262 screenBrightness = in.readFloat();
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001263 buttonBrightness = in.readFloat();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001264 token = in.readStrongBinder();
1265 packageName = in.readString();
1266 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
1267 screenOrientation = in.readInt();
Joe Onorato664644d2011-01-23 17:53:23 -08001268 systemUiVisibility = in.readInt();
Joe Onorato14782f72011-01-25 19:53:17 -08001269 subtreeSystemUiVisibility = in.readInt();
Joe Onorato664644d2011-01-23 17:53:23 -08001270 hasSystemUiListeners = in.readInt() != 0;
Jeff Brown474dcb52011-06-14 20:22:50 -07001271 inputFeatures = in.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001272 }
1273
Romain Guy72998072009-06-22 11:09:20 -07001274 @SuppressWarnings({"PointlessBitwiseExpression"})
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001275 public static final int LAYOUT_CHANGED = 1<<0;
1276 public static final int TYPE_CHANGED = 1<<1;
1277 public static final int FLAGS_CHANGED = 1<<2;
1278 public static final int FORMAT_CHANGED = 1<<3;
1279 public static final int ANIMATION_CHANGED = 1<<4;
1280 public static final int DIM_AMOUNT_CHANGED = 1<<5;
1281 public static final int TITLE_CHANGED = 1<<6;
1282 public static final int ALPHA_CHANGED = 1<<7;
1283 public static final int MEMORY_TYPE_CHANGED = 1<<8;
1284 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
1285 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
1286 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001287 /** {@hide} */
1288 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12;
Joe Onorato664644d2011-01-23 17:53:23 -08001289 /** {@hide} */
1290 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<13;
1291 /** {@hide} */
1292 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14;
Jeff Brown474dcb52011-06-14 20:22:50 -07001293 /** {@hide} */
1294 public static final int INPUT_FEATURES_CHANGED = 1<<15;
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001295 /** {@hide} */
1296 public static final int PRIVATE_FLAGS_CHANGED = 1<<16;
Romain Guyf21c9b02011-09-06 16:56:54 -07001297 /** {@hide} */
Romain Guyf21c9b02011-09-06 16:56:54 -07001298 public static final int EVERYTHING_CHANGED = 0xffffffff;
1299
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001300 // internal buffer to backup/restore parameters under compatibility mode.
1301 private int[] mCompatibilityParamsBackup = null;
1302
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001303 public final int copyFrom(LayoutParams o) {
1304 int changes = 0;
1305
1306 if (width != o.width) {
1307 width = o.width;
Chet Haase40e03832011-10-06 08:34:13 -07001308 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001309 }
1310 if (height != o.height) {
1311 height = o.height;
Chet Haase40e03832011-10-06 08:34:13 -07001312 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001313 }
1314 if (x != o.x) {
1315 x = o.x;
1316 changes |= LAYOUT_CHANGED;
1317 }
1318 if (y != o.y) {
1319 y = o.y;
1320 changes |= LAYOUT_CHANGED;
1321 }
1322 if (horizontalWeight != o.horizontalWeight) {
1323 horizontalWeight = o.horizontalWeight;
Chet Haase40e03832011-10-06 08:34:13 -07001324 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001325 }
1326 if (verticalWeight != o.verticalWeight) {
1327 verticalWeight = o.verticalWeight;
Chet Haase40e03832011-10-06 08:34:13 -07001328 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001329 }
1330 if (horizontalMargin != o.horizontalMargin) {
1331 horizontalMargin = o.horizontalMargin;
Chet Haase40e03832011-10-06 08:34:13 -07001332 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001333 }
1334 if (verticalMargin != o.verticalMargin) {
1335 verticalMargin = o.verticalMargin;
Chet Haase40e03832011-10-06 08:34:13 -07001336 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001337 }
1338 if (type != o.type) {
1339 type = o.type;
1340 changes |= TYPE_CHANGED;
1341 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001342 if (flags != o.flags) {
1343 flags = o.flags;
Chet Haase40e03832011-10-06 08:34:13 -07001344 changes |= FLAGS_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001345 }
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001346 if (privateFlags != o.privateFlags) {
1347 privateFlags = o.privateFlags;
1348 changes |= PRIVATE_FLAGS_CHANGED;
1349 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001350 if (softInputMode != o.softInputMode) {
1351 softInputMode = o.softInputMode;
1352 changes |= SOFT_INPUT_MODE_CHANGED;
1353 }
1354 if (gravity != o.gravity) {
1355 gravity = o.gravity;
Chet Haase40e03832011-10-06 08:34:13 -07001356 changes |= LAYOUT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001357 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001358 if (format != o.format) {
1359 format = o.format;
Chet Haase40e03832011-10-06 08:34:13 -07001360 changes |= FORMAT_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001361 }
1362 if (windowAnimations != o.windowAnimations) {
1363 windowAnimations = o.windowAnimations;
1364 changes |= ANIMATION_CHANGED;
1365 }
1366 if (token == null) {
1367 // NOTE: token only copied if the recipient doesn't
1368 // already have one.
1369 token = o.token;
1370 }
1371 if (packageName == null) {
1372 // NOTE: packageName only copied if the recipient doesn't
1373 // already have one.
1374 packageName = o.packageName;
1375 }
1376 if (!mTitle.equals(o.mTitle)) {
1377 mTitle = o.mTitle;
1378 changes |= TITLE_CHANGED;
1379 }
1380 if (alpha != o.alpha) {
1381 alpha = o.alpha;
1382 changes |= ALPHA_CHANGED;
1383 }
1384 if (dimAmount != o.dimAmount) {
1385 dimAmount = o.dimAmount;
1386 changes |= DIM_AMOUNT_CHANGED;
1387 }
1388 if (screenBrightness != o.screenBrightness) {
1389 screenBrightness = o.screenBrightness;
1390 changes |= SCREEN_BRIGHTNESS_CHANGED;
1391 }
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001392 if (buttonBrightness != o.buttonBrightness) {
1393 buttonBrightness = o.buttonBrightness;
1394 changes |= BUTTON_BRIGHTNESS_CHANGED;
1395 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001396
1397 if (screenOrientation != o.screenOrientation) {
1398 screenOrientation = o.screenOrientation;
Chet Haase40e03832011-10-06 08:34:13 -07001399 changes |= SCREEN_ORIENTATION_CHANGED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001400 }
Romain Guy529b60a2010-08-03 18:05:47 -07001401
Joe Onorato14782f72011-01-25 19:53:17 -08001402 if (systemUiVisibility != o.systemUiVisibility
1403 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
Joe Onorato664644d2011-01-23 17:53:23 -08001404 systemUiVisibility = o.systemUiVisibility;
Joe Onorato14782f72011-01-25 19:53:17 -08001405 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
Joe Onorato664644d2011-01-23 17:53:23 -08001406 changes |= SYSTEM_UI_VISIBILITY_CHANGED;
1407 }
1408
1409 if (hasSystemUiListeners != o.hasSystemUiListeners) {
1410 hasSystemUiListeners = o.hasSystemUiListeners;
1411 changes |= SYSTEM_UI_LISTENER_CHANGED;
1412 }
1413
Jeff Brown474dcb52011-06-14 20:22:50 -07001414 if (inputFeatures != o.inputFeatures) {
1415 inputFeatures = o.inputFeatures;
1416 changes |= INPUT_FEATURES_CHANGED;
1417 }
1418
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001419 return changes;
1420 }
1421
1422 @Override
1423 public String debug(String output) {
1424 output += "Contents of " + this + ":";
1425 Log.d("Debug", output);
1426 output = super.debug("");
1427 Log.d("Debug", output);
1428 Log.d("Debug", "");
1429 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
1430 return "";
1431 }
1432
1433 @Override
1434 public String toString() {
1435 StringBuilder sb = new StringBuilder(256);
1436 sb.append("WM.LayoutParams{");
1437 sb.append("(");
1438 sb.append(x);
1439 sb.append(',');
1440 sb.append(y);
1441 sb.append(")(");
Romain Guy980a9382010-01-08 15:06:28 -08001442 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001443 sb.append('x');
Romain Guy980a9382010-01-08 15:06:28 -08001444 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001445 sb.append(")");
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001446 if (horizontalMargin != 0) {
1447 sb.append(" hm=");
1448 sb.append(horizontalMargin);
1449 }
1450 if (verticalMargin != 0) {
1451 sb.append(" vm=");
1452 sb.append(verticalMargin);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001453 }
1454 if (gravity != 0) {
1455 sb.append(" gr=#");
1456 sb.append(Integer.toHexString(gravity));
1457 }
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001458 if (softInputMode != 0) {
1459 sb.append(" sim=#");
1460 sb.append(Integer.toHexString(softInputMode));
1461 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001462 sb.append(" ty=");
1463 sb.append(type);
1464 sb.append(" fl=#");
1465 sb.append(Integer.toHexString(flags));
Dianne Hackborn5d927c22011-09-02 12:22:18 -07001466 if (privateFlags != 0) {
1467 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags));
1468 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001469 if (format != PixelFormat.OPAQUE) {
1470 sb.append(" fmt=");
1471 sb.append(format);
1472 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001473 if (windowAnimations != 0) {
1474 sb.append(" wanim=0x");
1475 sb.append(Integer.toHexString(windowAnimations));
1476 }
1477 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
1478 sb.append(" or=");
1479 sb.append(screenOrientation);
1480 }
Dianne Hackborn8eb2e242010-11-01 12:31:24 -07001481 if (alpha != 1.0f) {
1482 sb.append(" alpha=");
1483 sb.append(alpha);
1484 }
1485 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) {
1486 sb.append(" sbrt=");
1487 sb.append(screenBrightness);
1488 }
1489 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) {
1490 sb.append(" bbrt=");
1491 sb.append(buttonBrightness);
1492 }
Mitsuru Oshima5a2b91d2009-07-16 16:30:02 -07001493 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) {
1494 sb.append(" compatible=true");
1495 }
Joe Onorato664644d2011-01-23 17:53:23 -08001496 if (systemUiVisibility != 0) {
1497 sb.append(" sysui=0x");
1498 sb.append(Integer.toHexString(systemUiVisibility));
1499 }
Joe Onorato14782f72011-01-25 19:53:17 -08001500 if (subtreeSystemUiVisibility != 0) {
1501 sb.append(" vsysui=0x");
1502 sb.append(Integer.toHexString(subtreeSystemUiVisibility));
1503 }
Joe Onorato664644d2011-01-23 17:53:23 -08001504 if (hasSystemUiListeners) {
1505 sb.append(" sysuil=");
1506 sb.append(hasSystemUiListeners);
1507 }
Dianne Hackborna44abeb2011-08-08 19:24:01 -07001508 if (inputFeatures != 0) {
1509 sb.append(" if=0x").append(Integer.toHexString(inputFeatures));
1510 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001511 sb.append('}');
1512 return sb.toString();
1513 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001514
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001515 /**
1516 * Scale the layout params' coordinates and size.
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001517 * @hide
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001518 */
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001519 public void scale(float scale) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001520 x = (int) (x * scale + 0.5f);
1521 y = (int) (y * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001522 if (width > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001523 width = (int) (width * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001524 }
1525 if (height > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001526 height = (int) (height * scale + 0.5f);
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001527 }
1528 }
1529
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001530 /**
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001531 * Backup the layout parameters used in compatibility mode.
1532 * @see LayoutParams#restore()
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001533 */
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001534 void backup() {
1535 int[] backup = mCompatibilityParamsBackup;
1536 if (backup == null) {
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001537 // we backup 4 elements, x, y, width, height
1538 backup = mCompatibilityParamsBackup = new int[4];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001539 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001540 backup[0] = x;
1541 backup[1] = y;
1542 backup[2] = width;
1543 backup[3] = height;
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001544 }
1545
1546 /**
1547 * Restore the layout params' coordinates, size and gravity
1548 * @see LayoutParams#backup()
1549 */
1550 void restore() {
1551 int[] backup = mCompatibilityParamsBackup;
1552 if (backup != null) {
1553 x = backup[0];
1554 y = backup[1];
1555 width = backup[2];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001556 height = backup[3];
1557 }
1558 }
1559
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001560 private CharSequence mTitle = "";
1561 }
1562}