1 /*
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 
17 package android.view;
18 
19 import android.annotation.ColorInt;
20 import android.annotation.DrawableRes;
21 import android.annotation.IdRes;
22 import android.annotation.LayoutRes;
23 import android.annotation.NonNull;
24 import android.annotation.Nullable;
25 import android.annotation.StyleRes;
26 import android.annotation.SystemApi;
27 import android.content.Context;
28 import android.content.res.Configuration;
29 import android.content.res.Resources;
30 import android.content.res.TypedArray;
31 import android.graphics.PixelFormat;
32 import android.graphics.drawable.Drawable;
33 import android.media.session.MediaController;
34 import android.net.Uri;
35 import android.os.Bundle;
36 import android.os.IBinder;
37 import android.os.SystemProperties;
38 import android.transition.Scene;
39 import android.transition.Transition;
40 import android.transition.TransitionManager;
41 import android.view.accessibility.AccessibilityEvent;
42 
43 /**
44  * Abstract base class for a top-level window look and behavior policy.  An
45  * instance of this class should be used as the top-level view added to the
46  * window manager. It provides standard UI policies such as a background, title
47  * area, default key processing, etc.
48  *
49  * <p>The only existing implementation of this abstract class is
50  * android.view.PhoneWindow, which you should instantiate when needing a
51  * Window.
52  */
53 public abstract class Window {
54     /** Flag for the "options panel" feature.  This is enabled by default. */
55     public static final int FEATURE_OPTIONS_PANEL = 0;
56     /** Flag for the "no title" feature, turning off the title at the top
57      *  of the screen. */
58     public static final int FEATURE_NO_TITLE = 1;
59     /** Flag for the progress indicator feature */
60     public static final int FEATURE_PROGRESS = 2;
61     /** Flag for having an icon on the left side of the title bar */
62     public static final int FEATURE_LEFT_ICON = 3;
63     /** Flag for having an icon on the right side of the title bar */
64     public static final int FEATURE_RIGHT_ICON = 4;
65     /** Flag for indeterminate progress */
66     public static final int FEATURE_INDETERMINATE_PROGRESS = 5;
67     /** Flag for the context menu.  This is enabled by default. */
68     public static final int FEATURE_CONTEXT_MENU = 6;
69     /** Flag for custom title. You cannot combine this feature with other title features. */
70     public static final int FEATURE_CUSTOM_TITLE = 7;
71     /**
72      * Flag for enabling the Action Bar.
73      * This is enabled by default for some devices. The Action Bar
74      * replaces the title bar and provides an alternate location
75      * for an on-screen menu button on some devices.
76      */
77     public static final int FEATURE_ACTION_BAR = 8;
78     /**
79      * Flag for requesting an Action Bar that overlays window content.
80      * Normally an Action Bar will sit in the space above window content, but if this
81      * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over
82      * the window content itself. This is useful if you would like your app to have more control
83      * over how the Action Bar is displayed, such as letting application content scroll beneath
84      * an Action Bar with a transparent background or otherwise displaying a transparent/translucent
85      * Action Bar over application content.
86      *
87      * <p>This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN
88      * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the
89      * action bar in conjunction with other screen decorations.
90      *
91      * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an
92      * ActionBar is in this mode it will adjust the insets provided to
93      * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)}
94      * to include the content covered by the action bar, so you can do layout within
95      * that space.
96      */
97     public static final int FEATURE_ACTION_BAR_OVERLAY = 9;
98     /**
99      * Flag for specifying the behavior of action modes when an Action Bar is not present.
100      * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
101      */
102     public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
103     /**
104      * Flag for requesting a decoration-free window that is dismissed by swiping from the left.
105      */
106     public static final int FEATURE_SWIPE_TO_DISMISS = 11;
107     /**
108      * Flag for requesting that window content changes should be animated using a
109      * TransitionManager.
110      *
111      * <p>The TransitionManager is set using
112      * {@link #setTransitionManager(android.transition.TransitionManager)}. If none is set,
113      * a default TransitionManager will be used.</p>
114      *
115      * @see #setContentView
116      */
117     public static final int FEATURE_CONTENT_TRANSITIONS = 12;
118 
119     /**
120      * Enables Activities to run Activity Transitions either through sending or receiving
121      * ActivityOptions bundle created with
122      * {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity,
123      * android.util.Pair[])} or {@link android.app.ActivityOptions#makeSceneTransitionAnimation(
124      * android.app.Activity, View, String)}.
125      */
126     public static final int FEATURE_ACTIVITY_TRANSITIONS = 13;
127 
128     /**
129      * Max value used as a feature ID
130      * @hide
131      */
132     public static final int FEATURE_MAX = FEATURE_ACTIVITY_TRANSITIONS;
133 
134     /** Flag for setting the progress bar's visibility to VISIBLE */
135     public static final int PROGRESS_VISIBILITY_ON = -1;
136     /** Flag for setting the progress bar's visibility to GONE */
137     public static final int PROGRESS_VISIBILITY_OFF = -2;
138     /** Flag for setting the progress bar's indeterminate mode on */
139     public static final int PROGRESS_INDETERMINATE_ON = -3;
140     /** Flag for setting the progress bar's indeterminate mode off */
141     public static final int PROGRESS_INDETERMINATE_OFF = -4;
142     /** Starting value for the (primary) progress */
143     public static final int PROGRESS_START = 0;
144     /** Ending value for the (primary) progress */
145     public static final int PROGRESS_END = 10000;
146     /** Lowest possible value for the secondary progress */
147     public static final int PROGRESS_SECONDARY_START = 20000;
148     /** Highest possible value for the secondary progress */
149     public static final int PROGRESS_SECONDARY_END = 30000;
150 
151     /**
152      * The transitionName for the status bar background View when a custom background is used.
153      * @see android.view.Window#setStatusBarColor(int)
154      */
155     public static final String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background";
156 
157     /**
158      * The transitionName for the navigation bar background View when a custom background is used.
159      * @see android.view.Window#setNavigationBarColor(int)
160      */
161     public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME =
162             "android:navigation:background";
163 
164     /**
165      * The default features enabled.
166      * @deprecated use {@link #getDefaultFeatures(android.content.Context)} instead.
167      */
168     @Deprecated
169     @SuppressWarnings({"PointlessBitwiseExpression"})
170     protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) |
171             (1 << FEATURE_CONTEXT_MENU);
172 
173     /**
174      * The ID that the main layout in the XML layout file should have.
175      */
176     public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content;
177 
178     private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw";
179 
180     private final Context mContext;
181 
182     private TypedArray mWindowStyle;
183     private Callback mCallback;
184     private OnWindowDismissedCallback mOnWindowDismissedCallback;
185     private WindowManager mWindowManager;
186     private IBinder mAppToken;
187     private String mAppName;
188     private boolean mHardwareAccelerated;
189     private Window mContainer;
190     private Window mActiveChild;
191     private boolean mIsActive = false;
192     private boolean mHasChildren = false;
193     private boolean mCloseOnTouchOutside = false;
194     private boolean mSetCloseOnTouchOutside = false;
195     private int mForcedWindowFlags = 0;
196 
197     private int mFeatures;
198     private int mLocalFeatures;
199 
200     private boolean mHaveWindowFormat = false;
201     private boolean mHaveDimAmount = false;
202     private int mDefaultWindowFormat = PixelFormat.OPAQUE;
203 
204     private boolean mHasSoftInputMode = false;
205 
206     private boolean mDestroyed;
207 
208     // The current window attributes.
209     private final WindowManager.LayoutParams mWindowAttributes =
210         new WindowManager.LayoutParams();
211 
212     /**
213      * API from a Window back to its caller.  This allows the client to
214      * intercept key dispatching, panels and menus, etc.
215      */
216     public interface Callback {
217         /**
218          * Called to process key events.  At the very least your
219          * implementation must call
220          * {@link android.view.Window#superDispatchKeyEvent} to do the
221          * standard key processing.
222          *
223          * @param event The key event.
224          *
225          * @return boolean Return true if this event was consumed.
226          */
dispatchKeyEvent(KeyEvent event)227         public boolean dispatchKeyEvent(KeyEvent event);
228 
229         /**
230          * Called to process a key shortcut event.
231          * At the very least your implementation must call
232          * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the
233          * standard key shortcut processing.
234          *
235          * @param event The key shortcut event.
236          * @return True if this event was consumed.
237          */
dispatchKeyShortcutEvent(KeyEvent event)238         public boolean dispatchKeyShortcutEvent(KeyEvent event);
239 
240         /**
241          * Called to process touch screen events.  At the very least your
242          * implementation must call
243          * {@link android.view.Window#superDispatchTouchEvent} to do the
244          * standard touch screen processing.
245          *
246          * @param event The touch screen event.
247          *
248          * @return boolean Return true if this event was consumed.
249          */
dispatchTouchEvent(MotionEvent event)250         public boolean dispatchTouchEvent(MotionEvent event);
251 
252         /**
253          * Called to process trackball events.  At the very least your
254          * implementation must call
255          * {@link android.view.Window#superDispatchTrackballEvent} to do the
256          * standard trackball processing.
257          *
258          * @param event The trackball event.
259          *
260          * @return boolean Return true if this event was consumed.
261          */
dispatchTrackballEvent(MotionEvent event)262         public boolean dispatchTrackballEvent(MotionEvent event);
263 
264         /**
265          * Called to process generic motion events.  At the very least your
266          * implementation must call
267          * {@link android.view.Window#superDispatchGenericMotionEvent} to do the
268          * standard processing.
269          *
270          * @param event The generic motion event.
271          *
272          * @return boolean Return true if this event was consumed.
273          */
dispatchGenericMotionEvent(MotionEvent event)274         public boolean dispatchGenericMotionEvent(MotionEvent event);
275 
276         /**
277          * Called to process population of {@link AccessibilityEvent}s.
278          *
279          * @param event The event.
280          *
281          * @return boolean Return true if event population was completed.
282          */
dispatchPopulateAccessibilityEvent(AccessibilityEvent event)283         public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event);
284 
285         /**
286          * Instantiate the view to display in the panel for 'featureId'.
287          * You can return null, in which case the default content (typically
288          * a menu) will be created for you.
289          *
290          * @param featureId Which panel is being created.
291          *
292          * @return view The top-level view to place in the panel.
293          *
294          * @see #onPreparePanel
295          */
296         @Nullable
onCreatePanelView(int featureId)297         public View onCreatePanelView(int featureId);
298 
299         /**
300          * Initialize the contents of the menu for panel 'featureId'.  This is
301          * called if onCreatePanelView() returns null, giving you a standard
302          * menu in which you can place your items.  It is only called once for
303          * the panel, the first time it is shown.
304          *
305          * <p>You can safely hold on to <var>menu</var> (and any items created
306          * from it), making modifications to it as desired, until the next
307          * time onCreatePanelMenu() is called for this feature.
308          *
309          * @param featureId The panel being created.
310          * @param menu The menu inside the panel.
311          *
312          * @return boolean You must return true for the panel to be displayed;
313          *         if you return false it will not be shown.
314          */
onCreatePanelMenu(int featureId, Menu menu)315         public boolean onCreatePanelMenu(int featureId, Menu menu);
316 
317         /**
318          * Prepare a panel to be displayed.  This is called right before the
319          * panel window is shown, every time it is shown.
320          *
321          * @param featureId The panel that is being displayed.
322          * @param view The View that was returned by onCreatePanelView().
323          * @param menu If onCreatePanelView() returned null, this is the Menu
324          *             being displayed in the panel.
325          *
326          * @return boolean You must return true for the panel to be displayed;
327          *         if you return false it will not be shown.
328          *
329          * @see #onCreatePanelView
330          */
onPreparePanel(int featureId, View view, Menu menu)331         public boolean onPreparePanel(int featureId, View view, Menu menu);
332 
333         /**
334          * Called when a panel's menu is opened by the user. This may also be
335          * called when the menu is changing from one type to another (for
336          * example, from the icon menu to the expanded menu).
337          *
338          * @param featureId The panel that the menu is in.
339          * @param menu The menu that is opened.
340          * @return Return true to allow the menu to open, or false to prevent
341          *         the menu from opening.
342          */
onMenuOpened(int featureId, Menu menu)343         public boolean onMenuOpened(int featureId, Menu menu);
344 
345         /**
346          * Called when a panel's menu item has been selected by the user.
347          *
348          * @param featureId The panel that the menu is in.
349          * @param item The menu item that was selected.
350          *
351          * @return boolean Return true to finish processing of selection, or
352          *         false to perform the normal menu handling (calling its
353          *         Runnable or sending a Message to its target Handler).
354          */
onMenuItemSelected(int featureId, MenuItem item)355         public boolean onMenuItemSelected(int featureId, MenuItem item);
356 
357         /**
358          * This is called whenever the current window attributes change.
359          *
360          */
onWindowAttributesChanged(WindowManager.LayoutParams attrs)361         public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
362 
363         /**
364          * This hook is called whenever the content view of the screen changes
365          * (due to a call to
366          * {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams)
367          * Window.setContentView} or
368          * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams)
369          * Window.addContentView}).
370          */
onContentChanged()371         public void onContentChanged();
372 
373         /**
374          * This hook is called whenever the window focus changes.  See
375          * {@link View#onWindowFocusChanged(boolean)
376          * View.onWindowFocusChangedNotLocked(boolean)} for more information.
377          *
378          * @param hasFocus Whether the window now has focus.
379          */
onWindowFocusChanged(boolean hasFocus)380         public void onWindowFocusChanged(boolean hasFocus);
381 
382         /**
383          * Called when the window has been attached to the window manager.
384          * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
385          * for more information.
386          */
onAttachedToWindow()387         public void onAttachedToWindow();
388 
389         /**
390          * Called when the window has been attached to the window manager.
391          * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
392          * for more information.
393          */
onDetachedFromWindow()394         public void onDetachedFromWindow();
395 
396         /**
397          * Called when a panel is being closed.  If another logical subsequent
398          * panel is being opened (and this panel is being closed to make room for the subsequent
399          * panel), this method will NOT be called.
400          *
401          * @param featureId The panel that is being displayed.
402          * @param menu If onCreatePanelView() returned null, this is the Menu
403          *            being displayed in the panel.
404          */
onPanelClosed(int featureId, Menu menu)405         public void onPanelClosed(int featureId, Menu menu);
406 
407         /**
408          * Called when the user signals the desire to start a search.
409          *
410          * @return true if search launched, false if activity refuses (blocks)
411          *
412          * @see android.app.Activity#onSearchRequested()
413          */
onSearchRequested()414         public boolean onSearchRequested();
415 
416         /**
417          * Called when the user signals the desire to start a search.
418          *
419          * @param searchEvent A {@link SearchEvent} describing the signal to
420          *                   start a search.
421          * @return true if search launched, false if activity refuses (blocks)
422          */
onSearchRequested(SearchEvent searchEvent)423         public boolean onSearchRequested(SearchEvent searchEvent);
424 
425         /**
426          * Called when an action mode is being started for this window. Gives the
427          * callback an opportunity to handle the action mode in its own unique and
428          * beautiful way. If this method returns null the system can choose a way
429          * to present the mode or choose not to start the mode at all. This is equivalent
430          * to {@link #onWindowStartingActionMode(android.view.ActionMode.Callback, int)}
431          * with type {@link ActionMode#TYPE_PRIMARY}.
432          *
433          * @param callback Callback to control the lifecycle of this action mode
434          * @return The ActionMode that was started, or null if the system should present it
435          */
436         @Nullable
onWindowStartingActionMode(ActionMode.Callback callback)437         public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
438 
439         /**
440          * Called when an action mode is being started for this window. Gives the
441          * callback an opportunity to handle the action mode in its own unique and
442          * beautiful way. If this method returns null the system can choose a way
443          * to present the mode or choose not to start the mode at all.
444          *
445          * @param callback Callback to control the lifecycle of this action mode
446          * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
447          * @return The ActionMode that was started, or null if the system should present it
448          */
449         @Nullable
onWindowStartingActionMode(ActionMode.Callback callback, int type)450         public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);
451 
452         /**
453          * Called when an action mode has been started. The appropriate mode callback
454          * method will have already been invoked.
455          *
456          * @param mode The new mode that has just been started.
457          */
onActionModeStarted(ActionMode mode)458         public void onActionModeStarted(ActionMode mode);
459 
460         /**
461          * Called when an action mode has been finished. The appropriate mode callback
462          * method will have already been invoked.
463          *
464          * @param mode The mode that was just finished.
465          */
onActionModeFinished(ActionMode mode)466         public void onActionModeFinished(ActionMode mode);
467     }
468 
469     /** @hide */
470     public interface OnWindowDismissedCallback {
471         /**
472          * Called when a window is dismissed. This informs the callback that the
473          * window is gone, and it should finish itself.
474          */
onWindowDismissed()475         public void onWindowDismissed();
476     }
477 
Window(Context context)478     public Window(Context context) {
479         mContext = context;
480         mFeatures = mLocalFeatures = getDefaultFeatures(context);
481     }
482 
483     /**
484      * Return the Context this window policy is running in, for retrieving
485      * resources and other information.
486      *
487      * @return Context The Context that was supplied to the constructor.
488      */
getContext()489     public final Context getContext() {
490         return mContext;
491     }
492 
493     /**
494      * Return the {@link android.R.styleable#Window} attributes from this
495      * window's theme.
496      */
getWindowStyle()497     public final TypedArray getWindowStyle() {
498         synchronized (this) {
499             if (mWindowStyle == null) {
500                 mWindowStyle = mContext.obtainStyledAttributes(
501                         com.android.internal.R.styleable.Window);
502             }
503             return mWindowStyle;
504         }
505     }
506 
507     /**
508      * Set the container for this window.  If not set, the DecorWindow
509      * operates as a top-level window; otherwise, it negotiates with the
510      * container to display itself appropriately.
511      *
512      * @param container The desired containing Window.
513      */
setContainer(Window container)514     public void setContainer(Window container) {
515         mContainer = container;
516         if (container != null) {
517             // Embedded screens never have a title.
518             mFeatures |= 1<<FEATURE_NO_TITLE;
519             mLocalFeatures |= 1<<FEATURE_NO_TITLE;
520             container.mHasChildren = true;
521         }
522     }
523 
524     /**
525      * Return the container for this Window.
526      *
527      * @return Window The containing window, or null if this is a
528      *         top-level window.
529      */
getContainer()530     public final Window getContainer() {
531         return mContainer;
532     }
533 
hasChildren()534     public final boolean hasChildren() {
535         return mHasChildren;
536     }
537 
538     /** @hide */
destroy()539     public final void destroy() {
540         mDestroyed = true;
541     }
542 
543     /** @hide */
isDestroyed()544     public final boolean isDestroyed() {
545         return mDestroyed;
546     }
547 
548     /**
549      * Set the window manager for use by this Window to, for example,
550      * display panels.  This is <em>not</em> used for displaying the
551      * Window itself -- that must be done by the client.
552      *
553      * @param wm The window manager for adding new windows.
554      */
setWindowManager(WindowManager wm, IBinder appToken, String appName)555     public void setWindowManager(WindowManager wm, IBinder appToken, String appName) {
556         setWindowManager(wm, appToken, appName, false);
557     }
558 
559     /**
560      * Set the window manager for use by this Window to, for example,
561      * display panels.  This is <em>not</em> used for displaying the
562      * Window itself -- that must be done by the client.
563      *
564      * @param wm The window manager for adding new windows.
565      */
setWindowManager(WindowManager wm, IBinder appToken, String appName, boolean hardwareAccelerated)566     public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
567             boolean hardwareAccelerated) {
568         mAppToken = appToken;
569         mAppName = appName;
570         mHardwareAccelerated = hardwareAccelerated
571                 || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false);
572         if (wm == null) {
573             wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
574         }
575         mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
576     }
577 
adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp)578     void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) {
579         CharSequence curTitle = wp.getTitle();
580         if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
581             wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
582             if (wp.token == null) {
583                 View decor = peekDecorView();
584                 if (decor != null) {
585                     wp.token = decor.getWindowToken();
586                 }
587             }
588             if (curTitle == null || curTitle.length() == 0) {
589                 String title;
590                 if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) {
591                     title="Media";
592                 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) {
593                     title="MediaOvr";
594                 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
595                     title="Panel";
596                 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) {
597                     title="SubPanel";
598                 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL) {
599                     title="AboveSubPanel";
600                 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) {
601                     title="AtchDlg";
602                 } else {
603                     title=Integer.toString(wp.type);
604                 }
605                 if (mAppName != null) {
606                     title += ":" + mAppName;
607                 }
608                 wp.setTitle(title);
609             }
610         } else {
611             if (wp.token == null) {
612                 wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
613             }
614             if ((curTitle == null || curTitle.length() == 0)
615                     && mAppName != null) {
616                 wp.setTitle(mAppName);
617             }
618         }
619         if (wp.packageName == null) {
620             wp.packageName = mContext.getPackageName();
621         }
622         if (mHardwareAccelerated) {
623             wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
624         }
625     }
626 
627     /**
628      * Return the window manager allowing this Window to display its own
629      * windows.
630      *
631      * @return WindowManager The ViewManager.
632      */
getWindowManager()633     public WindowManager getWindowManager() {
634         return mWindowManager;
635     }
636 
637     /**
638      * Set the Callback interface for this window, used to intercept key
639      * events and other dynamic operations in the window.
640      *
641      * @param callback The desired Callback interface.
642      */
setCallback(Callback callback)643     public void setCallback(Callback callback) {
644         mCallback = callback;
645     }
646 
647     /**
648      * Return the current Callback interface for this window.
649      */
getCallback()650     public final Callback getCallback() {
651         return mCallback;
652     }
653 
654     /** @hide */
setOnWindowDismissedCallback(OnWindowDismissedCallback dcb)655     public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) {
656         mOnWindowDismissedCallback = dcb;
657     }
658 
659     /** @hide */
dispatchOnWindowDismissed()660     public final void dispatchOnWindowDismissed() {
661         if (mOnWindowDismissedCallback != null) {
662             mOnWindowDismissedCallback.onWindowDismissed();
663         }
664     }
665 
666     /**
667      * Take ownership of this window's surface.  The window's view hierarchy
668      * will no longer draw into the surface, though it will otherwise continue
669      * to operate (such as for receiving input events).  The given SurfaceHolder
670      * callback will be used to tell you about state changes to the surface.
671      */
takeSurface(SurfaceHolder.Callback2 callback)672     public abstract void takeSurface(SurfaceHolder.Callback2 callback);
673 
674     /**
675      * Take ownership of this window's InputQueue.  The window will no
676      * longer read and dispatch input events from the queue; it is your
677      * responsibility to do so.
678      */
takeInputQueue(InputQueue.Callback callback)679     public abstract void takeInputQueue(InputQueue.Callback callback);
680 
681     /**
682      * Return whether this window is being displayed with a floating style
683      * (based on the {@link android.R.attr#windowIsFloating} attribute in
684      * the style/theme).
685      *
686      * @return Returns true if the window is configured to be displayed floating
687      * on top of whatever is behind it.
688      */
isFloating()689     public abstract boolean isFloating();
690 
691     /**
692      * Set the width and height layout parameters of the window.  The default
693      * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT
694      * or an absolute value to make a window that is not full-screen.
695      *
696      * @param width The desired layout width of the window.
697      * @param height The desired layout height of the window.
698      *
699      * @see ViewGroup.LayoutParams#height
700      * @see ViewGroup.LayoutParams#width
701      */
setLayout(int width, int height)702     public void setLayout(int width, int height) {
703         final WindowManager.LayoutParams attrs = getAttributes();
704         attrs.width = width;
705         attrs.height = height;
706         dispatchWindowAttributesChanged(attrs);
707     }
708 
709     /**
710      * Set the gravity of the window, as per the Gravity constants.  This
711      * controls how the window manager is positioned in the overall window; it
712      * is only useful when using WRAP_CONTENT for the layout width or height.
713      *
714      * @param gravity The desired gravity constant.
715      *
716      * @see Gravity
717      * @see #setLayout
718      */
setGravity(int gravity)719     public void setGravity(int gravity)
720     {
721         final WindowManager.LayoutParams attrs = getAttributes();
722         attrs.gravity = gravity;
723         dispatchWindowAttributesChanged(attrs);
724     }
725 
726     /**
727      * Set the type of the window, as per the WindowManager.LayoutParams
728      * types.
729      *
730      * @param type The new window type (see WindowManager.LayoutParams).
731      */
setType(int type)732     public void setType(int type) {
733         final WindowManager.LayoutParams attrs = getAttributes();
734         attrs.type = type;
735         dispatchWindowAttributesChanged(attrs);
736     }
737 
738     /**
739      * Set the format of window, as per the PixelFormat types.  This overrides
740      * the default format that is selected by the Window based on its
741      * window decorations.
742      *
743      * @param format The new window format (see PixelFormat).  Use
744      *               PixelFormat.UNKNOWN to allow the Window to select
745      *               the format.
746      *
747      * @see PixelFormat
748      */
setFormat(int format)749     public void setFormat(int format) {
750         final WindowManager.LayoutParams attrs = getAttributes();
751         if (format != PixelFormat.UNKNOWN) {
752             attrs.format = format;
753             mHaveWindowFormat = true;
754         } else {
755             attrs.format = mDefaultWindowFormat;
756             mHaveWindowFormat = false;
757         }
758         dispatchWindowAttributesChanged(attrs);
759     }
760 
761     /**
762      * Specify custom animations to use for the window, as per
763      * {@link WindowManager.LayoutParams#windowAnimations
764      * WindowManager.LayoutParams.windowAnimations}.  Providing anything besides
765      * 0 here will override the animations the window would
766      * normally retrieve from its theme.
767      */
setWindowAnimations(@tyleRes int resId)768     public void setWindowAnimations(@StyleRes int resId) {
769         final WindowManager.LayoutParams attrs = getAttributes();
770         attrs.windowAnimations = resId;
771         dispatchWindowAttributesChanged(attrs);
772     }
773 
774     /**
775      * Specify an explicit soft input mode to use for the window, as per
776      * {@link WindowManager.LayoutParams#softInputMode
777      * WindowManager.LayoutParams.softInputMode}.  Providing anything besides
778      * "unspecified" here will override the input mode the window would
779      * normally retrieve from its theme.
780      */
setSoftInputMode(int mode)781     public void setSoftInputMode(int mode) {
782         final WindowManager.LayoutParams attrs = getAttributes();
783         if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
784             attrs.softInputMode = mode;
785             mHasSoftInputMode = true;
786         } else {
787             mHasSoftInputMode = false;
788         }
789         dispatchWindowAttributesChanged(attrs);
790     }
791 
792     /**
793      * Convenience function to set the flag bits as specified in flags, as
794      * per {@link #setFlags}.
795      * @param flags The flag bits to be set.
796      * @see #setFlags
797      * @see #clearFlags
798      */
addFlags(int flags)799     public void addFlags(int flags) {
800         setFlags(flags, flags);
801     }
802 
803     /** @hide */
addPrivateFlags(int flags)804     public void addPrivateFlags(int flags) {
805         setPrivateFlags(flags, flags);
806     }
807 
808     /**
809      * Convenience function to clear the flag bits as specified in flags, as
810      * per {@link #setFlags}.
811      * @param flags The flag bits to be cleared.
812      * @see #setFlags
813      * @see #addFlags
814      */
clearFlags(int flags)815     public void clearFlags(int flags) {
816         setFlags(0, flags);
817     }
818 
819     /**
820      * Set the flags of the window, as per the
821      * {@link WindowManager.LayoutParams WindowManager.LayoutParams}
822      * flags.
823      *
824      * <p>Note that some flags must be set before the window decoration is
825      * created (by the first call to
826      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or
827      * {@link #getDecorView()}:
828      * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and
829      * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}.  These
830      * will be set for you based on the {@link android.R.attr#windowIsFloating}
831      * attribute.
832      *
833      * @param flags The new window flags (see WindowManager.LayoutParams).
834      * @param mask Which of the window flag bits to modify.
835      * @see #addFlags
836      * @see #clearFlags
837      */
setFlags(int flags, int mask)838     public void setFlags(int flags, int mask) {
839         final WindowManager.LayoutParams attrs = getAttributes();
840         attrs.flags = (attrs.flags&~mask) | (flags&mask);
841         mForcedWindowFlags |= mask;
842         dispatchWindowAttributesChanged(attrs);
843     }
844 
setPrivateFlags(int flags, int mask)845     private void setPrivateFlags(int flags, int mask) {
846         final WindowManager.LayoutParams attrs = getAttributes();
847         attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
848         dispatchWindowAttributesChanged(attrs);
849     }
850 
851     /**
852      * {@hide}
853      */
setNeedsMenuKey(int value)854     protected void setNeedsMenuKey(int value) {
855         final WindowManager.LayoutParams attrs = getAttributes();
856         attrs.needsMenuKey = value;
857         dispatchWindowAttributesChanged(attrs);
858     }
859 
860     /**
861      * {@hide}
862      */
dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs)863     protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) {
864         if (mCallback != null) {
865             mCallback.onWindowAttributesChanged(attrs);
866         }
867     }
868 
869     /**
870      * Set the amount of dim behind the window when using
871      * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}.  This overrides
872      * the default dim amount of that is selected by the Window based on
873      * its theme.
874      *
875      * @param amount The new dim amount, from 0 for no dim to 1 for full dim.
876      */
setDimAmount(float amount)877     public void setDimAmount(float amount) {
878         final WindowManager.LayoutParams attrs = getAttributes();
879         attrs.dimAmount = amount;
880         mHaveDimAmount = true;
881         dispatchWindowAttributesChanged(attrs);
882     }
883 
884     /**
885      * Specify custom window attributes.  <strong>PLEASE NOTE:</strong> the
886      * layout params you give here should generally be from values previously
887      * retrieved with {@link #getAttributes()}; you probably do not want to
888      * blindly create and apply your own, since this will blow away any values
889      * set by the framework that you are not interested in.
890      *
891      * @param a The new window attributes, which will completely override any
892      *          current values.
893      */
setAttributes(WindowManager.LayoutParams a)894     public void setAttributes(WindowManager.LayoutParams a) {
895         mWindowAttributes.copyFrom(a);
896         dispatchWindowAttributesChanged(mWindowAttributes);
897     }
898 
899     /**
900      * Retrieve the current window attributes associated with this panel.
901      *
902      * @return WindowManager.LayoutParams Either the existing window
903      *         attributes object, or a freshly created one if there is none.
904      */
getAttributes()905     public final WindowManager.LayoutParams getAttributes() {
906         return mWindowAttributes;
907     }
908 
909     /**
910      * Return the window flags that have been explicitly set by the client,
911      * so will not be modified by {@link #getDecorView}.
912      */
getForcedWindowFlags()913     protected final int getForcedWindowFlags() {
914         return mForcedWindowFlags;
915     }
916 
917     /**
918      * Has the app specified their own soft input mode?
919      */
hasSoftInputMode()920     protected final boolean hasSoftInputMode() {
921         return mHasSoftInputMode;
922     }
923 
924     /** @hide */
setCloseOnTouchOutside(boolean close)925     public void setCloseOnTouchOutside(boolean close) {
926         mCloseOnTouchOutside = close;
927         mSetCloseOnTouchOutside = true;
928     }
929 
930     /** @hide */
setCloseOnTouchOutsideIfNotSet(boolean close)931     public void setCloseOnTouchOutsideIfNotSet(boolean close) {
932         if (!mSetCloseOnTouchOutside) {
933             mCloseOnTouchOutside = close;
934             mSetCloseOnTouchOutside = true;
935         }
936     }
937 
938     /** @hide */
939     @SystemApi
setDisableWallpaperTouchEvents(boolean disable)940     public void setDisableWallpaperTouchEvents(boolean disable) {
941         setPrivateFlags(disable
942                 ? WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS : 0,
943                 WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS);
944     }
945 
946     /** @hide */
alwaysReadCloseOnTouchAttr()947     public abstract void alwaysReadCloseOnTouchAttr();
948 
949     /** @hide */
shouldCloseOnTouch(Context context, MotionEvent event)950     public boolean shouldCloseOnTouch(Context context, MotionEvent event) {
951         if (mCloseOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN
952                 && isOutOfBounds(context, event) && peekDecorView() != null) {
953             return true;
954         }
955         return false;
956     }
957 
isOutOfBounds(Context context, MotionEvent event)958     private boolean isOutOfBounds(Context context, MotionEvent event) {
959         final int x = (int) event.getX();
960         final int y = (int) event.getY();
961         final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
962         final View decorView = getDecorView();
963         return (x < -slop) || (y < -slop)
964                 || (x > (decorView.getWidth()+slop))
965                 || (y > (decorView.getHeight()+slop));
966     }
967 
968     /**
969      * Enable extended screen features.  This must be called before
970      * setContentView().  May be called as many times as desired as long as it
971      * is before setContentView().  If not called, no extended features
972      * will be available.  You can not turn off a feature once it is requested.
973      * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
974      *
975      * @param featureId The desired features, defined as constants by Window.
976      * @return The features that are now set.
977      */
requestFeature(int featureId)978     public boolean requestFeature(int featureId) {
979         final int flag = 1<<featureId;
980         mFeatures |= flag;
981         mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
982         return (mFeatures&flag) != 0;
983     }
984 
985     /**
986      * @hide Used internally to help resolve conflicting features.
987      */
removeFeature(int featureId)988     protected void removeFeature(int featureId) {
989         final int flag = 1<<featureId;
990         mFeatures &= ~flag;
991         mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag);
992     }
993 
makeActive()994     public final void makeActive() {
995         if (mContainer != null) {
996             if (mContainer.mActiveChild != null) {
997                 mContainer.mActiveChild.mIsActive = false;
998             }
999             mContainer.mActiveChild = this;
1000         }
1001         mIsActive = true;
1002         onActive();
1003     }
1004 
isActive()1005     public final boolean isActive()
1006     {
1007         return mIsActive;
1008     }
1009 
1010     /**
1011      * Finds a view that was identified by the id attribute from the XML that
1012      * was processed in {@link android.app.Activity#onCreate}.  This will
1013      * implicitly call {@link #getDecorView} for you, with all of the
1014      * associated side-effects.
1015      *
1016      * @return The view if found or null otherwise.
1017      */
1018     @Nullable
findViewById(@dRes int id)1019     public View findViewById(@IdRes int id) {
1020         return getDecorView().findViewById(id);
1021     }
1022 
1023     /**
1024      * Convenience for
1025      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1026      * to set the screen content from a layout resource.  The resource will be
1027      * inflated, adding all top-level views to the screen.
1028      *
1029      * @param layoutResID Resource ID to be inflated.
1030      * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1031      */
setContentView(@ayoutRes int layoutResID)1032     public abstract void setContentView(@LayoutRes int layoutResID);
1033 
1034     /**
1035      * Convenience for
1036      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1037      * set the screen content to an explicit view.  This view is placed
1038      * directly into the screen's view hierarchy.  It can itself be a complex
1039      * view hierarhcy.
1040      *
1041      * @param view The desired content to display.
1042      * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1043      */
setContentView(View view)1044     public abstract void setContentView(View view);
1045 
1046     /**
1047      * Set the screen content to an explicit view.  This view is placed
1048      * directly into the screen's view hierarchy.  It can itself be a complex
1049      * view hierarchy.
1050      *
1051      * <p>Note that calling this function "locks in" various characteristics
1052      * of the window that can not, from this point forward, be changed: the
1053      * features that have been requested with {@link #requestFeature(int)},
1054      * and certain window flags as described in {@link #setFlags(int, int)}.</p>
1055      *
1056      * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's
1057      * TransitionManager will be used to animate content from the current
1058      * content View to view.</p>
1059      *
1060      * @param view The desired content to display.
1061      * @param params Layout parameters for the view.
1062      * @see #getTransitionManager()
1063      * @see #setTransitionManager(android.transition.TransitionManager)
1064      */
setContentView(View view, ViewGroup.LayoutParams params)1065     public abstract void setContentView(View view, ViewGroup.LayoutParams params);
1066 
1067     /**
1068      * Variation on
1069      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1070      * to add an additional content view to the screen.  Added after any existing
1071      * ones in the screen -- existing views are NOT removed.
1072      *
1073      * @param view The desired content to display.
1074      * @param params Layout parameters for the view.
1075      */
addContentView(View view, ViewGroup.LayoutParams params)1076     public abstract void addContentView(View view, ViewGroup.LayoutParams params);
1077 
1078     /**
1079      * Return the view in this Window that currently has focus, or null if
1080      * there are none.  Note that this does not look in any containing
1081      * Window.
1082      *
1083      * @return View The current View with focus or null.
1084      */
1085     @Nullable
getCurrentFocus()1086     public abstract View getCurrentFocus();
1087 
1088     /**
1089      * Quick access to the {@link LayoutInflater} instance that this Window
1090      * retrieved from its Context.
1091      *
1092      * @return LayoutInflater The shared LayoutInflater.
1093      */
1094     @NonNull
getLayoutInflater()1095     public abstract LayoutInflater getLayoutInflater();
1096 
setTitle(CharSequence title)1097     public abstract void setTitle(CharSequence title);
1098 
1099     @Deprecated
setTitleColor(@olorInt int textColor)1100     public abstract void setTitleColor(@ColorInt int textColor);
1101 
openPanel(int featureId, KeyEvent event)1102     public abstract void openPanel(int featureId, KeyEvent event);
1103 
closePanel(int featureId)1104     public abstract void closePanel(int featureId);
1105 
togglePanel(int featureId, KeyEvent event)1106     public abstract void togglePanel(int featureId, KeyEvent event);
1107 
invalidatePanelMenu(int featureId)1108     public abstract void invalidatePanelMenu(int featureId);
1109 
performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags)1110     public abstract boolean performPanelShortcut(int featureId,
1111                                                  int keyCode,
1112                                                  KeyEvent event,
1113                                                  int flags);
performPanelIdentifierAction(int featureId, int id, int flags)1114     public abstract boolean performPanelIdentifierAction(int featureId,
1115                                                  int id,
1116                                                  int flags);
1117 
closeAllPanels()1118     public abstract void closeAllPanels();
1119 
performContextMenuIdentifierAction(int id, int flags)1120     public abstract boolean performContextMenuIdentifierAction(int id, int flags);
1121 
1122     /**
1123      * Should be called when the configuration is changed.
1124      *
1125      * @param newConfig The new configuration.
1126      */
onConfigurationChanged(Configuration newConfig)1127     public abstract void onConfigurationChanged(Configuration newConfig);
1128 
1129     /**
1130      * Sets the window elevation.
1131      * <p>
1132      * Changes to this property take effect immediately and will cause the
1133      * window surface to be recreated. This is an expensive operation and as a
1134      * result, this property should not be animated.
1135      *
1136      * @param elevation The window elevation.
1137      * @see View#setElevation(float)
1138      * @see android.R.styleable#Window_windowElevation
1139      */
setElevation(float elevation)1140     public void setElevation(float elevation) {}
1141 
1142     /**
1143      * Sets whether window content should be clipped to the outline of the
1144      * window background.
1145      *
1146      * @param clipToOutline Whether window content should be clipped to the
1147      *                      outline of the window background.
1148      * @see View#setClipToOutline(boolean)
1149      * @see android.R.styleable#Window_windowClipToOutline
1150      */
setClipToOutline(boolean clipToOutline)1151     public void setClipToOutline(boolean clipToOutline) {}
1152 
1153     /**
1154      * Change the background of this window to a Drawable resource. Setting the
1155      * background to null will make the window be opaque. To make the window
1156      * transparent, you can use an empty drawable (for instance a ColorDrawable
1157      * with the color 0 or the system drawable android:drawable/empty.)
1158      *
1159      * @param resId The resource identifier of a drawable resource which will
1160      *              be installed as the new background.
1161      */
setBackgroundDrawableResource(@rawableRes int resId)1162     public void setBackgroundDrawableResource(@DrawableRes int resId) {
1163         setBackgroundDrawable(mContext.getDrawable(resId));
1164     }
1165 
1166     /**
1167      * Change the background of this window to a custom Drawable. Setting the
1168      * background to null will make the window be opaque. To make the window
1169      * transparent, you can use an empty drawable (for instance a ColorDrawable
1170      * with the color 0 or the system drawable android:drawable/empty.)
1171      *
1172      * @param drawable The new Drawable to use for this window's background.
1173      */
setBackgroundDrawable(Drawable drawable)1174     public abstract void setBackgroundDrawable(Drawable drawable);
1175 
1176     /**
1177      * Set the value for a drawable feature of this window, from a resource
1178      * identifier.  You must have called requestFeature(featureId) before
1179      * calling this function.
1180      *
1181      * @see android.content.res.Resources#getDrawable(int)
1182      *
1183      * @param featureId The desired drawable feature to change, defined as a
1184      * constant by Window.
1185      * @param resId Resource identifier of the desired image.
1186      */
setFeatureDrawableResource(int featureId, @DrawableRes int resId)1187     public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId);
1188 
1189     /**
1190      * Set the value for a drawable feature of this window, from a URI. You
1191      * must have called requestFeature(featureId) before calling this
1192      * function.
1193      *
1194      * <p>The only URI currently supported is "content:", specifying an image
1195      * in a content provider.
1196      *
1197      * @see android.widget.ImageView#setImageURI
1198      *
1199      * @param featureId The desired drawable feature to change. Features are
1200      * constants defined by Window.
1201      * @param uri The desired URI.
1202      */
setFeatureDrawableUri(int featureId, Uri uri)1203     public abstract void setFeatureDrawableUri(int featureId, Uri uri);
1204 
1205     /**
1206      * Set an explicit Drawable value for feature of this window. You must
1207      * have called requestFeature(featureId) before calling this function.
1208      *
1209      * @param featureId The desired drawable feature to change. Features are
1210      *                  constants defined by Window.
1211      * @param drawable A Drawable object to display.
1212      */
setFeatureDrawable(int featureId, Drawable drawable)1213     public abstract void setFeatureDrawable(int featureId, Drawable drawable);
1214 
1215     /**
1216      * Set a custom alpha value for the given drawable feature, controlling how
1217      * much the background is visible through it.
1218      *
1219      * @param featureId The desired drawable feature to change. Features are
1220      *                  constants defined by Window.
1221      * @param alpha The alpha amount, 0 is completely transparent and 255 is
1222      *              completely opaque.
1223      */
setFeatureDrawableAlpha(int featureId, int alpha)1224     public abstract void setFeatureDrawableAlpha(int featureId, int alpha);
1225 
1226     /**
1227      * Set the integer value for a feature. The range of the value depends on
1228      * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from
1229      * 0 to 10000. At 10000 the progress is complete and the indicator hidden.
1230      *
1231      * @param featureId The desired feature to change. Features are constants
1232      *                  defined by Window.
1233      * @param value The value for the feature. The interpretation of this
1234      *              value is feature-specific.
1235      */
setFeatureInt(int featureId, int value)1236     public abstract void setFeatureInt(int featureId, int value);
1237 
1238     /**
1239      * Request that key events come to this activity. Use this if your
1240      * activity has no views with focus, but the activity still wants
1241      * a chance to process key events.
1242      */
takeKeyEvents(boolean get)1243     public abstract void takeKeyEvents(boolean get);
1244 
1245     /**
1246      * Used by custom windows, such as Dialog, to pass the key press event
1247      * further down the view hierarchy. Application developers should
1248      * not need to implement or call this.
1249      *
1250      */
superDispatchKeyEvent(KeyEvent event)1251     public abstract boolean superDispatchKeyEvent(KeyEvent event);
1252 
1253     /**
1254      * Used by custom windows, such as Dialog, to pass the key shortcut press event
1255      * further down the view hierarchy. Application developers should
1256      * not need to implement or call this.
1257      *
1258      */
superDispatchKeyShortcutEvent(KeyEvent event)1259     public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event);
1260 
1261     /**
1262      * Used by custom windows, such as Dialog, to pass the touch screen event
1263      * further down the view hierarchy. Application developers should
1264      * not need to implement or call this.
1265      *
1266      */
superDispatchTouchEvent(MotionEvent event)1267     public abstract boolean superDispatchTouchEvent(MotionEvent event);
1268 
1269     /**
1270      * Used by custom windows, such as Dialog, to pass the trackball event
1271      * further down the view hierarchy. Application developers should
1272      * not need to implement or call this.
1273      *
1274      */
superDispatchTrackballEvent(MotionEvent event)1275     public abstract boolean superDispatchTrackballEvent(MotionEvent event);
1276 
1277     /**
1278      * Used by custom windows, such as Dialog, to pass the generic motion event
1279      * further down the view hierarchy. Application developers should
1280      * not need to implement or call this.
1281      *
1282      */
superDispatchGenericMotionEvent(MotionEvent event)1283     public abstract boolean superDispatchGenericMotionEvent(MotionEvent event);
1284 
1285     /**
1286      * Retrieve the top-level window decor view (containing the standard
1287      * window frame/decorations and the client's content inside of that), which
1288      * can be added as a window to the window manager.
1289      *
1290      * <p><em>Note that calling this function for the first time "locks in"
1291      * various window characteristics as described in
1292      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p>
1293      *
1294      * @return Returns the top-level window decor view.
1295      */
getDecorView()1296     public abstract View getDecorView();
1297 
1298     /**
1299      * Retrieve the current decor view, but only if it has already been created;
1300      * otherwise returns null.
1301      *
1302      * @return Returns the top-level window decor or null.
1303      * @see #getDecorView
1304      */
peekDecorView()1305     public abstract View peekDecorView();
1306 
saveHierarchyState()1307     public abstract Bundle saveHierarchyState();
1308 
restoreHierarchyState(Bundle savedInstanceState)1309     public abstract void restoreHierarchyState(Bundle savedInstanceState);
1310 
onActive()1311     protected abstract void onActive();
1312 
1313     /**
1314      * Return the feature bits that are enabled.  This is the set of features
1315      * that were given to requestFeature(), and are being handled by this
1316      * Window itself or its container.  That is, it is the set of
1317      * requested features that you can actually use.
1318      *
1319      * <p>To do: add a public version of this API that allows you to check for
1320      * features by their feature ID.
1321      *
1322      * @return int The feature bits.
1323      */
getFeatures()1324     protected final int getFeatures()
1325     {
1326         return mFeatures;
1327     }
1328 
1329     /**
1330      * Return the feature bits set by default on a window.
1331      * @param context The context used to access resources
1332      */
getDefaultFeatures(Context context)1333     public static int getDefaultFeatures(Context context) {
1334         int features = 0;
1335 
1336         final Resources res = context.getResources();
1337         if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
1338             features |= 1 << FEATURE_OPTIONS_PANEL;
1339         }
1340 
1341         if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
1342             features |= 1 << FEATURE_CONTEXT_MENU;
1343         }
1344 
1345         return features;
1346     }
1347 
1348     /**
1349      * Query for the availability of a certain feature.
1350      *
1351      * @param feature The feature ID to check
1352      * @return true if the feature is enabled, false otherwise.
1353      */
hasFeature(int feature)1354     public boolean hasFeature(int feature) {
1355         return (getFeatures() & (1 << feature)) != 0;
1356     }
1357 
1358     /**
1359      * Return the feature bits that are being implemented by this Window.
1360      * This is the set of features that were given to requestFeature(), and are
1361      * being handled by only this Window itself, not by its containers.
1362      *
1363      * @return int The feature bits.
1364      */
getLocalFeatures()1365     protected final int getLocalFeatures()
1366     {
1367         return mLocalFeatures;
1368     }
1369 
1370     /**
1371      * Set the default format of window, as per the PixelFormat types.  This
1372      * is the format that will be used unless the client specifies in explicit
1373      * format with setFormat();
1374      *
1375      * @param format The new window format (see PixelFormat).
1376      *
1377      * @see #setFormat
1378      * @see PixelFormat
1379      */
setDefaultWindowFormat(int format)1380     protected void setDefaultWindowFormat(int format) {
1381         mDefaultWindowFormat = format;
1382         if (!mHaveWindowFormat) {
1383             final WindowManager.LayoutParams attrs = getAttributes();
1384             attrs.format = format;
1385             dispatchWindowAttributesChanged(attrs);
1386         }
1387     }
1388 
1389     /** @hide */
haveDimAmount()1390     protected boolean haveDimAmount() {
1391         return mHaveDimAmount;
1392     }
1393 
setChildDrawable(int featureId, Drawable drawable)1394     public abstract void setChildDrawable(int featureId, Drawable drawable);
1395 
setChildInt(int featureId, int value)1396     public abstract void setChildInt(int featureId, int value);
1397 
1398     /**
1399      * Is a keypress one of the defined shortcut keys for this window.
1400      * @param keyCode the key code from {@link android.view.KeyEvent} to check.
1401      * @param event the {@link android.view.KeyEvent} to use to help check.
1402      */
isShortcutKey(int keyCode, KeyEvent event)1403     public abstract boolean isShortcutKey(int keyCode, KeyEvent event);
1404 
1405     /**
1406      * @see android.app.Activity#setVolumeControlStream(int)
1407      */
setVolumeControlStream(int streamType)1408     public abstract void setVolumeControlStream(int streamType);
1409 
1410     /**
1411      * @see android.app.Activity#getVolumeControlStream()
1412      */
getVolumeControlStream()1413     public abstract int getVolumeControlStream();
1414 
1415     /**
1416      * Sets a {@link MediaController} to send media keys and volume changes to.
1417      * If set, this should be preferred for all media keys and volume requests
1418      * sent to this window.
1419      *
1420      * @param controller The controller for the session which should receive
1421      *            media keys and volume changes.
1422      * @see android.app.Activity#setMediaController(android.media.session.MediaController)
1423      */
setMediaController(MediaController controller)1424     public void setMediaController(MediaController controller) {
1425     }
1426 
1427     /**
1428      * Gets the {@link MediaController} that was previously set.
1429      *
1430      * @return The controller which should receive events.
1431      * @see #setMediaController(android.media.session.MediaController)
1432      * @see android.app.Activity#getMediaController()
1433      */
getMediaController()1434     public MediaController getMediaController() {
1435         return null;
1436     }
1437 
1438     /**
1439      * Set extra options that will influence the UI for this window.
1440      * @param uiOptions Flags specifying extra options for this window.
1441      */
setUiOptions(int uiOptions)1442     public void setUiOptions(int uiOptions) { }
1443 
1444     /**
1445      * Set extra options that will influence the UI for this window.
1446      * Only the bits filtered by mask will be modified.
1447      * @param uiOptions Flags specifying extra options for this window.
1448      * @param mask Flags specifying which options should be modified. Others will remain unchanged.
1449      */
setUiOptions(int uiOptions, int mask)1450     public void setUiOptions(int uiOptions, int mask) { }
1451 
1452     /**
1453      * Set the primary icon for this window.
1454      *
1455      * @param resId resource ID of a drawable to set
1456      */
setIcon(@rawableRes int resId)1457     public void setIcon(@DrawableRes int resId) { }
1458 
1459     /**
1460      * Set the default icon for this window.
1461      * This will be overridden by any other icon set operation which could come from the
1462      * theme or another explicit set.
1463      *
1464      * @hide
1465      */
setDefaultIcon(@rawableRes int resId)1466     public void setDefaultIcon(@DrawableRes int resId) { }
1467 
1468     /**
1469      * Set the logo for this window. A logo is often shown in place of an
1470      * {@link #setIcon(int) icon} but is generally wider and communicates window title information
1471      * as well.
1472      *
1473      * @param resId resource ID of a drawable to set
1474      */
setLogo(@rawableRes int resId)1475     public void setLogo(@DrawableRes int resId) { }
1476 
1477     /**
1478      * Set the default logo for this window.
1479      * This will be overridden by any other logo set operation which could come from the
1480      * theme or another explicit set.
1481      *
1482      * @hide
1483      */
setDefaultLogo(@rawableRes int resId)1484     public void setDefaultLogo(@DrawableRes int resId) { }
1485 
1486     /**
1487      * Set focus locally. The window should have the
1488      * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.
1489      * @param hasFocus Whether this window has focus or not.
1490      * @param inTouchMode Whether this window is in touch mode or not.
1491      */
setLocalFocus(boolean hasFocus, boolean inTouchMode)1492     public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { }
1493 
1494     /**
1495      * Inject an event to window locally.
1496      * @param event A key or touch event to inject to this window.
1497      */
injectInputEvent(InputEvent event)1498     public void injectInputEvent(InputEvent event) { }
1499 
1500     /**
1501      * Retrieve the {@link TransitionManager} responsible for  for default transitions
1502      * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1503      *
1504      * <p>This method will return non-null after content has been initialized (e.g. by using
1505      * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p>
1506      *
1507      * @return This window's content TransitionManager or null if none is set.
1508      * @attr ref android.R.styleable#Window_windowContentTransitionManager
1509      */
getTransitionManager()1510     public TransitionManager getTransitionManager() {
1511         return null;
1512     }
1513 
1514     /**
1515      * Set the {@link TransitionManager} to use for default transitions in this window.
1516      * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1517      *
1518      * @param tm The TransitionManager to use for scene changes.
1519      * @attr ref android.R.styleable#Window_windowContentTransitionManager
1520      */
setTransitionManager(TransitionManager tm)1521     public void setTransitionManager(TransitionManager tm) {
1522         throw new UnsupportedOperationException();
1523     }
1524 
1525     /**
1526      * Retrieve the {@link Scene} representing this window's current content.
1527      * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1528      *
1529      * <p>This method will return null if the current content is not represented by a Scene.</p>
1530      *
1531      * @return Current Scene being shown or null
1532      */
getContentScene()1533     public Scene getContentScene() {
1534         return null;
1535     }
1536 
1537     /**
1538      * Sets the Transition that will be used to move Views into the initial scene. The entering
1539      * Views will be those that are regular Views or ViewGroups that have
1540      * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1541      * {@link android.transition.Visibility} as entering is governed by changing visibility from
1542      * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1543      * entering Views will remain unaffected.
1544      *
1545      * @param transition The Transition to use to move Views into the initial Scene.
1546      * @attr ref android.R.styleable#Window_windowEnterTransition
1547      */
setEnterTransition(Transition transition)1548     public void setEnterTransition(Transition transition) {}
1549 
1550     /**
1551      * Sets the Transition that will be used to move Views out of the scene when the Window is
1552      * preparing to close, for example after a call to
1553      * {@link android.app.Activity#finishAfterTransition()}. The exiting
1554      * Views will be those that are regular Views or ViewGroups that have
1555      * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1556      * {@link android.transition.Visibility} as entering is governed by changing visibility from
1557      * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null,
1558      * entering Views will remain unaffected. If nothing is set, the default will be to
1559      * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
1560      *
1561      * @param transition The Transition to use to move Views out of the Scene when the Window
1562      *                   is preparing to close.
1563      * @attr ref android.R.styleable#Window_windowReturnTransition
1564      */
setReturnTransition(Transition transition)1565     public void setReturnTransition(Transition transition) {}
1566 
1567     /**
1568      * Sets the Transition that will be used to move Views out of the scene when starting a
1569      * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1570      * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1571      * {@link android.transition.Visibility} as exiting is governed by changing visibility
1572      * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
1573      * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1574      *
1575      * @param transition The Transition to use to move Views out of the scene when calling a
1576      *                   new Activity.
1577      * @attr ref android.R.styleable#Window_windowExitTransition
1578      */
setExitTransition(Transition transition)1579     public void setExitTransition(Transition transition) {}
1580 
1581     /**
1582      * Sets the Transition that will be used to move Views in to the scene when returning from
1583      * a previously-started Activity. The entering Views will be those that are regular Views
1584      * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1585      * will extend {@link android.transition.Visibility} as exiting is governed by changing
1586      * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
1587      * the views will remain unaffected. If nothing is set, the default will be to use the same
1588      * transition as {@link #setExitTransition(android.transition.Transition)}.
1589      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1590      *
1591      * @param transition The Transition to use to move Views into the scene when reentering from a
1592      *                   previously-started Activity.
1593      * @attr ref android.R.styleable#Window_windowReenterTransition
1594      */
setReenterTransition(Transition transition)1595     public void setReenterTransition(Transition transition) {}
1596 
1597     /**
1598      * Returns the transition used to move Views into the initial scene. The entering
1599      * Views will be those that are regular Views or ViewGroups that have
1600      * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1601      * {@link android.transition.Visibility} as entering is governed by changing visibility from
1602      * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1603      * entering Views will remain unaffected.  Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1604      *
1605      * @return the Transition to use to move Views into the initial Scene.
1606      * @attr ref android.R.styleable#Window_windowEnterTransition
1607      */
getEnterTransition()1608     public Transition getEnterTransition() { return null; }
1609 
1610     /**
1611      * Returns he Transition that will be used to move Views out of the scene when the Window is
1612      * preparing to close, for example after a call to
1613      * {@link android.app.Activity#finishAfterTransition()}. The exiting
1614      * Views will be those that are regular Views or ViewGroups that have
1615      * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1616      * {@link android.transition.Visibility} as entering is governed by changing visibility from
1617      * {@link View#VISIBLE} to {@link View#INVISIBLE}.
1618      *
1619      * @return The Transition to use to move Views out of the Scene when the Window
1620      *         is preparing to close.
1621      * @attr ref android.R.styleable#Window_windowReturnTransition
1622      */
getReturnTransition()1623     public Transition getReturnTransition() { return null; }
1624 
1625     /**
1626      * Returns the Transition that will be used to move Views out of the scene when starting a
1627      * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1628      * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1629      * {@link android.transition.Visibility} as exiting is governed by changing visibility
1630      * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
1631      * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1632      *
1633      * @return the Transition to use to move Views out of the scene when calling a
1634      * new Activity.
1635      * @attr ref android.R.styleable#Window_windowExitTransition
1636      */
getExitTransition()1637     public Transition getExitTransition() { return null; }
1638 
1639     /**
1640      * Returns the Transition that will be used to move Views in to the scene when returning from
1641      * a previously-started Activity. The entering Views will be those that are regular Views
1642      * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1643      * will extend {@link android.transition.Visibility} as exiting is governed by changing
1644      * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
1645      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1646      *
1647      * @return The Transition to use to move Views into the scene when reentering from a
1648      *         previously-started Activity.
1649      * @attr ref android.R.styleable#Window_windowReenterTransition
1650      */
getReenterTransition()1651     public Transition getReenterTransition() { return null; }
1652 
1653     /**
1654      * Sets the Transition that will be used for shared elements transferred into the content
1655      * Scene. Typical Transitions will affect size and location, such as
1656      * {@link android.transition.ChangeBounds}. A null
1657      * value will cause transferred shared elements to blink to the final position.
1658      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1659      *
1660      * @param transition The Transition to use for shared elements transferred into the content
1661      *                   Scene.
1662      * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
1663      */
setSharedElementEnterTransition(Transition transition)1664     public void setSharedElementEnterTransition(Transition transition) {}
1665 
1666     /**
1667      * Sets the Transition that will be used for shared elements transferred back to a
1668      * calling Activity. Typical Transitions will affect size and location, such as
1669      * {@link android.transition.ChangeBounds}. A null
1670      * value will cause transferred shared elements to blink to the final position.
1671      * If no value is set, the default will be to use the same value as
1672      * {@link #setSharedElementEnterTransition(android.transition.Transition)}.
1673      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1674      *
1675      * @param transition The Transition to use for shared elements transferred out of the content
1676      *                   Scene.
1677      * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
1678      */
setSharedElementReturnTransition(Transition transition)1679     public void setSharedElementReturnTransition(Transition transition) {}
1680 
1681     /**
1682      * Returns the Transition that will be used for shared elements transferred into the content
1683      * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1684      *
1685      * @return Transition to use for sharend elements transferred into the content Scene.
1686      * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
1687      */
getSharedElementEnterTransition()1688     public Transition getSharedElementEnterTransition() { return null; }
1689 
1690     /**
1691      * Returns the Transition that will be used for shared elements transferred back to a
1692      * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1693      *
1694      * @return Transition to use for sharend elements transferred into the content Scene.
1695      * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
1696      */
getSharedElementReturnTransition()1697     public Transition getSharedElementReturnTransition() { return null; }
1698 
1699     /**
1700      * Sets the Transition that will be used for shared elements after starting a new Activity
1701      * before the shared elements are transferred to the called Activity. If the shared elements
1702      * must animate during the exit transition, this Transition should be used. Upon completion,
1703      * the shared elements may be transferred to the started Activity.
1704      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1705      *
1706      * @param transition The Transition to use for shared elements in the launching Window
1707      *                   prior to transferring to the launched Activity's Window.
1708      * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
1709      */
setSharedElementExitTransition(Transition transition)1710     public void setSharedElementExitTransition(Transition transition) {}
1711 
1712     /**
1713      * Sets the Transition that will be used for shared elements reentering from a started
1714      * Activity after it has returned the shared element to it start location. If no value
1715      * is set, this will default to
1716      * {@link #setSharedElementExitTransition(android.transition.Transition)}.
1717      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1718      *
1719      * @param transition The Transition to use for shared elements in the launching Window
1720      *                   after the shared element has returned to the Window.
1721      * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
1722      */
setSharedElementReenterTransition(Transition transition)1723     public void setSharedElementReenterTransition(Transition transition) {}
1724 
1725     /**
1726      * Returns the Transition to use for shared elements in the launching Window prior
1727      * to transferring to the launched Activity's Window.
1728      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1729      *
1730      * @return the Transition to use for shared elements in the launching Window prior
1731      * to transferring to the launched Activity's Window.
1732      * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
1733      */
getSharedElementExitTransition()1734     public Transition getSharedElementExitTransition() { return null; }
1735 
1736     /**
1737      * Returns the Transition that will be used for shared elements reentering from a started
1738      * Activity after it has returned the shared element to it start location.
1739      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1740      *
1741      * @return the Transition that will be used for shared elements reentering from a started
1742      * Activity after it has returned the shared element to it start location.
1743      * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
1744      */
getSharedElementReenterTransition()1745     public Transition getSharedElementReenterTransition() { return null; }
1746 
1747     /**
1748      * Controls how the transition set in
1749      * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
1750      * transition of the calling Activity. When true, the transition will start as soon as possible.
1751      * When false, the transition will wait until the remote exiting transition completes before
1752      * starting.
1753      *
1754      * @param allow true to start the enter transition when possible or false to
1755      *              wait until the exiting transition completes.
1756      * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
1757      */
setAllowEnterTransitionOverlap(boolean allow)1758     public void setAllowEnterTransitionOverlap(boolean allow) {}
1759 
1760     /**
1761      * Returns how the transition set in
1762      * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
1763      * transition of the calling Activity. When true, the transition will start as soon as possible.
1764      * When false, the transition will wait until the remote exiting transition completes before
1765      * starting.
1766      *
1767      * @return true when the enter transition should start as soon as possible or false to
1768      * when it should wait until the exiting transition completes.
1769      * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
1770      */
getAllowEnterTransitionOverlap()1771     public boolean getAllowEnterTransitionOverlap() { return true; }
1772 
1773     /**
1774      * Controls how the transition set in
1775      * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
1776      * transition of the called Activity when reentering after if finishes. When true,
1777      * the transition will start as soon as possible. When false, the transition will wait
1778      * until the called Activity's exiting transition completes before starting.
1779      *
1780      * @param allow true to start the transition when possible or false to wait until the
1781      *              called Activity's exiting transition completes.
1782      * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
1783      */
setAllowReturnTransitionOverlap(boolean allow)1784     public void setAllowReturnTransitionOverlap(boolean allow) {}
1785 
1786     /**
1787      * Returns how the transition set in
1788      * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
1789      * transition of the called Activity when reentering after if finishes. When true,
1790      * the transition will start as soon as possible. When false, the transition will wait
1791      * until the called Activity's exiting transition completes before starting.
1792      *
1793      * @return true when the transition should start when possible or false when it should wait
1794      * until the called Activity's exiting transition completes.
1795      * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
1796      */
getAllowReturnTransitionOverlap()1797     public boolean getAllowReturnTransitionOverlap() { return true; }
1798 
1799     /**
1800      * Returns the duration, in milliseconds, of the window background fade
1801      * when transitioning into or away from an Activity when called with an Activity Transition.
1802      * <p>When executing the enter transition, the background starts transparent
1803      * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
1804      * 300 milliseconds.</p>
1805      *
1806      * @return The duration of the window background fade to opaque during enter transition.
1807      * @see #getEnterTransition()
1808      * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
1809      */
getTransitionBackgroundFadeDuration()1810     public long getTransitionBackgroundFadeDuration() { return 0; }
1811 
1812     /**
1813      * Sets the duration, in milliseconds, of the window background fade
1814      * when transitioning into or away from an Activity when called with an Activity Transition.
1815      * <p>When executing the enter transition, the background starts transparent
1816      * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
1817      * 300 milliseconds.</p>
1818      *
1819      * @param fadeDurationMillis The duration of the window background fade to or from opaque
1820      *                           during enter transition.
1821      * @see #setEnterTransition(android.transition.Transition)
1822      * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
1823      */
setTransitionBackgroundFadeDuration(long fadeDurationMillis)1824     public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { }
1825 
1826     /**
1827      * Returns <code>true</code> when shared elements should use an Overlay during
1828      * shared element transitions or <code>false</code> when they should animate as
1829      * part of the normal View hierarchy. The default value is true.
1830      *
1831      * @return <code>true</code> when shared elements should use an Overlay during
1832      * shared element transitions or <code>false</code> when they should animate as
1833      * part of the normal View hierarchy.
1834      * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
1835      */
getSharedElementsUseOverlay()1836     public boolean getSharedElementsUseOverlay() { return true; }
1837 
1838     /**
1839      * Sets whether or not shared elements should use an Overlay during shared element transitions.
1840      * The default value is true.
1841      *
1842      * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should
1843      *                                 be transitioned with an Overlay or <code>false</code>
1844      *                                 to transition within the normal View hierarchy.
1845      * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
1846      */
setSharedElementsUseOverlay(boolean sharedElementsUseOverlay)1847     public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { }
1848 
1849     /**
1850      * @return the color of the status bar.
1851      */
1852     @ColorInt
getStatusBarColor()1853     public abstract int getStatusBarColor();
1854 
1855     /**
1856      * Sets the color of the status bar to {@code color}.
1857      *
1858      * For this to take effect,
1859      * the window must be drawing the system bar backgrounds with
1860      * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
1861      * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set.
1862      *
1863      * If {@code color} is not opaque, consider setting
1864      * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
1865      * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
1866      * <p>
1867      * The transitionName for the view background will be "android:status:background".
1868      * </p>
1869      */
setStatusBarColor(@olorInt int color)1870     public abstract void setStatusBarColor(@ColorInt int color);
1871 
1872     /**
1873      * @return the color of the navigation bar.
1874      */
1875     @ColorInt
getNavigationBarColor()1876     public abstract int getNavigationBarColor();
1877 
1878     /**
1879      * Sets the color of the navigation bar to {@param color}.
1880      *
1881      * For this to take effect,
1882      * the window must be drawing the system bar backgrounds with
1883      * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
1884      * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
1885      *
1886      * If {@param color} is not opaque, consider setting
1887      * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
1888      * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
1889      * <p>
1890      * The transitionName for the view background will be "android:navigation:background".
1891      * </p>
1892      */
setNavigationBarColor(@olorInt int color)1893     public abstract void setNavigationBarColor(@ColorInt int color);
1894 
1895 
1896 }
1897