blob: 5bd0782d6056bccb9e741feaf2411727a491ed68 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.view;
18
Aurimas Liutikas67e2ae82016-10-11 18:17:42 -070019import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
20
Tor Norbye80756e32015-03-02 09:39:27 -080021import android.annotation.ColorInt;
Tor Norbye7b9c9122013-05-30 16:48:33 -070022import android.annotation.DrawableRes;
23import android.annotation.IdRes;
24import android.annotation.LayoutRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070025import android.annotation.NonNull;
26import android.annotation.Nullable;
Tor Norbye417ee5b2015-03-10 20:57:37 -070027import android.annotation.StyleRes;
Filip Gruszczynskife568352015-01-05 10:41:29 -080028import android.annotation.SystemApi;
Wale Ogunwale3382ab12017-07-27 08:55:03 -070029import android.app.WindowConfiguration;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.content.Context;
Romain Guy48327452017-01-23 17:03:35 -080031import android.content.pm.ActivityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.content.res.Configuration;
Bryce Leed6e6e722014-11-21 11:08:45 -080033import android.content.res.Resources;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.content.res.TypedArray;
Skuhnece2faa52015-08-11 10:36:38 -070035import android.graphics.PixelFormat;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -080036import android.graphics.Rect;
Filip Gruszczynski14418da2015-10-04 16:43:48 -070037import android.graphics.drawable.Drawable;
RoboErik55011652014-07-09 15:05:53 -070038import android.media.session.MediaController;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039import android.net.Uri;
40import android.os.Bundle;
Andres Morales910beb82016-02-02 16:19:40 -080041import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042import android.os.IBinder;
Wale Ogunwale868a5e12015-08-02 16:19:20 -070043import android.os.RemoteException;
Romain Guy9622e202011-09-29 16:37:27 -070044import android.os.SystemProperties;
Adam Powellcfbe9be2013-11-06 14:58:58 -080045import android.transition.Scene;
George Mounte1803372014-02-26 19:00:52 +000046import android.transition.Transition;
Adam Powellcfbe9be2013-11-06 14:58:58 -080047import android.transition.TransitionManager;
svetoslavganov75986cf2009-05-14 22:28:01 -070048import android.view.accessibility.AccessibilityEvent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049
Clara Bayarri75e09792015-07-29 16:20:40 +010050import java.util.List;
51
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052/**
53 * Abstract base class for a top-level window look and behavior policy. An
54 * instance of this class should be used as the top-level view added to the
55 * window manager. It provides standard UI policies such as a background, title
56 * area, default key processing, etc.
57 *
58 * <p>The only existing implementation of this abstract class is
Jorim Jaggib10e33f2015-02-04 21:57:40 +010059 * android.view.PhoneWindow, which you should instantiate when needing a
60 * Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061 */
62public abstract class Window {
63 /** Flag for the "options panel" feature. This is enabled by default. */
64 public static final int FEATURE_OPTIONS_PANEL = 0;
65 /** Flag for the "no title" feature, turning off the title at the top
66 * of the screen. */
67 public static final int FEATURE_NO_TITLE = 1;
Alan Viverette4aef7c82015-09-04 14:14:50 -040068
69 /**
70 * Flag for the progress indicator feature.
71 *
72 * @deprecated No longer supported starting in API 21.
73 */
74 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080075 public static final int FEATURE_PROGRESS = 2;
Alan Viverette4aef7c82015-09-04 14:14:50 -040076
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080077 /** Flag for having an icon on the left side of the title bar */
78 public static final int FEATURE_LEFT_ICON = 3;
79 /** Flag for having an icon on the right side of the title bar */
80 public static final int FEATURE_RIGHT_ICON = 4;
Alan Viverette4aef7c82015-09-04 14:14:50 -040081
82 /**
83 * Flag for indeterminate progress.
84 *
85 * @deprecated No longer supported starting in API 21.
86 */
87 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 public static final int FEATURE_INDETERMINATE_PROGRESS = 5;
Alan Viverette4aef7c82015-09-04 14:14:50 -040089
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080090 /** Flag for the context menu. This is enabled by default. */
91 public static final int FEATURE_CONTEXT_MENU = 6;
92 /** Flag for custom title. You cannot combine this feature with other title features. */
93 public static final int FEATURE_CUSTOM_TITLE = 7;
Adam Powell33b97432010-04-20 10:01:14 -070094 /**
95 * Flag for enabling the Action Bar.
96 * This is enabled by default for some devices. The Action Bar
97 * replaces the title bar and provides an alternate location
98 * for an on-screen menu button on some devices.
99 */
Adam Powell5d279772010-07-27 16:34:07 -0700100 public static final int FEATURE_ACTION_BAR = 8;
101 /**
Adam Powell6b336f82010-08-10 20:13:01 -0700102 * Flag for requesting an Action Bar that overlays window content.
103 * Normally an Action Bar will sit in the space above window content, but if this
104 * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over
105 * the window content itself. This is useful if you would like your app to have more control
106 * over how the Action Bar is displayed, such as letting application content scroll beneath
107 * an Action Bar with a transparent background or otherwise displaying a transparent/translucent
108 * Action Bar over application content.
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700109 *
110 * <p>This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN
111 * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the
112 * action bar in conjunction with other screen decorations.
113 *
114 * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an
115 * ActionBar is in this mode it will adjust the insets provided to
116 * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)}
117 * to include the content covered by the action bar, so you can do layout within
118 * that space.
Adam Powell6b336f82010-08-10 20:13:01 -0700119 */
120 public static final int FEATURE_ACTION_BAR_OVERLAY = 9;
121 /**
Adam Powell5d279772010-07-27 16:34:07 -0700122 * Flag for specifying the behavior of action modes when an Action Bar is not present.
123 * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
124 */
Adam Powell6b336f82010-08-10 20:13:01 -0700125 public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
Adam Powell18e905f2013-10-24 14:27:48 -0700126 /**
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800127 * Flag for requesting a decoration-free window that is dismissed by swiping from the left.
128 */
129 public static final int FEATURE_SWIPE_TO_DISMISS = 11;
Will Haldean Brown568628d2014-03-04 15:25:43 -0800130 /**
George Mountc3a043c2015-02-04 14:37:04 -0800131 * Flag for requesting that window content changes should be animated using a
132 * TransitionManager.
Adam Powell18e905f2013-10-24 14:27:48 -0700133 *
George Mountc3a043c2015-02-04 14:37:04 -0800134 * <p>The TransitionManager is set using
135 * {@link #setTransitionManager(android.transition.TransitionManager)}. If none is set,
136 * a default TransitionManager will be used.</p>
Adam Powell18e905f2013-10-24 14:27:48 -0700137 *
138 * @see #setContentView
139 */
Will Haldean Brown568628d2014-03-04 15:25:43 -0800140 public static final int FEATURE_CONTENT_TRANSITIONS = 12;
Adam Powell4b6d93f2012-09-18 18:34:08 -0700141
142 /**
George Mount9826f632014-09-11 08:50:09 -0700143 * Enables Activities to run Activity Transitions either through sending or receiving
144 * ActivityOptions bundle created with
145 * {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity,
146 * android.util.Pair[])} or {@link android.app.ActivityOptions#makeSceneTransitionAnimation(
147 * android.app.Activity, View, String)}.
148 */
149 public static final int FEATURE_ACTIVITY_TRANSITIONS = 13;
150
151 /**
Adam Powell4b6d93f2012-09-18 18:34:08 -0700152 * Max value used as a feature ID
153 * @hide
154 */
George Mount9826f632014-09-11 08:50:09 -0700155 public static final int FEATURE_MAX = FEATURE_ACTIVITY_TRANSITIONS;
Adam Powell4b6d93f2012-09-18 18:34:08 -0700156
Alan Viverette4aef7c82015-09-04 14:14:50 -0400157 /**
158 * Flag for setting the progress bar's visibility to VISIBLE.
159 *
160 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
161 * supported starting in API 21.
162 */
163 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800164 public static final int PROGRESS_VISIBILITY_ON = -1;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400165
166 /**
167 * Flag for setting the progress bar's visibility to GONE.
168 *
169 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
170 * supported starting in API 21.
171 */
172 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800173 public static final int PROGRESS_VISIBILITY_OFF = -2;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400174
175 /**
176 * Flag for setting the progress bar's indeterminate mode on.
177 *
178 * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
179 * are no longer supported starting in API 21.
180 */
181 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800182 public static final int PROGRESS_INDETERMINATE_ON = -3;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400183
184 /**
185 * Flag for setting the progress bar's indeterminate mode off.
186 *
187 * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
188 * are no longer supported starting in API 21.
189 */
190 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800191 public static final int PROGRESS_INDETERMINATE_OFF = -4;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400192
193 /**
194 * Starting value for the (primary) progress.
195 *
196 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
197 * supported starting in API 21.
198 */
199 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800200 public static final int PROGRESS_START = 0;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400201
202 /**
203 * Ending value for the (primary) progress.
204 *
205 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
206 * supported starting in API 21.
207 */
208 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800209 public static final int PROGRESS_END = 10000;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400210
211 /**
212 * Lowest possible value for the secondary progress.
213 *
214 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
215 * supported starting in API 21.
216 */
217 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800218 public static final int PROGRESS_SECONDARY_START = 20000;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400219
220 /**
221 * Highest possible value for the secondary progress.
222 *
223 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
224 * supported starting in API 21.
225 */
226 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800227 public static final int PROGRESS_SECONDARY_END = 30000;
George Mount238010f2014-06-30 17:31:17 -0700228
229 /**
230 * The transitionName for the status bar background View when a custom background is used.
231 * @see android.view.Window#setStatusBarColor(int)
232 */
233 public static final String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background";
234
235 /**
236 * The transitionName for the navigation bar background View when a custom background is used.
237 * @see android.view.Window#setNavigationBarColor(int)
238 */
239 public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME =
240 "android:navigation:background";
241
Bryce Leeaa1008c2015-01-13 09:26:46 -0800242 /**
243 * The default features enabled.
244 * @deprecated use {@link #getDefaultFeatures(android.content.Context)} instead.
245 */
Bryce Leed6e6e722014-11-21 11:08:45 -0800246 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800247 @SuppressWarnings({"PointlessBitwiseExpression"})
248 protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) |
249 (1 << FEATURE_CONTEXT_MENU);
250
251 /**
252 * The ID that the main layout in the XML layout file should have.
253 */
254 public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content;
255
Jeff Brownd32460c2012-07-20 16:15:36 -0700256 private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw";
257
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800258 /**
259 * Flag for letting the theme drive the color of the window caption controls. Use with
260 * {@link #setDecorCaptionShade(int)}. This is the default value.
261 */
262 public static final int DECOR_CAPTION_SHADE_AUTO = 0;
263 /**
264 * Flag for setting light-color controls on the window caption. Use with
265 * {@link #setDecorCaptionShade(int)}.
266 */
267 public static final int DECOR_CAPTION_SHADE_LIGHT = 1;
268 /**
269 * Flag for setting dark-color controls on the window caption. Use with
270 * {@link #setDecorCaptionShade(int)}.
271 */
272 public static final int DECOR_CAPTION_SHADE_DARK = 2;
273
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800274 private final Context mContext;
RoboErik55011652014-07-09 15:05:53 -0700275
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800276 private TypedArray mWindowStyle;
277 private Callback mCallback;
Adam Powell117b6952014-05-05 18:14:56 -0700278 private OnWindowDismissedCallback mOnWindowDismissedCallback;
Michael Kwan67639a52016-12-16 12:38:10 -0800279 private OnWindowSwipeDismissedCallback mOnWindowSwipeDismissedCallback;
Skuhnece2faa52015-08-11 10:36:38 -0700280 private WindowControllerCallback mWindowControllerCallback;
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800281 private OnRestrictedCaptionAreaChangedListener mOnRestrictedCaptionAreaChangedListener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800282 private Rect mRestrictedCaptionAreaRect;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800283 private WindowManager mWindowManager;
284 private IBinder mAppToken;
285 private String mAppName;
Jeff Brownd32460c2012-07-20 16:15:36 -0700286 private boolean mHardwareAccelerated;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287 private Window mContainer;
288 private Window mActiveChild;
289 private boolean mIsActive = false;
290 private boolean mHasChildren = false;
Dianne Hackborncfaf8872011-01-18 13:57:54 -0800291 private boolean mCloseOnTouchOutside = false;
292 private boolean mSetCloseOnTouchOutside = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 private int mForcedWindowFlags = 0;
294
Bryce Leed6e6e722014-11-21 11:08:45 -0800295 private int mFeatures;
296 private int mLocalFeatures;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297
298 private boolean mHaveWindowFormat = false;
Dianne Hackborn661cd522011-08-22 00:26:20 -0700299 private boolean mHaveDimAmount = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800300 private int mDefaultWindowFormat = PixelFormat.OPAQUE;
301
302 private boolean mHasSoftInputMode = false;
RoboErik55011652014-07-09 15:05:53 -0700303
Dianne Hackborn291905e2010-08-17 15:17:15 -0700304 private boolean mDestroyed;
305
Andrii Kulian933076d2016-03-29 17:04:42 -0700306 private boolean mOverlayWithDecorCaptionEnabled = false;
Michael Kwanf7964be2016-11-30 16:44:33 -0800307 private boolean mCloseOnSwipeEnabled = false;
Filip Gruszczynski63250652015-11-18 14:43:01 -0800308
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800309 // The current window attributes.
310 private final WindowManager.LayoutParams mWindowAttributes =
311 new WindowManager.LayoutParams();
312
313 /**
314 * API from a Window back to its caller. This allows the client to
315 * intercept key dispatching, panels and menus, etc.
316 */
317 public interface Callback {
318 /**
319 * Called to process key events. At the very least your
320 * implementation must call
321 * {@link android.view.Window#superDispatchKeyEvent} to do the
322 * standard key processing.
323 *
324 * @param event The key event.
325 *
326 * @return boolean Return true if this event was consumed.
327 */
328 public boolean dispatchKeyEvent(KeyEvent event);
329
330 /**
Jeff Brown64da12a2011-01-04 19:57:47 -0800331 * Called to process a key shortcut event.
332 * At the very least your implementation must call
333 * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the
334 * standard key shortcut processing.
335 *
336 * @param event The key shortcut event.
337 * @return True if this event was consumed.
338 */
339 public boolean dispatchKeyShortcutEvent(KeyEvent event);
340
341 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342 * Called to process touch screen events. At the very least your
343 * implementation must call
344 * {@link android.view.Window#superDispatchTouchEvent} to do the
345 * standard touch screen processing.
346 *
347 * @param event The touch screen event.
348 *
349 * @return boolean Return true if this event was consumed.
350 */
351 public boolean dispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -0700352
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800353 /**
354 * Called to process trackball events. At the very least your
355 * implementation must call
356 * {@link android.view.Window#superDispatchTrackballEvent} to do the
357 * standard trackball processing.
358 *
359 * @param event The trackball event.
360 *
361 * @return boolean Return true if this event was consumed.
362 */
363 public boolean dispatchTrackballEvent(MotionEvent event);
svetoslavganov75986cf2009-05-14 22:28:01 -0700364
365 /**
Jeff Browncb1404e2011-01-15 18:14:15 -0800366 * Called to process generic motion events. At the very least your
367 * implementation must call
368 * {@link android.view.Window#superDispatchGenericMotionEvent} to do the
369 * standard processing.
370 *
371 * @param event The generic motion event.
372 *
373 * @return boolean Return true if this event was consumed.
374 */
375 public boolean dispatchGenericMotionEvent(MotionEvent event);
376
377 /**
svetoslavganov75986cf2009-05-14 22:28:01 -0700378 * Called to process population of {@link AccessibilityEvent}s.
379 *
380 * @param event The event.
381 *
382 * @return boolean Return true if event population was completed.
383 */
384 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event);
385
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800386 /**
387 * Instantiate the view to display in the panel for 'featureId'.
388 * You can return null, in which case the default content (typically
389 * a menu) will be created for you.
390 *
391 * @param featureId Which panel is being created.
392 *
393 * @return view The top-level view to place in the panel.
394 *
395 * @see #onPreparePanel
396 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700397 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800398 public View onCreatePanelView(int featureId);
399
400 /**
401 * Initialize the contents of the menu for panel 'featureId'. This is
402 * called if onCreatePanelView() returns null, giving you a standard
403 * menu in which you can place your items. It is only called once for
404 * the panel, the first time it is shown.
405 *
406 * <p>You can safely hold on to <var>menu</var> (and any items created
407 * from it), making modifications to it as desired, until the next
408 * time onCreatePanelMenu() is called for this feature.
409 *
410 * @param featureId The panel being created.
411 * @param menu The menu inside the panel.
412 *
413 * @return boolean You must return true for the panel to be displayed;
414 * if you return false it will not be shown.
415 */
416 public boolean onCreatePanelMenu(int featureId, Menu menu);
417
418 /**
419 * Prepare a panel to be displayed. This is called right before the
420 * panel window is shown, every time it is shown.
421 *
422 * @param featureId The panel that is being displayed.
423 * @param view The View that was returned by onCreatePanelView().
424 * @param menu If onCreatePanelView() returned null, this is the Menu
425 * being displayed in the panel.
426 *
427 * @return boolean You must return true for the panel to be displayed;
428 * if you return false it will not be shown.
429 *
430 * @see #onCreatePanelView
431 */
432 public boolean onPreparePanel(int featureId, View view, Menu menu);
433
434 /**
435 * Called when a panel's menu is opened by the user. This may also be
436 * called when the menu is changing from one type to another (for
437 * example, from the icon menu to the expanded menu).
RoboErik55011652014-07-09 15:05:53 -0700438 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800439 * @param featureId The panel that the menu is in.
440 * @param menu The menu that is opened.
441 * @return Return true to allow the menu to open, or false to prevent
442 * the menu from opening.
443 */
444 public boolean onMenuOpened(int featureId, Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700445
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 /**
447 * Called when a panel's menu item has been selected by the user.
448 *
449 * @param featureId The panel that the menu is in.
450 * @param item The menu item that was selected.
451 *
452 * @return boolean Return true to finish processing of selection, or
453 * false to perform the normal menu handling (calling its
454 * Runnable or sending a Message to its target Handler).
455 */
456 public boolean onMenuItemSelected(int featureId, MenuItem item);
457
458 /**
459 * This is called whenever the current window attributes change.
460 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800461 */
462 public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
463
464 /**
465 * This hook is called whenever the content view of the screen changes
466 * (due to a call to
467 * {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams)
468 * Window.setContentView} or
469 * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams)
470 * Window.addContentView}).
471 */
472 public void onContentChanged();
473
474 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700475 * This hook is called whenever the window focus changes. See
476 * {@link View#onWindowFocusChanged(boolean)
Svetoslav3a0d8782014-12-04 12:50:11 -0800477 * View.onWindowFocusChangedNotLocked(boolean)} for more information.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800478 *
479 * @param hasFocus Whether the window now has focus.
480 */
481 public void onWindowFocusChanged(boolean hasFocus);
482
483 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700484 * Called when the window has been attached to the window manager.
485 * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
486 * for more information.
487 */
488 public void onAttachedToWindow();
RoboErik55011652014-07-09 15:05:53 -0700489
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700490 /**
Chet Haasee7bf2192017-08-18 15:24:56 -0700491 * Called when the window has been detached from the window manager.
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700492 * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
493 * for more information.
494 */
495 public void onDetachedFromWindow();
RoboErik55011652014-07-09 15:05:53 -0700496
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700497 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800498 * Called when a panel is being closed. If another logical subsequent
499 * panel is being opened (and this panel is being closed to make room for the subsequent
500 * panel), this method will NOT be called.
RoboErik55011652014-07-09 15:05:53 -0700501 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800502 * @param featureId The panel that is being displayed.
503 * @param menu If onCreatePanelView() returned null, this is the Menu
504 * being displayed in the panel.
505 */
506 public void onPanelClosed(int featureId, Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700507
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800508 /**
509 * Called when the user signals the desire to start a search.
RoboErik55011652014-07-09 15:05:53 -0700510 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800511 * @return true if search launched, false if activity refuses (blocks)
RoboErik55011652014-07-09 15:05:53 -0700512 *
513 * @see android.app.Activity#onSearchRequested()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800514 */
515 public boolean onSearchRequested();
Adam Powell6e346362010-07-23 10:18:23 -0700516
517 /**
Tim Kilbourn6a975b32015-04-09 17:14:34 -0700518 * Called when the user signals the desire to start a search.
519 *
520 * @param searchEvent A {@link SearchEvent} describing the signal to
521 * start a search.
522 * @return true if search launched, false if activity refuses (blocks)
523 */
524 public boolean onSearchRequested(SearchEvent searchEvent);
525
526 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800527 * Called when an action mode is being started for this window. Gives the
528 * callback an opportunity to handle the action mode in its own unique and
529 * beautiful way. If this method returns null the system can choose a way
Clara Bayarri4423d912015-03-02 19:42:48 +0000530 * to present the mode or choose not to start the mode at all. This is equivalent
531 * to {@link #onWindowStartingActionMode(android.view.ActionMode.Callback, int)}
532 * with type {@link ActionMode#TYPE_PRIMARY}.
Adam Powell6e346362010-07-23 10:18:23 -0700533 *
534 * @param callback Callback to control the lifecycle of this action mode
Adam Powelldebf3be2010-11-15 18:58:48 -0800535 * @return The ActionMode that was started, or null if the system should present it
Adam Powell6e346362010-07-23 10:18:23 -0700536 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700537 @Nullable
Adam Powelldebf3be2010-11-15 18:58:48 -0800538 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
539
540 /**
Clara Bayarri4423d912015-03-02 19:42:48 +0000541 * Called when an action mode is being started for this window. Gives the
542 * callback an opportunity to handle the action mode in its own unique and
543 * beautiful way. If this method returns null the system can choose a way
544 * to present the mode or choose not to start the mode at all.
545 *
546 * @param callback Callback to control the lifecycle of this action mode
547 * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
548 * @return The ActionMode that was started, or null if the system should present it
549 */
550 @Nullable
551 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);
552
553 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800554 * Called when an action mode has been started. The appropriate mode callback
555 * method will have already been invoked.
556 *
557 * @param mode The new mode that has just been started.
558 */
559 public void onActionModeStarted(ActionMode mode);
560
561 /**
562 * Called when an action mode has been finished. The appropriate mode callback
563 * method will have already been invoked.
564 *
565 * @param mode The mode that was just finished.
566 */
567 public void onActionModeFinished(ActionMode mode);
Clara Bayarri75e09792015-07-29 16:20:40 +0100568
569 /**
570 * Called when Keyboard Shortcuts are requested for the current window.
571 *
572 * @param data The data list to populate with shortcuts.
573 * @param menu The current menu, which may be null.
Clara Bayarrifcd7e802016-03-10 12:58:18 +0000574 * @param deviceId The id for the connected device the shortcuts should be provided for.
Clara Bayarri75e09792015-07-29 16:20:40 +0100575 */
Sunny Goyal2a6d9aa2016-03-16 17:12:46 -0700576 default public void onProvideKeyboardShortcuts(
Clara Bayarrifcd7e802016-03-10 12:58:18 +0000577 List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) { };
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800578
579 /**
580 * Called when pointer capture is enabled or disabled for the current window.
581 *
582 * @param hasCapture True if the window has pointer capture.
583 */
584 default public void onPointerCaptureChanged(boolean hasCapture) { };
Adam Powell117b6952014-05-05 18:14:56 -0700585 }
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800586
Adam Powell117b6952014-05-05 18:14:56 -0700587 /** @hide */
588 public interface OnWindowDismissedCallback {
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800589 /**
590 * Called when a window is dismissed. This informs the callback that the
591 * window is gone, and it should finish itself.
Wale Ogunwaleba7881c2015-08-01 19:28:29 -0700592 * @param finishTask True if the task should also be finished.
Ned Burns7d6cb912016-12-02 17:25:33 -0500593 * @param suppressWindowTransition True if the resulting exit and enter window transition
594 * animations should be suppressed.
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800595 */
Ned Burns7d6cb912016-12-02 17:25:33 -0500596 void onWindowDismissed(boolean finishTask, boolean suppressWindowTransition);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800597 }
598
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700599 /** @hide */
Michael Kwan67639a52016-12-16 12:38:10 -0800600 public interface OnWindowSwipeDismissedCallback {
601 /**
602 * Called when a window is swipe dismissed. This informs the callback that the
603 * window is gone, and it should finish itself.
604 * @param finishTask True if the task should also be finished.
605 * @param suppressWindowTransition True if the resulting exit and enter window transition
606 * animations should be suppressed.
607 */
608 void onWindowSwipeDismissed();
609 }
610
611 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700612 public interface WindowControllerCallback {
613 /**
Filip Gruszczynski411c06f2016-01-07 09:44:44 -0800614 * Moves the activity from
Wale Ogunwale3382ab12017-07-27 08:55:03 -0700615 * Moves the activity from {@link WindowConfiguration#WINDOWING_MODE_FREEFORM} windowing
616 * mode to {@link WindowConfiguration#WINDOWING_MODE_FULLSCREEN}.
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700617 */
Filip Gruszczynski411c06f2016-01-07 09:44:44 -0800618 void exitFreeformMode() throws RemoteException;
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700619
Jaewan Kimd98dcab2016-05-03 02:52:18 +0900620 /**
621 * Puts the activity in picture-in-picture mode if the activity supports.
622 * @see android.R.attr#supportsPictureInPicture
623 */
624 void enterPictureInPictureModeIfPossible();
625
Winson Chung4d8681f2017-05-23 16:22:08 -0700626 /** Returns whether the window belongs to the task root. */
627 boolean isTaskRoot();
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700628 }
629
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800630 /**
631 * Callback for clients that want to be aware of where caption draws content.
632 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800633 public interface OnRestrictedCaptionAreaChangedListener {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800634 /**
635 * Called when the area where caption draws content changes.
636 *
637 * @param rect The area where caption content is positioned, relative to the top view.
638 */
639 void onRestrictedCaptionAreaChanged(Rect rect);
640 }
641
Andres Morales910beb82016-02-02 16:19:40 -0800642 /**
643 * Callback for clients that want frame timing information for each
644 * frame rendered by the Window.
645 */
Andres Moralesd908c622016-04-20 13:13:34 -0700646 public interface OnFrameMetricsAvailableListener {
Andres Morales910beb82016-02-02 16:19:40 -0800647 /**
648 * Called when information is available for the previously rendered frame.
649 *
650 * Reports can be dropped if this callback takes too
651 * long to execute, as the report producer cannot wait for the consumer to
652 * complete.
653 *
654 * It is highly recommended that clients copy the passed in FrameMetrics
655 * via {@link FrameMetrics#FrameMetrics(FrameMetrics)} within this method and defer
656 * additional computation or storage to another thread to avoid unnecessarily
657 * dropping reports.
658 *
659 * @param window The {@link Window} on which the frame was displayed.
660 * @param frameMetrics the available metrics. This object is reused on every call
661 * and thus <strong>this reference is not valid outside the scope of this method</strong>.
662 * @param dropCountSinceLastInvocation the number of reports dropped since the last time
663 * this callback was invoked.
664 */
Andres Moralesd908c622016-04-20 13:13:34 -0700665 void onFrameMetricsAvailable(Window window, FrameMetrics frameMetrics,
Andres Morales910beb82016-02-02 16:19:40 -0800666 int dropCountSinceLastInvocation);
667 }
668
669
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800670 public Window(Context context) {
671 mContext = context;
Bryce Leed6e6e722014-11-21 11:08:45 -0800672 mFeatures = mLocalFeatures = getDefaultFeatures(context);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800673 }
674
675 /**
676 * Return the Context this window policy is running in, for retrieving
677 * resources and other information.
678 *
679 * @return Context The Context that was supplied to the constructor.
680 */
681 public final Context getContext() {
682 return mContext;
683 }
684
685 /**
686 * Return the {@link android.R.styleable#Window} attributes from this
687 * window's theme.
688 */
689 public final TypedArray getWindowStyle() {
690 synchronized (this) {
691 if (mWindowStyle == null) {
692 mWindowStyle = mContext.obtainStyledAttributes(
693 com.android.internal.R.styleable.Window);
694 }
695 return mWindowStyle;
696 }
697 }
RoboErik55011652014-07-09 15:05:53 -0700698
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800699 /**
700 * Set the container for this window. If not set, the DecorWindow
701 * operates as a top-level window; otherwise, it negotiates with the
702 * container to display itself appropriately.
703 *
704 * @param container The desired containing Window.
705 */
706 public void setContainer(Window container) {
707 mContainer = container;
708 if (container != null) {
709 // Embedded screens never have a title.
710 mFeatures |= 1<<FEATURE_NO_TITLE;
711 mLocalFeatures |= 1<<FEATURE_NO_TITLE;
712 container.mHasChildren = true;
713 }
714 }
715
716 /**
717 * Return the container for this Window.
718 *
719 * @return Window The containing window, or null if this is a
720 * top-level window.
721 */
722 public final Window getContainer() {
723 return mContainer;
724 }
725
726 public final boolean hasChildren() {
727 return mHasChildren;
728 }
RoboErik55011652014-07-09 15:05:53 -0700729
Dianne Hackborn291905e2010-08-17 15:17:15 -0700730 /** @hide */
731 public final void destroy() {
732 mDestroyed = true;
733 }
734
735 /** @hide */
736 public final boolean isDestroyed() {
737 return mDestroyed;
738 }
739
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800740 /**
741 * Set the window manager for use by this Window to, for example,
742 * display panels. This is <em>not</em> used for displaying the
743 * Window itself -- that must be done by the client.
744 *
Jeff Brown98365d72012-08-19 20:30:52 -0700745 * @param wm The window manager for adding new windows.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800746 */
Romain Guy529b60a2010-08-03 18:05:47 -0700747 public void setWindowManager(WindowManager wm, IBinder appToken, String appName) {
748 setWindowManager(wm, appToken, appName, false);
749 }
750
751 /**
752 * Set the window manager for use by this Window to, for example,
753 * display panels. This is <em>not</em> used for displaying the
754 * Window itself -- that must be done by the client.
755 *
Jeff Brown98365d72012-08-19 20:30:52 -0700756 * @param wm The window manager for adding new windows.
Romain Guy529b60a2010-08-03 18:05:47 -0700757 */
758 public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
759 boolean hardwareAccelerated) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800760 mAppToken = appToken;
761 mAppName = appName;
Jeff Brownd32460c2012-07-20 16:15:36 -0700762 mHardwareAccelerated = hardwareAccelerated
763 || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800764 if (wm == null) {
Jeff Brown98365d72012-08-19 20:30:52 -0700765 wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800766 }
Jeff Brown98365d72012-08-19 20:30:52 -0700767 mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
Dianne Hackborn5fd21692011-06-07 14:09:47 -0700768 }
769
Jeff Brownd32460c2012-07-20 16:15:36 -0700770 void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) {
771 CharSequence curTitle = wp.getTitle();
772 if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
tiger_huangff58e302015-10-13 21:38:19 +0800773 wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
Jeff Brownd32460c2012-07-20 16:15:36 -0700774 if (wp.token == null) {
775 View decor = peekDecorView();
776 if (decor != null) {
777 wp.token = decor.getWindowToken();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800778 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800779 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700780 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700781 final StringBuilder title = new StringBuilder(32);
Jeff Brownd32460c2012-07-20 16:15:36 -0700782 if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700783 title.append("Media");
Jeff Brownd32460c2012-07-20 16:15:36 -0700784 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700785 title.append("MediaOvr");
Jeff Brownd32460c2012-07-20 16:15:36 -0700786 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700787 title.append("Panel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700788 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700789 title.append("SubPanel");
Wale Ogunwale0a4dc222015-04-14 12:58:42 -0700790 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700791 title.append("AboveSubPanel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700792 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700793 title.append("AtchDlg");
Jeff Brownd32460c2012-07-20 16:15:36 -0700794 } else {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700795 title.append(wp.type);
Jeff Brownd32460c2012-07-20 16:15:36 -0700796 }
797 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700798 title.append(":").append(mAppName);
Jeff Brownd32460c2012-07-20 16:15:36 -0700799 }
800 wp.setTitle(title);
Romain Guy529b60a2010-08-03 18:05:47 -0700801 }
tiger_huangff58e302015-10-13 21:38:19 +0800802 } else if (wp.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW &&
803 wp.type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
804 // We don't set the app token to this system window because the life cycles should be
805 // independent. If an app creates a system window and then the app goes to the stopped
806 // state, the system window should not be affected (can still show and receive input
807 // events).
808 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700809 final StringBuilder title = new StringBuilder(32);
810 title.append("Sys").append(wp.type);
tiger_huangff58e302015-10-13 21:38:19 +0800811 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700812 title.append(":").append(mAppName);
tiger_huangff58e302015-10-13 21:38:19 +0800813 }
814 wp.setTitle(title);
815 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700816 } else {
817 if (wp.token == null) {
818 wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
819 }
820 if ((curTitle == null || curTitle.length() == 0)
821 && mAppName != null) {
822 wp.setTitle(mAppName);
823 }
824 }
825 if (wp.packageName == null) {
826 wp.packageName = mContext.getPackageName();
827 }
Robert Carr13678ee2016-04-20 14:04:15 -0700828 if (mHardwareAccelerated ||
829 (mWindowAttributes.flags & FLAG_HARDWARE_ACCELERATED) != 0) {
830 wp.flags |= FLAG_HARDWARE_ACCELERATED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800831 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800832 }
833
834 /**
835 * Return the window manager allowing this Window to display its own
836 * windows.
837 *
838 * @return WindowManager The ViewManager.
839 */
840 public WindowManager getWindowManager() {
841 return mWindowManager;
842 }
843
844 /**
845 * Set the Callback interface for this window, used to intercept key
846 * events and other dynamic operations in the window.
847 *
848 * @param callback The desired Callback interface.
849 */
850 public void setCallback(Callback callback) {
851 mCallback = callback;
852 }
853
854 /**
855 * Return the current Callback interface for this window.
856 */
857 public final Callback getCallback() {
858 return mCallback;
859 }
860
Andres Morales06f5bc72015-12-15 15:21:31 -0800861 /**
862 * Set an observer to collect frame stats for each frame rendererd in this window.
863 *
864 * Must be in hardware rendering mode.
Andres Morales06f5bc72015-12-15 15:21:31 -0800865 */
Andres Moralesd908c622016-04-20 13:13:34 -0700866 public final void addOnFrameMetricsAvailableListener(
867 @NonNull OnFrameMetricsAvailableListener listener,
Andres Morales910beb82016-02-02 16:19:40 -0800868 Handler handler) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800869 final View decorView = getDecorView();
870 if (decorView == null) {
871 throw new IllegalStateException("can't observe a Window without an attached view");
872 }
873
Andres Morales910beb82016-02-02 16:19:40 -0800874 if (listener == null) {
875 throw new NullPointerException("listener cannot be null");
Andres Morales06f5bc72015-12-15 15:21:31 -0800876 }
877
Andres Morales910beb82016-02-02 16:19:40 -0800878 decorView.addFrameMetricsListener(this, listener, handler);
Andres Morales06f5bc72015-12-15 15:21:31 -0800879 }
880
881 /**
882 * Remove observer and stop listening to frame stats for this window.
Andres Morales06f5bc72015-12-15 15:21:31 -0800883 */
Andres Moralesd908c622016-04-20 13:13:34 -0700884 public final void removeOnFrameMetricsAvailableListener(OnFrameMetricsAvailableListener listener) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800885 final View decorView = getDecorView();
886 if (decorView != null) {
Andres Morales910beb82016-02-02 16:19:40 -0800887 getDecorView().removeFrameMetricsListener(listener);
Andres Morales06f5bc72015-12-15 15:21:31 -0800888 }
889 }
890
Adam Powell117b6952014-05-05 18:14:56 -0700891 /** @hide */
892 public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) {
893 mOnWindowDismissedCallback = dcb;
894 }
895
896 /** @hide */
Ned Burns7d6cb912016-12-02 17:25:33 -0500897 public final void dispatchOnWindowDismissed(
898 boolean finishTask, boolean suppressWindowTransition) {
Adam Powell117b6952014-05-05 18:14:56 -0700899 if (mOnWindowDismissedCallback != null) {
Ned Burns7d6cb912016-12-02 17:25:33 -0500900 mOnWindowDismissedCallback.onWindowDismissed(finishTask, suppressWindowTransition);
Adam Powell117b6952014-05-05 18:14:56 -0700901 }
902 }
903
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700904 /** @hide */
Michael Kwan67639a52016-12-16 12:38:10 -0800905 public final void setOnWindowSwipeDismissedCallback(OnWindowSwipeDismissedCallback sdcb) {
906 mOnWindowSwipeDismissedCallback = sdcb;
907 }
908
909 /** @hide */
910 public final void dispatchOnWindowSwipeDismissed() {
911 if (mOnWindowSwipeDismissedCallback != null) {
912 mOnWindowSwipeDismissedCallback.onWindowSwipeDismissed();
913 }
914 }
915
916 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700917 public final void setWindowControllerCallback(WindowControllerCallback wccb) {
918 mWindowControllerCallback = wccb;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700919 }
920
921 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700922 public final WindowControllerCallback getWindowControllerCallback() {
923 return mWindowControllerCallback;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700924 }
925
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800926 /**
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800927 * Set a callback for changes of area where caption will draw its content.
928 *
929 * @param listener Callback that will be called when the area changes.
930 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800931 public final void setRestrictedCaptionAreaListener(OnRestrictedCaptionAreaChangedListener listener) {
932 mOnRestrictedCaptionAreaChangedListener = listener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800933 mRestrictedCaptionAreaRect = listener != null ? new Rect() : null;
934 }
935
936 /**
Dianne Hackborndc8a7f62010-05-10 11:29:34 -0700937 * Take ownership of this window's surface. The window's view hierarchy
938 * will no longer draw into the surface, though it will otherwise continue
939 * to operate (such as for receiving input events). The given SurfaceHolder
940 * callback will be used to tell you about state changes to the surface.
941 */
Dianne Hackbornd76b67c2010-07-13 17:48:30 -0700942 public abstract void takeSurface(SurfaceHolder.Callback2 callback);
RoboErik55011652014-07-09 15:05:53 -0700943
Dianne Hackborndc8a7f62010-05-10 11:29:34 -0700944 /**
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -0700945 * Take ownership of this window's InputQueue. The window will no
946 * longer read and dispatch input events from the queue; it is your
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700947 * responsibility to do so.
948 */
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -0700949 public abstract void takeInputQueue(InputQueue.Callback callback);
RoboErik55011652014-07-09 15:05:53 -0700950
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700951 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800952 * Return whether this window is being displayed with a floating style
953 * (based on the {@link android.R.attr#windowIsFloating} attribute in
954 * the style/theme).
955 *
956 * @return Returns true if the window is configured to be displayed floating
957 * on top of whatever is behind it.
958 */
959 public abstract boolean isFloating();
960
961 /**
962 * Set the width and height layout parameters of the window. The default
Dianne Hackbornc9189352010-12-15 14:57:25 -0800963 * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT
964 * or an absolute value to make a window that is not full-screen.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800965 *
966 * @param width The desired layout width of the window.
967 * @param height The desired layout height of the window.
Dianne Hackbornc9189352010-12-15 14:57:25 -0800968 *
969 * @see ViewGroup.LayoutParams#height
970 * @see ViewGroup.LayoutParams#width
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800971 */
Dianne Hackbornc9189352010-12-15 14:57:25 -0800972 public void setLayout(int width, int height) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800973 final WindowManager.LayoutParams attrs = getAttributes();
974 attrs.width = width;
975 attrs.height = height;
Adrian Roosea562512014-05-05 13:33:03 +0200976 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800977 }
978
979 /**
980 * Set the gravity of the window, as per the Gravity constants. This
981 * controls how the window manager is positioned in the overall window; it
982 * is only useful when using WRAP_CONTENT for the layout width or height.
983 *
984 * @param gravity The desired gravity constant.
985 *
986 * @see Gravity
987 * @see #setLayout
988 */
989 public void setGravity(int gravity)
990 {
991 final WindowManager.LayoutParams attrs = getAttributes();
992 attrs.gravity = gravity;
Adrian Roosea562512014-05-05 13:33:03 +0200993 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800994 }
995
996 /**
997 * Set the type of the window, as per the WindowManager.LayoutParams
998 * types.
999 *
1000 * @param type The new window type (see WindowManager.LayoutParams).
1001 */
1002 public void setType(int type) {
1003 final WindowManager.LayoutParams attrs = getAttributes();
1004 attrs.type = type;
Adrian Roosea562512014-05-05 13:33:03 +02001005 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001006 }
1007
1008 /**
1009 * Set the format of window, as per the PixelFormat types. This overrides
1010 * the default format that is selected by the Window based on its
1011 * window decorations.
1012 *
1013 * @param format The new window format (see PixelFormat). Use
1014 * PixelFormat.UNKNOWN to allow the Window to select
1015 * the format.
1016 *
1017 * @see PixelFormat
1018 */
1019 public void setFormat(int format) {
1020 final WindowManager.LayoutParams attrs = getAttributes();
1021 if (format != PixelFormat.UNKNOWN) {
1022 attrs.format = format;
1023 mHaveWindowFormat = true;
1024 } else {
1025 attrs.format = mDefaultWindowFormat;
1026 mHaveWindowFormat = false;
1027 }
Adrian Roosea562512014-05-05 13:33:03 +02001028 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001029 }
1030
1031 /**
1032 * Specify custom animations to use for the window, as per
1033 * {@link WindowManager.LayoutParams#windowAnimations
1034 * WindowManager.LayoutParams.windowAnimations}. Providing anything besides
1035 * 0 here will override the animations the window would
1036 * normally retrieve from its theme.
1037 */
Tor Norbye417ee5b2015-03-10 20:57:37 -07001038 public void setWindowAnimations(@StyleRes int resId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001039 final WindowManager.LayoutParams attrs = getAttributes();
1040 attrs.windowAnimations = resId;
Adrian Roosea562512014-05-05 13:33:03 +02001041 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001042 }
1043
1044 /**
1045 * Specify an explicit soft input mode to use for the window, as per
1046 * {@link WindowManager.LayoutParams#softInputMode
1047 * WindowManager.LayoutParams.softInputMode}. Providing anything besides
1048 * "unspecified" here will override the input mode the window would
1049 * normally retrieve from its theme.
1050 */
1051 public void setSoftInputMode(int mode) {
1052 final WindowManager.LayoutParams attrs = getAttributes();
1053 if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
1054 attrs.softInputMode = mode;
1055 mHasSoftInputMode = true;
1056 } else {
1057 mHasSoftInputMode = false;
1058 }
Adrian Roosea562512014-05-05 13:33:03 +02001059 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001060 }
RoboErik55011652014-07-09 15:05:53 -07001061
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001062 /**
1063 * Convenience function to set the flag bits as specified in flags, as
1064 * per {@link #setFlags}.
1065 * @param flags The flag bits to be set.
1066 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001067 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001068 */
1069 public void addFlags(int flags) {
1070 setFlags(flags, flags);
1071 }
Adam Lesinski95c42972013-10-02 10:13:27 -07001072
1073 /** @hide */
1074 public void addPrivateFlags(int flags) {
1075 setPrivateFlags(flags, flags);
1076 }
RoboErik55011652014-07-09 15:05:53 -07001077
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001078 /**
1079 * Convenience function to clear the flag bits as specified in flags, as
1080 * per {@link #setFlags}.
1081 * @param flags The flag bits to be cleared.
1082 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001083 * @see #addFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001084 */
1085 public void clearFlags(int flags) {
1086 setFlags(0, flags);
1087 }
1088
1089 /**
1090 * Set the flags of the window, as per the
1091 * {@link WindowManager.LayoutParams WindowManager.LayoutParams}
1092 * flags.
RoboErik55011652014-07-09 15:05:53 -07001093 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001094 * <p>Note that some flags must be set before the window decoration is
1095 * created (by the first call to
1096 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or
1097 * {@link #getDecorView()}:
1098 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and
1099 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These
1100 * will be set for you based on the {@link android.R.attr#windowIsFloating}
1101 * attribute.
1102 *
1103 * @param flags The new window flags (see WindowManager.LayoutParams).
1104 * @param mask Which of the window flag bits to modify.
Christopher Tate193fc072012-06-04 11:27:40 -07001105 * @see #addFlags
1106 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001107 */
1108 public void setFlags(int flags, int mask) {
1109 final WindowManager.LayoutParams attrs = getAttributes();
1110 attrs.flags = (attrs.flags&~mask) | (flags&mask);
1111 mForcedWindowFlags |= mask;
Adrian Roosea562512014-05-05 13:33:03 +02001112 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001113 }
1114
Adam Lesinski95c42972013-10-02 10:13:27 -07001115 private void setPrivateFlags(int flags, int mask) {
1116 final WindowManager.LayoutParams attrs = getAttributes();
1117 attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
Adrian Roosea562512014-05-05 13:33:03 +02001118 dispatchWindowAttributesChanged(attrs);
1119 }
1120
1121 /**
1122 * {@hide}
1123 */
Wale Ogunwale393b1c12014-10-18 16:22:01 -07001124 protected void setNeedsMenuKey(int value) {
1125 final WindowManager.LayoutParams attrs = getAttributes();
1126 attrs.needsMenuKey = value;
1127 dispatchWindowAttributesChanged(attrs);
1128 }
1129
1130 /**
1131 * {@hide}
1132 */
Adrian Roosea562512014-05-05 13:33:03 +02001133 protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) {
Adam Lesinski95c42972013-10-02 10:13:27 -07001134 if (mCallback != null) {
1135 mCallback.onWindowAttributesChanged(attrs);
1136 }
1137 }
1138
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001139 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001140 * <p>Sets the requested color mode of the window. The requested the color mode might
Romain Guy48327452017-01-23 17:03:35 -08001141 * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p>
1142 *
Romain Guyadae59b2017-06-20 14:45:53 -07001143 * <p>The requested color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
Romain Guy48327452017-01-23 17:03:35 -08001144 * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}.</p>
Romain Guyadae59b2017-06-20 14:45:53 -07001145 *
1146 * <p>The requested color mode is not guaranteed to be honored. Please refer to
1147 * {@link #getColorMode()} for more information.</p>
1148 *
1149 * @see #getColorMode()
1150 * @see Display#isWideColorGamut()
1151 * @see Configuration#isScreenWideColorGamut()
Romain Guy48327452017-01-23 17:03:35 -08001152 */
1153 public void setColorMode(@ActivityInfo.ColorMode int colorMode) {
1154 final WindowManager.LayoutParams attrs = getAttributes();
1155 attrs.setColorMode(colorMode);
1156 dispatchWindowAttributesChanged(attrs);
1157 }
1158
1159 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001160 * Returns the requested color mode of the window, one of
1161 * {@link ActivityInfo#COLOR_MODE_DEFAULT}, {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
1162 * or {@link ActivityInfo#COLOR_MODE_HDR}. If {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
1163 * was requested it is possible the window will not be put in wide color gamut mode depending
1164 * on device and display support for that mode. Use {@link #isWideColorGamut} to determine
1165 * if the window is currently in wide color gamut mode.
1166 *
1167 * @see #setColorMode(int)
1168 * @see Display#isWideColorGamut()
1169 * @see Configuration#isScreenWideColorGamut()
Romain Guy48327452017-01-23 17:03:35 -08001170 */
1171 @ActivityInfo.ColorMode
1172 public int getColorMode() {
1173 return getAttributes().getColorMode();
1174 }
1175
1176 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001177 * Returns true if this window's color mode is {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT},
1178 * the display has a wide color gamut and this device supports wide color gamut rendering.
1179 *
1180 * @see Display#isWideColorGamut()
1181 * @see Configuration#isScreenWideColorGamut()
1182 */
1183 public boolean isWideColorGamut() {
1184 return getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT
1185 && getContext().getResources().getConfiguration().isScreenWideColorGamut();
1186 }
1187
1188 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001189 * Set the amount of dim behind the window when using
1190 * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides
1191 * the default dim amount of that is selected by the Window based on
1192 * its theme.
1193 *
1194 * @param amount The new dim amount, from 0 for no dim to 1 for full dim.
1195 */
1196 public void setDimAmount(float amount) {
1197 final WindowManager.LayoutParams attrs = getAttributes();
1198 attrs.dimAmount = amount;
1199 mHaveDimAmount = true;
Adrian Roosea562512014-05-05 13:33:03 +02001200 dispatchWindowAttributesChanged(attrs);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001201 }
1202
1203 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001204 * Specify custom window attributes. <strong>PLEASE NOTE:</strong> the
1205 * layout params you give here should generally be from values previously
1206 * retrieved with {@link #getAttributes()}; you probably do not want to
1207 * blindly create and apply your own, since this will blow away any values
1208 * set by the framework that you are not interested in.
1209 *
1210 * @param a The new window attributes, which will completely override any
1211 * current values.
1212 */
1213 public void setAttributes(WindowManager.LayoutParams a) {
1214 mWindowAttributes.copyFrom(a);
Adrian Roosea562512014-05-05 13:33:03 +02001215 dispatchWindowAttributesChanged(mWindowAttributes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001216 }
1217
1218 /**
1219 * Retrieve the current window attributes associated with this panel.
1220 *
1221 * @return WindowManager.LayoutParams Either the existing window
1222 * attributes object, or a freshly created one if there is none.
1223 */
1224 public final WindowManager.LayoutParams getAttributes() {
1225 return mWindowAttributes;
1226 }
1227
1228 /**
1229 * Return the window flags that have been explicitly set by the client,
1230 * so will not be modified by {@link #getDecorView}.
1231 */
1232 protected final int getForcedWindowFlags() {
1233 return mForcedWindowFlags;
1234 }
RoboErik55011652014-07-09 15:05:53 -07001235
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001236 /**
1237 * Has the app specified their own soft input mode?
1238 */
1239 protected final boolean hasSoftInputMode() {
1240 return mHasSoftInputMode;
1241 }
RoboErik55011652014-07-09 15:05:53 -07001242
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001243 /** @hide */
1244 public void setCloseOnTouchOutside(boolean close) {
1245 mCloseOnTouchOutside = close;
1246 mSetCloseOnTouchOutside = true;
1247 }
RoboErik55011652014-07-09 15:05:53 -07001248
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001249 /** @hide */
Dianne Hackbornef575752011-01-18 17:35:17 -08001250 public void setCloseOnTouchOutsideIfNotSet(boolean close) {
1251 if (!mSetCloseOnTouchOutside) {
1252 mCloseOnTouchOutside = close;
1253 mSetCloseOnTouchOutside = true;
1254 }
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001255 }
RoboErik55011652014-07-09 15:05:53 -07001256
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001257 /** @hide */
Filip Gruszczynskife568352015-01-05 10:41:29 -08001258 @SystemApi
1259 public void setDisableWallpaperTouchEvents(boolean disable) {
1260 setPrivateFlags(disable
1261 ? WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS : 0,
1262 WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS);
1263 }
1264
1265 /** @hide */
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001266 public abstract void alwaysReadCloseOnTouchAttr();
RoboErik55011652014-07-09 15:05:53 -07001267
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001268 /** @hide */
1269 public boolean shouldCloseOnTouch(Context context, MotionEvent event) {
Michael Wrightddec8fb2017-06-16 18:36:26 +01001270 final boolean isOutside =
1271 event.getAction() == MotionEvent.ACTION_DOWN && isOutOfBounds(context, event)
1272 || event.getAction() == MotionEvent.ACTION_OUTSIDE;
1273 if (mCloseOnTouchOutside && peekDecorView() != null && isOutside) {
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001274 return true;
1275 }
1276 return false;
1277 }
RoboErik55011652014-07-09 15:05:53 -07001278
Ruchi Kandoi43e38de2016-04-14 19:34:53 -07001279 /* Sets the Sustained Performance requirement for the calling window.
1280 * @param enable disables or enables the mode.
1281 */
1282 public void setSustainedPerformanceMode(boolean enable) {
1283 setPrivateFlags(enable
1284 ? WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE : 0,
1285 WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE);
1286 }
1287
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001288 private boolean isOutOfBounds(Context context, MotionEvent event) {
1289 final int x = (int) event.getX();
1290 final int y = (int) event.getY();
1291 final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
1292 final View decorView = getDecorView();
1293 return (x < -slop) || (y < -slop)
1294 || (x > (decorView.getWidth()+slop))
1295 || (y > (decorView.getHeight()+slop));
1296 }
RoboErik55011652014-07-09 15:05:53 -07001297
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001298 /**
1299 * Enable extended screen features. This must be called before
1300 * setContentView(). May be called as many times as desired as long as it
1301 * is before setContentView(). If not called, no extended features
1302 * will be available. You can not turn off a feature once it is requested.
1303 * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
1304 *
1305 * @param featureId The desired features, defined as constants by Window.
1306 * @return The features that are now set.
1307 */
1308 public boolean requestFeature(int featureId) {
1309 final int flag = 1<<featureId;
1310 mFeatures |= flag;
1311 mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
1312 return (mFeatures&flag) != 0;
1313 }
1314
Adam Powellf4a6ec42010-08-24 14:18:10 -07001315 /**
1316 * @hide Used internally to help resolve conflicting features.
1317 */
1318 protected void removeFeature(int featureId) {
1319 final int flag = 1<<featureId;
1320 mFeatures &= ~flag;
1321 mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag);
1322 }
1323
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001324 public final void makeActive() {
1325 if (mContainer != null) {
1326 if (mContainer.mActiveChild != null) {
1327 mContainer.mActiveChild.mIsActive = false;
1328 }
1329 mContainer.mActiveChild = this;
1330 }
1331 mIsActive = true;
1332 onActive();
1333 }
1334
1335 public final boolean isActive()
1336 {
1337 return mIsActive;
1338 }
1339
1340 /**
Alan Viverettedb7423c2017-03-31 13:13:58 -04001341 * Finds a view that was identified by the {@code android:id} XML attribute
Chris Craik6faa9e52018-01-11 10:46:10 -08001342 * that was processed in {@link android.app.Activity#onCreate}.
1343 * <p>
1344 * This will implicitly call {@link #getDecorView} with all of the associated side-effects.
Alan Viverettedb7423c2017-03-31 13:13:58 -04001345 * <p>
1346 * <strong>Note:</strong> In most cases -- depending on compiler support --
1347 * the resulting view is automatically cast to the target class type. If
1348 * the target class type is unconstrained, an explicit cast may be
1349 * necessary.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001350 *
Alan Viverettedb7423c2017-03-31 13:13:58 -04001351 * @param id the ID to search for
1352 * @return a view with given ID if found, or {@code null} otherwise
1353 * @see View#findViewById(int)
Chris Craik6faa9e52018-01-11 10:46:10 -08001354 * @see Window#requireViewById(int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001355 */
Scott Kennedyc0519552015-02-11 15:33:10 -08001356 @Nullable
Alan Viverettedb7423c2017-03-31 13:13:58 -04001357 public <T extends View> T findViewById(@IdRes int id) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001358 return getDecorView().findViewById(id);
1359 }
Chris Craik6faa9e52018-01-11 10:46:10 -08001360 /**
1361 * Finds a view that was identified by the {@code android:id} XML attribute
1362 * that was processed in {@link android.app.Activity#onCreate}, or throws an
1363 * IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy.
1364 * <p>
1365 * <strong>Note:</strong> In most cases -- depending on compiler support --
1366 * the resulting view is automatically cast to the target class type. If
1367 * the target class type is unconstrained, an explicit cast may be
1368 * necessary.
1369 *
1370 * @param id the ID to search for
1371 * @return a view with given ID
1372 * @see View#requireViewById(int)
1373 * @see Window#findViewById(int)
1374 */
1375 @NonNull
1376 public final <T extends View> T requireViewById(@IdRes int id) {
1377 T view = findViewById(id);
1378 if (view == null) {
1379 throw new IllegalArgumentException("ID does not reference a View inside this Window");
1380 }
1381 return view;
1382 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001383
1384 /**
1385 * Convenience for
1386 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1387 * to set the screen content from a layout resource. The resource will be
1388 * inflated, adding all top-level views to the screen.
1389 *
1390 * @param layoutResID Resource ID to be inflated.
1391 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1392 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001393 public abstract void setContentView(@LayoutRes int layoutResID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001394
1395 /**
1396 * Convenience for
1397 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1398 * set the screen content to an explicit view. This view is placed
1399 * directly into the screen's view hierarchy. It can itself be a complex
1400 * view hierarhcy.
1401 *
1402 * @param view The desired content to display.
1403 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1404 */
1405 public abstract void setContentView(View view);
1406
1407 /**
1408 * Set the screen content to an explicit view. This view is placed
1409 * directly into the screen's view hierarchy. It can itself be a complex
1410 * view hierarchy.
1411 *
1412 * <p>Note that calling this function "locks in" various characteristics
1413 * of the window that can not, from this point forward, be changed: the
1414 * features that have been requested with {@link #requestFeature(int)},
George Mountc3a043c2015-02-04 14:37:04 -08001415 * and certain window flags as described in {@link #setFlags(int, int)}.</p>
1416 *
1417 * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's
1418 * TransitionManager will be used to animate content from the current
1419 * content View to view.</p>
RoboErik55011652014-07-09 15:05:53 -07001420 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001421 * @param view The desired content to display.
1422 * @param params Layout parameters for the view.
George Mountc3a043c2015-02-04 14:37:04 -08001423 * @see #getTransitionManager()
1424 * @see #setTransitionManager(android.transition.TransitionManager)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001425 */
1426 public abstract void setContentView(View view, ViewGroup.LayoutParams params);
1427
1428 /**
1429 * Variation on
1430 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1431 * to add an additional content view to the screen. Added after any existing
1432 * ones in the screen -- existing views are NOT removed.
1433 *
1434 * @param view The desired content to display.
1435 * @param params Layout parameters for the view.
1436 */
1437 public abstract void addContentView(View view, ViewGroup.LayoutParams params);
1438
1439 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001440 * Remove the view that was used as the screen content.
1441 *
1442 * @hide
1443 */
1444 public abstract void clearContentView();
1445
1446 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001447 * Return the view in this Window that currently has focus, or null if
1448 * there are none. Note that this does not look in any containing
1449 * Window.
1450 *
1451 * @return View The current View with focus or null.
1452 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001453 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001454 public abstract View getCurrentFocus();
1455
1456 /**
1457 * Quick access to the {@link LayoutInflater} instance that this Window
1458 * retrieved from its Context.
1459 *
1460 * @return LayoutInflater The shared LayoutInflater.
1461 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001462 @NonNull
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001463 public abstract LayoutInflater getLayoutInflater();
1464
1465 public abstract void setTitle(CharSequence title);
1466
Alan Viverette2525d9c2013-11-15 14:42:19 -08001467 @Deprecated
Tor Norbye80756e32015-03-02 09:39:27 -08001468 public abstract void setTitleColor(@ColorInt int textColor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001469
1470 public abstract void openPanel(int featureId, KeyEvent event);
1471
1472 public abstract void closePanel(int featureId);
1473
1474 public abstract void togglePanel(int featureId, KeyEvent event);
1475
Dianne Hackbornb31e84bc2010-06-08 18:04:35 -07001476 public abstract void invalidatePanelMenu(int featureId);
RoboErik55011652014-07-09 15:05:53 -07001477
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001478 public abstract boolean performPanelShortcut(int featureId,
1479 int keyCode,
1480 KeyEvent event,
1481 int flags);
1482 public abstract boolean performPanelIdentifierAction(int featureId,
1483 int id,
1484 int flags);
1485
1486 public abstract void closeAllPanels();
1487
1488 public abstract boolean performContextMenuIdentifierAction(int id, int flags);
1489
1490 /**
1491 * Should be called when the configuration is changed.
RoboErik55011652014-07-09 15:05:53 -07001492 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001493 * @param newConfig The new configuration.
1494 */
1495 public abstract void onConfigurationChanged(Configuration newConfig);
RoboErik55011652014-07-09 15:05:53 -07001496
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001497 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001498 * Sets the window elevation.
Alan Viverette71922de2015-01-12 16:14:02 -08001499 * <p>
1500 * Changes to this property take effect immediately and will cause the
1501 * window surface to be recreated. This is an expensive operation and as a
1502 * result, this property should not be animated.
Alan Viverette79c067c52014-10-29 14:27:47 -07001503 *
1504 * @param elevation The window elevation.
1505 * @see View#setElevation(float)
1506 * @see android.R.styleable#Window_windowElevation
1507 */
1508 public void setElevation(float elevation) {}
1509
1510 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001511 * Gets the window elevation.
1512 *
1513 * @hide
1514 */
1515 public float getElevation() {
1516 return 0.0f;
1517 }
1518
1519 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001520 * Sets whether window content should be clipped to the outline of the
1521 * window background.
1522 *
1523 * @param clipToOutline Whether window content should be clipped to the
1524 * outline of the window background.
1525 * @see View#setClipToOutline(boolean)
1526 * @see android.R.styleable#Window_windowClipToOutline
1527 */
1528 public void setClipToOutline(boolean clipToOutline) {}
1529
1530 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001531 * Change the background of this window to a Drawable resource. Setting the
1532 * background to null will make the window be opaque. To make the window
1533 * transparent, you can use an empty drawable (for instance a ColorDrawable
1534 * with the color 0 or the system drawable android:drawable/empty.)
RoboErik55011652014-07-09 15:05:53 -07001535 *
Alan Viverette79c067c52014-10-29 14:27:47 -07001536 * @param resId The resource identifier of a drawable resource which will
1537 * be installed as the new background.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001538 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001539 public void setBackgroundDrawableResource(@DrawableRes int resId) {
Alan Viverette79c067c52014-10-29 14:27:47 -07001540 setBackgroundDrawable(mContext.getDrawable(resId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001541 }
1542
1543 /**
1544 * Change the background of this window to a custom Drawable. Setting the
1545 * background to null will make the window be opaque. To make the window
1546 * transparent, you can use an empty drawable (for instance a ColorDrawable
1547 * with the color 0 or the system drawable android:drawable/empty.)
1548 *
1549 * @param drawable The new Drawable to use for this window's background.
1550 */
1551 public abstract void setBackgroundDrawable(Drawable drawable);
1552
1553 /**
1554 * Set the value for a drawable feature of this window, from a resource
Tor Norbye7b9c9122013-05-30 16:48:33 -07001555 * identifier. You must have called requestFeature(featureId) before
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001556 * calling this function.
1557 *
1558 * @see android.content.res.Resources#getDrawable(int)
1559 *
1560 * @param featureId The desired drawable feature to change, defined as a
1561 * constant by Window.
1562 * @param resId Resource identifier of the desired image.
1563 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001564 public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001565
1566 /**
1567 * Set the value for a drawable feature of this window, from a URI. You
1568 * must have called requestFeature(featureId) before calling this
1569 * function.
1570 *
1571 * <p>The only URI currently supported is "content:", specifying an image
1572 * in a content provider.
1573 *
1574 * @see android.widget.ImageView#setImageURI
1575 *
1576 * @param featureId The desired drawable feature to change. Features are
1577 * constants defined by Window.
1578 * @param uri The desired URI.
1579 */
1580 public abstract void setFeatureDrawableUri(int featureId, Uri uri);
1581
1582 /**
1583 * Set an explicit Drawable value for feature of this window. You must
1584 * have called requestFeature(featureId) before calling this function.
1585 *
Alan Viverette9678e342014-10-24 15:23:58 -07001586 * @param featureId The desired drawable feature to change. Features are
1587 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001588 * @param drawable A Drawable object to display.
1589 */
1590 public abstract void setFeatureDrawable(int featureId, Drawable drawable);
1591
1592 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001593 * Set a custom alpha value for the given drawable feature, controlling how
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001594 * much the background is visible through it.
1595 *
Alan Viverette9678e342014-10-24 15:23:58 -07001596 * @param featureId The desired drawable feature to change. Features are
1597 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001598 * @param alpha The alpha amount, 0 is completely transparent and 255 is
1599 * completely opaque.
1600 */
1601 public abstract void setFeatureDrawableAlpha(int featureId, int alpha);
1602
1603 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001604 * Set the integer value for a feature. The range of the value depends on
1605 * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from
1606 * 0 to 10000. At 10000 the progress is complete and the indicator hidden.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001607 *
Alan Viverette9678e342014-10-24 15:23:58 -07001608 * @param featureId The desired feature to change. Features are constants
1609 * defined by Window.
1610 * @param value The value for the feature. The interpretation of this
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001611 * value is feature-specific.
1612 */
1613 public abstract void setFeatureInt(int featureId, int value);
1614
1615 /**
1616 * Request that key events come to this activity. Use this if your
1617 * activity has no views with focus, but the activity still wants
1618 * a chance to process key events.
1619 */
1620 public abstract void takeKeyEvents(boolean get);
1621
1622 /**
1623 * Used by custom windows, such as Dialog, to pass the key press event
1624 * further down the view hierarchy. Application developers should
1625 * not need to implement or call this.
1626 *
1627 */
1628 public abstract boolean superDispatchKeyEvent(KeyEvent event);
1629
1630 /**
Jeff Brown64da12a2011-01-04 19:57:47 -08001631 * Used by custom windows, such as Dialog, to pass the key shortcut press event
1632 * further down the view hierarchy. Application developers should
1633 * not need to implement or call this.
1634 *
1635 */
1636 public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event);
1637
1638 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001639 * Used by custom windows, such as Dialog, to pass the touch screen event
1640 * further down the view hierarchy. Application developers should
1641 * not need to implement or call this.
1642 *
1643 */
1644 public abstract boolean superDispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001645
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001646 /**
1647 * Used by custom windows, such as Dialog, to pass the trackball event
1648 * further down the view hierarchy. Application developers should
1649 * not need to implement or call this.
1650 *
1651 */
1652 public abstract boolean superDispatchTrackballEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001653
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001654 /**
Jeff Browncb1404e2011-01-15 18:14:15 -08001655 * Used by custom windows, such as Dialog, to pass the generic motion event
1656 * further down the view hierarchy. Application developers should
1657 * not need to implement or call this.
1658 *
1659 */
1660 public abstract boolean superDispatchGenericMotionEvent(MotionEvent event);
1661
1662 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001663 * Retrieve the top-level window decor view (containing the standard
1664 * window frame/decorations and the client's content inside of that), which
1665 * can be added as a window to the window manager.
RoboErik55011652014-07-09 15:05:53 -07001666 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001667 * <p><em>Note that calling this function for the first time "locks in"
1668 * various window characteristics as described in
1669 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p>
RoboErik55011652014-07-09 15:05:53 -07001670 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001671 * @return Returns the top-level window decor view.
1672 */
1673 public abstract View getDecorView();
1674
1675 /**
1676 * Retrieve the current decor view, but only if it has already been created;
1677 * otherwise returns null.
RoboErik55011652014-07-09 15:05:53 -07001678 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001679 * @return Returns the top-level window decor or null.
1680 * @see #getDecorView
1681 */
1682 public abstract View peekDecorView();
1683
1684 public abstract Bundle saveHierarchyState();
RoboErik55011652014-07-09 15:05:53 -07001685
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001686 public abstract void restoreHierarchyState(Bundle savedInstanceState);
RoboErik55011652014-07-09 15:05:53 -07001687
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001688 protected abstract void onActive();
1689
1690 /**
1691 * Return the feature bits that are enabled. This is the set of features
1692 * that were given to requestFeature(), and are being handled by this
1693 * Window itself or its container. That is, it is the set of
1694 * requested features that you can actually use.
1695 *
1696 * <p>To do: add a public version of this API that allows you to check for
1697 * features by their feature ID.
1698 *
1699 * @return int The feature bits.
1700 */
1701 protected final int getFeatures()
1702 {
1703 return mFeatures;
1704 }
RoboErik55011652014-07-09 15:05:53 -07001705
Adam Powell33b97432010-04-20 10:01:14 -07001706 /**
Bryce Leed6e6e722014-11-21 11:08:45 -08001707 * Return the feature bits set by default on a window.
1708 * @param context The context used to access resources
1709 */
1710 public static int getDefaultFeatures(Context context) {
1711 int features = 0;
1712
1713 final Resources res = context.getResources();
1714 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
1715 features |= 1 << FEATURE_OPTIONS_PANEL;
1716 }
1717
1718 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
1719 features |= 1 << FEATURE_CONTEXT_MENU;
1720 }
1721
1722 return features;
1723 }
1724
1725 /**
Adam Powell33b97432010-04-20 10:01:14 -07001726 * Query for the availability of a certain feature.
RoboErik55011652014-07-09 15:05:53 -07001727 *
Adam Powell33b97432010-04-20 10:01:14 -07001728 * @param feature The feature ID to check
1729 * @return true if the feature is enabled, false otherwise.
1730 */
1731 public boolean hasFeature(int feature) {
1732 return (getFeatures() & (1 << feature)) != 0;
1733 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001734
1735 /**
1736 * Return the feature bits that are being implemented by this Window.
1737 * This is the set of features that were given to requestFeature(), and are
1738 * being handled by only this Window itself, not by its containers.
1739 *
1740 * @return int The feature bits.
1741 */
1742 protected final int getLocalFeatures()
1743 {
1744 return mLocalFeatures;
1745 }
1746
1747 /**
1748 * Set the default format of window, as per the PixelFormat types. This
1749 * is the format that will be used unless the client specifies in explicit
1750 * format with setFormat();
1751 *
1752 * @param format The new window format (see PixelFormat).
1753 *
1754 * @see #setFormat
1755 * @see PixelFormat
1756 */
1757 protected void setDefaultWindowFormat(int format) {
1758 mDefaultWindowFormat = format;
1759 if (!mHaveWindowFormat) {
1760 final WindowManager.LayoutParams attrs = getAttributes();
1761 attrs.format = format;
Adrian Roosea562512014-05-05 13:33:03 +02001762 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001763 }
1764 }
1765
Dianne Hackborn661cd522011-08-22 00:26:20 -07001766 /** @hide */
1767 protected boolean haveDimAmount() {
1768 return mHaveDimAmount;
1769 }
1770
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001771 public abstract void setChildDrawable(int featureId, Drawable drawable);
1772
1773 public abstract void setChildInt(int featureId, int value);
1774
1775 /**
1776 * Is a keypress one of the defined shortcut keys for this window.
1777 * @param keyCode the key code from {@link android.view.KeyEvent} to check.
1778 * @param event the {@link android.view.KeyEvent} to use to help check.
1779 */
1780 public abstract boolean isShortcutKey(int keyCode, KeyEvent event);
RoboErik55011652014-07-09 15:05:53 -07001781
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001782 /**
RoboErik55011652014-07-09 15:05:53 -07001783 * @see android.app.Activity#setVolumeControlStream(int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001784 */
1785 public abstract void setVolumeControlStream(int streamType);
1786
1787 /**
1788 * @see android.app.Activity#getVolumeControlStream()
1789 */
1790 public abstract int getVolumeControlStream();
Adam Powell269248d2011-08-02 10:26:54 -07001791
1792 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001793 * Sets a {@link MediaController} to send media keys and volume changes to.
1794 * If set, this should be preferred for all media keys and volume requests
1795 * sent to this window.
1796 *
1797 * @param controller The controller for the session which should receive
1798 * media keys and volume changes.
RoboErik55011652014-07-09 15:05:53 -07001799 * @see android.app.Activity#setMediaController(android.media.session.MediaController)
1800 */
1801 public void setMediaController(MediaController controller) {
1802 }
1803
1804 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001805 * Gets the {@link MediaController} that was previously set.
1806 *
1807 * @return The controller which should receive events.
1808 * @see #setMediaController(android.media.session.MediaController)
RoboErik55011652014-07-09 15:05:53 -07001809 * @see android.app.Activity#getMediaController()
1810 */
1811 public MediaController getMediaController() {
1812 return null;
1813 }
1814
1815 /**
Adam Powell269248d2011-08-02 10:26:54 -07001816 * Set extra options that will influence the UI for this window.
1817 * @param uiOptions Flags specifying extra options for this window.
1818 */
1819 public void setUiOptions(int uiOptions) { }
Adam Powelle43fca92011-08-16 12:57:01 -07001820
1821 /**
1822 * Set extra options that will influence the UI for this window.
1823 * Only the bits filtered by mask will be modified.
1824 * @param uiOptions Flags specifying extra options for this window.
1825 * @param mask Flags specifying which options should be modified. Others will remain unchanged.
1826 */
1827 public void setUiOptions(int uiOptions, int mask) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001828
1829 /**
1830 * Set the primary icon for this window.
1831 *
1832 * @param resId resource ID of a drawable to set
1833 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001834 public void setIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001835
1836 /**
1837 * Set the default icon for this window.
1838 * This will be overridden by any other icon set operation which could come from the
1839 * theme or another explicit set.
1840 *
1841 * @hide
1842 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001843 public void setDefaultIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001844
1845 /**
1846 * Set the logo for this window. A logo is often shown in place of an
1847 * {@link #setIcon(int) icon} but is generally wider and communicates window title information
1848 * as well.
1849 *
1850 * @param resId resource ID of a drawable to set
1851 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001852 public void setLogo(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001853
1854 /**
1855 * Set the default logo for this window.
1856 * This will be overridden by any other logo set operation which could come from the
1857 * theme or another explicit set.
1858 *
1859 * @hide
1860 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001861 public void setDefaultLogo(@DrawableRes int resId) { }
keunyoung30f420f2013-08-02 14:23:10 -07001862
1863 /**
1864 * Set focus locally. The window should have the
1865 * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.
1866 * @param hasFocus Whether this window has focus or not.
1867 * @param inTouchMode Whether this window is in touch mode or not.
1868 */
1869 public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { }
1870
1871 /**
1872 * Inject an event to window locally.
1873 * @param event A key or touch event to inject to this window.
1874 */
1875 public void injectInputEvent(InputEvent event) { }
Adam Powellcfbe9be2013-11-06 14:58:58 -08001876
1877 /**
1878 * Retrieve the {@link TransitionManager} responsible for for default transitions
1879 * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1880 *
1881 * <p>This method will return non-null after content has been initialized (e.g. by using
1882 * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p>
1883 *
1884 * @return This window's content TransitionManager or null if none is set.
George Mountc3a043c2015-02-04 14:37:04 -08001885 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08001886 */
1887 public TransitionManager getTransitionManager() {
1888 return null;
1889 }
1890
1891 /**
1892 * Set the {@link TransitionManager} to use for default transitions in this window.
1893 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1894 *
1895 * @param tm The TransitionManager to use for scene changes.
George Mountc3a043c2015-02-04 14:37:04 -08001896 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08001897 */
1898 public void setTransitionManager(TransitionManager tm) {
1899 throw new UnsupportedOperationException();
1900 }
1901
1902 /**
1903 * Retrieve the {@link Scene} representing this window's current content.
1904 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1905 *
1906 * <p>This method will return null if the current content is not represented by a Scene.</p>
1907 *
1908 * @return Current Scene being shown or null
1909 */
1910 public Scene getContentScene() {
1911 return null;
1912 }
1913
1914 /**
George Mount31a21722014-03-24 17:44:36 -07001915 * Sets the Transition that will be used to move Views into the initial scene. The entering
1916 * Views will be those that are regular Views or ViewGroups that have
1917 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1918 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1919 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1920 * entering Views will remain unaffected.
George Mountc03da0e2014-08-22 17:04:02 -07001921 *
George Mount31a21722014-03-24 17:44:36 -07001922 * @param transition The Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001923 * @attr ref android.R.styleable#Window_windowEnterTransition
Adam Powellcfbe9be2013-11-06 14:58:58 -08001924 */
George Mount31a21722014-03-24 17:44:36 -07001925 public void setEnterTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08001926
1927 /**
George Mount68f96d82014-07-31 13:13:10 -07001928 * Sets the Transition that will be used to move Views out of the scene when the Window is
1929 * preparing to close, for example after a call to
1930 * {@link android.app.Activity#finishAfterTransition()}. The exiting
1931 * Views will be those that are regular Views or ViewGroups that have
1932 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1933 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1934 * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null,
1935 * entering Views will remain unaffected. If nothing is set, the default will be to
1936 * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
George Mountc03da0e2014-08-22 17:04:02 -07001937 *
George Mount68f96d82014-07-31 13:13:10 -07001938 * @param transition The Transition to use to move Views out of the Scene when the Window
1939 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07001940 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07001941 */
1942 public void setReturnTransition(Transition transition) {}
1943
1944 /**
George Mount31a21722014-03-24 17:44:36 -07001945 * Sets the Transition that will be used to move Views out of the scene when starting a
1946 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1947 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1948 * {@link android.transition.Visibility} as exiting is governed by changing visibility
1949 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07001950 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001951 *
George Mount31a21722014-03-24 17:44:36 -07001952 * @param transition The Transition to use to move Views out of the scene when calling a
1953 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07001954 * @attr ref android.R.styleable#Window_windowExitTransition
George Mount0a778ed2013-12-13 13:35:36 -08001955 */
George Mount31a21722014-03-24 17:44:36 -07001956 public void setExitTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08001957
1958 /**
George Mount68f96d82014-07-31 13:13:10 -07001959 * Sets the Transition that will be used to move Views in to the scene when returning from
1960 * a previously-started Activity. The entering Views will be those that are regular Views
1961 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1962 * will extend {@link android.transition.Visibility} as exiting is governed by changing
1963 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
1964 * the views will remain unaffected. If nothing is set, the default will be to use the same
1965 * transition as {@link #setExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07001966 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001967 *
George Mount68f96d82014-07-31 13:13:10 -07001968 * @param transition The Transition to use to move Views into the scene when reentering from a
1969 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07001970 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07001971 */
1972 public void setReenterTransition(Transition transition) {}
1973
1974 /**
George Mount31a21722014-03-24 17:44:36 -07001975 * Returns the transition used to move Views into the initial scene. The entering
1976 * Views will be those that are regular Views or ViewGroups that have
1977 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1978 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1979 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
George Mount9826f632014-09-11 08:50:09 -07001980 * entering Views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07001981 *
1982 * @return the Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001983 * @attr ref android.R.styleable#Window_windowEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08001984 */
George Mount31a21722014-03-24 17:44:36 -07001985 public Transition getEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08001986
1987 /**
Chet Haaseb64e777f2016-12-09 07:17:10 -08001988 * Returns the Transition that will be used to move Views out of the scene when the Window is
George Mount68f96d82014-07-31 13:13:10 -07001989 * preparing to close, for example after a call to
1990 * {@link android.app.Activity#finishAfterTransition()}. The exiting
1991 * Views will be those that are regular Views or ViewGroups that have
1992 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1993 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1994 * {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mountc03da0e2014-08-22 17:04:02 -07001995 *
George Mount68f96d82014-07-31 13:13:10 -07001996 * @return The Transition to use to move Views out of the Scene when the Window
1997 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07001998 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07001999 */
2000 public Transition getReturnTransition() { return null; }
2001
2002 /**
George Mount31a21722014-03-24 17:44:36 -07002003 * Returns the Transition that will be used to move Views out of the scene when starting a
2004 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
2005 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2006 * {@link android.transition.Visibility} as exiting is governed by changing visibility
2007 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07002008 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002009 *
George Mount31a21722014-03-24 17:44:36 -07002010 * @return the Transition to use to move Views out of the scene when calling a
2011 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002012 * @attr ref android.R.styleable#Window_windowExitTransition
George Mountcb4b7d92014-02-25 10:47:55 -08002013 */
George Mount31a21722014-03-24 17:44:36 -07002014 public Transition getExitTransition() { return null; }
George Mount0a778ed2013-12-13 13:35:36 -08002015
2016 /**
George Mount68f96d82014-07-31 13:13:10 -07002017 * Returns the Transition that will be used to move Views in to the scene when returning from
2018 * a previously-started Activity. The entering Views will be those that are regular Views
2019 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
2020 * will extend {@link android.transition.Visibility} as exiting is governed by changing
2021 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mount9826f632014-09-11 08:50:09 -07002022 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002023 *
George Mount68f96d82014-07-31 13:13:10 -07002024 * @return The Transition to use to move Views into the scene when reentering from a
2025 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002026 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002027 */
2028 public Transition getReenterTransition() { return null; }
2029
2030 /**
George Mount31a21722014-03-24 17:44:36 -07002031 * Sets the Transition that will be used for shared elements transferred into the content
2032 * Scene. Typical Transitions will affect size and location, such as
George Mount990205e2014-06-24 09:36:18 -07002033 * {@link android.transition.ChangeBounds}. A null
George Mount31a21722014-03-24 17:44:36 -07002034 * value will cause transferred shared elements to blink to the final position.
George Mount9826f632014-09-11 08:50:09 -07002035 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002036 *
George Mount31a21722014-03-24 17:44:36 -07002037 * @param transition The Transition to use for shared elements transferred into the content
2038 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002039 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08002040 */
George Mount31a21722014-03-24 17:44:36 -07002041 public void setSharedElementEnterTransition(Transition transition) {}
George Mounte1803372014-02-26 19:00:52 +00002042
2043 /**
George Mount68f96d82014-07-31 13:13:10 -07002044 * Sets the Transition that will be used for shared elements transferred back to a
2045 * calling Activity. Typical Transitions will affect size and location, such as
2046 * {@link android.transition.ChangeBounds}. A null
2047 * value will cause transferred shared elements to blink to the final position.
2048 * If no value is set, the default will be to use the same value as
2049 * {@link #setSharedElementEnterTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07002050 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002051 *
George Mount68f96d82014-07-31 13:13:10 -07002052 * @param transition The Transition to use for shared elements transferred out of the content
2053 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002054 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002055 */
2056 public void setSharedElementReturnTransition(Transition transition) {}
2057
2058 /**
George Mount31a21722014-03-24 17:44:36 -07002059 * Returns the Transition that will be used for shared elements transferred into the content
George Mount9826f632014-09-11 08:50:09 -07002060 * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002061 *
George Mount31a21722014-03-24 17:44:36 -07002062 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002063 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mountcb4b7d92014-02-25 10:47:55 -08002064 */
George Mount31a21722014-03-24 17:44:36 -07002065 public Transition getSharedElementEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08002066
2067 /**
George Mount68f96d82014-07-31 13:13:10 -07002068 * Returns the Transition that will be used for shared elements transferred back to a
George Mount9826f632014-09-11 08:50:09 -07002069 * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002070 *
George Mount68f96d82014-07-31 13:13:10 -07002071 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002072 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002073 */
2074 public Transition getSharedElementReturnTransition() { return null; }
2075
2076 /**
George Mount31a21722014-03-24 17:44:36 -07002077 * Sets the Transition that will be used for shared elements after starting a new Activity
2078 * before the shared elements are transferred to the called Activity. If the shared elements
2079 * must animate during the exit transition, this Transition should be used. Upon completion,
2080 * the shared elements may be transferred to the started Activity.
George Mount9826f632014-09-11 08:50:09 -07002081 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002082 *
George Mount31a21722014-03-24 17:44:36 -07002083 * @param transition The Transition to use for shared elements in the launching Window
2084 * prior to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07002085 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mounte1803372014-02-26 19:00:52 +00002086 */
George Mount31a21722014-03-24 17:44:36 -07002087 public void setSharedElementExitTransition(Transition transition) {}
2088
2089 /**
George Mount68f96d82014-07-31 13:13:10 -07002090 * Sets the Transition that will be used for shared elements reentering from a started
2091 * Activity after it has returned the shared element to it start location. If no value
2092 * is set, this will default to
2093 * {@link #setSharedElementExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07002094 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002095 *
George Mount68f96d82014-07-31 13:13:10 -07002096 * @param transition The Transition to use for shared elements in the launching Window
2097 * after the shared element has returned to the Window.
George Mountc03da0e2014-08-22 17:04:02 -07002098 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002099 */
2100 public void setSharedElementReenterTransition(Transition transition) {}
2101
2102 /**
George Mount31a21722014-03-24 17:44:36 -07002103 * Returns the Transition to use for shared elements in the launching Window prior
2104 * to transferring to the launched Activity's Window.
George Mount9826f632014-09-11 08:50:09 -07002105 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07002106 *
2107 * @return the Transition to use for shared elements in the launching Window prior
2108 * to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07002109 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mount31a21722014-03-24 17:44:36 -07002110 */
2111 public Transition getSharedElementExitTransition() { return null; }
2112
2113 /**
George Mount68f96d82014-07-31 13:13:10 -07002114 * Returns the Transition that will be used for shared elements reentering from a started
2115 * Activity after it has returned the shared element to it start location.
George Mount9826f632014-09-11 08:50:09 -07002116 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount68f96d82014-07-31 13:13:10 -07002117 *
2118 * @return the Transition that will be used for shared elements reentering from a started
2119 * Activity after it has returned the shared element to it start location.
George Mountc03da0e2014-08-22 17:04:02 -07002120 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002121 */
2122 public Transition getSharedElementReenterTransition() { return null; }
2123
2124 /**
George Mount31a21722014-03-24 17:44:36 -07002125 * Controls how the transition set in
2126 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
2127 * transition of the calling Activity. When true, the transition will start as soon as possible.
2128 * When false, the transition will wait until the remote exiting transition completes before
George Mount5d52d312016-06-10 14:16:45 -07002129 * starting. The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002130 *
George Mount31a21722014-03-24 17:44:36 -07002131 * @param allow true to start the enter transition when possible or false to
2132 * wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002133 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002134 */
2135 public void setAllowEnterTransitionOverlap(boolean allow) {}
2136
2137 /**
2138 * Returns how the transition set in
2139 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
2140 * transition of the calling Activity. When true, the transition will start as soon as possible.
2141 * When false, the transition will wait until the remote exiting transition completes before
George Mount5d52d312016-06-10 14:16:45 -07002142 * starting. The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002143 *
George Mount31a21722014-03-24 17:44:36 -07002144 * @return true when the enter transition should start as soon as possible or false to
2145 * when it should wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002146 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002147 */
2148 public boolean getAllowEnterTransitionOverlap() { return true; }
2149
2150 /**
2151 * Controls how the transition set in
2152 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2153 * transition of the called Activity when reentering after if finishes. When true,
2154 * the transition will start as soon as possible. When false, the transition will wait
2155 * until the called Activity's exiting transition completes before starting.
George Mount5d52d312016-06-10 14:16:45 -07002156 * The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002157 *
George Mount31a21722014-03-24 17:44:36 -07002158 * @param allow true to start the transition when possible or false to wait until the
2159 * called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002160 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002161 */
George Mountc03da0e2014-08-22 17:04:02 -07002162 public void setAllowReturnTransitionOverlap(boolean allow) {}
2163
2164 /**
George Mount31a21722014-03-24 17:44:36 -07002165 * Returns how the transition set in
2166 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2167 * transition of the called Activity when reentering after if finishes. When true,
2168 * the transition will start as soon as possible. When false, the transition will wait
2169 * until the called Activity's exiting transition completes before starting.
George Mount5d52d312016-06-10 14:16:45 -07002170 * The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002171 *
George Mount31a21722014-03-24 17:44:36 -07002172 * @return true when the transition should start when possible or false when it should wait
2173 * until the called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002174 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002175 */
George Mountc03da0e2014-08-22 17:04:02 -07002176 public boolean getAllowReturnTransitionOverlap() { return true; }
2177
2178 /**
George Mounted1e01d2014-06-05 13:49:12 -07002179 * Returns the duration, in milliseconds, of the window background fade
2180 * when transitioning into or away from an Activity when called with an Activity Transition.
2181 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002182 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002183 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002184 *
George Mounted1e01d2014-06-05 13:49:12 -07002185 * @return The duration of the window background fade to opaque during enter transition.
2186 * @see #getEnterTransition()
George Mountc03da0e2014-08-22 17:04:02 -07002187 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002188 */
2189 public long getTransitionBackgroundFadeDuration() { return 0; }
2190
2191 /**
2192 * Sets the duration, in milliseconds, of the window background fade
2193 * when transitioning into or away from an Activity when called with an Activity Transition.
2194 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002195 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002196 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002197 *
George Mounted1e01d2014-06-05 13:49:12 -07002198 * @param fadeDurationMillis The duration of the window background fade to or from opaque
2199 * during enter transition.
2200 * @see #setEnterTransition(android.transition.Transition)
George Mountc03da0e2014-08-22 17:04:02 -07002201 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002202 */
2203 public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { }
2204
2205 /**
George Mountb89d5cc2014-08-18 16:50:50 -07002206 * Returns <code>true</code> when shared elements should use an Overlay during
2207 * shared element transitions or <code>false</code> when they should animate as
2208 * part of the normal View hierarchy. The default value is true.
2209 *
2210 * @return <code>true</code> when shared elements should use an Overlay during
2211 * shared element transitions or <code>false</code> when they should animate as
2212 * part of the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002213 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002214 */
2215 public boolean getSharedElementsUseOverlay() { return true; }
2216
2217 /**
2218 * Sets whether or not shared elements should use an Overlay during shared element transitions.
2219 * The default value is true.
2220 *
2221 * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should
2222 * be transitioned with an Overlay or <code>false</code>
2223 * to transition within the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002224 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002225 */
2226 public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { }
2227
2228 /**
Adrian Roos217ccd22014-05-09 14:29:04 +02002229 * @return the color of the status bar.
2230 */
Tor Norbye80756e32015-03-02 09:39:27 -08002231 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002232 public abstract int getStatusBarColor();
2233
2234 /**
John Spurlockbc4cf002015-03-24 21:51:20 -04002235 * Sets the color of the status bar to {@code color}.
Adrian Roos217ccd22014-05-09 14:29:04 +02002236 *
2237 * For this to take effect,
2238 * the window must be drawing the system bar backgrounds with
2239 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2240 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set.
2241 *
John Spurlockbc4cf002015-03-24 21:51:20 -04002242 * If {@code color} is not opaque, consider setting
Adrian Roos217ccd22014-05-09 14:29:04 +02002243 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2244 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
George Mount238010f2014-06-30 17:31:17 -07002245 * <p>
2246 * The transitionName for the view background will be "android:status:background".
2247 * </p>
Adrian Roos217ccd22014-05-09 14:29:04 +02002248 */
Tor Norbye80756e32015-03-02 09:39:27 -08002249 public abstract void setStatusBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002250
2251 /**
2252 * @return the color of the navigation bar.
2253 */
Tor Norbye80756e32015-03-02 09:39:27 -08002254 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002255 public abstract int getNavigationBarColor();
2256
2257 /**
2258 * Sets the color of the navigation bar to {@param color}.
2259 *
2260 * For this to take effect,
2261 * the window must be drawing the system bar backgrounds with
2262 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2263 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
2264 *
2265 * If {@param color} is not opaque, consider setting
2266 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2267 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
George Mount238010f2014-06-30 17:31:17 -07002268 * <p>
2269 * The transitionName for the view background will be "android:navigation:background".
2270 * </p>
Jorim Jaggia0b78d52018-01-22 19:01:42 +01002271 * @attr ref android.R.styleable#Window_navigationBarColor
Adrian Roos217ccd22014-05-09 14:29:04 +02002272 */
Tor Norbye80756e32015-03-02 09:39:27 -08002273 public abstract void setNavigationBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002274
Jorim Jaggia0b78d52018-01-22 19:01:42 +01002275 /**
2276 * Shows a thin line of the specified color between the navigation bar and the app
2277 * content.
2278 * <p>
2279 * For this to take effect,
2280 * the window must be drawing the system bar backgrounds with
2281 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2282 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
2283 *
2284 * @param dividerColor The color of the thin line.
2285 * @attr ref android.R.styleable#Window_navigationBarDividerColor
2286 */
2287 public void setNavigationBarDividerColor(@ColorInt int dividerColor) {
2288 }
2289
2290 /**
2291 * Retrieves the color of the navigation bar divider.
2292 *
2293 * @return The color of the navigation bar divider color.
2294 * @see #setNavigationBarColor(int)
2295 * @attr ref android.R.styleable#Window_navigationBarDividerColor
2296 */
2297 public @ColorInt int getNavigationBarDividerColor() {
2298 return 0;
2299 }
2300
Filip Gruszczynski0daf2102015-09-29 08:39:07 -07002301 /** @hide */
2302 public void setTheme(int resId) {
2303 }
Filip Gruszczynski63250652015-11-18 14:43:01 -08002304
2305 /**
2306 * Whether the caption should be displayed directly on the content rather than push the content
2307 * down. This affects only freeform windows since they display the caption.
2308 * @hide
2309 */
Andrii Kulian933076d2016-03-29 17:04:42 -07002310 public void setOverlayWithDecorCaptionEnabled(boolean enabled) {
2311 mOverlayWithDecorCaptionEnabled = enabled;
Filip Gruszczynski63250652015-11-18 14:43:01 -08002312 }
2313
2314 /** @hide */
Andrii Kulian933076d2016-03-29 17:04:42 -07002315 public boolean isOverlayWithDecorCaptionEnabled() {
2316 return mOverlayWithDecorCaptionEnabled;
Filip Gruszczynski63250652015-11-18 14:43:01 -08002317 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002318
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002319 /** @hide */
2320 public void notifyRestrictedCaptionAreaCallback(int left, int top, int right, int bottom) {
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002321 if (mOnRestrictedCaptionAreaChangedListener != null) {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002322 mRestrictedCaptionAreaRect.set(left, top, right, bottom);
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002323 mOnRestrictedCaptionAreaChangedListener.onRestrictedCaptionAreaChanged(
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002324 mRestrictedCaptionAreaRect);
2325 }
2326 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002327
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002328 /**
2329 * Set what color should the caption controls be. By default the system will try to determine
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002330 * the color from the theme. You can overwrite this by using {@link #DECOR_CAPTION_SHADE_DARK},
2331 * {@link #DECOR_CAPTION_SHADE_LIGHT}, or {@link #DECOR_CAPTION_SHADE_AUTO}.
2332 * @see #DECOR_CAPTION_SHADE_DARK
2333 * @see #DECOR_CAPTION_SHADE_LIGHT
2334 * @see #DECOR_CAPTION_SHADE_AUTO
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002335 */
2336 public abstract void setDecorCaptionShade(int decorCaptionShade);
2337
2338 /**
2339 * Set the drawable that is drawn underneath the caption during the resizing.
2340 *
2341 * During the resizing the caption might not be drawn fast enough to match the new dimensions.
2342 * There is a second caption drawn underneath it that will be fast enough. By default the
2343 * caption is constructed from the theme. You can provide a drawable, that will be drawn instead
2344 * to better match your application.
2345 */
2346 public abstract void setResizingCaptionDrawable(Drawable drawable);
Wale Ogunwaleeb6722c2015-12-08 11:43:43 -08002347
2348 /**
2349 * Called when the activity changes from fullscreen mode to multi-window mode and visa-versa.
2350 * @hide
2351 */
Andrii Kulian933076d2016-03-29 17:04:42 -07002352 public abstract void onMultiWindowModeChanged();
Jorim Jaggi4846ee32016-01-07 17:39:12 +01002353
2354 /**
Winson Chung4d8681f2017-05-23 16:22:08 -07002355 * Called when the activity changes to/from picture-in-picture mode.
2356 * @hide
2357 */
2358 public abstract void onPictureInPictureModeChanged(boolean isInPictureInPictureMode);
2359
2360 /**
Jorim Jaggi4846ee32016-01-07 17:39:12 +01002361 * Called when the activity just relaunched.
2362 * @hide
2363 */
2364 public abstract void reportActivityRelaunched();
Michael Kwanf7964be2016-11-30 16:44:33 -08002365
2366 /**
2367 * Called to set flag to check if the close on swipe is enabled. This will only function if
2368 * FEATURE_SWIPE_TO_DISMISS has been set.
2369 * @hide
2370 */
2371 public void setCloseOnSwipeEnabled(boolean closeOnSwipeEnabled) {
2372 mCloseOnSwipeEnabled = closeOnSwipeEnabled;
2373 }
2374
2375 /**
2376 * @return {@code true} if the close on swipe is enabled.
2377 * @hide
2378 */
2379 public boolean isCloseOnSwipeEnabled() {
2380 return mCloseOnSwipeEnabled;
2381 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002382}