• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 if (wp.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW &&
611                 wp.type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
612             // We don't set the app token to this system window because the life cycles should be
613             // independent. If an app creates a system window and then the app goes to the stopped
614             // state, the system window should not be affected (can still show and receive input
615             // events).
616             if (curTitle == null || curTitle.length() == 0) {
617                 String title = "Sys" + Integer.toString(wp.type);
618                 if (mAppName != null) {
619                     title += ":" + mAppName;
620                 }
621                 wp.setTitle(title);
622             }
623         } else {
624             if (wp.token == null) {
625                 wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
626             }
627             if ((curTitle == null || curTitle.length() == 0)
628                     && mAppName != null) {
629                 wp.setTitle(mAppName);
630             }
631         }
632         if (wp.packageName == null) {
633             wp.packageName = mContext.getPackageName();
634         }
635         if (mHardwareAccelerated) {
636             wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
637         }
638     }
639 
640     /**
641      * Return the window manager allowing this Window to display its own
642      * windows.
643      *
644      * @return WindowManager The ViewManager.
645      */
getWindowManager()646     public WindowManager getWindowManager() {
647         return mWindowManager;
648     }
649 
650     /**
651      * Set the Callback interface for this window, used to intercept key
652      * events and other dynamic operations in the window.
653      *
654      * @param callback The desired Callback interface.
655      */
setCallback(Callback callback)656     public void setCallback(Callback callback) {
657         mCallback = callback;
658     }
659 
660     /**
661      * Return the current Callback interface for this window.
662      */
getCallback()663     public final Callback getCallback() {
664         return mCallback;
665     }
666 
667     /** @hide */
setOnWindowDismissedCallback(OnWindowDismissedCallback dcb)668     public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) {
669         mOnWindowDismissedCallback = dcb;
670     }
671 
672     /** @hide */
dispatchOnWindowDismissed()673     public final void dispatchOnWindowDismissed() {
674         if (mOnWindowDismissedCallback != null) {
675             mOnWindowDismissedCallback.onWindowDismissed();
676         }
677     }
678 
679     /**
680      * Take ownership of this window's surface.  The window's view hierarchy
681      * will no longer draw into the surface, though it will otherwise continue
682      * to operate (such as for receiving input events).  The given SurfaceHolder
683      * callback will be used to tell you about state changes to the surface.
684      */
takeSurface(SurfaceHolder.Callback2 callback)685     public abstract void takeSurface(SurfaceHolder.Callback2 callback);
686 
687     /**
688      * Take ownership of this window's InputQueue.  The window will no
689      * longer read and dispatch input events from the queue; it is your
690      * responsibility to do so.
691      */
takeInputQueue(InputQueue.Callback callback)692     public abstract void takeInputQueue(InputQueue.Callback callback);
693 
694     /**
695      * Return whether this window is being displayed with a floating style
696      * (based on the {@link android.R.attr#windowIsFloating} attribute in
697      * the style/theme).
698      *
699      * @return Returns true if the window is configured to be displayed floating
700      * on top of whatever is behind it.
701      */
isFloating()702     public abstract boolean isFloating();
703 
704     /**
705      * Set the width and height layout parameters of the window.  The default
706      * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT
707      * or an absolute value to make a window that is not full-screen.
708      *
709      * @param width The desired layout width of the window.
710      * @param height The desired layout height of the window.
711      *
712      * @see ViewGroup.LayoutParams#height
713      * @see ViewGroup.LayoutParams#width
714      */
setLayout(int width, int height)715     public void setLayout(int width, int height) {
716         final WindowManager.LayoutParams attrs = getAttributes();
717         attrs.width = width;
718         attrs.height = height;
719         dispatchWindowAttributesChanged(attrs);
720     }
721 
722     /**
723      * Set the gravity of the window, as per the Gravity constants.  This
724      * controls how the window manager is positioned in the overall window; it
725      * is only useful when using WRAP_CONTENT for the layout width or height.
726      *
727      * @param gravity The desired gravity constant.
728      *
729      * @see Gravity
730      * @see #setLayout
731      */
setGravity(int gravity)732     public void setGravity(int gravity)
733     {
734         final WindowManager.LayoutParams attrs = getAttributes();
735         attrs.gravity = gravity;
736         dispatchWindowAttributesChanged(attrs);
737     }
738 
739     /**
740      * Set the type of the window, as per the WindowManager.LayoutParams
741      * types.
742      *
743      * @param type The new window type (see WindowManager.LayoutParams).
744      */
setType(int type)745     public void setType(int type) {
746         final WindowManager.LayoutParams attrs = getAttributes();
747         attrs.type = type;
748         dispatchWindowAttributesChanged(attrs);
749     }
750 
751     /**
752      * Set the format of window, as per the PixelFormat types.  This overrides
753      * the default format that is selected by the Window based on its
754      * window decorations.
755      *
756      * @param format The new window format (see PixelFormat).  Use
757      *               PixelFormat.UNKNOWN to allow the Window to select
758      *               the format.
759      *
760      * @see PixelFormat
761      */
setFormat(int format)762     public void setFormat(int format) {
763         final WindowManager.LayoutParams attrs = getAttributes();
764         if (format != PixelFormat.UNKNOWN) {
765             attrs.format = format;
766             mHaveWindowFormat = true;
767         } else {
768             attrs.format = mDefaultWindowFormat;
769             mHaveWindowFormat = false;
770         }
771         dispatchWindowAttributesChanged(attrs);
772     }
773 
774     /**
775      * Specify custom animations to use for the window, as per
776      * {@link WindowManager.LayoutParams#windowAnimations
777      * WindowManager.LayoutParams.windowAnimations}.  Providing anything besides
778      * 0 here will override the animations the window would
779      * normally retrieve from its theme.
780      */
setWindowAnimations(@tyleRes int resId)781     public void setWindowAnimations(@StyleRes int resId) {
782         final WindowManager.LayoutParams attrs = getAttributes();
783         attrs.windowAnimations = resId;
784         dispatchWindowAttributesChanged(attrs);
785     }
786 
787     /**
788      * Specify an explicit soft input mode to use for the window, as per
789      * {@link WindowManager.LayoutParams#softInputMode
790      * WindowManager.LayoutParams.softInputMode}.  Providing anything besides
791      * "unspecified" here will override the input mode the window would
792      * normally retrieve from its theme.
793      */
setSoftInputMode(int mode)794     public void setSoftInputMode(int mode) {
795         final WindowManager.LayoutParams attrs = getAttributes();
796         if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
797             attrs.softInputMode = mode;
798             mHasSoftInputMode = true;
799         } else {
800             mHasSoftInputMode = false;
801         }
802         dispatchWindowAttributesChanged(attrs);
803     }
804 
805     /**
806      * Convenience function to set the flag bits as specified in flags, as
807      * per {@link #setFlags}.
808      * @param flags The flag bits to be set.
809      * @see #setFlags
810      * @see #clearFlags
811      */
addFlags(int flags)812     public void addFlags(int flags) {
813         setFlags(flags, flags);
814     }
815 
816     /** @hide */
addPrivateFlags(int flags)817     public void addPrivateFlags(int flags) {
818         setPrivateFlags(flags, flags);
819     }
820 
821     /**
822      * Convenience function to clear the flag bits as specified in flags, as
823      * per {@link #setFlags}.
824      * @param flags The flag bits to be cleared.
825      * @see #setFlags
826      * @see #addFlags
827      */
clearFlags(int flags)828     public void clearFlags(int flags) {
829         setFlags(0, flags);
830     }
831 
832     /**
833      * Set the flags of the window, as per the
834      * {@link WindowManager.LayoutParams WindowManager.LayoutParams}
835      * flags.
836      *
837      * <p>Note that some flags must be set before the window decoration is
838      * created (by the first call to
839      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or
840      * {@link #getDecorView()}:
841      * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and
842      * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}.  These
843      * will be set for you based on the {@link android.R.attr#windowIsFloating}
844      * attribute.
845      *
846      * @param flags The new window flags (see WindowManager.LayoutParams).
847      * @param mask Which of the window flag bits to modify.
848      * @see #addFlags
849      * @see #clearFlags
850      */
setFlags(int flags, int mask)851     public void setFlags(int flags, int mask) {
852         final WindowManager.LayoutParams attrs = getAttributes();
853         attrs.flags = (attrs.flags&~mask) | (flags&mask);
854         mForcedWindowFlags |= mask;
855         dispatchWindowAttributesChanged(attrs);
856     }
857 
setPrivateFlags(int flags, int mask)858     private void setPrivateFlags(int flags, int mask) {
859         final WindowManager.LayoutParams attrs = getAttributes();
860         attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
861         dispatchWindowAttributesChanged(attrs);
862     }
863 
864     /**
865      * {@hide}
866      */
setNeedsMenuKey(int value)867     protected void setNeedsMenuKey(int value) {
868         final WindowManager.LayoutParams attrs = getAttributes();
869         attrs.needsMenuKey = value;
870         dispatchWindowAttributesChanged(attrs);
871     }
872 
873     /**
874      * {@hide}
875      */
dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs)876     protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) {
877         if (mCallback != null) {
878             mCallback.onWindowAttributesChanged(attrs);
879         }
880     }
881 
882     /**
883      * Set the amount of dim behind the window when using
884      * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}.  This overrides
885      * the default dim amount of that is selected by the Window based on
886      * its theme.
887      *
888      * @param amount The new dim amount, from 0 for no dim to 1 for full dim.
889      */
setDimAmount(float amount)890     public void setDimAmount(float amount) {
891         final WindowManager.LayoutParams attrs = getAttributes();
892         attrs.dimAmount = amount;
893         mHaveDimAmount = true;
894         dispatchWindowAttributesChanged(attrs);
895     }
896 
897     /**
898      * Specify custom window attributes.  <strong>PLEASE NOTE:</strong> the
899      * layout params you give here should generally be from values previously
900      * retrieved with {@link #getAttributes()}; you probably do not want to
901      * blindly create and apply your own, since this will blow away any values
902      * set by the framework that you are not interested in.
903      *
904      * @param a The new window attributes, which will completely override any
905      *          current values.
906      */
setAttributes(WindowManager.LayoutParams a)907     public void setAttributes(WindowManager.LayoutParams a) {
908         mWindowAttributes.copyFrom(a);
909         dispatchWindowAttributesChanged(mWindowAttributes);
910     }
911 
912     /**
913      * Retrieve the current window attributes associated with this panel.
914      *
915      * @return WindowManager.LayoutParams Either the existing window
916      *         attributes object, or a freshly created one if there is none.
917      */
getAttributes()918     public final WindowManager.LayoutParams getAttributes() {
919         return mWindowAttributes;
920     }
921 
922     /**
923      * Return the window flags that have been explicitly set by the client,
924      * so will not be modified by {@link #getDecorView}.
925      */
getForcedWindowFlags()926     protected final int getForcedWindowFlags() {
927         return mForcedWindowFlags;
928     }
929 
930     /**
931      * Has the app specified their own soft input mode?
932      */
hasSoftInputMode()933     protected final boolean hasSoftInputMode() {
934         return mHasSoftInputMode;
935     }
936 
937     /** @hide */
setCloseOnTouchOutside(boolean close)938     public void setCloseOnTouchOutside(boolean close) {
939         mCloseOnTouchOutside = close;
940         mSetCloseOnTouchOutside = true;
941     }
942 
943     /** @hide */
setCloseOnTouchOutsideIfNotSet(boolean close)944     public void setCloseOnTouchOutsideIfNotSet(boolean close) {
945         if (!mSetCloseOnTouchOutside) {
946             mCloseOnTouchOutside = close;
947             mSetCloseOnTouchOutside = true;
948         }
949     }
950 
951     /** @hide */
952     @SystemApi
setDisableWallpaperTouchEvents(boolean disable)953     public void setDisableWallpaperTouchEvents(boolean disable) {
954         setPrivateFlags(disable
955                 ? WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS : 0,
956                 WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS);
957     }
958 
959     /** @hide */
alwaysReadCloseOnTouchAttr()960     public abstract void alwaysReadCloseOnTouchAttr();
961 
962     /** @hide */
shouldCloseOnTouch(Context context, MotionEvent event)963     public boolean shouldCloseOnTouch(Context context, MotionEvent event) {
964         if (mCloseOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN
965                 && isOutOfBounds(context, event) && peekDecorView() != null) {
966             return true;
967         }
968         return false;
969     }
970 
isOutOfBounds(Context context, MotionEvent event)971     private boolean isOutOfBounds(Context context, MotionEvent event) {
972         final int x = (int) event.getX();
973         final int y = (int) event.getY();
974         final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
975         final View decorView = getDecorView();
976         return (x < -slop) || (y < -slop)
977                 || (x > (decorView.getWidth()+slop))
978                 || (y > (decorView.getHeight()+slop));
979     }
980 
981     /**
982      * Enable extended screen features.  This must be called before
983      * setContentView().  May be called as many times as desired as long as it
984      * is before setContentView().  If not called, no extended features
985      * will be available.  You can not turn off a feature once it is requested.
986      * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
987      *
988      * @param featureId The desired features, defined as constants by Window.
989      * @return The features that are now set.
990      */
requestFeature(int featureId)991     public boolean requestFeature(int featureId) {
992         final int flag = 1<<featureId;
993         mFeatures |= flag;
994         mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
995         return (mFeatures&flag) != 0;
996     }
997 
998     /**
999      * @hide Used internally to help resolve conflicting features.
1000      */
removeFeature(int featureId)1001     protected void removeFeature(int featureId) {
1002         final int flag = 1<<featureId;
1003         mFeatures &= ~flag;
1004         mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag);
1005     }
1006 
makeActive()1007     public final void makeActive() {
1008         if (mContainer != null) {
1009             if (mContainer.mActiveChild != null) {
1010                 mContainer.mActiveChild.mIsActive = false;
1011             }
1012             mContainer.mActiveChild = this;
1013         }
1014         mIsActive = true;
1015         onActive();
1016     }
1017 
isActive()1018     public final boolean isActive()
1019     {
1020         return mIsActive;
1021     }
1022 
1023     /**
1024      * Finds a view that was identified by the id attribute from the XML that
1025      * was processed in {@link android.app.Activity#onCreate}.  This will
1026      * implicitly call {@link #getDecorView} for you, with all of the
1027      * associated side-effects.
1028      *
1029      * @return The view if found or null otherwise.
1030      */
1031     @Nullable
findViewById(@dRes int id)1032     public View findViewById(@IdRes int id) {
1033         return getDecorView().findViewById(id);
1034     }
1035 
1036     /**
1037      * Convenience for
1038      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1039      * to set the screen content from a layout resource.  The resource will be
1040      * inflated, adding all top-level views to the screen.
1041      *
1042      * @param layoutResID Resource ID to be inflated.
1043      * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1044      */
setContentView(@ayoutRes int layoutResID)1045     public abstract void setContentView(@LayoutRes int layoutResID);
1046 
1047     /**
1048      * Convenience for
1049      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1050      * set the screen content to an explicit view.  This view is placed
1051      * directly into the screen's view hierarchy.  It can itself be a complex
1052      * view hierarhcy.
1053      *
1054      * @param view The desired content to display.
1055      * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1056      */
setContentView(View view)1057     public abstract void setContentView(View view);
1058 
1059     /**
1060      * Set the screen content to an explicit view.  This view is placed
1061      * directly into the screen's view hierarchy.  It can itself be a complex
1062      * view hierarchy.
1063      *
1064      * <p>Note that calling this function "locks in" various characteristics
1065      * of the window that can not, from this point forward, be changed: the
1066      * features that have been requested with {@link #requestFeature(int)},
1067      * and certain window flags as described in {@link #setFlags(int, int)}.</p>
1068      *
1069      * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's
1070      * TransitionManager will be used to animate content from the current
1071      * content View to view.</p>
1072      *
1073      * @param view The desired content to display.
1074      * @param params Layout parameters for the view.
1075      * @see #getTransitionManager()
1076      * @see #setTransitionManager(android.transition.TransitionManager)
1077      */
setContentView(View view, ViewGroup.LayoutParams params)1078     public abstract void setContentView(View view, ViewGroup.LayoutParams params);
1079 
1080     /**
1081      * Variation on
1082      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1083      * to add an additional content view to the screen.  Added after any existing
1084      * ones in the screen -- existing views are NOT removed.
1085      *
1086      * @param view The desired content to display.
1087      * @param params Layout parameters for the view.
1088      */
addContentView(View view, ViewGroup.LayoutParams params)1089     public abstract void addContentView(View view, ViewGroup.LayoutParams params);
1090 
1091     /**
1092      * Return the view in this Window that currently has focus, or null if
1093      * there are none.  Note that this does not look in any containing
1094      * Window.
1095      *
1096      * @return View The current View with focus or null.
1097      */
1098     @Nullable
getCurrentFocus()1099     public abstract View getCurrentFocus();
1100 
1101     /**
1102      * Quick access to the {@link LayoutInflater} instance that this Window
1103      * retrieved from its Context.
1104      *
1105      * @return LayoutInflater The shared LayoutInflater.
1106      */
1107     @NonNull
getLayoutInflater()1108     public abstract LayoutInflater getLayoutInflater();
1109 
setTitle(CharSequence title)1110     public abstract void setTitle(CharSequence title);
1111 
1112     @Deprecated
setTitleColor(@olorInt int textColor)1113     public abstract void setTitleColor(@ColorInt int textColor);
1114 
openPanel(int featureId, KeyEvent event)1115     public abstract void openPanel(int featureId, KeyEvent event);
1116 
closePanel(int featureId)1117     public abstract void closePanel(int featureId);
1118 
togglePanel(int featureId, KeyEvent event)1119     public abstract void togglePanel(int featureId, KeyEvent event);
1120 
invalidatePanelMenu(int featureId)1121     public abstract void invalidatePanelMenu(int featureId);
1122 
performPanelShortcut(int featureId, int keyCode, KeyEvent event, int flags)1123     public abstract boolean performPanelShortcut(int featureId,
1124                                                  int keyCode,
1125                                                  KeyEvent event,
1126                                                  int flags);
performPanelIdentifierAction(int featureId, int id, int flags)1127     public abstract boolean performPanelIdentifierAction(int featureId,
1128                                                  int id,
1129                                                  int flags);
1130 
closeAllPanels()1131     public abstract void closeAllPanels();
1132 
performContextMenuIdentifierAction(int id, int flags)1133     public abstract boolean performContextMenuIdentifierAction(int id, int flags);
1134 
1135     /**
1136      * Should be called when the configuration is changed.
1137      *
1138      * @param newConfig The new configuration.
1139      */
onConfigurationChanged(Configuration newConfig)1140     public abstract void onConfigurationChanged(Configuration newConfig);
1141 
1142     /**
1143      * Sets the window elevation.
1144      * <p>
1145      * Changes to this property take effect immediately and will cause the
1146      * window surface to be recreated. This is an expensive operation and as a
1147      * result, this property should not be animated.
1148      *
1149      * @param elevation The window elevation.
1150      * @see View#setElevation(float)
1151      * @see android.R.styleable#Window_windowElevation
1152      */
setElevation(float elevation)1153     public void setElevation(float elevation) {}
1154 
1155     /**
1156      * Sets whether window content should be clipped to the outline of the
1157      * window background.
1158      *
1159      * @param clipToOutline Whether window content should be clipped to the
1160      *                      outline of the window background.
1161      * @see View#setClipToOutline(boolean)
1162      * @see android.R.styleable#Window_windowClipToOutline
1163      */
setClipToOutline(boolean clipToOutline)1164     public void setClipToOutline(boolean clipToOutline) {}
1165 
1166     /**
1167      * Change the background of this window to a Drawable resource. 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 resId The resource identifier of a drawable resource which will
1173      *              be installed as the new background.
1174      */
setBackgroundDrawableResource(@rawableRes int resId)1175     public void setBackgroundDrawableResource(@DrawableRes int resId) {
1176         setBackgroundDrawable(mContext.getDrawable(resId));
1177     }
1178 
1179     /**
1180      * Change the background of this window to a custom Drawable. Setting the
1181      * background to null will make the window be opaque. To make the window
1182      * transparent, you can use an empty drawable (for instance a ColorDrawable
1183      * with the color 0 or the system drawable android:drawable/empty.)
1184      *
1185      * @param drawable The new Drawable to use for this window's background.
1186      */
setBackgroundDrawable(Drawable drawable)1187     public abstract void setBackgroundDrawable(Drawable drawable);
1188 
1189     /**
1190      * Set the value for a drawable feature of this window, from a resource
1191      * identifier.  You must have called requestFeature(featureId) before
1192      * calling this function.
1193      *
1194      * @see android.content.res.Resources#getDrawable(int)
1195      *
1196      * @param featureId The desired drawable feature to change, defined as a
1197      * constant by Window.
1198      * @param resId Resource identifier of the desired image.
1199      */
setFeatureDrawableResource(int featureId, @DrawableRes int resId)1200     public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId);
1201 
1202     /**
1203      * Set the value for a drawable feature of this window, from a URI. You
1204      * must have called requestFeature(featureId) before calling this
1205      * function.
1206      *
1207      * <p>The only URI currently supported is "content:", specifying an image
1208      * in a content provider.
1209      *
1210      * @see android.widget.ImageView#setImageURI
1211      *
1212      * @param featureId The desired drawable feature to change. Features are
1213      * constants defined by Window.
1214      * @param uri The desired URI.
1215      */
setFeatureDrawableUri(int featureId, Uri uri)1216     public abstract void setFeatureDrawableUri(int featureId, Uri uri);
1217 
1218     /**
1219      * Set an explicit Drawable value for feature of this window. You must
1220      * have called requestFeature(featureId) before calling this function.
1221      *
1222      * @param featureId The desired drawable feature to change. Features are
1223      *                  constants defined by Window.
1224      * @param drawable A Drawable object to display.
1225      */
setFeatureDrawable(int featureId, Drawable drawable)1226     public abstract void setFeatureDrawable(int featureId, Drawable drawable);
1227 
1228     /**
1229      * Set a custom alpha value for the given drawable feature, controlling how
1230      * much the background is visible through it.
1231      *
1232      * @param featureId The desired drawable feature to change. Features are
1233      *                  constants defined by Window.
1234      * @param alpha The alpha amount, 0 is completely transparent and 255 is
1235      *              completely opaque.
1236      */
setFeatureDrawableAlpha(int featureId, int alpha)1237     public abstract void setFeatureDrawableAlpha(int featureId, int alpha);
1238 
1239     /**
1240      * Set the integer value for a feature. The range of the value depends on
1241      * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from
1242      * 0 to 10000. At 10000 the progress is complete and the indicator hidden.
1243      *
1244      * @param featureId The desired feature to change. Features are constants
1245      *                  defined by Window.
1246      * @param value The value for the feature. The interpretation of this
1247      *              value is feature-specific.
1248      */
setFeatureInt(int featureId, int value)1249     public abstract void setFeatureInt(int featureId, int value);
1250 
1251     /**
1252      * Request that key events come to this activity. Use this if your
1253      * activity has no views with focus, but the activity still wants
1254      * a chance to process key events.
1255      */
takeKeyEvents(boolean get)1256     public abstract void takeKeyEvents(boolean get);
1257 
1258     /**
1259      * Used by custom windows, such as Dialog, to pass the key press event
1260      * further down the view hierarchy. Application developers should
1261      * not need to implement or call this.
1262      *
1263      */
superDispatchKeyEvent(KeyEvent event)1264     public abstract boolean superDispatchKeyEvent(KeyEvent event);
1265 
1266     /**
1267      * Used by custom windows, such as Dialog, to pass the key shortcut press event
1268      * further down the view hierarchy. Application developers should
1269      * not need to implement or call this.
1270      *
1271      */
superDispatchKeyShortcutEvent(KeyEvent event)1272     public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event);
1273 
1274     /**
1275      * Used by custom windows, such as Dialog, to pass the touch screen event
1276      * further down the view hierarchy. Application developers should
1277      * not need to implement or call this.
1278      *
1279      */
superDispatchTouchEvent(MotionEvent event)1280     public abstract boolean superDispatchTouchEvent(MotionEvent event);
1281 
1282     /**
1283      * Used by custom windows, such as Dialog, to pass the trackball event
1284      * further down the view hierarchy. Application developers should
1285      * not need to implement or call this.
1286      *
1287      */
superDispatchTrackballEvent(MotionEvent event)1288     public abstract boolean superDispatchTrackballEvent(MotionEvent event);
1289 
1290     /**
1291      * Used by custom windows, such as Dialog, to pass the generic motion event
1292      * further down the view hierarchy. Application developers should
1293      * not need to implement or call this.
1294      *
1295      */
superDispatchGenericMotionEvent(MotionEvent event)1296     public abstract boolean superDispatchGenericMotionEvent(MotionEvent event);
1297 
1298     /**
1299      * Retrieve the top-level window decor view (containing the standard
1300      * window frame/decorations and the client's content inside of that), which
1301      * can be added as a window to the window manager.
1302      *
1303      * <p><em>Note that calling this function for the first time "locks in"
1304      * various window characteristics as described in
1305      * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p>
1306      *
1307      * @return Returns the top-level window decor view.
1308      */
getDecorView()1309     public abstract View getDecorView();
1310 
1311     /**
1312      * Retrieve the current decor view, but only if it has already been created;
1313      * otherwise returns null.
1314      *
1315      * @return Returns the top-level window decor or null.
1316      * @see #getDecorView
1317      */
peekDecorView()1318     public abstract View peekDecorView();
1319 
saveHierarchyState()1320     public abstract Bundle saveHierarchyState();
1321 
restoreHierarchyState(Bundle savedInstanceState)1322     public abstract void restoreHierarchyState(Bundle savedInstanceState);
1323 
onActive()1324     protected abstract void onActive();
1325 
1326     /**
1327      * Return the feature bits that are enabled.  This is the set of features
1328      * that were given to requestFeature(), and are being handled by this
1329      * Window itself or its container.  That is, it is the set of
1330      * requested features that you can actually use.
1331      *
1332      * <p>To do: add a public version of this API that allows you to check for
1333      * features by their feature ID.
1334      *
1335      * @return int The feature bits.
1336      */
getFeatures()1337     protected final int getFeatures()
1338     {
1339         return mFeatures;
1340     }
1341 
1342     /**
1343      * Return the feature bits set by default on a window.
1344      * @param context The context used to access resources
1345      */
getDefaultFeatures(Context context)1346     public static int getDefaultFeatures(Context context) {
1347         int features = 0;
1348 
1349         final Resources res = context.getResources();
1350         if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
1351             features |= 1 << FEATURE_OPTIONS_PANEL;
1352         }
1353 
1354         if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
1355             features |= 1 << FEATURE_CONTEXT_MENU;
1356         }
1357 
1358         return features;
1359     }
1360 
1361     /**
1362      * Query for the availability of a certain feature.
1363      *
1364      * @param feature The feature ID to check
1365      * @return true if the feature is enabled, false otherwise.
1366      */
hasFeature(int feature)1367     public boolean hasFeature(int feature) {
1368         return (getFeatures() & (1 << feature)) != 0;
1369     }
1370 
1371     /**
1372      * Return the feature bits that are being implemented by this Window.
1373      * This is the set of features that were given to requestFeature(), and are
1374      * being handled by only this Window itself, not by its containers.
1375      *
1376      * @return int The feature bits.
1377      */
getLocalFeatures()1378     protected final int getLocalFeatures()
1379     {
1380         return mLocalFeatures;
1381     }
1382 
1383     /**
1384      * Set the default format of window, as per the PixelFormat types.  This
1385      * is the format that will be used unless the client specifies in explicit
1386      * format with setFormat();
1387      *
1388      * @param format The new window format (see PixelFormat).
1389      *
1390      * @see #setFormat
1391      * @see PixelFormat
1392      */
setDefaultWindowFormat(int format)1393     protected void setDefaultWindowFormat(int format) {
1394         mDefaultWindowFormat = format;
1395         if (!mHaveWindowFormat) {
1396             final WindowManager.LayoutParams attrs = getAttributes();
1397             attrs.format = format;
1398             dispatchWindowAttributesChanged(attrs);
1399         }
1400     }
1401 
1402     /** @hide */
haveDimAmount()1403     protected boolean haveDimAmount() {
1404         return mHaveDimAmount;
1405     }
1406 
setChildDrawable(int featureId, Drawable drawable)1407     public abstract void setChildDrawable(int featureId, Drawable drawable);
1408 
setChildInt(int featureId, int value)1409     public abstract void setChildInt(int featureId, int value);
1410 
1411     /**
1412      * Is a keypress one of the defined shortcut keys for this window.
1413      * @param keyCode the key code from {@link android.view.KeyEvent} to check.
1414      * @param event the {@link android.view.KeyEvent} to use to help check.
1415      */
isShortcutKey(int keyCode, KeyEvent event)1416     public abstract boolean isShortcutKey(int keyCode, KeyEvent event);
1417 
1418     /**
1419      * @see android.app.Activity#setVolumeControlStream(int)
1420      */
setVolumeControlStream(int streamType)1421     public abstract void setVolumeControlStream(int streamType);
1422 
1423     /**
1424      * @see android.app.Activity#getVolumeControlStream()
1425      */
getVolumeControlStream()1426     public abstract int getVolumeControlStream();
1427 
1428     /**
1429      * Sets a {@link MediaController} to send media keys and volume changes to.
1430      * If set, this should be preferred for all media keys and volume requests
1431      * sent to this window.
1432      *
1433      * @param controller The controller for the session which should receive
1434      *            media keys and volume changes.
1435      * @see android.app.Activity#setMediaController(android.media.session.MediaController)
1436      */
setMediaController(MediaController controller)1437     public void setMediaController(MediaController controller) {
1438     }
1439 
1440     /**
1441      * Gets the {@link MediaController} that was previously set.
1442      *
1443      * @return The controller which should receive events.
1444      * @see #setMediaController(android.media.session.MediaController)
1445      * @see android.app.Activity#getMediaController()
1446      */
getMediaController()1447     public MediaController getMediaController() {
1448         return null;
1449     }
1450 
1451     /**
1452      * Set extra options that will influence the UI for this window.
1453      * @param uiOptions Flags specifying extra options for this window.
1454      */
setUiOptions(int uiOptions)1455     public void setUiOptions(int uiOptions) { }
1456 
1457     /**
1458      * Set extra options that will influence the UI for this window.
1459      * Only the bits filtered by mask will be modified.
1460      * @param uiOptions Flags specifying extra options for this window.
1461      * @param mask Flags specifying which options should be modified. Others will remain unchanged.
1462      */
setUiOptions(int uiOptions, int mask)1463     public void setUiOptions(int uiOptions, int mask) { }
1464 
1465     /**
1466      * Set the primary icon for this window.
1467      *
1468      * @param resId resource ID of a drawable to set
1469      */
setIcon(@rawableRes int resId)1470     public void setIcon(@DrawableRes int resId) { }
1471 
1472     /**
1473      * Set the default icon for this window.
1474      * This will be overridden by any other icon set operation which could come from the
1475      * theme or another explicit set.
1476      *
1477      * @hide
1478      */
setDefaultIcon(@rawableRes int resId)1479     public void setDefaultIcon(@DrawableRes int resId) { }
1480 
1481     /**
1482      * Set the logo for this window. A logo is often shown in place of an
1483      * {@link #setIcon(int) icon} but is generally wider and communicates window title information
1484      * as well.
1485      *
1486      * @param resId resource ID of a drawable to set
1487      */
setLogo(@rawableRes int resId)1488     public void setLogo(@DrawableRes int resId) { }
1489 
1490     /**
1491      * Set the default logo for this window.
1492      * This will be overridden by any other logo set operation which could come from the
1493      * theme or another explicit set.
1494      *
1495      * @hide
1496      */
setDefaultLogo(@rawableRes int resId)1497     public void setDefaultLogo(@DrawableRes int resId) { }
1498 
1499     /**
1500      * Set focus locally. The window should have the
1501      * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.
1502      * @param hasFocus Whether this window has focus or not.
1503      * @param inTouchMode Whether this window is in touch mode or not.
1504      */
setLocalFocus(boolean hasFocus, boolean inTouchMode)1505     public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { }
1506 
1507     /**
1508      * Inject an event to window locally.
1509      * @param event A key or touch event to inject to this window.
1510      */
injectInputEvent(InputEvent event)1511     public void injectInputEvent(InputEvent event) { }
1512 
1513     /**
1514      * Retrieve the {@link TransitionManager} responsible for  for default transitions
1515      * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1516      *
1517      * <p>This method will return non-null after content has been initialized (e.g. by using
1518      * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p>
1519      *
1520      * @return This window's content TransitionManager or null if none is set.
1521      * @attr ref android.R.styleable#Window_windowContentTransitionManager
1522      */
getTransitionManager()1523     public TransitionManager getTransitionManager() {
1524         return null;
1525     }
1526 
1527     /**
1528      * Set the {@link TransitionManager} to use for default transitions in this window.
1529      * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1530      *
1531      * @param tm The TransitionManager to use for scene changes.
1532      * @attr ref android.R.styleable#Window_windowContentTransitionManager
1533      */
setTransitionManager(TransitionManager tm)1534     public void setTransitionManager(TransitionManager tm) {
1535         throw new UnsupportedOperationException();
1536     }
1537 
1538     /**
1539      * Retrieve the {@link Scene} representing this window's current content.
1540      * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1541      *
1542      * <p>This method will return null if the current content is not represented by a Scene.</p>
1543      *
1544      * @return Current Scene being shown or null
1545      */
getContentScene()1546     public Scene getContentScene() {
1547         return null;
1548     }
1549 
1550     /**
1551      * Sets the Transition that will be used to move Views into the initial scene. The entering
1552      * Views will be those that are regular Views or ViewGroups that have
1553      * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1554      * {@link android.transition.Visibility} as entering is governed by changing visibility from
1555      * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1556      * entering Views will remain unaffected.
1557      *
1558      * @param transition The Transition to use to move Views into the initial Scene.
1559      * @attr ref android.R.styleable#Window_windowEnterTransition
1560      */
setEnterTransition(Transition transition)1561     public void setEnterTransition(Transition transition) {}
1562 
1563     /**
1564      * Sets the Transition that will be used to move Views out of the scene when the Window is
1565      * preparing to close, for example after a call to
1566      * {@link android.app.Activity#finishAfterTransition()}. The exiting
1567      * Views will be those that are regular Views or ViewGroups that have
1568      * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1569      * {@link android.transition.Visibility} as entering is governed by changing visibility from
1570      * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null,
1571      * entering Views will remain unaffected. If nothing is set, the default will be to
1572      * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
1573      *
1574      * @param transition The Transition to use to move Views out of the Scene when the Window
1575      *                   is preparing to close.
1576      * @attr ref android.R.styleable#Window_windowReturnTransition
1577      */
setReturnTransition(Transition transition)1578     public void setReturnTransition(Transition transition) {}
1579 
1580     /**
1581      * Sets the Transition that will be used to move Views out of the scene when starting a
1582      * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1583      * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1584      * {@link android.transition.Visibility} as exiting is governed by changing visibility
1585      * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
1586      * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1587      *
1588      * @param transition The Transition to use to move Views out of the scene when calling a
1589      *                   new Activity.
1590      * @attr ref android.R.styleable#Window_windowExitTransition
1591      */
setExitTransition(Transition transition)1592     public void setExitTransition(Transition transition) {}
1593 
1594     /**
1595      * Sets the Transition that will be used to move Views in to the scene when returning from
1596      * a previously-started Activity. The entering Views will be those that are regular Views
1597      * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1598      * will extend {@link android.transition.Visibility} as exiting is governed by changing
1599      * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
1600      * the views will remain unaffected. If nothing is set, the default will be to use the same
1601      * transition as {@link #setExitTransition(android.transition.Transition)}.
1602      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1603      *
1604      * @param transition The Transition to use to move Views into the scene when reentering from a
1605      *                   previously-started Activity.
1606      * @attr ref android.R.styleable#Window_windowReenterTransition
1607      */
setReenterTransition(Transition transition)1608     public void setReenterTransition(Transition transition) {}
1609 
1610     /**
1611      * Returns the transition used to move Views into the initial scene. The entering
1612      * Views will be those that are regular Views or ViewGroups that have
1613      * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1614      * {@link android.transition.Visibility} as entering is governed by changing visibility from
1615      * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1616      * entering Views will remain unaffected.  Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1617      *
1618      * @return the Transition to use to move Views into the initial Scene.
1619      * @attr ref android.R.styleable#Window_windowEnterTransition
1620      */
getEnterTransition()1621     public Transition getEnterTransition() { return null; }
1622 
1623     /**
1624      * Returns he Transition that will be used to move Views out of the scene when the Window is
1625      * preparing to close, for example after a call to
1626      * {@link android.app.Activity#finishAfterTransition()}. The exiting
1627      * Views will be those that are regular Views or ViewGroups that have
1628      * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1629      * {@link android.transition.Visibility} as entering is governed by changing visibility from
1630      * {@link View#VISIBLE} to {@link View#INVISIBLE}.
1631      *
1632      * @return The Transition to use to move Views out of the Scene when the Window
1633      *         is preparing to close.
1634      * @attr ref android.R.styleable#Window_windowReturnTransition
1635      */
getReturnTransition()1636     public Transition getReturnTransition() { return null; }
1637 
1638     /**
1639      * Returns the Transition that will be used to move Views out of the scene when starting a
1640      * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1641      * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1642      * {@link android.transition.Visibility} as exiting is governed by changing visibility
1643      * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
1644      * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1645      *
1646      * @return the Transition to use to move Views out of the scene when calling a
1647      * new Activity.
1648      * @attr ref android.R.styleable#Window_windowExitTransition
1649      */
getExitTransition()1650     public Transition getExitTransition() { return null; }
1651 
1652     /**
1653      * Returns the Transition that will be used to move Views in to the scene when returning from
1654      * a previously-started Activity. The entering Views will be those that are regular Views
1655      * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1656      * will extend {@link android.transition.Visibility} as exiting is governed by changing
1657      * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
1658      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1659      *
1660      * @return The Transition to use to move Views into the scene when reentering from a
1661      *         previously-started Activity.
1662      * @attr ref android.R.styleable#Window_windowReenterTransition
1663      */
getReenterTransition()1664     public Transition getReenterTransition() { return null; }
1665 
1666     /**
1667      * Sets the Transition that will be used for shared elements transferred into the content
1668      * Scene. 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      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1672      *
1673      * @param transition The Transition to use for shared elements transferred into the content
1674      *                   Scene.
1675      * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
1676      */
setSharedElementEnterTransition(Transition transition)1677     public void setSharedElementEnterTransition(Transition transition) {}
1678 
1679     /**
1680      * Sets the Transition that will be used for shared elements transferred back to a
1681      * calling Activity. Typical Transitions will affect size and location, such as
1682      * {@link android.transition.ChangeBounds}. A null
1683      * value will cause transferred shared elements to blink to the final position.
1684      * If no value is set, the default will be to use the same value as
1685      * {@link #setSharedElementEnterTransition(android.transition.Transition)}.
1686      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1687      *
1688      * @param transition The Transition to use for shared elements transferred out of the content
1689      *                   Scene.
1690      * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
1691      */
setSharedElementReturnTransition(Transition transition)1692     public void setSharedElementReturnTransition(Transition transition) {}
1693 
1694     /**
1695      * Returns the Transition that will be used for shared elements transferred into the content
1696      * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1697      *
1698      * @return Transition to use for sharend elements transferred into the content Scene.
1699      * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
1700      */
getSharedElementEnterTransition()1701     public Transition getSharedElementEnterTransition() { return null; }
1702 
1703     /**
1704      * Returns the Transition that will be used for shared elements transferred back to a
1705      * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1706      *
1707      * @return Transition to use for sharend elements transferred into the content Scene.
1708      * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
1709      */
getSharedElementReturnTransition()1710     public Transition getSharedElementReturnTransition() { return null; }
1711 
1712     /**
1713      * Sets the Transition that will be used for shared elements after starting a new Activity
1714      * before the shared elements are transferred to the called Activity. If the shared elements
1715      * must animate during the exit transition, this Transition should be used. Upon completion,
1716      * the shared elements may be transferred to the started Activity.
1717      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1718      *
1719      * @param transition The Transition to use for shared elements in the launching Window
1720      *                   prior to transferring to the launched Activity's Window.
1721      * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
1722      */
setSharedElementExitTransition(Transition transition)1723     public void setSharedElementExitTransition(Transition transition) {}
1724 
1725     /**
1726      * Sets the Transition that will be used for shared elements reentering from a started
1727      * Activity after it has returned the shared element to it start location. If no value
1728      * is set, this will default to
1729      * {@link #setSharedElementExitTransition(android.transition.Transition)}.
1730      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1731      *
1732      * @param transition The Transition to use for shared elements in the launching Window
1733      *                   after the shared element has returned to the Window.
1734      * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
1735      */
setSharedElementReenterTransition(Transition transition)1736     public void setSharedElementReenterTransition(Transition transition) {}
1737 
1738     /**
1739      * Returns the Transition to use for shared elements in the launching Window prior
1740      * to transferring to the launched Activity's Window.
1741      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1742      *
1743      * @return the Transition to use for shared elements in the launching Window prior
1744      * to transferring to the launched Activity's Window.
1745      * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
1746      */
getSharedElementExitTransition()1747     public Transition getSharedElementExitTransition() { return null; }
1748 
1749     /**
1750      * Returns the Transition that will be used for shared elements reentering from a started
1751      * Activity after it has returned the shared element to it start location.
1752      * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
1753      *
1754      * @return the Transition that will be used for shared elements reentering from a started
1755      * Activity after it has returned the shared element to it start location.
1756      * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
1757      */
getSharedElementReenterTransition()1758     public Transition getSharedElementReenterTransition() { return null; }
1759 
1760     /**
1761      * Controls 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      * @param allow true to start the enter transition when possible or false to
1768      *              wait until the exiting transition completes.
1769      * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
1770      */
setAllowEnterTransitionOverlap(boolean allow)1771     public void setAllowEnterTransitionOverlap(boolean allow) {}
1772 
1773     /**
1774      * Returns how the transition set in
1775      * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
1776      * transition of the calling Activity. When true, the transition will start as soon as possible.
1777      * When false, the transition will wait until the remote exiting transition completes before
1778      * starting.
1779      *
1780      * @return true when the enter transition should start as soon as possible or false to
1781      * when it should wait until the exiting transition completes.
1782      * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
1783      */
getAllowEnterTransitionOverlap()1784     public boolean getAllowEnterTransitionOverlap() { return true; }
1785 
1786     /**
1787      * Controls 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      * @param allow true to start the transition when possible or false to wait until the
1794      *              called Activity's exiting transition completes.
1795      * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
1796      */
setAllowReturnTransitionOverlap(boolean allow)1797     public void setAllowReturnTransitionOverlap(boolean allow) {}
1798 
1799     /**
1800      * Returns how the transition set in
1801      * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
1802      * transition of the called Activity when reentering after if finishes. When true,
1803      * the transition will start as soon as possible. When false, the transition will wait
1804      * until the called Activity's exiting transition completes before starting.
1805      *
1806      * @return true when the transition should start when possible or false when it should wait
1807      * until the called Activity's exiting transition completes.
1808      * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
1809      */
getAllowReturnTransitionOverlap()1810     public boolean getAllowReturnTransitionOverlap() { return true; }
1811 
1812     /**
1813      * Returns 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      * @return The duration of the window background fade to opaque during enter transition.
1820      * @see #getEnterTransition()
1821      * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
1822      */
getTransitionBackgroundFadeDuration()1823     public long getTransitionBackgroundFadeDuration() { return 0; }
1824 
1825     /**
1826      * Sets the duration, in milliseconds, of the window background fade
1827      * when transitioning into or away from an Activity when called with an Activity Transition.
1828      * <p>When executing the enter transition, the background starts transparent
1829      * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
1830      * 300 milliseconds.</p>
1831      *
1832      * @param fadeDurationMillis The duration of the window background fade to or from opaque
1833      *                           during enter transition.
1834      * @see #setEnterTransition(android.transition.Transition)
1835      * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
1836      */
setTransitionBackgroundFadeDuration(long fadeDurationMillis)1837     public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { }
1838 
1839     /**
1840      * Returns <code>true</code> when shared elements should use an Overlay during
1841      * shared element transitions or <code>false</code> when they should animate as
1842      * part of the normal View hierarchy. The default value is true.
1843      *
1844      * @return <code>true</code> when shared elements should use an Overlay during
1845      * shared element transitions or <code>false</code> when they should animate as
1846      * part of the normal View hierarchy.
1847      * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
1848      */
getSharedElementsUseOverlay()1849     public boolean getSharedElementsUseOverlay() { return true; }
1850 
1851     /**
1852      * Sets whether or not shared elements should use an Overlay during shared element transitions.
1853      * The default value is true.
1854      *
1855      * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should
1856      *                                 be transitioned with an Overlay or <code>false</code>
1857      *                                 to transition within the normal View hierarchy.
1858      * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
1859      */
setSharedElementsUseOverlay(boolean sharedElementsUseOverlay)1860     public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { }
1861 
1862     /**
1863      * @return the color of the status bar.
1864      */
1865     @ColorInt
getStatusBarColor()1866     public abstract int getStatusBarColor();
1867 
1868     /**
1869      * Sets the color of the status bar to {@code color}.
1870      *
1871      * For this to take effect,
1872      * the window must be drawing the system bar backgrounds with
1873      * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
1874      * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set.
1875      *
1876      * If {@code color} is not opaque, consider setting
1877      * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
1878      * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
1879      * <p>
1880      * The transitionName for the view background will be "android:status:background".
1881      * </p>
1882      */
setStatusBarColor(@olorInt int color)1883     public abstract void setStatusBarColor(@ColorInt int color);
1884 
1885     /**
1886      * @return the color of the navigation bar.
1887      */
1888     @ColorInt
getNavigationBarColor()1889     public abstract int getNavigationBarColor();
1890 
1891     /**
1892      * Sets the color of the navigation bar to {@param color}.
1893      *
1894      * For this to take effect,
1895      * the window must be drawing the system bar backgrounds with
1896      * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
1897      * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
1898      *
1899      * If {@param color} is not opaque, consider setting
1900      * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
1901      * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
1902      * <p>
1903      * The transitionName for the view background will be "android:navigation:background".
1904      * </p>
1905      */
setNavigationBarColor(@olorInt int color)1906     public abstract void setNavigationBarColor(@ColorInt int color);
1907 
1908 
1909 }
1910