blob: eddd04ebd3144c725eaf56b645cd494958c1d9b6 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.view;
18
19import android.content.pm.ActivityInfo;
20import android.graphics.PixelFormat;
21import android.os.IBinder;
22import android.os.Parcel;
23import android.os.Parcelable;
24import android.text.TextUtils;
25import android.util.Log;
26
27
28/**
29 * The interface that apps use to talk to the window manager.
30 * <p>
31 * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these.
32 *
33 * @see android.content.Context#getSystemService
34 * @see android.content.Context#WINDOW_SERVICE
35 */
36public interface WindowManager extends ViewManager {
37 /**
38 * Exception that is thrown when trying to add view whose
39 * {@link WindowManager.LayoutParams} {@link WindowManager.LayoutParams#token}
40 * is invalid.
41 */
42 public static class BadTokenException extends RuntimeException {
43 public BadTokenException() {
44 }
45
46 public BadTokenException(String name) {
47 super(name);
48 }
49 }
50
51 /**
52 * Use this method to get the default Display object.
53 *
54 * @return default Display object
55 */
56 public Display getDefaultDisplay();
57
58 /**
59 * Special variation of {@link #removeView} that immediately invokes
60 * the given view hierarchy's {@link View#onDetachedFromWindow()
61 * View.onDetachedFromWindow()} methods before returning. This is not
62 * for normal applications; using it correctly requires great care.
63 *
64 * @param view The view to be removed.
65 */
66 public void removeViewImmediate(View view);
67
68 public static class LayoutParams extends ViewGroup.LayoutParams
69 implements Parcelable {
70 /**
71 * X position for this window. With the default gravity it is ignored.
72 * When using {@link Gravity#LEFT} or {@link Gravity#RIGHT} it provides
73 * an offset from the given edge.
74 */
Romain Guy529b60a2010-08-03 18:05:47 -070075 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 public int x;
77
78 /**
79 * Y position for this window. With the default gravity it is ignored.
80 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
81 * an offset from the given edge.
82 */
Romain Guy529b60a2010-08-03 18:05:47 -070083 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080084 public int y;
85
86 /**
87 * Indicates how much of the extra space will be allocated horizontally
88 * to the view associated with these LayoutParams. Specify 0 if the view
89 * should not be stretched. Otherwise the extra pixels will be pro-rated
90 * among all views whose weight is greater than 0.
91 */
Romain Guy529b60a2010-08-03 18:05:47 -070092 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093 public float horizontalWeight;
94
95 /**
96 * Indicates how much of the extra space will be allocated vertically
97 * to the view associated with these LayoutParams. Specify 0 if the view
98 * should not be stretched. Otherwise the extra pixels will be pro-rated
99 * among all views whose weight is greater than 0.
100 */
Romain Guy529b60a2010-08-03 18:05:47 -0700101 @ViewDebug.ExportedProperty
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102 public float verticalWeight;
Romain Guy529b60a2010-08-03 18:05:47 -0700103
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104 /**
105 * The general type of window. There are three main classes of
106 * window types:
107 * <ul>
108 * <li> <strong>Application windows</strong> (ranging from
109 * {@link #FIRST_APPLICATION_WINDOW} to
110 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
111 * windows. For these types of windows, the {@link #token} must be
112 * set to the token of the activity they are a part of (this will
113 * normally be done for you if {@link #token} is null).
114 * <li> <strong>Sub-windows</strong> (ranging from
115 * {@link #FIRST_SUB_WINDOW} to
116 * {@link #LAST_SUB_WINDOW}) are associated with another top-level
117 * window. For these types of windows, the {@link #token} must be
118 * the token of the window it is attached to.
119 * <li> <strong>System windows</strong> (ranging from
120 * {@link #FIRST_SYSTEM_WINDOW} to
121 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
122 * use by the system for specific purposes. They should not normally
123 * be used by applications, and a special permission is required
124 * to use them.
125 * </ul>
126 *
127 * @see #TYPE_BASE_APPLICATION
128 * @see #TYPE_APPLICATION
129 * @see #TYPE_APPLICATION_STARTING
130 * @see #TYPE_APPLICATION_PANEL
131 * @see #TYPE_APPLICATION_MEDIA
132 * @see #TYPE_APPLICATION_SUB_PANEL
133 * @see #TYPE_APPLICATION_ATTACHED_DIALOG
134 * @see #TYPE_STATUS_BAR
135 * @see #TYPE_SEARCH_BAR
136 * @see #TYPE_PHONE
137 * @see #TYPE_SYSTEM_ALERT
138 * @see #TYPE_KEYGUARD
139 * @see #TYPE_TOAST
140 * @see #TYPE_SYSTEM_OVERLAY
141 * @see #TYPE_PRIORITY_PHONE
142 * @see #TYPE_STATUS_BAR_PANEL
143 * @see #TYPE_SYSTEM_DIALOG
144 * @see #TYPE_KEYGUARD_DIALOG
145 * @see #TYPE_SYSTEM_ERROR
146 * @see #TYPE_INPUT_METHOD
147 * @see #TYPE_INPUT_METHOD_DIALOG
148 */
Joe Onorato8f2bd432010-03-25 11:45:28 -0700149 @ViewDebug.ExportedProperty(mapping = {
150 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"),
151 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"),
152 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"),
153 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"),
154 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"),
155 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"),
156 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"),
157 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"),
158 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"),
159 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"),
160 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"),
161 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"),
162 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"),
163 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"),
164 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"),
165 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"),
166 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"),
167 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"),
168 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"),
169 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"),
170 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG")
171 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800172 public int type;
173
174 /**
175 * Start of window types that represent normal application windows.
176 */
177 public static final int FIRST_APPLICATION_WINDOW = 1;
178
179 /**
180 * Window type: an application window that serves as the "base" window
181 * of the overall application; all other application windows will
182 * appear on top of it.
183 */
184 public static final int TYPE_BASE_APPLICATION = 1;
185
186 /**
187 * Window type: a normal application window. The {@link #token} must be
188 * an Activity token identifying who the window belongs to.
189 */
190 public static final int TYPE_APPLICATION = 2;
191
192 /**
193 * Window type: special application window that is displayed while the
194 * application is starting. Not for use by applications themselves;
195 * this is used by the system to display something until the
196 * application can show its own windows.
197 */
198 public static final int TYPE_APPLICATION_STARTING = 3;
199
200 /**
201 * End of types of application windows.
202 */
203 public static final int LAST_APPLICATION_WINDOW = 99;
204
205 /**
206 * Start of types of sub-windows. The {@link #token} of these windows
207 * must be set to the window they are attached to. These types of
208 * windows are kept next to their attached window in Z-order, and their
209 * coordinate space is relative to their attached window.
210 */
211 public static final int FIRST_SUB_WINDOW = 1000;
212
213 /**
214 * Window type: a panel on top of an application window. These windows
215 * appear on top of their attached window.
216 */
217 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
218
219 /**
220 * Window type: window for showing media (e.g. video). These windows
221 * are displayed behind their attached window.
222 */
223 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1;
224
225 /**
226 * Window type: a sub-panel on top of an application window. These
227 * windows are displayed on top their attached window and any
228 * {@link #TYPE_APPLICATION_PANEL} panels.
229 */
230 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2;
231
232 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
233 * of the window happens as that of a top-level window, <em>not</em>
234 * as a child of its container.
235 */
236 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3;
237
238 /**
Dianne Hackbornc4d5d022009-05-21 17:32:42 -0700239 * Window type: window for showing overlays on top of media windows.
240 * These windows are displayed between TYPE_APPLICATION_MEDIA and the
241 * application window. They should be translucent to be useful. This
242 * is a big ugly hack so:
243 * @hide
244 */
245 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4;
246
247 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800248 * End of types of sub-windows.
249 */
250 public static final int LAST_SUB_WINDOW = 1999;
251
252 /**
253 * Start of system-specific window types. These are not normally
254 * created by applications.
255 */
256 public static final int FIRST_SYSTEM_WINDOW = 2000;
257
258 /**
259 * Window type: the status bar. There can be only one status bar
260 * window; it is placed at the top of the screen, and all other
261 * windows are shifted down so they are below it.
262 */
263 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW;
264
265 /**
266 * Window type: the search bar. There can be only one search bar
267 * window; it is placed at the top of the screen.
268 */
269 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1;
270
271 /**
272 * Window type: phone. These are non-application windows providing
273 * user interaction with the phone (in particular incoming calls).
274 * These windows are normally placed above all applications, but behind
275 * the status bar.
276 */
277 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2;
278
279 /**
280 * Window type: system window, such as low power alert. These windows
281 * are always on top of application windows.
282 */
283 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3;
284
285 /**
286 * Window type: keyguard window.
287 */
288 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4;
289
290 /**
291 * Window type: transient notifications.
292 */
293 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5;
294
295 /**
296 * Window type: system overlay windows, which need to be displayed
297 * on top of everything else. These windows must not take input
298 * focus, or they will interfere with the keyguard.
299 */
300 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6;
301
302 /**
303 * Window type: priority phone UI, which needs to be displayed even if
304 * the keyguard is active. These windows must not take input
305 * focus, or they will interfere with the keyguard.
306 */
307 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7;
308
309 /**
310 * Window type: panel that slides out from the status bar
311 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800312 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8;
313
314 /**
315 * Window type: dialogs that the keyguard shows
316 */
317 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9;
318
319 /**
320 * Window type: internal system error windows, appear on top of
321 * everything they can.
322 */
323 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10;
324
325 /**
326 * Window type: internal input methods windows, which appear above
327 * the normal UI. Application windows may be resized or panned to keep
328 * the input focus visible while this window is displayed.
329 */
330 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11;
331
332 /**
333 * Window type: internal input methods dialog windows, which appear above
334 * the current input method window.
335 */
336 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
337
338 /**
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700339 * Window type: wallpaper window, placed behind any window that wants
340 * to sit on top of the wallpaper.
341 */
342 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13;
343
344 /**
Dianne Hackbornbadc47e2009-11-08 17:37:07 -0800345 * Window type: panel that slides out from the status bar
346 */
347 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14;
348
349 /**
Christopher Tatea53146c2010-09-07 11:57:52 -0700350 * Window type: the drag-and-drop pseudowindow. There is only one
351 * drag layer (at most), and it is placed on top of all other windows.
352 * @hide
353 */
354 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+15;
355
356 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800357 * End of types of system windows.
358 */
359 public static final int LAST_SYSTEM_WINDOW = 2999;
360
361 /**
362 * Specifies what type of memory buffers should be used by this window.
363 * Default is normal.
364 *
365 * @see #MEMORY_TYPE_NORMAL
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800366 * @see #MEMORY_TYPE_PUSH_BUFFERS
367 */
368 public int memoryType;
369
370 /** Memory type: The window's surface is allocated in main memory. */
371 public static final int MEMORY_TYPE_NORMAL = 0;
372 /** Memory type: The window's surface is configured to be accessible
Mathias Agopian317a6282009-08-13 17:29:02 -0700373 * by DMA engines and hardware accelerators.
374 * @deprecated this is ignored, this value is set automatically when needed.
375 */
376 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800377 public static final int MEMORY_TYPE_HARDWARE = 1;
378 /** Memory type: The window's surface is configured to be accessible
Mathias Agopian317a6282009-08-13 17:29:02 -0700379 * by graphics accelerators.
380 * @deprecated this is ignored, this value is set automatically when needed.
381 */
382 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800383 public static final int MEMORY_TYPE_GPU = 2;
384 /** Memory type: The window's surface doesn't own its buffers and
385 * therefore cannot be locked. Instead the buffers are pushed to
386 * it through native binder calls. */
387 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
388
389 /**
390 * Various behavioral options/flags. Default is none.
391 *
392 * @see #FLAG_BLUR_BEHIND
393 * @see #FLAG_DIM_BEHIND
394 * @see #FLAG_NOT_FOCUSABLE
395 * @see #FLAG_NOT_TOUCHABLE
396 * @see #FLAG_NOT_TOUCH_MODAL
397 * @see #FLAG_LAYOUT_IN_SCREEN
398 * @see #FLAG_DITHER
399 * @see #FLAG_KEEP_SCREEN_ON
400 * @see #FLAG_FULLSCREEN
401 * @see #FLAG_FORCE_NOT_FULLSCREEN
402 * @see #FLAG_IGNORE_CHEEK_PRESSES
Romain Guy529b60a2010-08-03 18:05:47 -0700403 * @see #FLAG_HARDWARE_ACCELERATED
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800404 */
Joe Onorato8f2bd432010-03-25 11:45:28 -0700405 @ViewDebug.ExportedProperty(flagMapping = {
406 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
407 name = "FLAG_BLUR_BEHIND"),
408 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
409 name = "FLAG_DIM_BEHIND"),
410 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
411 name = "FLAG_NOT_FOCUSABLE"),
412 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
413 name = "FLAG_NOT_TOUCHABLE"),
414 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
415 name = "FLAG_NOT_TOUCH_MODAL"),
416 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
417 name = "FLAG_LAYOUT_IN_SCREEN"),
418 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
419 name = "FLAG_DITHER"),
Daniel Sandler20e92712010-04-02 16:51:58 -0400420 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
421 name = "FLAG_TURN_SCREEN_ON"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700422 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
423 name = "FLAG_KEEP_SCREEN_ON"),
Daniel Sandler20e92712010-04-02 16:51:58 -0400424 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
425 name = "FLAG_SHOW_WHEN_LOCKED"),
426 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
427 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
428 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
429 name = "FLAG_DISMISS_KEYGUARD"),
Joe Onorato8f2bd432010-03-25 11:45:28 -0700430 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
431 name = "FLAG_FULLSCREEN"),
432 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN,
433 equals = FLAG_FORCE_NOT_FULLSCREEN, name = "FLAG_FORCE_NOT_FULLSCREEN"),
434 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES,
Romain Guy529b60a2010-08-03 18:05:47 -0700435 equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES"),
436 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED,
437 equals = FLAG_HARDWARE_ACCELERATED, name = "FLAG_HARDWARE_ACCELERATED")
Joe Onorato8f2bd432010-03-25 11:45:28 -0700438 })
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800439 public int flags;
440
Mike Lockwoodef731622010-01-27 17:51:34 -0500441 /** Window flag: as long as this window is visible to the user, allow
442 * the lock screen to activate while the screen is on.
443 * This can be used independently, or in combination with
Christopher Tate95f78502010-01-29 15:57:34 -0800444 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
Mike Lockwoodef731622010-01-27 17:51:34 -0500445 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001;
446
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800447 /** Window flag: everything behind this window will be dimmed.
448 * Use {@link #dimAmount} to control the amount of dim. */
449 public static final int FLAG_DIM_BEHIND = 0x00000002;
450
451 /** Window flag: blur everything behind this window. */
452 public static final int FLAG_BLUR_BEHIND = 0x00000004;
453
454 /** Window flag: this window won't ever get key input focus, so the
455 * user can not send key or other button events to it. Those will
456 * instead go to whatever focusable window is behind it. This flag
457 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
458 * is explicitly set.
459 *
460 * <p>Setting this flag also implies that the window will not need to
461 * interact with
462 * a soft input method, so it will be Z-ordered and positioned
463 * independently of any active input method (typically this means it
464 * gets Z-ordered on top of the input method, so it can use the full
465 * screen for its content and cover the input method if needed. You
466 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
467 public static final int FLAG_NOT_FOCUSABLE = 0x00000008;
468
469 /** Window flag: this window can never receive touch events. */
470 public static final int FLAG_NOT_TOUCHABLE = 0x00000010;
471
472 /** Window flag: Even when this window is focusable (its
473 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events
474 * outside of the window to be sent to the windows behind it. Otherwise
475 * it will consume all pointer events itself, regardless of whether they
476 * are inside of the window. */
477 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020;
478
479 /** Window flag: When set, if the device is asleep when the touch
480 * screen is pressed, you will receive this first touch event. Usually
481 * the first touch event is consumed by the system since the user can
482 * not see what they are pressing on.
483 */
484 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
485
486 /** Window flag: as long as this window is visible to the user, keep
487 * the device's screen turned on and bright. */
488 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080;
489
490 /** Window flag: place the window within the entire screen, ignoring
491 * decorations around the border (a.k.a. the status bar). The
492 * window must correctly position its contents to take the screen
493 * decoration into account. This flag is normally set for you
494 * by Window as described in {@link Window#setFlags}. */
495 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100;
496
497 /** Window flag: allow window to extend outside of the screen. */
498 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200;
499
500 /** Window flag: Hide all screen decorations (e.g. status bar) while
501 * this window is displayed. This allows the window to use the entire
502 * display space for itself -- the status bar will be hidden when
503 * an app window with this flag set is on the top layer. */
504 public static final int FLAG_FULLSCREEN = 0x00000400;
505
506 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the
507 * screen decorations (such as status bar) to be shown. */
508 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800;
509
510 /** Window flag: turn on dithering when compositing this window to
511 * the screen. */
512 public static final int FLAG_DITHER = 0x00001000;
513
514 /** Window flag: don't allow screen shots while this window is
515 * displayed. */
516 public static final int FLAG_SECURE = 0x00002000;
517
518 /** Window flag: a special mode where the layout parameters are used
519 * to perform scaling of the surface when it is composited to the
520 * screen. */
521 public static final int FLAG_SCALED = 0x00004000;
522
523 /** Window flag: intended for windows that will often be used when the user is
524 * holding the screen against their face, it will aggressively filter the event
525 * stream to prevent unintended presses in this situation that may not be
526 * desired for a particular window, when such an event stream is detected, the
527 * application will receive a CANCEL motion event to indicate this so applications
528 * can handle this accordingly by taking no action on the event
529 * until the finger is released. */
530 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000;
531
532 /** Window flag: a special option only for use in combination with
533 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the
534 * screen your window may appear on top of or behind screen decorations
535 * such as the status bar. By also including this flag, the window
536 * manager will report the inset rectangle needed to ensure your
537 * content is not covered by screen decorations. This flag is normally
538 * set for you by Window as described in {@link Window#setFlags}.*/
539 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
540
541 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
542 * respect to how this window interacts with the current method. That
543 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
544 * window will behave as if it needs to interact with the input method
545 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
546 * not set and this flag is set, then the window will behave as if it
547 * doesn't need to interact with the input method and can be placed
548 * to use more space and cover the input method.
549 */
550 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
551
552 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
553 * can set this flag to receive a single special MotionEvent with
554 * the action
555 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
556 * touches that occur outside of your window. Note that you will not
557 * receive the full down/move/up gesture, only the location of the
558 * first down as an ACTION_OUTSIDE.
559 */
560 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
561
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700562 /** Window flag: special flag to let windows be shown when the screen
563 * is locked. This will let application windows take precedence over
564 * key guard or any other lock screens. Can be used with
565 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700566 * directly before showing the key guard window. Can be used with
567 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
568 * non-secure keyguards. This flag only applies to the top-most
569 * full-screen window.
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700570 */
Suchi Amalapurapud1a93372009-05-14 17:54:31 -0700571 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
572
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700573 /** Window flag: ask that the system wallpaper be shown behind
574 * your window. The window surface must be translucent to be able
575 * to actually see the wallpaper behind it; this flag just ensures
576 * that the wallpaper surface will be there if this window actually
577 * has translucent regions.
578 */
579 public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
580
Dianne Hackborn93e462b2009-09-15 22:50:40 -0700581 /** Window flag: when set as a window is being added or made
582 * visible, once the window has been shown then the system will
583 * poke the power manager's user activity (as if the user had woken
584 * up the device) to turn the screen on. */
585 public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
586
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700587 /** Window flag: when set the window will cause the keyguard to
588 * be dismissed, only if it is not a secure lock keyguard. Because such
589 * a keyguard is not needed for security, it will never re-appear if
590 * the user navigates to another window (in contrast to
591 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
592 * hide both secure and non-secure keyguards but ensure they reappear
593 * when the user moves to another UI that doesn't hide them).
594 * If the keyguard is currently active and is secure (requires an
595 * unlock pattern) than the user will still need to confirm it before
596 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has
Daniel Sandlerae069f72010-06-17 21:56:26 -0400597 * also been set.
598 */
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700599 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
Jeff Brown01ce2e92010-09-26 22:20:12 -0700600
601 /** Window flag: when set the window will accept for touch events
602 * outside of its bounds to be sent to other windows that also
603 * support split touch. When this flag is not set, the first pointer
604 * that goes down determines the window to which all subsequent touches
605 * go until all pointers go up. When this flag is set, each pointer
606 * (not necessarily the first) that goes down determines the window
607 * to which all subsequent touches of that pointer will go until that
608 * pointer goes up thereby enabling touches with multiple pointers
609 * to be split across multiple windows.
610 *
611 * {@hide} */
612 public static final int FLAG_SPLIT_TOUCH = 0x00800000;
Daniel Sandler611fae42010-06-17 10:45:00 -0400613
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700614 /** Window flag: *sigh* The lock screen wants to continue running its
615 * animation while it is fading. A kind-of hack to allow this. Maybe
616 * in the future we just make this the default behavior.
617 *
618 * {@hide} */
619 public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000;
620
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700621 /** Window flag: special flag to limit the size of the window to be
622 * original size ([320x480] x density). Used to create window for applications
623 * running under compatibility mode.
624 *
625 * {@hide} */
Dianne Hackborn4c62fc02009-08-08 20:40:27 -0700626 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000;
Mitsuru Oshima1ecf5d22009-07-06 17:20:38 -0700627
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800628 /** Window flag: a special option intended for system dialogs. When
629 * this flag is set, the window will demand focus unconditionally when
630 * it is created.
631 * {@hide} */
632 public static final int FLAG_SYSTEM_ERROR = 0x40000000;
Romain Guy529b60a2010-08-03 18:05:47 -0700633
634 /**
635 * Indicates whether this window should be hardware accelerated.
636 * Requesting hardware acceleration does not guarantee it will happen.
637 */
638 public static final int FLAG_HARDWARE_ACCELERATED = 0x80000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800639
640 /**
641 * Given a particular set of window manager flags, determine whether
642 * such a window may be a target for an input method when it has
643 * focus. In particular, this checks the
644 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
645 * flags and returns true if the combination of the two corresponds
646 * to a window that needs to be behind the input method so that the
647 * user can type into it.
648 *
649 * @param flags The current window manager flags.
650 *
651 * @return Returns true if such a window should be behind/interact
652 * with an input method, false if not.
653 */
654 public static boolean mayUseInputMethod(int flags) {
655 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
656 case 0:
657 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
658 return true;
659 }
660 return false;
661 }
662
663 /**
664 * Mask for {@link #softInputMode} of the bits that determine the
665 * desired visibility state of the soft input area for this window.
666 */
667 public static final int SOFT_INPUT_MASK_STATE = 0x0f;
668
669 /**
670 * Visibility state for {@link #softInputMode}: no state has been specified.
671 */
672 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
673
674 /**
675 * Visibility state for {@link #softInputMode}: please don't change the state of
676 * the soft input area.
677 */
678 public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
679
680 /**
681 * Visibility state for {@link #softInputMode}: please hide any soft input
682 * area when normally appropriate (when the user is navigating
683 * forward to your window).
684 */
685 public static final int SOFT_INPUT_STATE_HIDDEN = 2;
686
687 /**
688 * Visibility state for {@link #softInputMode}: please always hide any
689 * soft input area when this window receives focus.
690 */
691 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
692
693 /**
694 * Visibility state for {@link #softInputMode}: please show the soft
695 * input area when normally appropriate (when the user is navigating
696 * forward to your window).
697 */
698 public static final int SOFT_INPUT_STATE_VISIBLE = 4;
699
700 /**
701 * Visibility state for {@link #softInputMode}: please always make the
702 * soft input area visible when this window receives input focus.
703 */
704 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
705
706 /**
707 * Mask for {@link #softInputMode} of the bits that determine the
708 * way that the window should be adjusted to accommodate the soft
709 * input window.
710 */
711 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
712
713 /** Adjustment option for {@link #softInputMode}: nothing specified.
714 * The system will try to pick one or
715 * the other depending on the contents of the window.
716 */
717 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
718
719 /** Adjustment option for {@link #softInputMode}: set to allow the
720 * window to be resized when an input
721 * method is shown, so that its contents are not covered by the input
Scott Mainf10e6332010-06-11 09:03:22 -0700722 * method. This can <em>not</em> be combined with
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800723 * {@link #SOFT_INPUT_ADJUST_PAN}; if
724 * neither of these are set, then the system will try to pick one or
725 * the other depending on the contents of the window.
726 */
727 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
728
729 /** Adjustment option for {@link #softInputMode}: set to have a window
730 * pan when an input method is
731 * shown, so it doesn't need to deal with resizing but just panned
732 * by the framework to ensure the current input focus is visible. This
Scott Mainf10e6332010-06-11 09:03:22 -0700733 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800734 * neither of these are set, then the system will try to pick one or
735 * the other depending on the contents of the window.
736 */
737 public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
738
739 /**
740 * Bit for {@link #softInputMode}: set when the user has navigated
741 * forward to the window. This is normally set automatically for
742 * you by the system, though you may want to set it in certain cases
743 * when you are displaying a window yourself. This flag will always
744 * be cleared automatically after the window is displayed.
745 */
746 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500747
748 /**
749 * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
750 * indicating that the brightness value is not overridden for this window
751 * and normal brightness policy should be used.
752 */
753 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
754
755 /**
756 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
757 * indicating that the screen or button backlight brightness should be set
758 * to the lowest value when this window is in front.
759 */
760 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
761
762 /**
763 * Value for {@link #screenBrightness} and {@link #buttonBrightness}
764 * indicating that the screen or button backlight brightness should be set
765 * to the hightest value when this window is in front.
766 */
767 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
768
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800769 /**
770 * Desired operating mode for any soft input area. May any combination
771 * of:
772 *
773 * <ul>
774 * <li> One of the visibility states
775 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
776 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
777 * {@link #SOFT_INPUT_STATE_VISIBLE}.
778 * <li> One of the adjustment options
779 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
780 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or
781 * {@link #SOFT_INPUT_ADJUST_PAN}.
782 */
783 public int softInputMode;
784
785 /**
786 * Placement of window within the screen as per {@link Gravity}
787 *
788 * @see Gravity
789 */
790 public int gravity;
791
792 /**
793 * The horizontal margin, as a percentage of the container's width,
794 * between the container and the widget.
795 */
796 public float horizontalMargin;
797
798 /**
799 * The vertical margin, as a percentage of the container's height,
800 * between the container and the widget.
801 */
802 public float verticalMargin;
803
804 /**
805 * The desired bitmap format. May be one of the constants in
806 * {@link android.graphics.PixelFormat}. Default is OPAQUE.
807 */
808 public int format;
809
810 /**
811 * A style resource defining the animations to use for this window.
812 * This must be a system resource; it can not be an application resource
813 * because the window manager does not have access to applications.
814 */
815 public int windowAnimations;
816
817 /**
818 * An alpha value to apply to this entire window.
819 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
820 */
821 public float alpha = 1.0f;
822
823 /**
824 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
825 * to apply. Range is from 1.0 for completely opaque to 0.0 for no
826 * dim.
827 */
828 public float dimAmount = 1.0f;
829
830 /**
831 * This can be used to override the user's preferred brightness of
832 * the screen. A value of less than 0, the default, means to use the
833 * preferred screen brightness. 0 to 1 adjusts the brightness from
834 * dark to full bright.
835 */
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500836 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800837
838 /**
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500839 * This can be used to override the standard behavior of the button and
840 * keyboard backlights. A value of less than 0, the default, means to
841 * use the standard backlight behavior. 0 to 1 adjusts the brightness
842 * from dark to full bright.
843 */
844 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
845
846 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800847 * Identifier for this window. This will usually be filled in for
848 * you.
849 */
850 public IBinder token = null;
851
852 /**
853 * Name of the package owning this window.
854 */
855 public String packageName = null;
856
857 /**
858 * Specific orientation value for a window.
859 * May be any of the same values allowed
860 * for {@link android.content.pm.ActivityInfo#screenOrientation}.
861 * If not set, a default value of
862 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
863 * will be used.
864 */
865 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
866
867
868 public LayoutParams() {
Romain Guy980a9382010-01-08 15:06:28 -0800869 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800870 type = TYPE_APPLICATION;
871 format = PixelFormat.OPAQUE;
872 }
873
874 public LayoutParams(int _type) {
Romain Guy980a9382010-01-08 15:06:28 -0800875 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800876 type = _type;
877 format = PixelFormat.OPAQUE;
878 }
879
880 public LayoutParams(int _type, int _flags) {
Romain Guy980a9382010-01-08 15:06:28 -0800881 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800882 type = _type;
883 flags = _flags;
884 format = PixelFormat.OPAQUE;
885 }
886
887 public LayoutParams(int _type, int _flags, int _format) {
Romain Guy980a9382010-01-08 15:06:28 -0800888 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800889 type = _type;
890 flags = _flags;
891 format = _format;
892 }
893
894 public LayoutParams(int w, int h, int _type, int _flags, int _format) {
895 super(w, h);
896 type = _type;
897 flags = _flags;
898 format = _format;
899 }
900
901 public LayoutParams(int w, int h, int xpos, int ypos, int _type,
902 int _flags, int _format) {
903 super(w, h);
904 x = xpos;
905 y = ypos;
906 type = _type;
907 flags = _flags;
908 format = _format;
909 }
910
911 public final void setTitle(CharSequence title) {
912 if (null == title)
913 title = "";
914
915 mTitle = TextUtils.stringOrSpannedString(title);
916 }
917
918 public final CharSequence getTitle() {
919 return mTitle;
920 }
921
922 public int describeContents() {
923 return 0;
924 }
925
926 public void writeToParcel(Parcel out, int parcelableFlags) {
927 out.writeInt(width);
928 out.writeInt(height);
929 out.writeInt(x);
930 out.writeInt(y);
931 out.writeInt(type);
932 out.writeInt(memoryType);
933 out.writeInt(flags);
934 out.writeInt(softInputMode);
935 out.writeInt(gravity);
936 out.writeFloat(horizontalMargin);
937 out.writeFloat(verticalMargin);
938 out.writeInt(format);
939 out.writeInt(windowAnimations);
940 out.writeFloat(alpha);
941 out.writeFloat(dimAmount);
942 out.writeFloat(screenBrightness);
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500943 out.writeFloat(buttonBrightness);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800944 out.writeStrongBinder(token);
945 out.writeString(packageName);
946 TextUtils.writeToParcel(mTitle, out, parcelableFlags);
947 out.writeInt(screenOrientation);
948 }
949
950 public static final Parcelable.Creator<LayoutParams> CREATOR
951 = new Parcelable.Creator<LayoutParams>() {
952 public LayoutParams createFromParcel(Parcel in) {
953 return new LayoutParams(in);
954 }
955
956 public LayoutParams[] newArray(int size) {
957 return new LayoutParams[size];
958 }
959 };
960
961
962 public LayoutParams(Parcel in) {
963 width = in.readInt();
964 height = in.readInt();
965 x = in.readInt();
966 y = in.readInt();
967 type = in.readInt();
968 memoryType = in.readInt();
969 flags = in.readInt();
970 softInputMode = in.readInt();
971 gravity = in.readInt();
972 horizontalMargin = in.readFloat();
973 verticalMargin = in.readFloat();
974 format = in.readInt();
975 windowAnimations = in.readInt();
976 alpha = in.readFloat();
977 dimAmount = in.readFloat();
978 screenBrightness = in.readFloat();
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500979 buttonBrightness = in.readFloat();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800980 token = in.readStrongBinder();
981 packageName = in.readString();
982 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
983 screenOrientation = in.readInt();
984 }
985
Romain Guy72998072009-06-22 11:09:20 -0700986 @SuppressWarnings({"PointlessBitwiseExpression"})
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800987 public static final int LAYOUT_CHANGED = 1<<0;
988 public static final int TYPE_CHANGED = 1<<1;
989 public static final int FLAGS_CHANGED = 1<<2;
990 public static final int FORMAT_CHANGED = 1<<3;
991 public static final int ANIMATION_CHANGED = 1<<4;
992 public static final int DIM_AMOUNT_CHANGED = 1<<5;
993 public static final int TITLE_CHANGED = 1<<6;
994 public static final int ALPHA_CHANGED = 1<<7;
995 public static final int MEMORY_TYPE_CHANGED = 1<<8;
996 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
997 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
998 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
Mike Lockwoodfb73f792009-11-20 11:31:18 -0500999 /** {@hide} */
1000 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001001
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001002 // internal buffer to backup/restore parameters under compatibility mode.
1003 private int[] mCompatibilityParamsBackup = null;
1004
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001005 public final int copyFrom(LayoutParams o) {
1006 int changes = 0;
1007
1008 if (width != o.width) {
1009 width = o.width;
1010 changes |= LAYOUT_CHANGED;
1011 }
1012 if (height != o.height) {
1013 height = o.height;
1014 changes |= LAYOUT_CHANGED;
1015 }
1016 if (x != o.x) {
1017 x = o.x;
1018 changes |= LAYOUT_CHANGED;
1019 }
1020 if (y != o.y) {
1021 y = o.y;
1022 changes |= LAYOUT_CHANGED;
1023 }
1024 if (horizontalWeight != o.horizontalWeight) {
1025 horizontalWeight = o.horizontalWeight;
1026 changes |= LAYOUT_CHANGED;
1027 }
1028 if (verticalWeight != o.verticalWeight) {
1029 verticalWeight = o.verticalWeight;
1030 changes |= LAYOUT_CHANGED;
1031 }
1032 if (horizontalMargin != o.horizontalMargin) {
1033 horizontalMargin = o.horizontalMargin;
1034 changes |= LAYOUT_CHANGED;
1035 }
1036 if (verticalMargin != o.verticalMargin) {
1037 verticalMargin = o.verticalMargin;
1038 changes |= LAYOUT_CHANGED;
1039 }
1040 if (type != o.type) {
1041 type = o.type;
1042 changes |= TYPE_CHANGED;
1043 }
1044 if (memoryType != o.memoryType) {
1045 memoryType = o.memoryType;
1046 changes |= MEMORY_TYPE_CHANGED;
1047 }
1048 if (flags != o.flags) {
1049 flags = o.flags;
1050 changes |= FLAGS_CHANGED;
1051 }
1052 if (softInputMode != o.softInputMode) {
1053 softInputMode = o.softInputMode;
1054 changes |= SOFT_INPUT_MODE_CHANGED;
1055 }
1056 if (gravity != o.gravity) {
1057 gravity = o.gravity;
1058 changes |= LAYOUT_CHANGED;
1059 }
1060 if (horizontalMargin != o.horizontalMargin) {
1061 horizontalMargin = o.horizontalMargin;
1062 changes |= LAYOUT_CHANGED;
1063 }
1064 if (verticalMargin != o.verticalMargin) {
1065 verticalMargin = o.verticalMargin;
1066 changes |= LAYOUT_CHANGED;
1067 }
1068 if (format != o.format) {
1069 format = o.format;
1070 changes |= FORMAT_CHANGED;
1071 }
1072 if (windowAnimations != o.windowAnimations) {
1073 windowAnimations = o.windowAnimations;
1074 changes |= ANIMATION_CHANGED;
1075 }
1076 if (token == null) {
1077 // NOTE: token only copied if the recipient doesn't
1078 // already have one.
1079 token = o.token;
1080 }
1081 if (packageName == null) {
1082 // NOTE: packageName only copied if the recipient doesn't
1083 // already have one.
1084 packageName = o.packageName;
1085 }
1086 if (!mTitle.equals(o.mTitle)) {
1087 mTitle = o.mTitle;
1088 changes |= TITLE_CHANGED;
1089 }
1090 if (alpha != o.alpha) {
1091 alpha = o.alpha;
1092 changes |= ALPHA_CHANGED;
1093 }
1094 if (dimAmount != o.dimAmount) {
1095 dimAmount = o.dimAmount;
1096 changes |= DIM_AMOUNT_CHANGED;
1097 }
1098 if (screenBrightness != o.screenBrightness) {
1099 screenBrightness = o.screenBrightness;
1100 changes |= SCREEN_BRIGHTNESS_CHANGED;
1101 }
Mike Lockwoodfb73f792009-11-20 11:31:18 -05001102 if (buttonBrightness != o.buttonBrightness) {
1103 buttonBrightness = o.buttonBrightness;
1104 changes |= BUTTON_BRIGHTNESS_CHANGED;
1105 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001106
1107 if (screenOrientation != o.screenOrientation) {
1108 screenOrientation = o.screenOrientation;
1109 changes |= SCREEN_ORIENTATION_CHANGED;
1110 }
Romain Guy529b60a2010-08-03 18:05:47 -07001111
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001112 return changes;
1113 }
1114
1115 @Override
1116 public String debug(String output) {
1117 output += "Contents of " + this + ":";
1118 Log.d("Debug", output);
1119 output = super.debug("");
1120 Log.d("Debug", output);
1121 Log.d("Debug", "");
1122 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
1123 return "";
1124 }
1125
1126 @Override
1127 public String toString() {
1128 StringBuilder sb = new StringBuilder(256);
1129 sb.append("WM.LayoutParams{");
1130 sb.append("(");
1131 sb.append(x);
1132 sb.append(',');
1133 sb.append(y);
1134 sb.append(")(");
Romain Guy980a9382010-01-08 15:06:28 -08001135 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001136 sb.append('x');
Romain Guy980a9382010-01-08 15:06:28 -08001137 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height)));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001138 sb.append(")");
1139 if (softInputMode != 0) {
1140 sb.append(" sim=#");
1141 sb.append(Integer.toHexString(softInputMode));
1142 }
1143 if (gravity != 0) {
1144 sb.append(" gr=#");
1145 sb.append(Integer.toHexString(gravity));
1146 }
1147 sb.append(" ty=");
1148 sb.append(type);
1149 sb.append(" fl=#");
1150 sb.append(Integer.toHexString(flags));
1151 sb.append(" fmt=");
1152 sb.append(format);
1153 if (windowAnimations != 0) {
1154 sb.append(" wanim=0x");
1155 sb.append(Integer.toHexString(windowAnimations));
1156 }
1157 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
1158 sb.append(" or=");
1159 sb.append(screenOrientation);
1160 }
Mitsuru Oshima5a2b91d2009-07-16 16:30:02 -07001161 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) {
1162 sb.append(" compatible=true");
1163 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001164 sb.append('}');
1165 return sb.toString();
1166 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001167
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001168 /**
1169 * Scale the layout params' coordinates and size.
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001170 * @hide
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001171 */
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001172 public void scale(float scale) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001173 x = (int) (x * scale + 0.5f);
1174 y = (int) (y * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001175 if (width > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001176 width = (int) (width * scale + 0.5f);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001177 }
1178 if (height > 0) {
Mitsuru Oshima61324e52009-07-21 15:40:36 -07001179 height = (int) (height * scale + 0.5f);
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001180 }
1181 }
1182
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001183 /**
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001184 * Backup the layout parameters used in compatibility mode.
1185 * @see LayoutParams#restore()
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001186 */
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001187 void backup() {
1188 int[] backup = mCompatibilityParamsBackup;
1189 if (backup == null) {
Mitsuru Oshima64f59342009-06-21 00:03:11 -07001190 // we backup 4 elements, x, y, width, height
1191 backup = mCompatibilityParamsBackup = new int[4];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001192 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001193 backup[0] = x;
1194 backup[1] = y;
1195 backup[2] = width;
1196 backup[3] = height;
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001197 }
1198
1199 /**
1200 * Restore the layout params' coordinates, size and gravity
1201 * @see LayoutParams#backup()
1202 */
1203 void restore() {
1204 int[] backup = mCompatibilityParamsBackup;
1205 if (backup != null) {
1206 x = backup[0];
1207 y = backup[1];
1208 width = backup[2];
Mitsuru Oshima3d914922009-05-13 22:29:15 -07001209 height = backup[3];
1210 }
1211 }
1212
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001213 private CharSequence mTitle = "";
1214 }
1215}