blob: 9f05990fd781e87d6476c96e0fef5b439e8da942 [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
Tor Norbye80756e32015-03-02 09:39:27 -080019import android.annotation.ColorInt;
Tor Norbye7b9c9122013-05-30 16:48:33 -070020import android.annotation.DrawableRes;
21import android.annotation.IdRes;
22import android.annotation.LayoutRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070023import android.annotation.NonNull;
24import android.annotation.Nullable;
Tor Norbye417ee5b2015-03-10 20:57:37 -070025import android.annotation.StyleRes;
Filip Gruszczynskife568352015-01-05 10:41:29 -080026import android.annotation.SystemApi;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.content.Context;
28import android.content.res.Configuration;
Bryce Leed6e6e722014-11-21 11:08:45 -080029import android.content.res.Resources;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.content.res.TypedArray;
Skuhnece2faa52015-08-11 10:36:38 -070031import android.graphics.PixelFormat;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -080032import android.graphics.Rect;
Filip Gruszczynski14418da2015-10-04 16:43:48 -070033import android.graphics.drawable.Drawable;
RoboErik55011652014-07-09 15:05:53 -070034import android.media.session.MediaController;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035import android.net.Uri;
36import android.os.Bundle;
Andres Morales910beb82016-02-02 16:19:40 -080037import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038import android.os.IBinder;
Wale Ogunwale868a5e12015-08-02 16:19:20 -070039import android.os.RemoteException;
Romain Guy9622e202011-09-29 16:37:27 -070040import android.os.SystemProperties;
Adam Powellcfbe9be2013-11-06 14:58:58 -080041import android.transition.Scene;
George Mounte1803372014-02-26 19:00:52 +000042import android.transition.Transition;
Adam Powellcfbe9be2013-11-06 14:58:58 -080043import android.transition.TransitionManager;
svetoslavganov75986cf2009-05-14 22:28:01 -070044import android.view.accessibility.AccessibilityEvent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045
Clara Bayarri75e09792015-07-29 16:20:40 +010046import java.util.List;
47
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048/**
49 * Abstract base class for a top-level window look and behavior policy. An
50 * instance of this class should be used as the top-level view added to the
51 * window manager. It provides standard UI policies such as a background, title
52 * area, default key processing, etc.
53 *
54 * <p>The only existing implementation of this abstract class is
Jorim Jaggib10e33f2015-02-04 21:57:40 +010055 * android.view.PhoneWindow, which you should instantiate when needing a
56 * Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057 */
58public abstract class Window {
59 /** Flag for the "options panel" feature. This is enabled by default. */
60 public static final int FEATURE_OPTIONS_PANEL = 0;
61 /** Flag for the "no title" feature, turning off the title at the top
62 * of the screen. */
63 public static final int FEATURE_NO_TITLE = 1;
Alan Viverette4aef7c82015-09-04 14:14:50 -040064
65 /**
66 * Flag for the progress indicator feature.
67 *
68 * @deprecated No longer supported starting in API 21.
69 */
70 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071 public static final int FEATURE_PROGRESS = 2;
Alan Viverette4aef7c82015-09-04 14:14:50 -040072
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073 /** Flag for having an icon on the left side of the title bar */
74 public static final int FEATURE_LEFT_ICON = 3;
75 /** Flag for having an icon on the right side of the title bar */
76 public static final int FEATURE_RIGHT_ICON = 4;
Alan Viverette4aef7c82015-09-04 14:14:50 -040077
78 /**
79 * Flag for indeterminate progress.
80 *
81 * @deprecated No longer supported starting in API 21.
82 */
83 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080084 public static final int FEATURE_INDETERMINATE_PROGRESS = 5;
Alan Viverette4aef7c82015-09-04 14:14:50 -040085
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086 /** Flag for the context menu. This is enabled by default. */
87 public static final int FEATURE_CONTEXT_MENU = 6;
88 /** Flag for custom title. You cannot combine this feature with other title features. */
89 public static final int FEATURE_CUSTOM_TITLE = 7;
Adam Powell33b97432010-04-20 10:01:14 -070090 /**
91 * Flag for enabling the Action Bar.
92 * This is enabled by default for some devices. The Action Bar
93 * replaces the title bar and provides an alternate location
94 * for an on-screen menu button on some devices.
95 */
Adam Powell5d279772010-07-27 16:34:07 -070096 public static final int FEATURE_ACTION_BAR = 8;
97 /**
Adam Powell6b336f82010-08-10 20:13:01 -070098 * Flag for requesting an Action Bar that overlays window content.
99 * Normally an Action Bar will sit in the space above window content, but if this
100 * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over
101 * the window content itself. This is useful if you would like your app to have more control
102 * over how the Action Bar is displayed, such as letting application content scroll beneath
103 * an Action Bar with a transparent background or otherwise displaying a transparent/translucent
104 * Action Bar over application content.
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700105 *
106 * <p>This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN
107 * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the
108 * action bar in conjunction with other screen decorations.
109 *
110 * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an
111 * ActionBar is in this mode it will adjust the insets provided to
112 * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)}
113 * to include the content covered by the action bar, so you can do layout within
114 * that space.
Adam Powell6b336f82010-08-10 20:13:01 -0700115 */
116 public static final int FEATURE_ACTION_BAR_OVERLAY = 9;
117 /**
Adam Powell5d279772010-07-27 16:34:07 -0700118 * Flag for specifying the behavior of action modes when an Action Bar is not present.
119 * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
120 */
Adam Powell6b336f82010-08-10 20:13:01 -0700121 public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
Adam Powell18e905f2013-10-24 14:27:48 -0700122 /**
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800123 * Flag for requesting a decoration-free window that is dismissed by swiping from the left.
124 */
125 public static final int FEATURE_SWIPE_TO_DISMISS = 11;
Will Haldean Brown568628d2014-03-04 15:25:43 -0800126 /**
George Mountc3a043c2015-02-04 14:37:04 -0800127 * Flag for requesting that window content changes should be animated using a
128 * TransitionManager.
Adam Powell18e905f2013-10-24 14:27:48 -0700129 *
George Mountc3a043c2015-02-04 14:37:04 -0800130 * <p>The TransitionManager is set using
131 * {@link #setTransitionManager(android.transition.TransitionManager)}. If none is set,
132 * a default TransitionManager will be used.</p>
Adam Powell18e905f2013-10-24 14:27:48 -0700133 *
134 * @see #setContentView
135 */
Will Haldean Brown568628d2014-03-04 15:25:43 -0800136 public static final int FEATURE_CONTENT_TRANSITIONS = 12;
Adam Powell4b6d93f2012-09-18 18:34:08 -0700137
138 /**
George Mount9826f632014-09-11 08:50:09 -0700139 * Enables Activities to run Activity Transitions either through sending or receiving
140 * ActivityOptions bundle created with
141 * {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity,
142 * android.util.Pair[])} or {@link android.app.ActivityOptions#makeSceneTransitionAnimation(
143 * android.app.Activity, View, String)}.
144 */
145 public static final int FEATURE_ACTIVITY_TRANSITIONS = 13;
146
147 /**
Adam Powell4b6d93f2012-09-18 18:34:08 -0700148 * Max value used as a feature ID
149 * @hide
150 */
George Mount9826f632014-09-11 08:50:09 -0700151 public static final int FEATURE_MAX = FEATURE_ACTIVITY_TRANSITIONS;
Adam Powell4b6d93f2012-09-18 18:34:08 -0700152
Alan Viverette4aef7c82015-09-04 14:14:50 -0400153 /**
154 * Flag for setting the progress bar's visibility to VISIBLE.
155 *
156 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
157 * supported starting in API 21.
158 */
159 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800160 public static final int PROGRESS_VISIBILITY_ON = -1;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400161
162 /**
163 * Flag for setting the progress bar's visibility to GONE.
164 *
165 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
166 * supported starting in API 21.
167 */
168 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800169 public static final int PROGRESS_VISIBILITY_OFF = -2;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400170
171 /**
172 * Flag for setting the progress bar's indeterminate mode on.
173 *
174 * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
175 * are no longer supported starting in API 21.
176 */
177 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800178 public static final int PROGRESS_INDETERMINATE_ON = -3;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400179
180 /**
181 * Flag for setting the progress bar's indeterminate mode off.
182 *
183 * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
184 * are no longer supported starting in API 21.
185 */
186 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 public static final int PROGRESS_INDETERMINATE_OFF = -4;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400188
189 /**
190 * Starting value for the (primary) progress.
191 *
192 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
193 * supported starting in API 21.
194 */
195 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800196 public static final int PROGRESS_START = 0;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400197
198 /**
199 * Ending value for the (primary) progress.
200 *
201 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
202 * supported starting in API 21.
203 */
204 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800205 public static final int PROGRESS_END = 10000;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400206
207 /**
208 * Lowest possible value for the secondary progress.
209 *
210 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
211 * supported starting in API 21.
212 */
213 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800214 public static final int PROGRESS_SECONDARY_START = 20000;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400215
216 /**
217 * Highest possible value for the secondary progress.
218 *
219 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
220 * supported starting in API 21.
221 */
222 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800223 public static final int PROGRESS_SECONDARY_END = 30000;
George Mount238010f2014-06-30 17:31:17 -0700224
225 /**
226 * The transitionName for the status bar background View when a custom background is used.
227 * @see android.view.Window#setStatusBarColor(int)
228 */
229 public static final String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background";
230
231 /**
232 * The transitionName for the navigation bar background View when a custom background is used.
233 * @see android.view.Window#setNavigationBarColor(int)
234 */
235 public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME =
236 "android:navigation:background";
237
Bryce Leeaa1008c2015-01-13 09:26:46 -0800238 /**
239 * The default features enabled.
240 * @deprecated use {@link #getDefaultFeatures(android.content.Context)} instead.
241 */
Bryce Leed6e6e722014-11-21 11:08:45 -0800242 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800243 @SuppressWarnings({"PointlessBitwiseExpression"})
244 protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) |
245 (1 << FEATURE_CONTEXT_MENU);
246
247 /**
248 * The ID that the main layout in the XML layout file should have.
249 */
250 public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content;
251
Jeff Brownd32460c2012-07-20 16:15:36 -0700252 private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw";
253
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800254 /**
255 * Flag for letting the theme drive the color of the window caption controls. Use with
256 * {@link #setDecorCaptionShade(int)}. This is the default value.
257 */
258 public static final int DECOR_CAPTION_SHADE_AUTO = 0;
259 /**
260 * Flag for setting light-color controls on the window caption. Use with
261 * {@link #setDecorCaptionShade(int)}.
262 */
263 public static final int DECOR_CAPTION_SHADE_LIGHT = 1;
264 /**
265 * Flag for setting dark-color controls on the window caption. Use with
266 * {@link #setDecorCaptionShade(int)}.
267 */
268 public static final int DECOR_CAPTION_SHADE_DARK = 2;
269
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800270 private final Context mContext;
RoboErik55011652014-07-09 15:05:53 -0700271
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800272 private TypedArray mWindowStyle;
273 private Callback mCallback;
Adam Powell117b6952014-05-05 18:14:56 -0700274 private OnWindowDismissedCallback mOnWindowDismissedCallback;
Skuhnece2faa52015-08-11 10:36:38 -0700275 private WindowControllerCallback mWindowControllerCallback;
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800276 private OnRestrictedCaptionAreaChangedListener mOnRestrictedCaptionAreaChangedListener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800277 private Rect mRestrictedCaptionAreaRect;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800278 private WindowManager mWindowManager;
279 private IBinder mAppToken;
280 private String mAppName;
Jeff Brownd32460c2012-07-20 16:15:36 -0700281 private boolean mHardwareAccelerated;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800282 private Window mContainer;
283 private Window mActiveChild;
284 private boolean mIsActive = false;
285 private boolean mHasChildren = false;
Dianne Hackborncfaf8872011-01-18 13:57:54 -0800286 private boolean mCloseOnTouchOutside = false;
287 private boolean mSetCloseOnTouchOutside = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800288 private int mForcedWindowFlags = 0;
289
Bryce Leed6e6e722014-11-21 11:08:45 -0800290 private int mFeatures;
291 private int mLocalFeatures;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292
293 private boolean mHaveWindowFormat = false;
Dianne Hackborn661cd522011-08-22 00:26:20 -0700294 private boolean mHaveDimAmount = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800295 private int mDefaultWindowFormat = PixelFormat.OPAQUE;
296
297 private boolean mHasSoftInputMode = false;
RoboErik55011652014-07-09 15:05:53 -0700298
Dianne Hackborn291905e2010-08-17 15:17:15 -0700299 private boolean mDestroyed;
300
Filip Gruszczynski63250652015-11-18 14:43:01 -0800301 private boolean mOverlayWithDecorCaption = false;
302
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800303 // The current window attributes.
304 private final WindowManager.LayoutParams mWindowAttributes =
305 new WindowManager.LayoutParams();
306
307 /**
308 * API from a Window back to its caller. This allows the client to
309 * intercept key dispatching, panels and menus, etc.
310 */
311 public interface Callback {
312 /**
313 * Called to process key events. At the very least your
314 * implementation must call
315 * {@link android.view.Window#superDispatchKeyEvent} to do the
316 * standard key processing.
317 *
318 * @param event The key event.
319 *
320 * @return boolean Return true if this event was consumed.
321 */
322 public boolean dispatchKeyEvent(KeyEvent event);
323
324 /**
Jeff Brown64da12a2011-01-04 19:57:47 -0800325 * Called to process a key shortcut event.
326 * At the very least your implementation must call
327 * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the
328 * standard key shortcut processing.
329 *
330 * @param event The key shortcut event.
331 * @return True if this event was consumed.
332 */
333 public boolean dispatchKeyShortcutEvent(KeyEvent event);
334
335 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800336 * Called to process touch screen events. At the very least your
337 * implementation must call
338 * {@link android.view.Window#superDispatchTouchEvent} to do the
339 * standard touch screen processing.
340 *
341 * @param event The touch screen event.
342 *
343 * @return boolean Return true if this event was consumed.
344 */
345 public boolean dispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -0700346
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800347 /**
348 * Called to process trackball events. At the very least your
349 * implementation must call
350 * {@link android.view.Window#superDispatchTrackballEvent} to do the
351 * standard trackball processing.
352 *
353 * @param event The trackball event.
354 *
355 * @return boolean Return true if this event was consumed.
356 */
357 public boolean dispatchTrackballEvent(MotionEvent event);
svetoslavganov75986cf2009-05-14 22:28:01 -0700358
359 /**
Jeff Browncb1404e2011-01-15 18:14:15 -0800360 * Called to process generic motion events. At the very least your
361 * implementation must call
362 * {@link android.view.Window#superDispatchGenericMotionEvent} to do the
363 * standard processing.
364 *
365 * @param event The generic motion event.
366 *
367 * @return boolean Return true if this event was consumed.
368 */
369 public boolean dispatchGenericMotionEvent(MotionEvent event);
370
371 /**
svetoslavganov75986cf2009-05-14 22:28:01 -0700372 * Called to process population of {@link AccessibilityEvent}s.
373 *
374 * @param event The event.
375 *
376 * @return boolean Return true if event population was completed.
377 */
378 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event);
379
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800380 /**
381 * Instantiate the view to display in the panel for 'featureId'.
382 * You can return null, in which case the default content (typically
383 * a menu) will be created for you.
384 *
385 * @param featureId Which panel is being created.
386 *
387 * @return view The top-level view to place in the panel.
388 *
389 * @see #onPreparePanel
390 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700391 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800392 public View onCreatePanelView(int featureId);
393
394 /**
395 * Initialize the contents of the menu for panel 'featureId'. This is
396 * called if onCreatePanelView() returns null, giving you a standard
397 * menu in which you can place your items. It is only called once for
398 * the panel, the first time it is shown.
399 *
400 * <p>You can safely hold on to <var>menu</var> (and any items created
401 * from it), making modifications to it as desired, until the next
402 * time onCreatePanelMenu() is called for this feature.
403 *
404 * @param featureId The panel being created.
405 * @param menu The menu inside the panel.
406 *
407 * @return boolean You must return true for the panel to be displayed;
408 * if you return false it will not be shown.
409 */
410 public boolean onCreatePanelMenu(int featureId, Menu menu);
411
412 /**
413 * Prepare a panel to be displayed. This is called right before the
414 * panel window is shown, every time it is shown.
415 *
416 * @param featureId The panel that is being displayed.
417 * @param view The View that was returned by onCreatePanelView().
418 * @param menu If onCreatePanelView() returned null, this is the Menu
419 * being displayed in the panel.
420 *
421 * @return boolean You must return true for the panel to be displayed;
422 * if you return false it will not be shown.
423 *
424 * @see #onCreatePanelView
425 */
426 public boolean onPreparePanel(int featureId, View view, Menu menu);
427
428 /**
429 * Called when a panel's menu is opened by the user. This may also be
430 * called when the menu is changing from one type to another (for
431 * example, from the icon menu to the expanded menu).
RoboErik55011652014-07-09 15:05:53 -0700432 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800433 * @param featureId The panel that the menu is in.
434 * @param menu The menu that is opened.
435 * @return Return true to allow the menu to open, or false to prevent
436 * the menu from opening.
437 */
438 public boolean onMenuOpened(int featureId, Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700439
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 /**
441 * Called when a panel's menu item has been selected by the user.
442 *
443 * @param featureId The panel that the menu is in.
444 * @param item The menu item that was selected.
445 *
446 * @return boolean Return true to finish processing of selection, or
447 * false to perform the normal menu handling (calling its
448 * Runnable or sending a Message to its target Handler).
449 */
450 public boolean onMenuItemSelected(int featureId, MenuItem item);
451
452 /**
453 * This is called whenever the current window attributes change.
454 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455 */
456 public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
457
458 /**
459 * This hook is called whenever the content view of the screen changes
460 * (due to a call to
461 * {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams)
462 * Window.setContentView} or
463 * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams)
464 * Window.addContentView}).
465 */
466 public void onContentChanged();
467
468 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700469 * This hook is called whenever the window focus changes. See
470 * {@link View#onWindowFocusChanged(boolean)
Svetoslav3a0d8782014-12-04 12:50:11 -0800471 * View.onWindowFocusChangedNotLocked(boolean)} for more information.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800472 *
473 * @param hasFocus Whether the window now has focus.
474 */
475 public void onWindowFocusChanged(boolean hasFocus);
476
477 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700478 * Called when the window has been attached to the window manager.
479 * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
480 * for more information.
481 */
482 public void onAttachedToWindow();
RoboErik55011652014-07-09 15:05:53 -0700483
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700484 /**
485 * Called when the window has been attached to the window manager.
486 * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
487 * for more information.
488 */
489 public void onDetachedFromWindow();
RoboErik55011652014-07-09 15:05:53 -0700490
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700491 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800492 * Called when a panel is being closed. If another logical subsequent
493 * panel is being opened (and this panel is being closed to make room for the subsequent
494 * panel), this method will NOT be called.
RoboErik55011652014-07-09 15:05:53 -0700495 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800496 * @param featureId The panel that is being displayed.
497 * @param menu If onCreatePanelView() returned null, this is the Menu
498 * being displayed in the panel.
499 */
500 public void onPanelClosed(int featureId, Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700501
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800502 /**
503 * Called when the user signals the desire to start a search.
RoboErik55011652014-07-09 15:05:53 -0700504 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800505 * @return true if search launched, false if activity refuses (blocks)
RoboErik55011652014-07-09 15:05:53 -0700506 *
507 * @see android.app.Activity#onSearchRequested()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800508 */
509 public boolean onSearchRequested();
Adam Powell6e346362010-07-23 10:18:23 -0700510
511 /**
Tim Kilbourn6a975b32015-04-09 17:14:34 -0700512 * Called when the user signals the desire to start a search.
513 *
514 * @param searchEvent A {@link SearchEvent} describing the signal to
515 * start a search.
516 * @return true if search launched, false if activity refuses (blocks)
517 */
518 public boolean onSearchRequested(SearchEvent searchEvent);
519
520 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800521 * Called when an action mode is being started for this window. Gives the
522 * callback an opportunity to handle the action mode in its own unique and
523 * beautiful way. If this method returns null the system can choose a way
Clara Bayarri4423d912015-03-02 19:42:48 +0000524 * to present the mode or choose not to start the mode at all. This is equivalent
525 * to {@link #onWindowStartingActionMode(android.view.ActionMode.Callback, int)}
526 * with type {@link ActionMode#TYPE_PRIMARY}.
Adam Powell6e346362010-07-23 10:18:23 -0700527 *
528 * @param callback Callback to control the lifecycle of this action mode
Adam Powelldebf3be2010-11-15 18:58:48 -0800529 * @return The ActionMode that was started, or null if the system should present it
Adam Powell6e346362010-07-23 10:18:23 -0700530 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700531 @Nullable
Adam Powelldebf3be2010-11-15 18:58:48 -0800532 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
533
534 /**
Clara Bayarri4423d912015-03-02 19:42:48 +0000535 * Called when an action mode is being started for this window. Gives the
536 * callback an opportunity to handle the action mode in its own unique and
537 * beautiful way. If this method returns null the system can choose a way
538 * to present the mode or choose not to start the mode at all.
539 *
540 * @param callback Callback to control the lifecycle of this action mode
541 * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
542 * @return The ActionMode that was started, or null if the system should present it
543 */
544 @Nullable
545 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);
546
547 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800548 * Called when an action mode has been started. The appropriate mode callback
549 * method will have already been invoked.
550 *
551 * @param mode The new mode that has just been started.
552 */
553 public void onActionModeStarted(ActionMode mode);
554
555 /**
556 * Called when an action mode has been finished. The appropriate mode callback
557 * method will have already been invoked.
558 *
559 * @param mode The mode that was just finished.
560 */
561 public void onActionModeFinished(ActionMode mode);
Clara Bayarri75e09792015-07-29 16:20:40 +0100562
563 /**
564 * Called when Keyboard Shortcuts are requested for the current window.
565 *
566 * @param data The data list to populate with shortcuts.
567 * @param menu The current menu, which may be null.
568 */
569 public void onProvideKeyboardShortcuts(
570 List<KeyboardShortcutGroup> data, @Nullable Menu menu);
Adam Powell117b6952014-05-05 18:14:56 -0700571 }
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800572
Adam Powell117b6952014-05-05 18:14:56 -0700573 /** @hide */
574 public interface OnWindowDismissedCallback {
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800575 /**
576 * Called when a window is dismissed. This informs the callback that the
577 * window is gone, and it should finish itself.
Wale Ogunwaleba7881c2015-08-01 19:28:29 -0700578 * @param finishTask True if the task should also be finished.
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800579 */
Wale Ogunwaleba7881c2015-08-01 19:28:29 -0700580 void onWindowDismissed(boolean finishTask);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800581 }
582
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700583 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700584 public interface WindowControllerCallback {
585 /**
Filip Gruszczynski411c06f2016-01-07 09:44:44 -0800586 * Moves the activity from
587 * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} to
588 * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack.
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700589 */
Filip Gruszczynski411c06f2016-01-07 09:44:44 -0800590 void exitFreeformMode() throws RemoteException;
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700591
592 /** Returns the current stack Id for the window. */
593 int getWindowStackId() throws RemoteException;
594 }
595
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800596 /**
597 * Callback for clients that want to be aware of where caption draws content.
598 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800599 public interface OnRestrictedCaptionAreaChangedListener {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800600 /**
601 * Called when the area where caption draws content changes.
602 *
603 * @param rect The area where caption content is positioned, relative to the top view.
604 */
605 void onRestrictedCaptionAreaChanged(Rect rect);
606 }
607
Andres Morales910beb82016-02-02 16:19:40 -0800608 /**
609 * Callback for clients that want frame timing information for each
610 * frame rendered by the Window.
611 */
612 public interface FrameMetricsListener {
613 /**
614 * Called when information is available for the previously rendered frame.
615 *
616 * Reports can be dropped if this callback takes too
617 * long to execute, as the report producer cannot wait for the consumer to
618 * complete.
619 *
620 * It is highly recommended that clients copy the passed in FrameMetrics
621 * via {@link FrameMetrics#FrameMetrics(FrameMetrics)} within this method and defer
622 * additional computation or storage to another thread to avoid unnecessarily
623 * dropping reports.
624 *
625 * @param window The {@link Window} on which the frame was displayed.
626 * @param frameMetrics the available metrics. This object is reused on every call
627 * and thus <strong>this reference is not valid outside the scope of this method</strong>.
628 * @param dropCountSinceLastInvocation the number of reports dropped since the last time
629 * this callback was invoked.
630 */
631 void onMetricsAvailable(Window window, FrameMetrics frameMetrics,
632 int dropCountSinceLastInvocation);
633 }
634
635
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800636 public Window(Context context) {
637 mContext = context;
Bryce Leed6e6e722014-11-21 11:08:45 -0800638 mFeatures = mLocalFeatures = getDefaultFeatures(context);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800639 }
640
641 /**
642 * Return the Context this window policy is running in, for retrieving
643 * resources and other information.
644 *
645 * @return Context The Context that was supplied to the constructor.
646 */
647 public final Context getContext() {
648 return mContext;
649 }
650
651 /**
652 * Return the {@link android.R.styleable#Window} attributes from this
653 * window's theme.
654 */
655 public final TypedArray getWindowStyle() {
656 synchronized (this) {
657 if (mWindowStyle == null) {
658 mWindowStyle = mContext.obtainStyledAttributes(
659 com.android.internal.R.styleable.Window);
660 }
661 return mWindowStyle;
662 }
663 }
RoboErik55011652014-07-09 15:05:53 -0700664
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800665 /**
666 * Set the container for this window. If not set, the DecorWindow
667 * operates as a top-level window; otherwise, it negotiates with the
668 * container to display itself appropriately.
669 *
670 * @param container The desired containing Window.
671 */
672 public void setContainer(Window container) {
673 mContainer = container;
674 if (container != null) {
675 // Embedded screens never have a title.
676 mFeatures |= 1<<FEATURE_NO_TITLE;
677 mLocalFeatures |= 1<<FEATURE_NO_TITLE;
678 container.mHasChildren = true;
679 }
680 }
681
682 /**
683 * Return the container for this Window.
684 *
685 * @return Window The containing window, or null if this is a
686 * top-level window.
687 */
688 public final Window getContainer() {
689 return mContainer;
690 }
691
692 public final boolean hasChildren() {
693 return mHasChildren;
694 }
RoboErik55011652014-07-09 15:05:53 -0700695
Dianne Hackborn291905e2010-08-17 15:17:15 -0700696 /** @hide */
697 public final void destroy() {
698 mDestroyed = true;
699 }
700
701 /** @hide */
702 public final boolean isDestroyed() {
703 return mDestroyed;
704 }
705
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800706 /**
707 * Set the window manager for use by this Window to, for example,
708 * display panels. This is <em>not</em> used for displaying the
709 * Window itself -- that must be done by the client.
710 *
Jeff Brown98365d72012-08-19 20:30:52 -0700711 * @param wm The window manager for adding new windows.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800712 */
Romain Guy529b60a2010-08-03 18:05:47 -0700713 public void setWindowManager(WindowManager wm, IBinder appToken, String appName) {
714 setWindowManager(wm, appToken, appName, false);
715 }
716
717 /**
718 * Set the window manager for use by this Window to, for example,
719 * display panels. This is <em>not</em> used for displaying the
720 * Window itself -- that must be done by the client.
721 *
Jeff Brown98365d72012-08-19 20:30:52 -0700722 * @param wm The window manager for adding new windows.
Romain Guy529b60a2010-08-03 18:05:47 -0700723 */
724 public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
725 boolean hardwareAccelerated) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800726 mAppToken = appToken;
727 mAppName = appName;
Jeff Brownd32460c2012-07-20 16:15:36 -0700728 mHardwareAccelerated = hardwareAccelerated
729 || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800730 if (wm == null) {
Jeff Brown98365d72012-08-19 20:30:52 -0700731 wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800732 }
Jeff Brown98365d72012-08-19 20:30:52 -0700733 mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
Dianne Hackborn5fd21692011-06-07 14:09:47 -0700734 }
735
Jeff Brownd32460c2012-07-20 16:15:36 -0700736 void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) {
737 CharSequence curTitle = wp.getTitle();
738 if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
tiger_huangff58e302015-10-13 21:38:19 +0800739 wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
Jeff Brownd32460c2012-07-20 16:15:36 -0700740 if (wp.token == null) {
741 View decor = peekDecorView();
742 if (decor != null) {
743 wp.token = decor.getWindowToken();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800744 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800745 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700746 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700747 final StringBuilder title = new StringBuilder(32);
Jeff Brownd32460c2012-07-20 16:15:36 -0700748 if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700749 title.append("Media");
Jeff Brownd32460c2012-07-20 16:15:36 -0700750 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700751 title.append("MediaOvr");
Jeff Brownd32460c2012-07-20 16:15:36 -0700752 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700753 title.append("Panel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700754 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700755 title.append("SubPanel");
Wale Ogunwale0a4dc222015-04-14 12:58:42 -0700756 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700757 title.append("AboveSubPanel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700758 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700759 title.append("AtchDlg");
Jeff Brownd32460c2012-07-20 16:15:36 -0700760 } else {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700761 title.append(wp.type);
Jeff Brownd32460c2012-07-20 16:15:36 -0700762 }
763 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700764 title.append(":").append(mAppName);
Jeff Brownd32460c2012-07-20 16:15:36 -0700765 }
766 wp.setTitle(title);
Romain Guy529b60a2010-08-03 18:05:47 -0700767 }
tiger_huangff58e302015-10-13 21:38:19 +0800768 } else if (wp.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW &&
769 wp.type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
770 // We don't set the app token to this system window because the life cycles should be
771 // independent. If an app creates a system window and then the app goes to the stopped
772 // state, the system window should not be affected (can still show and receive input
773 // events).
774 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700775 final StringBuilder title = new StringBuilder(32);
776 title.append("Sys").append(wp.type);
tiger_huangff58e302015-10-13 21:38:19 +0800777 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700778 title.append(":").append(mAppName);
tiger_huangff58e302015-10-13 21:38:19 +0800779 }
780 wp.setTitle(title);
781 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700782 } else {
783 if (wp.token == null) {
784 wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
785 }
786 if ((curTitle == null || curTitle.length() == 0)
787 && mAppName != null) {
788 wp.setTitle(mAppName);
789 }
790 }
791 if (wp.packageName == null) {
792 wp.packageName = mContext.getPackageName();
793 }
794 if (mHardwareAccelerated) {
795 wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800796 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800797 }
798
799 /**
800 * Return the window manager allowing this Window to display its own
801 * windows.
802 *
803 * @return WindowManager The ViewManager.
804 */
805 public WindowManager getWindowManager() {
806 return mWindowManager;
807 }
808
809 /**
810 * Set the Callback interface for this window, used to intercept key
811 * events and other dynamic operations in the window.
812 *
813 * @param callback The desired Callback interface.
814 */
815 public void setCallback(Callback callback) {
816 mCallback = callback;
817 }
818
819 /**
820 * Return the current Callback interface for this window.
821 */
822 public final Callback getCallback() {
823 return mCallback;
824 }
825
Andres Morales06f5bc72015-12-15 15:21:31 -0800826 /**
827 * Set an observer to collect frame stats for each frame rendererd in this window.
828 *
829 * Must be in hardware rendering mode.
Andres Morales06f5bc72015-12-15 15:21:31 -0800830 */
Andres Morales910beb82016-02-02 16:19:40 -0800831 public final void addFrameMetricsListener(@NonNull FrameMetricsListener listener,
832 Handler handler) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800833 final View decorView = getDecorView();
834 if (decorView == null) {
835 throw new IllegalStateException("can't observe a Window without an attached view");
836 }
837
Andres Morales910beb82016-02-02 16:19:40 -0800838 if (listener == null) {
839 throw new NullPointerException("listener cannot be null");
Andres Morales06f5bc72015-12-15 15:21:31 -0800840 }
841
Andres Morales910beb82016-02-02 16:19:40 -0800842 decorView.addFrameMetricsListener(this, listener, handler);
Andres Morales06f5bc72015-12-15 15:21:31 -0800843 }
844
845 /**
846 * Remove observer and stop listening to frame stats for this window.
Andres Morales06f5bc72015-12-15 15:21:31 -0800847 */
Andres Morales910beb82016-02-02 16:19:40 -0800848 public final void removeFrameMetricsListener(FrameMetricsListener listener) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800849 final View decorView = getDecorView();
850 if (decorView != null) {
Andres Morales910beb82016-02-02 16:19:40 -0800851 getDecorView().removeFrameMetricsListener(listener);
Andres Morales06f5bc72015-12-15 15:21:31 -0800852 }
853 }
854
Adam Powell117b6952014-05-05 18:14:56 -0700855 /** @hide */
856 public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) {
857 mOnWindowDismissedCallback = dcb;
858 }
859
860 /** @hide */
Stefan Kuhne1b420572015-08-07 10:50:19 -0700861 public final void dispatchOnWindowDismissed(boolean finishTask) {
Adam Powell117b6952014-05-05 18:14:56 -0700862 if (mOnWindowDismissedCallback != null) {
Stefan Kuhne1b420572015-08-07 10:50:19 -0700863 mOnWindowDismissedCallback.onWindowDismissed(finishTask);
Adam Powell117b6952014-05-05 18:14:56 -0700864 }
865 }
866
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700867 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700868 public final void setWindowControllerCallback(WindowControllerCallback wccb) {
869 mWindowControllerCallback = wccb;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700870 }
871
872 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700873 public final WindowControllerCallback getWindowControllerCallback() {
874 return mWindowControllerCallback;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700875 }
876
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800877 /**
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800878 * Set a callback for changes of area where caption will draw its content.
879 *
880 * @param listener Callback that will be called when the area changes.
881 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800882 public final void setRestrictedCaptionAreaListener(OnRestrictedCaptionAreaChangedListener listener) {
883 mOnRestrictedCaptionAreaChangedListener = listener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800884 mRestrictedCaptionAreaRect = listener != null ? new Rect() : null;
885 }
886
887 /**
Dianne Hackborndc8a7f62010-05-10 11:29:34 -0700888 * Take ownership of this window's surface. The window's view hierarchy
889 * will no longer draw into the surface, though it will otherwise continue
890 * to operate (such as for receiving input events). The given SurfaceHolder
891 * callback will be used to tell you about state changes to the surface.
892 */
Dianne Hackbornd76b67c2010-07-13 17:48:30 -0700893 public abstract void takeSurface(SurfaceHolder.Callback2 callback);
RoboErik55011652014-07-09 15:05:53 -0700894
Dianne Hackborndc8a7f62010-05-10 11:29:34 -0700895 /**
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -0700896 * Take ownership of this window's InputQueue. The window will no
897 * longer read and dispatch input events from the queue; it is your
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700898 * responsibility to do so.
899 */
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -0700900 public abstract void takeInputQueue(InputQueue.Callback callback);
RoboErik55011652014-07-09 15:05:53 -0700901
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700902 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800903 * Return whether this window is being displayed with a floating style
904 * (based on the {@link android.R.attr#windowIsFloating} attribute in
905 * the style/theme).
906 *
907 * @return Returns true if the window is configured to be displayed floating
908 * on top of whatever is behind it.
909 */
910 public abstract boolean isFloating();
911
912 /**
913 * Set the width and height layout parameters of the window. The default
Dianne Hackbornc9189352010-12-15 14:57:25 -0800914 * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT
915 * or an absolute value to make a window that is not full-screen.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800916 *
917 * @param width The desired layout width of the window.
918 * @param height The desired layout height of the window.
Dianne Hackbornc9189352010-12-15 14:57:25 -0800919 *
920 * @see ViewGroup.LayoutParams#height
921 * @see ViewGroup.LayoutParams#width
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800922 */
Dianne Hackbornc9189352010-12-15 14:57:25 -0800923 public void setLayout(int width, int height) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800924 final WindowManager.LayoutParams attrs = getAttributes();
925 attrs.width = width;
926 attrs.height = height;
Adrian Roosea562512014-05-05 13:33:03 +0200927 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800928 }
929
930 /**
931 * Set the gravity of the window, as per the Gravity constants. This
932 * controls how the window manager is positioned in the overall window; it
933 * is only useful when using WRAP_CONTENT for the layout width or height.
934 *
935 * @param gravity The desired gravity constant.
936 *
937 * @see Gravity
938 * @see #setLayout
939 */
940 public void setGravity(int gravity)
941 {
942 final WindowManager.LayoutParams attrs = getAttributes();
943 attrs.gravity = gravity;
Adrian Roosea562512014-05-05 13:33:03 +0200944 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800945 }
946
947 /**
948 * Set the type of the window, as per the WindowManager.LayoutParams
949 * types.
950 *
951 * @param type The new window type (see WindowManager.LayoutParams).
952 */
953 public void setType(int type) {
954 final WindowManager.LayoutParams attrs = getAttributes();
955 attrs.type = type;
Adrian Roosea562512014-05-05 13:33:03 +0200956 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800957 }
958
959 /**
960 * Set the format of window, as per the PixelFormat types. This overrides
961 * the default format that is selected by the Window based on its
962 * window decorations.
963 *
964 * @param format The new window format (see PixelFormat). Use
965 * PixelFormat.UNKNOWN to allow the Window to select
966 * the format.
967 *
968 * @see PixelFormat
969 */
970 public void setFormat(int format) {
971 final WindowManager.LayoutParams attrs = getAttributes();
972 if (format != PixelFormat.UNKNOWN) {
973 attrs.format = format;
974 mHaveWindowFormat = true;
975 } else {
976 attrs.format = mDefaultWindowFormat;
977 mHaveWindowFormat = false;
978 }
Adrian Roosea562512014-05-05 13:33:03 +0200979 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800980 }
981
982 /**
983 * Specify custom animations to use for the window, as per
984 * {@link WindowManager.LayoutParams#windowAnimations
985 * WindowManager.LayoutParams.windowAnimations}. Providing anything besides
986 * 0 here will override the animations the window would
987 * normally retrieve from its theme.
988 */
Tor Norbye417ee5b2015-03-10 20:57:37 -0700989 public void setWindowAnimations(@StyleRes int resId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800990 final WindowManager.LayoutParams attrs = getAttributes();
991 attrs.windowAnimations = resId;
Adrian Roosea562512014-05-05 13:33:03 +0200992 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800993 }
994
995 /**
996 * Specify an explicit soft input mode to use for the window, as per
997 * {@link WindowManager.LayoutParams#softInputMode
998 * WindowManager.LayoutParams.softInputMode}. Providing anything besides
999 * "unspecified" here will override the input mode the window would
1000 * normally retrieve from its theme.
1001 */
1002 public void setSoftInputMode(int mode) {
1003 final WindowManager.LayoutParams attrs = getAttributes();
1004 if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
1005 attrs.softInputMode = mode;
1006 mHasSoftInputMode = true;
1007 } else {
1008 mHasSoftInputMode = false;
1009 }
Adrian Roosea562512014-05-05 13:33:03 +02001010 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001011 }
RoboErik55011652014-07-09 15:05:53 -07001012
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001013 /**
1014 * Convenience function to set the flag bits as specified in flags, as
1015 * per {@link #setFlags}.
1016 * @param flags The flag bits to be set.
1017 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001018 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001019 */
1020 public void addFlags(int flags) {
1021 setFlags(flags, flags);
1022 }
Adam Lesinski95c42972013-10-02 10:13:27 -07001023
1024 /** @hide */
1025 public void addPrivateFlags(int flags) {
1026 setPrivateFlags(flags, flags);
1027 }
RoboErik55011652014-07-09 15:05:53 -07001028
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001029 /**
1030 * Convenience function to clear the flag bits as specified in flags, as
1031 * per {@link #setFlags}.
1032 * @param flags The flag bits to be cleared.
1033 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001034 * @see #addFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001035 */
1036 public void clearFlags(int flags) {
1037 setFlags(0, flags);
1038 }
1039
1040 /**
1041 * Set the flags of the window, as per the
1042 * {@link WindowManager.LayoutParams WindowManager.LayoutParams}
1043 * flags.
RoboErik55011652014-07-09 15:05:53 -07001044 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001045 * <p>Note that some flags must be set before the window decoration is
1046 * created (by the first call to
1047 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or
1048 * {@link #getDecorView()}:
1049 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and
1050 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These
1051 * will be set for you based on the {@link android.R.attr#windowIsFloating}
1052 * attribute.
1053 *
1054 * @param flags The new window flags (see WindowManager.LayoutParams).
1055 * @param mask Which of the window flag bits to modify.
Christopher Tate193fc072012-06-04 11:27:40 -07001056 * @see #addFlags
1057 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001058 */
1059 public void setFlags(int flags, int mask) {
1060 final WindowManager.LayoutParams attrs = getAttributes();
1061 attrs.flags = (attrs.flags&~mask) | (flags&mask);
1062 mForcedWindowFlags |= mask;
Adrian Roosea562512014-05-05 13:33:03 +02001063 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001064 }
1065
Adam Lesinski95c42972013-10-02 10:13:27 -07001066 private void setPrivateFlags(int flags, int mask) {
1067 final WindowManager.LayoutParams attrs = getAttributes();
1068 attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
Adrian Roosea562512014-05-05 13:33:03 +02001069 dispatchWindowAttributesChanged(attrs);
1070 }
1071
1072 /**
1073 * {@hide}
1074 */
Wale Ogunwale393b1c12014-10-18 16:22:01 -07001075 protected void setNeedsMenuKey(int value) {
1076 final WindowManager.LayoutParams attrs = getAttributes();
1077 attrs.needsMenuKey = value;
1078 dispatchWindowAttributesChanged(attrs);
1079 }
1080
1081 /**
1082 * {@hide}
1083 */
Adrian Roosea562512014-05-05 13:33:03 +02001084 protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) {
Adam Lesinski95c42972013-10-02 10:13:27 -07001085 if (mCallback != null) {
1086 mCallback.onWindowAttributesChanged(attrs);
1087 }
1088 }
1089
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001090 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001091 * Set the amount of dim behind the window when using
1092 * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides
1093 * the default dim amount of that is selected by the Window based on
1094 * its theme.
1095 *
1096 * @param amount The new dim amount, from 0 for no dim to 1 for full dim.
1097 */
1098 public void setDimAmount(float amount) {
1099 final WindowManager.LayoutParams attrs = getAttributes();
1100 attrs.dimAmount = amount;
1101 mHaveDimAmount = true;
Adrian Roosea562512014-05-05 13:33:03 +02001102 dispatchWindowAttributesChanged(attrs);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001103 }
1104
1105 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001106 * Specify custom window attributes. <strong>PLEASE NOTE:</strong> the
1107 * layout params you give here should generally be from values previously
1108 * retrieved with {@link #getAttributes()}; you probably do not want to
1109 * blindly create and apply your own, since this will blow away any values
1110 * set by the framework that you are not interested in.
1111 *
1112 * @param a The new window attributes, which will completely override any
1113 * current values.
1114 */
1115 public void setAttributes(WindowManager.LayoutParams a) {
1116 mWindowAttributes.copyFrom(a);
Adrian Roosea562512014-05-05 13:33:03 +02001117 dispatchWindowAttributesChanged(mWindowAttributes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001118 }
1119
1120 /**
1121 * Retrieve the current window attributes associated with this panel.
1122 *
1123 * @return WindowManager.LayoutParams Either the existing window
1124 * attributes object, or a freshly created one if there is none.
1125 */
1126 public final WindowManager.LayoutParams getAttributes() {
1127 return mWindowAttributes;
1128 }
1129
1130 /**
1131 * Return the window flags that have been explicitly set by the client,
1132 * so will not be modified by {@link #getDecorView}.
1133 */
1134 protected final int getForcedWindowFlags() {
1135 return mForcedWindowFlags;
1136 }
RoboErik55011652014-07-09 15:05:53 -07001137
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001138 /**
1139 * Has the app specified their own soft input mode?
1140 */
1141 protected final boolean hasSoftInputMode() {
1142 return mHasSoftInputMode;
1143 }
RoboErik55011652014-07-09 15:05:53 -07001144
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001145 /** @hide */
1146 public void setCloseOnTouchOutside(boolean close) {
1147 mCloseOnTouchOutside = close;
1148 mSetCloseOnTouchOutside = true;
1149 }
RoboErik55011652014-07-09 15:05:53 -07001150
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001151 /** @hide */
Dianne Hackbornef575752011-01-18 17:35:17 -08001152 public void setCloseOnTouchOutsideIfNotSet(boolean close) {
1153 if (!mSetCloseOnTouchOutside) {
1154 mCloseOnTouchOutside = close;
1155 mSetCloseOnTouchOutside = true;
1156 }
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001157 }
RoboErik55011652014-07-09 15:05:53 -07001158
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001159 /** @hide */
Filip Gruszczynskife568352015-01-05 10:41:29 -08001160 @SystemApi
1161 public void setDisableWallpaperTouchEvents(boolean disable) {
1162 setPrivateFlags(disable
1163 ? WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS : 0,
1164 WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS);
1165 }
1166
1167 /** @hide */
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001168 public abstract void alwaysReadCloseOnTouchAttr();
RoboErik55011652014-07-09 15:05:53 -07001169
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001170 /** @hide */
1171 public boolean shouldCloseOnTouch(Context context, MotionEvent event) {
1172 if (mCloseOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN
1173 && isOutOfBounds(context, event) && peekDecorView() != null) {
1174 return true;
1175 }
1176 return false;
1177 }
RoboErik55011652014-07-09 15:05:53 -07001178
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001179 private boolean isOutOfBounds(Context context, MotionEvent event) {
1180 final int x = (int) event.getX();
1181 final int y = (int) event.getY();
1182 final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
1183 final View decorView = getDecorView();
1184 return (x < -slop) || (y < -slop)
1185 || (x > (decorView.getWidth()+slop))
1186 || (y > (decorView.getHeight()+slop));
1187 }
RoboErik55011652014-07-09 15:05:53 -07001188
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 /**
1190 * Enable extended screen features. This must be called before
1191 * setContentView(). May be called as many times as desired as long as it
1192 * is before setContentView(). If not called, no extended features
1193 * will be available. You can not turn off a feature once it is requested.
1194 * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
1195 *
1196 * @param featureId The desired features, defined as constants by Window.
1197 * @return The features that are now set.
1198 */
1199 public boolean requestFeature(int featureId) {
1200 final int flag = 1<<featureId;
1201 mFeatures |= flag;
1202 mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
1203 return (mFeatures&flag) != 0;
1204 }
1205
Adam Powellf4a6ec42010-08-24 14:18:10 -07001206 /**
1207 * @hide Used internally to help resolve conflicting features.
1208 */
1209 protected void removeFeature(int featureId) {
1210 final int flag = 1<<featureId;
1211 mFeatures &= ~flag;
1212 mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag);
1213 }
1214
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001215 public final void makeActive() {
1216 if (mContainer != null) {
1217 if (mContainer.mActiveChild != null) {
1218 mContainer.mActiveChild.mIsActive = false;
1219 }
1220 mContainer.mActiveChild = this;
1221 }
1222 mIsActive = true;
1223 onActive();
1224 }
1225
1226 public final boolean isActive()
1227 {
1228 return mIsActive;
1229 }
1230
1231 /**
1232 * Finds a view that was identified by the id attribute from the XML that
1233 * was processed in {@link android.app.Activity#onCreate}. This will
1234 * implicitly call {@link #getDecorView} for you, with all of the
1235 * associated side-effects.
1236 *
1237 * @return The view if found or null otherwise.
1238 */
Scott Kennedyc0519552015-02-11 15:33:10 -08001239 @Nullable
Tor Norbye7b9c9122013-05-30 16:48:33 -07001240 public View findViewById(@IdRes int id) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001241 return getDecorView().findViewById(id);
1242 }
1243
1244 /**
1245 * Convenience for
1246 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1247 * to set the screen content from a layout resource. The resource will be
1248 * inflated, adding all top-level views to the screen.
1249 *
1250 * @param layoutResID Resource ID to be inflated.
1251 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1252 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001253 public abstract void setContentView(@LayoutRes int layoutResID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001254
1255 /**
1256 * Convenience for
1257 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1258 * set the screen content to an explicit view. This view is placed
1259 * directly into the screen's view hierarchy. It can itself be a complex
1260 * view hierarhcy.
1261 *
1262 * @param view The desired content to display.
1263 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1264 */
1265 public abstract void setContentView(View view);
1266
1267 /**
1268 * Set the screen content to an explicit view. This view is placed
1269 * directly into the screen's view hierarchy. It can itself be a complex
1270 * view hierarchy.
1271 *
1272 * <p>Note that calling this function "locks in" various characteristics
1273 * of the window that can not, from this point forward, be changed: the
1274 * features that have been requested with {@link #requestFeature(int)},
George Mountc3a043c2015-02-04 14:37:04 -08001275 * and certain window flags as described in {@link #setFlags(int, int)}.</p>
1276 *
1277 * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's
1278 * TransitionManager will be used to animate content from the current
1279 * content View to view.</p>
RoboErik55011652014-07-09 15:05:53 -07001280 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001281 * @param view The desired content to display.
1282 * @param params Layout parameters for the view.
George Mountc3a043c2015-02-04 14:37:04 -08001283 * @see #getTransitionManager()
1284 * @see #setTransitionManager(android.transition.TransitionManager)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001285 */
1286 public abstract void setContentView(View view, ViewGroup.LayoutParams params);
1287
1288 /**
1289 * Variation on
1290 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1291 * to add an additional content view to the screen. Added after any existing
1292 * ones in the screen -- existing views are NOT removed.
1293 *
1294 * @param view The desired content to display.
1295 * @param params Layout parameters for the view.
1296 */
1297 public abstract void addContentView(View view, ViewGroup.LayoutParams params);
1298
1299 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001300 * Remove the view that was used as the screen content.
1301 *
1302 * @hide
1303 */
1304 public abstract void clearContentView();
1305
1306 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001307 * Return the view in this Window that currently has focus, or null if
1308 * there are none. Note that this does not look in any containing
1309 * Window.
1310 *
1311 * @return View The current View with focus or null.
1312 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001313 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001314 public abstract View getCurrentFocus();
1315
1316 /**
1317 * Quick access to the {@link LayoutInflater} instance that this Window
1318 * retrieved from its Context.
1319 *
1320 * @return LayoutInflater The shared LayoutInflater.
1321 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001322 @NonNull
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001323 public abstract LayoutInflater getLayoutInflater();
1324
1325 public abstract void setTitle(CharSequence title);
1326
Alan Viverette2525d9c2013-11-15 14:42:19 -08001327 @Deprecated
Tor Norbye80756e32015-03-02 09:39:27 -08001328 public abstract void setTitleColor(@ColorInt int textColor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001329
1330 public abstract void openPanel(int featureId, KeyEvent event);
1331
1332 public abstract void closePanel(int featureId);
1333
1334 public abstract void togglePanel(int featureId, KeyEvent event);
1335
Dianne Hackbornb31e84bc2010-06-08 18:04:35 -07001336 public abstract void invalidatePanelMenu(int featureId);
RoboErik55011652014-07-09 15:05:53 -07001337
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001338 public abstract boolean performPanelShortcut(int featureId,
1339 int keyCode,
1340 KeyEvent event,
1341 int flags);
1342 public abstract boolean performPanelIdentifierAction(int featureId,
1343 int id,
1344 int flags);
1345
1346 public abstract void closeAllPanels();
1347
1348 public abstract boolean performContextMenuIdentifierAction(int id, int flags);
1349
1350 /**
1351 * Should be called when the configuration is changed.
RoboErik55011652014-07-09 15:05:53 -07001352 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001353 * @param newConfig The new configuration.
1354 */
1355 public abstract void onConfigurationChanged(Configuration newConfig);
RoboErik55011652014-07-09 15:05:53 -07001356
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001357 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001358 * Sets the window elevation.
Alan Viverette71922de2015-01-12 16:14:02 -08001359 * <p>
1360 * Changes to this property take effect immediately and will cause the
1361 * window surface to be recreated. This is an expensive operation and as a
1362 * result, this property should not be animated.
Alan Viverette79c067c52014-10-29 14:27:47 -07001363 *
1364 * @param elevation The window elevation.
1365 * @see View#setElevation(float)
1366 * @see android.R.styleable#Window_windowElevation
1367 */
1368 public void setElevation(float elevation) {}
1369
1370 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001371 * Gets the window elevation.
1372 *
1373 * @hide
1374 */
1375 public float getElevation() {
1376 return 0.0f;
1377 }
1378
1379 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001380 * Sets whether window content should be clipped to the outline of the
1381 * window background.
1382 *
1383 * @param clipToOutline Whether window content should be clipped to the
1384 * outline of the window background.
1385 * @see View#setClipToOutline(boolean)
1386 * @see android.R.styleable#Window_windowClipToOutline
1387 */
1388 public void setClipToOutline(boolean clipToOutline) {}
1389
1390 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001391 * Change the background of this window to a Drawable resource. Setting the
1392 * background to null will make the window be opaque. To make the window
1393 * transparent, you can use an empty drawable (for instance a ColorDrawable
1394 * with the color 0 or the system drawable android:drawable/empty.)
RoboErik55011652014-07-09 15:05:53 -07001395 *
Alan Viverette79c067c52014-10-29 14:27:47 -07001396 * @param resId The resource identifier of a drawable resource which will
1397 * be installed as the new background.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001398 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001399 public void setBackgroundDrawableResource(@DrawableRes int resId) {
Alan Viverette79c067c52014-10-29 14:27:47 -07001400 setBackgroundDrawable(mContext.getDrawable(resId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001401 }
1402
1403 /**
1404 * Change the background of this window to a custom Drawable. Setting the
1405 * background to null will make the window be opaque. To make the window
1406 * transparent, you can use an empty drawable (for instance a ColorDrawable
1407 * with the color 0 or the system drawable android:drawable/empty.)
1408 *
1409 * @param drawable The new Drawable to use for this window's background.
1410 */
1411 public abstract void setBackgroundDrawable(Drawable drawable);
1412
1413 /**
1414 * Set the value for a drawable feature of this window, from a resource
Tor Norbye7b9c9122013-05-30 16:48:33 -07001415 * identifier. You must have called requestFeature(featureId) before
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001416 * calling this function.
1417 *
1418 * @see android.content.res.Resources#getDrawable(int)
1419 *
1420 * @param featureId The desired drawable feature to change, defined as a
1421 * constant by Window.
1422 * @param resId Resource identifier of the desired image.
1423 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001424 public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001425
1426 /**
1427 * Set the value for a drawable feature of this window, from a URI. You
1428 * must have called requestFeature(featureId) before calling this
1429 * function.
1430 *
1431 * <p>The only URI currently supported is "content:", specifying an image
1432 * in a content provider.
1433 *
1434 * @see android.widget.ImageView#setImageURI
1435 *
1436 * @param featureId The desired drawable feature to change. Features are
1437 * constants defined by Window.
1438 * @param uri The desired URI.
1439 */
1440 public abstract void setFeatureDrawableUri(int featureId, Uri uri);
1441
1442 /**
1443 * Set an explicit Drawable value for feature of this window. You must
1444 * have called requestFeature(featureId) before calling this function.
1445 *
Alan Viverette9678e342014-10-24 15:23:58 -07001446 * @param featureId The desired drawable feature to change. Features are
1447 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001448 * @param drawable A Drawable object to display.
1449 */
1450 public abstract void setFeatureDrawable(int featureId, Drawable drawable);
1451
1452 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001453 * Set a custom alpha value for the given drawable feature, controlling how
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001454 * much the background is visible through it.
1455 *
Alan Viverette9678e342014-10-24 15:23:58 -07001456 * @param featureId The desired drawable feature to change. Features are
1457 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001458 * @param alpha The alpha amount, 0 is completely transparent and 255 is
1459 * completely opaque.
1460 */
1461 public abstract void setFeatureDrawableAlpha(int featureId, int alpha);
1462
1463 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001464 * Set the integer value for a feature. The range of the value depends on
1465 * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from
1466 * 0 to 10000. At 10000 the progress is complete and the indicator hidden.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001467 *
Alan Viverette9678e342014-10-24 15:23:58 -07001468 * @param featureId The desired feature to change. Features are constants
1469 * defined by Window.
1470 * @param value The value for the feature. The interpretation of this
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001471 * value is feature-specific.
1472 */
1473 public abstract void setFeatureInt(int featureId, int value);
1474
1475 /**
1476 * Request that key events come to this activity. Use this if your
1477 * activity has no views with focus, but the activity still wants
1478 * a chance to process key events.
1479 */
1480 public abstract void takeKeyEvents(boolean get);
1481
1482 /**
1483 * Used by custom windows, such as Dialog, to pass the key press event
1484 * further down the view hierarchy. Application developers should
1485 * not need to implement or call this.
1486 *
1487 */
1488 public abstract boolean superDispatchKeyEvent(KeyEvent event);
1489
1490 /**
Jeff Brown64da12a2011-01-04 19:57:47 -08001491 * Used by custom windows, such as Dialog, to pass the key shortcut press event
1492 * further down the view hierarchy. Application developers should
1493 * not need to implement or call this.
1494 *
1495 */
1496 public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event);
1497
1498 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001499 * Used by custom windows, such as Dialog, to pass the touch screen event
1500 * further down the view hierarchy. Application developers should
1501 * not need to implement or call this.
1502 *
1503 */
1504 public abstract boolean superDispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001505
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001506 /**
1507 * Used by custom windows, such as Dialog, to pass the trackball event
1508 * further down the view hierarchy. Application developers should
1509 * not need to implement or call this.
1510 *
1511 */
1512 public abstract boolean superDispatchTrackballEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001513
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001514 /**
Jeff Browncb1404e2011-01-15 18:14:15 -08001515 * Used by custom windows, such as Dialog, to pass the generic motion event
1516 * further down the view hierarchy. Application developers should
1517 * not need to implement or call this.
1518 *
1519 */
1520 public abstract boolean superDispatchGenericMotionEvent(MotionEvent event);
1521
1522 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001523 * Retrieve the top-level window decor view (containing the standard
1524 * window frame/decorations and the client's content inside of that), which
1525 * can be added as a window to the window manager.
RoboErik55011652014-07-09 15:05:53 -07001526 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001527 * <p><em>Note that calling this function for the first time "locks in"
1528 * various window characteristics as described in
1529 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p>
RoboErik55011652014-07-09 15:05:53 -07001530 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001531 * @return Returns the top-level window decor view.
1532 */
1533 public abstract View getDecorView();
1534
1535 /**
1536 * Retrieve the current decor view, but only if it has already been created;
1537 * otherwise returns null.
RoboErik55011652014-07-09 15:05:53 -07001538 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001539 * @return Returns the top-level window decor or null.
1540 * @see #getDecorView
1541 */
1542 public abstract View peekDecorView();
1543
1544 public abstract Bundle saveHierarchyState();
RoboErik55011652014-07-09 15:05:53 -07001545
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001546 public abstract void restoreHierarchyState(Bundle savedInstanceState);
RoboErik55011652014-07-09 15:05:53 -07001547
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001548 protected abstract void onActive();
1549
1550 /**
1551 * Return the feature bits that are enabled. This is the set of features
1552 * that were given to requestFeature(), and are being handled by this
1553 * Window itself or its container. That is, it is the set of
1554 * requested features that you can actually use.
1555 *
1556 * <p>To do: add a public version of this API that allows you to check for
1557 * features by their feature ID.
1558 *
1559 * @return int The feature bits.
1560 */
1561 protected final int getFeatures()
1562 {
1563 return mFeatures;
1564 }
RoboErik55011652014-07-09 15:05:53 -07001565
Adam Powell33b97432010-04-20 10:01:14 -07001566 /**
Bryce Leed6e6e722014-11-21 11:08:45 -08001567 * Return the feature bits set by default on a window.
1568 * @param context The context used to access resources
1569 */
1570 public static int getDefaultFeatures(Context context) {
1571 int features = 0;
1572
1573 final Resources res = context.getResources();
1574 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
1575 features |= 1 << FEATURE_OPTIONS_PANEL;
1576 }
1577
1578 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
1579 features |= 1 << FEATURE_CONTEXT_MENU;
1580 }
1581
1582 return features;
1583 }
1584
1585 /**
Adam Powell33b97432010-04-20 10:01:14 -07001586 * Query for the availability of a certain feature.
RoboErik55011652014-07-09 15:05:53 -07001587 *
Adam Powell33b97432010-04-20 10:01:14 -07001588 * @param feature The feature ID to check
1589 * @return true if the feature is enabled, false otherwise.
1590 */
1591 public boolean hasFeature(int feature) {
1592 return (getFeatures() & (1 << feature)) != 0;
1593 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001594
1595 /**
1596 * Return the feature bits that are being implemented by this Window.
1597 * This is the set of features that were given to requestFeature(), and are
1598 * being handled by only this Window itself, not by its containers.
1599 *
1600 * @return int The feature bits.
1601 */
1602 protected final int getLocalFeatures()
1603 {
1604 return mLocalFeatures;
1605 }
1606
1607 /**
1608 * Set the default format of window, as per the PixelFormat types. This
1609 * is the format that will be used unless the client specifies in explicit
1610 * format with setFormat();
1611 *
1612 * @param format The new window format (see PixelFormat).
1613 *
1614 * @see #setFormat
1615 * @see PixelFormat
1616 */
1617 protected void setDefaultWindowFormat(int format) {
1618 mDefaultWindowFormat = format;
1619 if (!mHaveWindowFormat) {
1620 final WindowManager.LayoutParams attrs = getAttributes();
1621 attrs.format = format;
Adrian Roosea562512014-05-05 13:33:03 +02001622 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001623 }
1624 }
1625
Dianne Hackborn661cd522011-08-22 00:26:20 -07001626 /** @hide */
1627 protected boolean haveDimAmount() {
1628 return mHaveDimAmount;
1629 }
1630
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001631 public abstract void setChildDrawable(int featureId, Drawable drawable);
1632
1633 public abstract void setChildInt(int featureId, int value);
1634
1635 /**
1636 * Is a keypress one of the defined shortcut keys for this window.
1637 * @param keyCode the key code from {@link android.view.KeyEvent} to check.
1638 * @param event the {@link android.view.KeyEvent} to use to help check.
1639 */
1640 public abstract boolean isShortcutKey(int keyCode, KeyEvent event);
RoboErik55011652014-07-09 15:05:53 -07001641
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001642 /**
RoboErik55011652014-07-09 15:05:53 -07001643 * @see android.app.Activity#setVolumeControlStream(int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001644 */
1645 public abstract void setVolumeControlStream(int streamType);
1646
1647 /**
1648 * @see android.app.Activity#getVolumeControlStream()
1649 */
1650 public abstract int getVolumeControlStream();
Adam Powell269248d2011-08-02 10:26:54 -07001651
1652 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001653 * Sets a {@link MediaController} to send media keys and volume changes to.
1654 * If set, this should be preferred for all media keys and volume requests
1655 * sent to this window.
1656 *
1657 * @param controller The controller for the session which should receive
1658 * media keys and volume changes.
RoboErik55011652014-07-09 15:05:53 -07001659 * @see android.app.Activity#setMediaController(android.media.session.MediaController)
1660 */
1661 public void setMediaController(MediaController controller) {
1662 }
1663
1664 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001665 * Gets the {@link MediaController} that was previously set.
1666 *
1667 * @return The controller which should receive events.
1668 * @see #setMediaController(android.media.session.MediaController)
RoboErik55011652014-07-09 15:05:53 -07001669 * @see android.app.Activity#getMediaController()
1670 */
1671 public MediaController getMediaController() {
1672 return null;
1673 }
1674
1675 /**
Adam Powell269248d2011-08-02 10:26:54 -07001676 * Set extra options that will influence the UI for this window.
1677 * @param uiOptions Flags specifying extra options for this window.
1678 */
1679 public void setUiOptions(int uiOptions) { }
Adam Powelle43fca92011-08-16 12:57:01 -07001680
1681 /**
1682 * Set extra options that will influence the UI for this window.
1683 * Only the bits filtered by mask will be modified.
1684 * @param uiOptions Flags specifying extra options for this window.
1685 * @param mask Flags specifying which options should be modified. Others will remain unchanged.
1686 */
1687 public void setUiOptions(int uiOptions, int mask) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001688
1689 /**
1690 * Set the primary icon for this window.
1691 *
1692 * @param resId resource ID of a drawable to set
1693 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001694 public void setIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001695
1696 /**
1697 * Set the default icon for this window.
1698 * This will be overridden by any other icon set operation which could come from the
1699 * theme or another explicit set.
1700 *
1701 * @hide
1702 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001703 public void setDefaultIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001704
1705 /**
1706 * Set the logo for this window. A logo is often shown in place of an
1707 * {@link #setIcon(int) icon} but is generally wider and communicates window title information
1708 * as well.
1709 *
1710 * @param resId resource ID of a drawable to set
1711 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001712 public void setLogo(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001713
1714 /**
1715 * Set the default logo for this window.
1716 * This will be overridden by any other logo set operation which could come from the
1717 * theme or another explicit set.
1718 *
1719 * @hide
1720 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001721 public void setDefaultLogo(@DrawableRes int resId) { }
keunyoung30f420f2013-08-02 14:23:10 -07001722
1723 /**
1724 * Set focus locally. The window should have the
1725 * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.
1726 * @param hasFocus Whether this window has focus or not.
1727 * @param inTouchMode Whether this window is in touch mode or not.
1728 */
1729 public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { }
1730
1731 /**
1732 * Inject an event to window locally.
1733 * @param event A key or touch event to inject to this window.
1734 */
1735 public void injectInputEvent(InputEvent event) { }
Adam Powellcfbe9be2013-11-06 14:58:58 -08001736
1737 /**
1738 * Retrieve the {@link TransitionManager} responsible for for default transitions
1739 * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1740 *
1741 * <p>This method will return non-null after content has been initialized (e.g. by using
1742 * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p>
1743 *
1744 * @return This window's content TransitionManager or null if none is set.
George Mountc3a043c2015-02-04 14:37:04 -08001745 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08001746 */
1747 public TransitionManager getTransitionManager() {
1748 return null;
1749 }
1750
1751 /**
1752 * Set the {@link TransitionManager} to use for default transitions in this window.
1753 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1754 *
1755 * @param tm The TransitionManager to use for scene changes.
George Mountc3a043c2015-02-04 14:37:04 -08001756 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08001757 */
1758 public void setTransitionManager(TransitionManager tm) {
1759 throw new UnsupportedOperationException();
1760 }
1761
1762 /**
1763 * Retrieve the {@link Scene} representing this window's current content.
1764 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1765 *
1766 * <p>This method will return null if the current content is not represented by a Scene.</p>
1767 *
1768 * @return Current Scene being shown or null
1769 */
1770 public Scene getContentScene() {
1771 return null;
1772 }
1773
1774 /**
George Mount31a21722014-03-24 17:44:36 -07001775 * Sets the Transition that will be used to move Views into the initial scene. The entering
1776 * Views will be those that are regular Views or ViewGroups that have
1777 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1778 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1779 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1780 * entering Views will remain unaffected.
George Mountc03da0e2014-08-22 17:04:02 -07001781 *
George Mount31a21722014-03-24 17:44:36 -07001782 * @param transition The Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001783 * @attr ref android.R.styleable#Window_windowEnterTransition
Adam Powellcfbe9be2013-11-06 14:58:58 -08001784 */
George Mount31a21722014-03-24 17:44:36 -07001785 public void setEnterTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08001786
1787 /**
George Mount68f96d82014-07-31 13:13:10 -07001788 * Sets the Transition that will be used to move Views out of the scene when the Window is
1789 * preparing to close, for example after a call to
1790 * {@link android.app.Activity#finishAfterTransition()}. The exiting
1791 * Views will be those that are regular Views or ViewGroups that have
1792 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1793 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1794 * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null,
1795 * entering Views will remain unaffected. If nothing is set, the default will be to
1796 * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
George Mountc03da0e2014-08-22 17:04:02 -07001797 *
George Mount68f96d82014-07-31 13:13:10 -07001798 * @param transition The Transition to use to move Views out of the Scene when the Window
1799 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07001800 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07001801 */
1802 public void setReturnTransition(Transition transition) {}
1803
1804 /**
George Mount31a21722014-03-24 17:44:36 -07001805 * Sets the Transition that will be used to move Views out of the scene when starting a
1806 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1807 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1808 * {@link android.transition.Visibility} as exiting is governed by changing visibility
1809 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07001810 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001811 *
George Mount31a21722014-03-24 17:44:36 -07001812 * @param transition The Transition to use to move Views out of the scene when calling a
1813 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07001814 * @attr ref android.R.styleable#Window_windowExitTransition
George Mount0a778ed2013-12-13 13:35:36 -08001815 */
George Mount31a21722014-03-24 17:44:36 -07001816 public void setExitTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08001817
1818 /**
George Mount68f96d82014-07-31 13:13:10 -07001819 * Sets the Transition that will be used to move Views in to the scene when returning from
1820 * a previously-started Activity. The entering Views will be those that are regular Views
1821 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1822 * will extend {@link android.transition.Visibility} as exiting is governed by changing
1823 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
1824 * the views will remain unaffected. If nothing is set, the default will be to use the same
1825 * transition as {@link #setExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07001826 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001827 *
George Mount68f96d82014-07-31 13:13:10 -07001828 * @param transition The Transition to use to move Views into the scene when reentering from a
1829 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07001830 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07001831 */
1832 public void setReenterTransition(Transition transition) {}
1833
1834 /**
George Mount31a21722014-03-24 17:44:36 -07001835 * Returns the transition used to move Views into the initial scene. The entering
1836 * Views will be those that are regular Views or ViewGroups that have
1837 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1838 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1839 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
George Mount9826f632014-09-11 08:50:09 -07001840 * entering Views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07001841 *
1842 * @return the Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001843 * @attr ref android.R.styleable#Window_windowEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08001844 */
George Mount31a21722014-03-24 17:44:36 -07001845 public Transition getEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08001846
1847 /**
George Mount68f96d82014-07-31 13:13:10 -07001848 * Returns he Transition that will be used to move Views out of the scene when the Window is
1849 * preparing to close, for example after a call to
1850 * {@link android.app.Activity#finishAfterTransition()}. The exiting
1851 * Views will be those that are regular Views or ViewGroups that have
1852 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1853 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1854 * {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mountc03da0e2014-08-22 17:04:02 -07001855 *
George Mount68f96d82014-07-31 13:13:10 -07001856 * @return The Transition to use to move Views out of the Scene when the Window
1857 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07001858 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07001859 */
1860 public Transition getReturnTransition() { return null; }
1861
1862 /**
George Mount31a21722014-03-24 17:44:36 -07001863 * Returns the Transition that will be used to move Views out of the scene when starting a
1864 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1865 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1866 * {@link android.transition.Visibility} as exiting is governed by changing visibility
1867 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07001868 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001869 *
George Mount31a21722014-03-24 17:44:36 -07001870 * @return the Transition to use to move Views out of the scene when calling a
1871 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07001872 * @attr ref android.R.styleable#Window_windowExitTransition
George Mountcb4b7d92014-02-25 10:47:55 -08001873 */
George Mount31a21722014-03-24 17:44:36 -07001874 public Transition getExitTransition() { return null; }
George Mount0a778ed2013-12-13 13:35:36 -08001875
1876 /**
George Mount68f96d82014-07-31 13:13:10 -07001877 * Returns the Transition that will be used to move Views in to the scene when returning from
1878 * a previously-started Activity. The entering Views will be those that are regular Views
1879 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1880 * will extend {@link android.transition.Visibility} as exiting is governed by changing
1881 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mount9826f632014-09-11 08:50:09 -07001882 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001883 *
George Mount68f96d82014-07-31 13:13:10 -07001884 * @return The Transition to use to move Views into the scene when reentering from a
1885 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07001886 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07001887 */
1888 public Transition getReenterTransition() { return null; }
1889
1890 /**
George Mount31a21722014-03-24 17:44:36 -07001891 * Sets the Transition that will be used for shared elements transferred into the content
1892 * Scene. Typical Transitions will affect size and location, such as
George Mount990205e2014-06-24 09:36:18 -07001893 * {@link android.transition.ChangeBounds}. A null
George Mount31a21722014-03-24 17:44:36 -07001894 * value will cause transferred shared elements to blink to the final position.
George Mount9826f632014-09-11 08:50:09 -07001895 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001896 *
George Mount31a21722014-03-24 17:44:36 -07001897 * @param transition The Transition to use for shared elements transferred into the content
1898 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001899 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08001900 */
George Mount31a21722014-03-24 17:44:36 -07001901 public void setSharedElementEnterTransition(Transition transition) {}
George Mounte1803372014-02-26 19:00:52 +00001902
1903 /**
George Mount68f96d82014-07-31 13:13:10 -07001904 * Sets the Transition that will be used for shared elements transferred back to a
1905 * calling Activity. Typical Transitions will affect size and location, such as
1906 * {@link android.transition.ChangeBounds}. A null
1907 * value will cause transferred shared elements to blink to the final position.
1908 * If no value is set, the default will be to use the same value as
1909 * {@link #setSharedElementEnterTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07001910 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001911 *
George Mount68f96d82014-07-31 13:13:10 -07001912 * @param transition The Transition to use for shared elements transferred out of the content
1913 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001914 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07001915 */
1916 public void setSharedElementReturnTransition(Transition transition) {}
1917
1918 /**
George Mount31a21722014-03-24 17:44:36 -07001919 * Returns the Transition that will be used for shared elements transferred into the content
George Mount9826f632014-09-11 08:50:09 -07001920 * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001921 *
George Mount31a21722014-03-24 17:44:36 -07001922 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001923 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mountcb4b7d92014-02-25 10:47:55 -08001924 */
George Mount31a21722014-03-24 17:44:36 -07001925 public Transition getSharedElementEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08001926
1927 /**
George Mount68f96d82014-07-31 13:13:10 -07001928 * Returns the Transition that will be used for shared elements transferred back to a
George Mount9826f632014-09-11 08:50:09 -07001929 * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001930 *
George Mount68f96d82014-07-31 13:13:10 -07001931 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001932 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07001933 */
1934 public Transition getSharedElementReturnTransition() { return null; }
1935
1936 /**
George Mount31a21722014-03-24 17:44:36 -07001937 * Sets the Transition that will be used for shared elements after starting a new Activity
1938 * before the shared elements are transferred to the called Activity. If the shared elements
1939 * must animate during the exit transition, this Transition should be used. Upon completion,
1940 * the shared elements may be transferred to the started Activity.
George Mount9826f632014-09-11 08:50:09 -07001941 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001942 *
George Mount31a21722014-03-24 17:44:36 -07001943 * @param transition The Transition to use for shared elements in the launching Window
1944 * prior to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07001945 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mounte1803372014-02-26 19:00:52 +00001946 */
George Mount31a21722014-03-24 17:44:36 -07001947 public void setSharedElementExitTransition(Transition transition) {}
1948
1949 /**
George Mount68f96d82014-07-31 13:13:10 -07001950 * Sets the Transition that will be used for shared elements reentering from a started
1951 * Activity after it has returned the shared element to it start location. If no value
1952 * is set, this will default to
1953 * {@link #setSharedElementExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07001954 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001955 *
George Mount68f96d82014-07-31 13:13:10 -07001956 * @param transition The Transition to use for shared elements in the launching Window
1957 * after the shared element has returned to the Window.
George Mountc03da0e2014-08-22 17:04:02 -07001958 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07001959 */
1960 public void setSharedElementReenterTransition(Transition transition) {}
1961
1962 /**
George Mount31a21722014-03-24 17:44:36 -07001963 * Returns the Transition to use for shared elements in the launching Window prior
1964 * to transferring to the launched Activity's Window.
George Mount9826f632014-09-11 08:50:09 -07001965 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07001966 *
1967 * @return the Transition to use for shared elements in the launching Window prior
1968 * to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07001969 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mount31a21722014-03-24 17:44:36 -07001970 */
1971 public Transition getSharedElementExitTransition() { return null; }
1972
1973 /**
George Mount68f96d82014-07-31 13:13:10 -07001974 * Returns the Transition that will be used for shared elements reentering from a started
1975 * Activity after it has returned the shared element to it start location.
George Mount9826f632014-09-11 08:50:09 -07001976 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount68f96d82014-07-31 13:13:10 -07001977 *
1978 * @return the Transition that will be used for shared elements reentering from a started
1979 * Activity after it has returned the shared element to it start location.
George Mountc03da0e2014-08-22 17:04:02 -07001980 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07001981 */
1982 public Transition getSharedElementReenterTransition() { return null; }
1983
1984 /**
George Mount31a21722014-03-24 17:44:36 -07001985 * Controls how the transition set in
1986 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
1987 * transition of the calling Activity. When true, the transition will start as soon as possible.
1988 * When false, the transition will wait until the remote exiting transition completes before
1989 * starting.
George Mountc03da0e2014-08-22 17:04:02 -07001990 *
George Mount31a21722014-03-24 17:44:36 -07001991 * @param allow true to start the enter transition when possible or false to
1992 * wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07001993 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07001994 */
1995 public void setAllowEnterTransitionOverlap(boolean allow) {}
1996
1997 /**
1998 * Returns how the transition set in
1999 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
2000 * transition of the calling Activity. When true, the transition will start as soon as possible.
2001 * When false, the transition will wait until the remote exiting transition completes before
2002 * starting.
George Mountc03da0e2014-08-22 17:04:02 -07002003 *
George Mount31a21722014-03-24 17:44:36 -07002004 * @return true when the enter transition should start as soon as possible or false to
2005 * when it should wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002006 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002007 */
2008 public boolean getAllowEnterTransitionOverlap() { return true; }
2009
2010 /**
2011 * Controls how the transition set in
2012 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2013 * transition of the called Activity when reentering after if finishes. When true,
2014 * the transition will start as soon as possible. When false, the transition will wait
2015 * until the called Activity's exiting transition completes before starting.
George Mountc03da0e2014-08-22 17:04:02 -07002016 *
George Mount31a21722014-03-24 17:44:36 -07002017 * @param allow true to start the transition when possible or false to wait until the
2018 * called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002019 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002020 */
George Mountc03da0e2014-08-22 17:04:02 -07002021 public void setAllowReturnTransitionOverlap(boolean allow) {}
2022
2023 /**
George Mount31a21722014-03-24 17:44:36 -07002024 * Returns how the transition set in
2025 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2026 * transition of the called Activity when reentering after if finishes. When true,
2027 * the transition will start as soon as possible. When false, the transition will wait
2028 * until the called Activity's exiting transition completes before starting.
George Mountc03da0e2014-08-22 17:04:02 -07002029 *
George Mount31a21722014-03-24 17:44:36 -07002030 * @return true when the transition should start when possible or false when it should wait
2031 * until the called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002032 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002033 */
George Mountc03da0e2014-08-22 17:04:02 -07002034 public boolean getAllowReturnTransitionOverlap() { return true; }
2035
2036 /**
George Mounted1e01d2014-06-05 13:49:12 -07002037 * Returns the duration, in milliseconds, of the window background fade
2038 * when transitioning into or away from an Activity when called with an Activity Transition.
2039 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002040 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002041 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002042 *
George Mounted1e01d2014-06-05 13:49:12 -07002043 * @return The duration of the window background fade to opaque during enter transition.
2044 * @see #getEnterTransition()
George Mountc03da0e2014-08-22 17:04:02 -07002045 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002046 */
2047 public long getTransitionBackgroundFadeDuration() { return 0; }
2048
2049 /**
2050 * Sets the duration, in milliseconds, of the window background fade
2051 * when transitioning into or away from an Activity when called with an Activity Transition.
2052 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002053 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002054 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002055 *
George Mounted1e01d2014-06-05 13:49:12 -07002056 * @param fadeDurationMillis The duration of the window background fade to or from opaque
2057 * during enter transition.
2058 * @see #setEnterTransition(android.transition.Transition)
George Mountc03da0e2014-08-22 17:04:02 -07002059 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002060 */
2061 public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { }
2062
2063 /**
George Mountb89d5cc2014-08-18 16:50:50 -07002064 * Returns <code>true</code> when shared elements should use an Overlay during
2065 * shared element transitions or <code>false</code> when they should animate as
2066 * part of the normal View hierarchy. The default value is true.
2067 *
2068 * @return <code>true</code> when shared elements should use an Overlay during
2069 * shared element transitions or <code>false</code> when they should animate as
2070 * part of the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002071 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002072 */
2073 public boolean getSharedElementsUseOverlay() { return true; }
2074
2075 /**
2076 * Sets whether or not shared elements should use an Overlay during shared element transitions.
2077 * The default value is true.
2078 *
2079 * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should
2080 * be transitioned with an Overlay or <code>false</code>
2081 * to transition within the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002082 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002083 */
2084 public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { }
2085
2086 /**
Adrian Roos217ccd22014-05-09 14:29:04 +02002087 * @return the color of the status bar.
2088 */
Tor Norbye80756e32015-03-02 09:39:27 -08002089 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002090 public abstract int getStatusBarColor();
2091
2092 /**
John Spurlockbc4cf002015-03-24 21:51:20 -04002093 * Sets the color of the status bar to {@code color}.
Adrian Roos217ccd22014-05-09 14:29:04 +02002094 *
2095 * For this to take effect,
2096 * the window must be drawing the system bar backgrounds with
2097 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2098 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set.
2099 *
John Spurlockbc4cf002015-03-24 21:51:20 -04002100 * If {@code color} is not opaque, consider setting
Adrian Roos217ccd22014-05-09 14:29:04 +02002101 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2102 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
George Mount238010f2014-06-30 17:31:17 -07002103 * <p>
2104 * The transitionName for the view background will be "android:status:background".
2105 * </p>
Adrian Roos217ccd22014-05-09 14:29:04 +02002106 */
Tor Norbye80756e32015-03-02 09:39:27 -08002107 public abstract void setStatusBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002108
2109 /**
2110 * @return the color of the navigation bar.
2111 */
Tor Norbye80756e32015-03-02 09:39:27 -08002112 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002113 public abstract int getNavigationBarColor();
2114
2115 /**
2116 * Sets the color of the navigation bar to {@param color}.
2117 *
2118 * For this to take effect,
2119 * the window must be drawing the system bar backgrounds with
2120 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2121 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
2122 *
2123 * If {@param color} is not opaque, consider setting
2124 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2125 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
George Mount238010f2014-06-30 17:31:17 -07002126 * <p>
2127 * The transitionName for the view background will be "android:navigation:background".
2128 * </p>
Adrian Roos217ccd22014-05-09 14:29:04 +02002129 */
Tor Norbye80756e32015-03-02 09:39:27 -08002130 public abstract void setNavigationBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002131
Filip Gruszczynski0daf2102015-09-29 08:39:07 -07002132 /** @hide */
2133 public void setTheme(int resId) {
2134 }
Filip Gruszczynski63250652015-11-18 14:43:01 -08002135
2136 /**
2137 * Whether the caption should be displayed directly on the content rather than push the content
2138 * down. This affects only freeform windows since they display the caption.
2139 * @hide
2140 */
2141 public void setOverlayDecorCaption(boolean overlayCaption) {
2142 mOverlayWithDecorCaption = overlayCaption;
2143 }
2144
2145 /** @hide */
2146 public boolean getOverlayDecorCaption() {
2147 return mOverlayWithDecorCaption;
2148 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002149
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002150 /** @hide */
2151 public void notifyRestrictedCaptionAreaCallback(int left, int top, int right, int bottom) {
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002152 if (mOnRestrictedCaptionAreaChangedListener != null) {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002153 mRestrictedCaptionAreaRect.set(left, top, right, bottom);
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002154 mOnRestrictedCaptionAreaChangedListener.onRestrictedCaptionAreaChanged(
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002155 mRestrictedCaptionAreaRect);
2156 }
2157 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002158
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002159 /**
2160 * Set what color should the caption controls be. By default the system will try to determine
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002161 * the color from the theme. You can overwrite this by using {@link #DECOR_CAPTION_SHADE_DARK},
2162 * {@link #DECOR_CAPTION_SHADE_LIGHT}, or {@link #DECOR_CAPTION_SHADE_AUTO}.
2163 * @see #DECOR_CAPTION_SHADE_DARK
2164 * @see #DECOR_CAPTION_SHADE_LIGHT
2165 * @see #DECOR_CAPTION_SHADE_AUTO
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002166 */
2167 public abstract void setDecorCaptionShade(int decorCaptionShade);
2168
2169 /**
2170 * Set the drawable that is drawn underneath the caption during the resizing.
2171 *
2172 * During the resizing the caption might not be drawn fast enough to match the new dimensions.
2173 * There is a second caption drawn underneath it that will be fast enough. By default the
2174 * caption is constructed from the theme. You can provide a drawable, that will be drawn instead
2175 * to better match your application.
2176 */
2177 public abstract void setResizingCaptionDrawable(Drawable drawable);
Wale Ogunwaleeb6722c2015-12-08 11:43:43 -08002178
2179 /**
2180 * Called when the activity changes from fullscreen mode to multi-window mode and visa-versa.
2181 * @hide
2182 */
Wale Ogunwale3b93a4d2016-01-29 17:46:53 -08002183 public abstract void onMultiWindowChanged();
Jorim Jaggi4846ee32016-01-07 17:39:12 +01002184
2185 /**
2186 * Called when the activity just relaunched.
2187 * @hide
2188 */
2189 public abstract void reportActivityRelaunched();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002190}