blob: 0c5c18316e61028c60a0cb1117b44e56460904c6 [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;
Philip P. Moltmannd66dd992018-09-17 11:26:04 -070028import android.annotation.SystemApi;
Wale Ogunwale3382ab12017-07-27 08:55:03 -070029import android.app.WindowConfiguration;
Artur Satayevad9254c2019-12-10 17:47:54 +000030import android.compat.annotation.UnsupportedAppUsage;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031import android.content.Context;
Romain Guy48327452017-01-23 17:03:35 -080032import android.content.pm.ActivityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033import android.content.res.Configuration;
Bryce Leed6e6e722014-11-21 11:08:45 -080034import android.content.res.Resources;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035import android.content.res.TypedArray;
Jorim Jaggi7fb715c2020-01-09 23:45:41 +010036import android.graphics.Insets;
Skuhnece2faa52015-08-11 10:36:38 -070037import android.graphics.PixelFormat;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -080038import android.graphics.Rect;
Filip Gruszczynski14418da2015-10-04 16:43:48 -070039import android.graphics.drawable.Drawable;
RoboErik55011652014-07-09 15:05:53 -070040import android.media.session.MediaController;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041import android.net.Uri;
Mathew Inwood31755f92018-12-20 13:53:36 +000042import android.os.Build;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043import android.os.Bundle;
Andres Morales910beb82016-02-02 16:19:40 -080044import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045import android.os.IBinder;
Wale Ogunwale868a5e12015-08-02 16:19:20 -070046import android.os.RemoteException;
Adam Powellcfbe9be2013-11-06 14:58:58 -080047import android.transition.Scene;
George Mounte1803372014-02-26 19:00:52 +000048import android.transition.Transition;
Adam Powellcfbe9be2013-11-06 14:58:58 -080049import android.transition.TransitionManager;
Jorim Jaggi7fb715c2020-01-09 23:45:41 +010050import android.util.Pair;
51import android.view.View.OnApplyWindowInsetsListener;
52import android.view.ViewGroup.LayoutParams;
Tiger Huang4a7835f2019-11-06 00:07:56 +080053import android.view.WindowInsets.Side.InsetsSide;
54import android.view.WindowInsets.Type.InsetsType;
svetoslavganov75986cf2009-05-14 22:28:01 -070055import android.view.accessibility.AccessibilityEvent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056
Adam Powell5a40b712019-04-15 15:54:02 -070057import java.util.Collections;
Clara Bayarri75e09792015-07-29 16:20:40 +010058import java.util.List;
59
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060/**
61 * Abstract base class for a top-level window look and behavior policy. An
62 * instance of this class should be used as the top-level view added to the
63 * window manager. It provides standard UI policies such as a background, title
64 * area, default key processing, etc.
65 *
66 * <p>The only existing implementation of this abstract class is
Jorim Jaggib10e33f2015-02-04 21:57:40 +010067 * android.view.PhoneWindow, which you should instantiate when needing a
68 * Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 */
70public abstract class Window {
71 /** Flag for the "options panel" feature. This is enabled by default. */
72 public static final int FEATURE_OPTIONS_PANEL = 0;
73 /** Flag for the "no title" feature, turning off the title at the top
74 * of the screen. */
75 public static final int FEATURE_NO_TITLE = 1;
Alan Viverette4aef7c82015-09-04 14:14:50 -040076
77 /**
78 * Flag for the progress indicator feature.
79 *
80 * @deprecated No longer supported starting in API 21.
81 */
82 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 public static final int FEATURE_PROGRESS = 2;
Alan Viverette4aef7c82015-09-04 14:14:50 -040084
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080085 /** Flag for having an icon on the left side of the title bar */
86 public static final int FEATURE_LEFT_ICON = 3;
87 /** Flag for having an icon on the right side of the title bar */
88 public static final int FEATURE_RIGHT_ICON = 4;
Alan Viverette4aef7c82015-09-04 14:14:50 -040089
90 /**
91 * Flag for indeterminate progress.
92 *
93 * @deprecated No longer supported starting in API 21.
94 */
95 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096 public static final int FEATURE_INDETERMINATE_PROGRESS = 5;
Alan Viverette4aef7c82015-09-04 14:14:50 -040097
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 /** Flag for the context menu. This is enabled by default. */
99 public static final int FEATURE_CONTEXT_MENU = 6;
100 /** Flag for custom title. You cannot combine this feature with other title features. */
101 public static final int FEATURE_CUSTOM_TITLE = 7;
Adam Powell33b97432010-04-20 10:01:14 -0700102 /**
103 * Flag for enabling the Action Bar.
104 * This is enabled by default for some devices. The Action Bar
105 * replaces the title bar and provides an alternate location
106 * for an on-screen menu button on some devices.
107 */
Adam Powell5d279772010-07-27 16:34:07 -0700108 public static final int FEATURE_ACTION_BAR = 8;
109 /**
Adam Powell6b336f82010-08-10 20:13:01 -0700110 * Flag for requesting an Action Bar that overlays window content.
111 * Normally an Action Bar will sit in the space above window content, but if this
112 * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over
113 * the window content itself. This is useful if you would like your app to have more control
114 * over how the Action Bar is displayed, such as letting application content scroll beneath
115 * an Action Bar with a transparent background or otherwise displaying a transparent/translucent
116 * Action Bar over application content.
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700117 *
118 * <p>This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN
119 * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the
120 * action bar in conjunction with other screen decorations.
121 *
122 * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an
123 * ActionBar is in this mode it will adjust the insets provided to
124 * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)}
125 * to include the content covered by the action bar, so you can do layout within
126 * that space.
Adam Powell6b336f82010-08-10 20:13:01 -0700127 */
128 public static final int FEATURE_ACTION_BAR_OVERLAY = 9;
129 /**
Adam Powell5d279772010-07-27 16:34:07 -0700130 * Flag for specifying the behavior of action modes when an Action Bar is not present.
131 * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
132 */
Adam Powell6b336f82010-08-10 20:13:01 -0700133 public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
Adam Powell18e905f2013-10-24 14:27:48 -0700134 /**
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800135 * Flag for requesting a decoration-free window that is dismissed by swiping from the left.
Jorim Jaggie06b1fd2019-10-25 14:35:10 +0200136 *
137 * @deprecated Swipe-to-dismiss isn't functional anymore.
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800138 */
Jorim Jaggie06b1fd2019-10-25 14:35:10 +0200139 @Deprecated
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800140 public static final int FEATURE_SWIPE_TO_DISMISS = 11;
Will Haldean Brown568628d2014-03-04 15:25:43 -0800141 /**
George Mountc3a043c2015-02-04 14:37:04 -0800142 * Flag for requesting that window content changes should be animated using a
143 * TransitionManager.
Adam Powell18e905f2013-10-24 14:27:48 -0700144 *
George Mountc3a043c2015-02-04 14:37:04 -0800145 * <p>The TransitionManager is set using
146 * {@link #setTransitionManager(android.transition.TransitionManager)}. If none is set,
147 * a default TransitionManager will be used.</p>
Adam Powell18e905f2013-10-24 14:27:48 -0700148 *
149 * @see #setContentView
150 */
Will Haldean Brown568628d2014-03-04 15:25:43 -0800151 public static final int FEATURE_CONTENT_TRANSITIONS = 12;
Adam Powell4b6d93f2012-09-18 18:34:08 -0700152
153 /**
George Mount9826f632014-09-11 08:50:09 -0700154 * Enables Activities to run Activity Transitions either through sending or receiving
155 * ActivityOptions bundle created with
156 * {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity,
157 * android.util.Pair[])} or {@link android.app.ActivityOptions#makeSceneTransitionAnimation(
158 * android.app.Activity, View, String)}.
159 */
160 public static final int FEATURE_ACTIVITY_TRANSITIONS = 13;
161
162 /**
Adam Powell4b6d93f2012-09-18 18:34:08 -0700163 * Max value used as a feature ID
164 * @hide
165 */
Mathew Inwooda570dee2018-08-17 14:56:00 +0100166 @UnsupportedAppUsage
George Mount9826f632014-09-11 08:50:09 -0700167 public static final int FEATURE_MAX = FEATURE_ACTIVITY_TRANSITIONS;
Adam Powell4b6d93f2012-09-18 18:34:08 -0700168
Alan Viverette4aef7c82015-09-04 14:14:50 -0400169 /**
170 * Flag for setting the progress bar's visibility to VISIBLE.
171 *
172 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
173 * supported starting in API 21.
174 */
175 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800176 public static final int PROGRESS_VISIBILITY_ON = -1;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400177
178 /**
179 * Flag for setting the progress bar's visibility to GONE.
180 *
181 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
182 * supported starting in API 21.
183 */
184 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800185 public static final int PROGRESS_VISIBILITY_OFF = -2;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400186
187 /**
188 * Flag for setting the progress bar's indeterminate mode on.
189 *
190 * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
191 * are no longer supported starting in API 21.
192 */
193 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194 public static final int PROGRESS_INDETERMINATE_ON = -3;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400195
196 /**
197 * Flag for setting the progress bar's indeterminate mode off.
198 *
199 * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
200 * are no longer supported starting in API 21.
201 */
202 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800203 public static final int PROGRESS_INDETERMINATE_OFF = -4;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400204
205 /**
206 * Starting value for the (primary) progress.
207 *
208 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
209 * supported starting in API 21.
210 */
211 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800212 public static final int PROGRESS_START = 0;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400213
214 /**
215 * Ending value for the (primary) progress.
216 *
217 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
218 * supported starting in API 21.
219 */
220 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800221 public static final int PROGRESS_END = 10000;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400222
223 /**
224 * Lowest possible value for the secondary progress.
225 *
226 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
227 * supported starting in API 21.
228 */
229 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800230 public static final int PROGRESS_SECONDARY_START = 20000;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400231
232 /**
233 * Highest possible value for the secondary progress.
234 *
235 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
236 * supported starting in API 21.
237 */
238 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800239 public static final int PROGRESS_SECONDARY_END = 30000;
George Mount238010f2014-06-30 17:31:17 -0700240
241 /**
242 * The transitionName for the status bar background View when a custom background is used.
243 * @see android.view.Window#setStatusBarColor(int)
244 */
245 public static final String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background";
246
247 /**
248 * The transitionName for the navigation bar background View when a custom background is used.
249 * @see android.view.Window#setNavigationBarColor(int)
250 */
251 public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME =
252 "android:navigation:background";
253
Bryce Leeaa1008c2015-01-13 09:26:46 -0800254 /**
255 * The default features enabled.
256 * @deprecated use {@link #getDefaultFeatures(android.content.Context)} instead.
257 */
Bryce Leed6e6e722014-11-21 11:08:45 -0800258 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 @SuppressWarnings({"PointlessBitwiseExpression"})
260 protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) |
261 (1 << FEATURE_CONTEXT_MENU);
262
263 /**
264 * The ID that the main layout in the XML layout file should have.
265 */
266 public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content;
267
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800268 /**
269 * Flag for letting the theme drive the color of the window caption controls. Use with
270 * {@link #setDecorCaptionShade(int)}. This is the default value.
271 */
272 public static final int DECOR_CAPTION_SHADE_AUTO = 0;
273 /**
274 * Flag for setting light-color controls on the window caption. Use with
275 * {@link #setDecorCaptionShade(int)}.
276 */
277 public static final int DECOR_CAPTION_SHADE_LIGHT = 1;
278 /**
279 * Flag for setting dark-color controls on the window caption. Use with
280 * {@link #setDecorCaptionShade(int)}.
281 */
282 public static final int DECOR_CAPTION_SHADE_DARK = 2;
283
Mathew Inwooda570dee2018-08-17 14:56:00 +0100284 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800285 private final Context mContext;
RoboErik55011652014-07-09 15:05:53 -0700286
Mathew Inwooda570dee2018-08-17 14:56:00 +0100287 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800288 private TypedArray mWindowStyle;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100289 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800290 private Callback mCallback;
Adam Powell117b6952014-05-05 18:14:56 -0700291 private OnWindowDismissedCallback mOnWindowDismissedCallback;
Michael Kwan67639a52016-12-16 12:38:10 -0800292 private OnWindowSwipeDismissedCallback mOnWindowSwipeDismissedCallback;
Skuhnece2faa52015-08-11 10:36:38 -0700293 private WindowControllerCallback mWindowControllerCallback;
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800294 private OnRestrictedCaptionAreaChangedListener mOnRestrictedCaptionAreaChangedListener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800295 private Rect mRestrictedCaptionAreaRect;
Mathew Inwood31755f92018-12-20 13:53:36 +0000296 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297 private WindowManager mWindowManager;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100298 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299 private IBinder mAppToken;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100300 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800301 private String mAppName;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100302 @UnsupportedAppUsage
Jeff Brownd32460c2012-07-20 16:15:36 -0700303 private boolean mHardwareAccelerated;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800304 private Window mContainer;
305 private Window mActiveChild;
306 private boolean mIsActive = false;
307 private boolean mHasChildren = false;
Dianne Hackborncfaf8872011-01-18 13:57:54 -0800308 private boolean mCloseOnTouchOutside = false;
309 private boolean mSetCloseOnTouchOutside = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800310 private int mForcedWindowFlags = 0;
311
Mathew Inwooda570dee2018-08-17 14:56:00 +0100312 @UnsupportedAppUsage
Bryce Leed6e6e722014-11-21 11:08:45 -0800313 private int mFeatures;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100314 @UnsupportedAppUsage
Bryce Leed6e6e722014-11-21 11:08:45 -0800315 private int mLocalFeatures;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800316
317 private boolean mHaveWindowFormat = false;
Dianne Hackborn661cd522011-08-22 00:26:20 -0700318 private boolean mHaveDimAmount = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800319 private int mDefaultWindowFormat = PixelFormat.OPAQUE;
320
321 private boolean mHasSoftInputMode = false;
RoboErik55011652014-07-09 15:05:53 -0700322
Mathew Inwooda570dee2018-08-17 14:56:00 +0100323 @UnsupportedAppUsage
Dianne Hackborn291905e2010-08-17 15:17:15 -0700324 private boolean mDestroyed;
325
Andrii Kulian933076d2016-03-29 17:04:42 -0700326 private boolean mOverlayWithDecorCaptionEnabled = false;
Michael Kwanf7964be2016-11-30 16:44:33 -0800327 private boolean mCloseOnSwipeEnabled = false;
Filip Gruszczynski63250652015-11-18 14:43:01 -0800328
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800329 // The current window attributes.
Mathew Inwooda570dee2018-08-17 14:56:00 +0100330 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800331 private final WindowManager.LayoutParams mWindowAttributes =
332 new WindowManager.LayoutParams();
333
334 /**
335 * API from a Window back to its caller. This allows the client to
336 * intercept key dispatching, panels and menus, etc.
337 */
338 public interface Callback {
339 /**
340 * Called to process key events. At the very least your
341 * implementation must call
342 * {@link android.view.Window#superDispatchKeyEvent} to do the
343 * standard key processing.
344 *
345 * @param event The key event.
346 *
347 * @return boolean Return true if this event was consumed.
348 */
349 public boolean dispatchKeyEvent(KeyEvent event);
350
351 /**
Jeff Brown64da12a2011-01-04 19:57:47 -0800352 * Called to process a key shortcut event.
353 * At the very least your implementation must call
354 * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the
355 * standard key shortcut processing.
356 *
357 * @param event The key shortcut event.
358 * @return True if this event was consumed.
359 */
360 public boolean dispatchKeyShortcutEvent(KeyEvent event);
361
362 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800363 * Called to process touch screen events. At the very least your
364 * implementation must call
365 * {@link android.view.Window#superDispatchTouchEvent} to do the
366 * standard touch screen processing.
367 *
368 * @param event The touch screen event.
369 *
370 * @return boolean Return true if this event was consumed.
371 */
372 public boolean dispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -0700373
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800374 /**
375 * Called to process trackball events. At the very least your
376 * implementation must call
377 * {@link android.view.Window#superDispatchTrackballEvent} to do the
378 * standard trackball processing.
379 *
380 * @param event The trackball event.
381 *
382 * @return boolean Return true if this event was consumed.
383 */
384 public boolean dispatchTrackballEvent(MotionEvent event);
svetoslavganov75986cf2009-05-14 22:28:01 -0700385
386 /**
Jeff Browncb1404e2011-01-15 18:14:15 -0800387 * Called to process generic motion events. At the very least your
388 * implementation must call
389 * {@link android.view.Window#superDispatchGenericMotionEvent} to do the
390 * standard processing.
391 *
392 * @param event The generic motion event.
393 *
394 * @return boolean Return true if this event was consumed.
395 */
396 public boolean dispatchGenericMotionEvent(MotionEvent event);
397
398 /**
svetoslavganov75986cf2009-05-14 22:28:01 -0700399 * Called to process population of {@link AccessibilityEvent}s.
400 *
401 * @param event The event.
402 *
403 * @return boolean Return true if event population was completed.
404 */
405 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event);
406
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800407 /**
408 * Instantiate the view to display in the panel for 'featureId'.
409 * You can return null, in which case the default content (typically
410 * a menu) will be created for you.
411 *
412 * @param featureId Which panel is being created.
413 *
414 * @return view The top-level view to place in the panel.
415 *
416 * @see #onPreparePanel
417 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700418 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800419 public View onCreatePanelView(int featureId);
420
421 /**
422 * Initialize the contents of the menu for panel 'featureId'. This is
423 * called if onCreatePanelView() returns null, giving you a standard
424 * menu in which you can place your items. It is only called once for
425 * the panel, the first time it is shown.
426 *
427 * <p>You can safely hold on to <var>menu</var> (and any items created
428 * from it), making modifications to it as desired, until the next
429 * time onCreatePanelMenu() is called for this feature.
430 *
431 * @param featureId The panel being created.
432 * @param menu The menu inside the panel.
433 *
434 * @return boolean You must return true for the panel to be displayed;
435 * if you return false it will not be shown.
436 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700437 boolean onCreatePanelMenu(int featureId, @NonNull Menu menu);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438
439 /**
440 * Prepare a panel to be displayed. This is called right before the
441 * panel window is shown, every time it is shown.
442 *
443 * @param featureId The panel that is being displayed.
444 * @param view The View that was returned by onCreatePanelView().
445 * @param menu If onCreatePanelView() returned null, this is the Menu
446 * being displayed in the panel.
447 *
448 * @return boolean You must return true for the panel to be displayed;
449 * if you return false it will not be shown.
450 *
451 * @see #onCreatePanelView
452 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700453 boolean onPreparePanel(int featureId, @Nullable View view, @NonNull Menu menu);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800454
455 /**
456 * Called when a panel's menu is opened by the user. This may also be
457 * called when the menu is changing from one type to another (for
458 * example, from the icon menu to the expanded menu).
RoboErik55011652014-07-09 15:05:53 -0700459 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800460 * @param featureId The panel that the menu is in.
461 * @param menu The menu that is opened.
462 * @return Return true to allow the menu to open, or false to prevent
463 * the menu from opening.
464 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700465 boolean onMenuOpened(int featureId, @NonNull Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700466
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800467 /**
468 * Called when a panel's menu item has been selected by the user.
469 *
470 * @param featureId The panel that the menu is in.
471 * @param item The menu item that was selected.
472 *
473 * @return boolean Return true to finish processing of selection, or
474 * false to perform the normal menu handling (calling its
475 * Runnable or sending a Message to its target Handler).
476 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700477 boolean onMenuItemSelected(int featureId, @NonNull MenuItem item);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800478
479 /**
480 * This is called whenever the current window attributes change.
481 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800482 */
483 public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
484
485 /**
486 * This hook is called whenever the content view of the screen changes
487 * (due to a call to
488 * {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams)
489 * Window.setContentView} or
490 * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams)
491 * Window.addContentView}).
492 */
493 public void onContentChanged();
494
495 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700496 * This hook is called whenever the window focus changes. See
497 * {@link View#onWindowFocusChanged(boolean)
Svetoslav3a0d8782014-12-04 12:50:11 -0800498 * View.onWindowFocusChangedNotLocked(boolean)} for more information.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800499 *
500 * @param hasFocus Whether the window now has focus.
501 */
502 public void onWindowFocusChanged(boolean hasFocus);
503
504 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700505 * Called when the window has been attached to the window manager.
506 * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
507 * for more information.
508 */
509 public void onAttachedToWindow();
RoboErik55011652014-07-09 15:05:53 -0700510
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700511 /**
Chet Haasee7bf2192017-08-18 15:24:56 -0700512 * Called when the window has been detached from the window manager.
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700513 * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
514 * for more information.
515 */
516 public void onDetachedFromWindow();
RoboErik55011652014-07-09 15:05:53 -0700517
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700518 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519 * Called when a panel is being closed. If another logical subsequent
520 * panel is being opened (and this panel is being closed to make room for the subsequent
521 * panel), this method will NOT be called.
RoboErik55011652014-07-09 15:05:53 -0700522 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800523 * @param featureId The panel that is being displayed.
524 * @param menu If onCreatePanelView() returned null, this is the Menu
525 * being displayed in the panel.
526 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700527 void onPanelClosed(int featureId, @NonNull Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700528
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800529 /**
530 * Called when the user signals the desire to start a search.
RoboErik55011652014-07-09 15:05:53 -0700531 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800532 * @return true if search launched, false if activity refuses (blocks)
RoboErik55011652014-07-09 15:05:53 -0700533 *
534 * @see android.app.Activity#onSearchRequested()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800535 */
536 public boolean onSearchRequested();
Adam Powell6e346362010-07-23 10:18:23 -0700537
538 /**
Tim Kilbourn6a975b32015-04-09 17:14:34 -0700539 * Called when the user signals the desire to start a search.
540 *
541 * @param searchEvent A {@link SearchEvent} describing the signal to
542 * start a search.
543 * @return true if search launched, false if activity refuses (blocks)
544 */
545 public boolean onSearchRequested(SearchEvent searchEvent);
546
547 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800548 * Called when an action mode is being started for this window. Gives the
549 * callback an opportunity to handle the action mode in its own unique and
550 * beautiful way. If this method returns null the system can choose a way
Clara Bayarri4423d912015-03-02 19:42:48 +0000551 * to present the mode or choose not to start the mode at all. This is equivalent
552 * to {@link #onWindowStartingActionMode(android.view.ActionMode.Callback, int)}
553 * with type {@link ActionMode#TYPE_PRIMARY}.
Adam Powell6e346362010-07-23 10:18:23 -0700554 *
555 * @param callback Callback to control the lifecycle of this action mode
Adam Powelldebf3be2010-11-15 18:58:48 -0800556 * @return The ActionMode that was started, or null if the system should present it
Adam Powell6e346362010-07-23 10:18:23 -0700557 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700558 @Nullable
Adam Powelldebf3be2010-11-15 18:58:48 -0800559 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
560
561 /**
Clara Bayarri4423d912015-03-02 19:42:48 +0000562 * Called when an action mode is being started for this window. Gives the
563 * callback an opportunity to handle the action mode in its own unique and
564 * beautiful way. If this method returns null the system can choose a way
565 * to present the mode or choose not to start the mode at all.
566 *
567 * @param callback Callback to control the lifecycle of this action mode
568 * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
569 * @return The ActionMode that was started, or null if the system should present it
570 */
571 @Nullable
572 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);
573
574 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800575 * Called when an action mode has been started. The appropriate mode callback
576 * method will have already been invoked.
577 *
578 * @param mode The new mode that has just been started.
579 */
580 public void onActionModeStarted(ActionMode mode);
581
582 /**
583 * Called when an action mode has been finished. The appropriate mode callback
584 * method will have already been invoked.
585 *
586 * @param mode The mode that was just finished.
587 */
588 public void onActionModeFinished(ActionMode mode);
Clara Bayarri75e09792015-07-29 16:20:40 +0100589
590 /**
591 * Called when Keyboard Shortcuts are requested for the current window.
592 *
593 * @param data The data list to populate with shortcuts.
594 * @param menu The current menu, which may be null.
Clara Bayarrifcd7e802016-03-10 12:58:18 +0000595 * @param deviceId The id for the connected device the shortcuts should be provided for.
Clara Bayarri75e09792015-07-29 16:20:40 +0100596 */
Sunny Goyal2a6d9aa2016-03-16 17:12:46 -0700597 default public void onProvideKeyboardShortcuts(
Clara Bayarrifcd7e802016-03-10 12:58:18 +0000598 List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) { };
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800599
600 /**
601 * Called when pointer capture is enabled or disabled for the current window.
602 *
603 * @param hasCapture True if the window has pointer capture.
604 */
605 default public void onPointerCaptureChanged(boolean hasCapture) { };
Adam Powell117b6952014-05-05 18:14:56 -0700606 }
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800607
Adam Powell117b6952014-05-05 18:14:56 -0700608 /** @hide */
609 public interface OnWindowDismissedCallback {
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800610 /**
611 * Called when a window is dismissed. This informs the callback that the
612 * window is gone, and it should finish itself.
Wale Ogunwaleba7881c2015-08-01 19:28:29 -0700613 * @param finishTask True if the task should also be finished.
Ned Burns7d6cb912016-12-02 17:25:33 -0500614 * @param suppressWindowTransition True if the resulting exit and enter window transition
615 * animations should be suppressed.
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800616 */
Ned Burns7d6cb912016-12-02 17:25:33 -0500617 void onWindowDismissed(boolean finishTask, boolean suppressWindowTransition);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800618 }
619
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700620 /** @hide */
Michael Kwan67639a52016-12-16 12:38:10 -0800621 public interface OnWindowSwipeDismissedCallback {
622 /**
623 * Called when a window is swipe dismissed. This informs the callback that the
624 * window is gone, and it should finish itself.
625 * @param finishTask True if the task should also be finished.
626 * @param suppressWindowTransition True if the resulting exit and enter window transition
627 * animations should be suppressed.
628 */
629 void onWindowSwipeDismissed();
630 }
631
632 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700633 public interface WindowControllerCallback {
634 /**
Yunfan Chend967af82019-01-17 18:30:18 +0900635 * Moves the activity between {@link WindowConfiguration#WINDOWING_MODE_FREEFORM} windowing
636 * mode and {@link WindowConfiguration#WINDOWING_MODE_FULLSCREEN}.
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700637 */
Yunfan Chend967af82019-01-17 18:30:18 +0900638 void toggleFreeformWindowingMode() throws RemoteException;
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700639
Jaewan Kimd98dcab2016-05-03 02:52:18 +0900640 /**
641 * Puts the activity in picture-in-picture mode if the activity supports.
642 * @see android.R.attr#supportsPictureInPicture
643 */
644 void enterPictureInPictureModeIfPossible();
645
Winson Chung4d8681f2017-05-23 16:22:08 -0700646 /** Returns whether the window belongs to the task root. */
647 boolean isTaskRoot();
Yunfan Chen91b3a1b2019-11-05 16:19:13 -0800648
649 /**
650 * Update the status bar color to a forced one.
651 */
652 void updateStatusBarColor(int color);
653
654 /**
655 * Update the navigation bar color to a forced one.
656 */
657 void updateNavigationBarColor(int color);
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700658 }
659
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800660 /**
661 * Callback for clients that want to be aware of where caption draws content.
662 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800663 public interface OnRestrictedCaptionAreaChangedListener {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800664 /**
665 * Called when the area where caption draws content changes.
666 *
667 * @param rect The area where caption content is positioned, relative to the top view.
668 */
669 void onRestrictedCaptionAreaChanged(Rect rect);
670 }
671
Andres Morales910beb82016-02-02 16:19:40 -0800672 /**
673 * Callback for clients that want frame timing information for each
674 * frame rendered by the Window.
675 */
Andres Moralesd908c622016-04-20 13:13:34 -0700676 public interface OnFrameMetricsAvailableListener {
Andres Morales910beb82016-02-02 16:19:40 -0800677 /**
678 * Called when information is available for the previously rendered frame.
679 *
680 * Reports can be dropped if this callback takes too
681 * long to execute, as the report producer cannot wait for the consumer to
682 * complete.
683 *
684 * It is highly recommended that clients copy the passed in FrameMetrics
685 * via {@link FrameMetrics#FrameMetrics(FrameMetrics)} within this method and defer
686 * additional computation or storage to another thread to avoid unnecessarily
687 * dropping reports.
688 *
689 * @param window The {@link Window} on which the frame was displayed.
690 * @param frameMetrics the available metrics. This object is reused on every call
691 * and thus <strong>this reference is not valid outside the scope of this method</strong>.
692 * @param dropCountSinceLastInvocation the number of reports dropped since the last time
693 * this callback was invoked.
694 */
Andres Moralesd908c622016-04-20 13:13:34 -0700695 void onFrameMetricsAvailable(Window window, FrameMetrics frameMetrics,
Andres Morales910beb82016-02-02 16:19:40 -0800696 int dropCountSinceLastInvocation);
697 }
698
Jorim Jaggi7fb715c2020-01-09 23:45:41 +0100699 /**
Jorim Jaggi1f08f642020-01-29 13:11:46 +0100700 * Listener for applying window insets on the content of a window. Used only by the framework to
701 * fit content according to legacy SystemUI flags.
Jorim Jaggi7fb715c2020-01-09 23:45:41 +0100702 *
Jorim Jaggi1f08f642020-01-29 13:11:46 +0100703 * @hide
Jorim Jaggi7fb715c2020-01-09 23:45:41 +0100704 */
705 public interface OnContentApplyWindowInsetsListener {
706
707 /**
708 * Called when the window needs to apply insets on the container of its content view which
709 * are set by calling {@link #setContentView}. The method should determine what insets to
710 * apply on the container of the root level content view and what should be dispatched to
711 * the content view's
712 * {@link View#setOnApplyWindowInsetsListener(OnApplyWindowInsetsListener)} through the view
713 * hierarchy.
714 *
Adrian Rooscd9cf092020-02-27 17:46:30 +0100715 * @param view The view for which to apply insets. Must not be directly modified.
Jorim Jaggi7fb715c2020-01-09 23:45:41 +0100716 * @param insets The root level insets that are about to be dispatched
717 * @return A pair, with the first element containing the insets to apply as margin to the
Jorim Jaggi1f08f642020-01-29 13:11:46 +0100718 * root-level content views, and the second element determining what should be
719 * dispatched to the content view.
Jorim Jaggi7fb715c2020-01-09 23:45:41 +0100720 */
Jorim Jaggi1f08f642020-01-29 13:11:46 +0100721 @NonNull
Adrian Rooscd9cf092020-02-27 17:46:30 +0100722 Pair<Insets, WindowInsets> onContentApplyWindowInsets(@NonNull View view,
Jorim Jaggi7fb715c2020-01-09 23:45:41 +0100723 @NonNull WindowInsets insets);
724 }
Andres Morales910beb82016-02-02 16:19:40 -0800725
Jorim Jaggi1f08f642020-01-29 13:11:46 +0100726
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800727 public Window(Context context) {
728 mContext = context;
Bryce Leed6e6e722014-11-21 11:08:45 -0800729 mFeatures = mLocalFeatures = getDefaultFeatures(context);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800730 }
731
732 /**
733 * Return the Context this window policy is running in, for retrieving
734 * resources and other information.
735 *
736 * @return Context The Context that was supplied to the constructor.
737 */
738 public final Context getContext() {
739 return mContext;
740 }
741
742 /**
743 * Return the {@link android.R.styleable#Window} attributes from this
744 * window's theme.
745 */
746 public final TypedArray getWindowStyle() {
747 synchronized (this) {
748 if (mWindowStyle == null) {
749 mWindowStyle = mContext.obtainStyledAttributes(
750 com.android.internal.R.styleable.Window);
751 }
752 return mWindowStyle;
753 }
754 }
RoboErik55011652014-07-09 15:05:53 -0700755
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800756 /**
757 * Set the container for this window. If not set, the DecorWindow
758 * operates as a top-level window; otherwise, it negotiates with the
759 * container to display itself appropriately.
760 *
761 * @param container The desired containing Window.
762 */
763 public void setContainer(Window container) {
764 mContainer = container;
765 if (container != null) {
766 // Embedded screens never have a title.
767 mFeatures |= 1<<FEATURE_NO_TITLE;
768 mLocalFeatures |= 1<<FEATURE_NO_TITLE;
769 container.mHasChildren = true;
770 }
771 }
772
773 /**
774 * Return the container for this Window.
775 *
776 * @return Window The containing window, or null if this is a
777 * top-level window.
778 */
779 public final Window getContainer() {
780 return mContainer;
781 }
782
783 public final boolean hasChildren() {
784 return mHasChildren;
785 }
RoboErik55011652014-07-09 15:05:53 -0700786
Dianne Hackborn291905e2010-08-17 15:17:15 -0700787 /** @hide */
788 public final void destroy() {
789 mDestroyed = true;
790 }
791
792 /** @hide */
Mathew Inwooda570dee2018-08-17 14:56:00 +0100793 @UnsupportedAppUsage
Dianne Hackborn291905e2010-08-17 15:17:15 -0700794 public final boolean isDestroyed() {
795 return mDestroyed;
796 }
797
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800798 /**
799 * Set the window manager for use by this Window to, for example,
800 * display panels. This is <em>not</em> used for displaying the
801 * Window itself -- that must be done by the client.
802 *
Jeff Brown98365d72012-08-19 20:30:52 -0700803 * @param wm The window manager for adding new windows.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800804 */
Romain Guy529b60a2010-08-03 18:05:47 -0700805 public void setWindowManager(WindowManager wm, IBinder appToken, String appName) {
806 setWindowManager(wm, appToken, appName, false);
807 }
808
809 /**
810 * Set the window manager for use by this Window to, for example,
811 * display panels. This is <em>not</em> used for displaying the
812 * Window itself -- that must be done by the client.
813 *
Jeff Brown98365d72012-08-19 20:30:52 -0700814 * @param wm The window manager for adding new windows.
Romain Guy529b60a2010-08-03 18:05:47 -0700815 */
816 public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
817 boolean hardwareAccelerated) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800818 mAppToken = appToken;
819 mAppName = appName;
John Recke22d4d72018-03-02 15:49:48 -0800820 mHardwareAccelerated = hardwareAccelerated;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800821 if (wm == null) {
Jeff Brown98365d72012-08-19 20:30:52 -0700822 wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800823 }
Jeff Brown98365d72012-08-19 20:30:52 -0700824 mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
Dianne Hackborn5fd21692011-06-07 14:09:47 -0700825 }
826
Jeff Brownd32460c2012-07-20 16:15:36 -0700827 void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) {
828 CharSequence curTitle = wp.getTitle();
829 if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
tiger_huangff58e302015-10-13 21:38:19 +0800830 wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
Jeff Brownd32460c2012-07-20 16:15:36 -0700831 if (wp.token == null) {
832 View decor = peekDecorView();
833 if (decor != null) {
834 wp.token = decor.getWindowToken();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800835 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800836 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700837 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700838 final StringBuilder title = new StringBuilder(32);
Jeff Brownd32460c2012-07-20 16:15:36 -0700839 if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700840 title.append("Media");
Jeff Brownd32460c2012-07-20 16:15:36 -0700841 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700842 title.append("MediaOvr");
Jeff Brownd32460c2012-07-20 16:15:36 -0700843 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700844 title.append("Panel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700845 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700846 title.append("SubPanel");
Wale Ogunwale0a4dc222015-04-14 12:58:42 -0700847 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700848 title.append("AboveSubPanel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700849 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700850 title.append("AtchDlg");
Jeff Brownd32460c2012-07-20 16:15:36 -0700851 } else {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700852 title.append(wp.type);
Jeff Brownd32460c2012-07-20 16:15:36 -0700853 }
854 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700855 title.append(":").append(mAppName);
Jeff Brownd32460c2012-07-20 16:15:36 -0700856 }
857 wp.setTitle(title);
Romain Guy529b60a2010-08-03 18:05:47 -0700858 }
tiger_huangff58e302015-10-13 21:38:19 +0800859 } else if (wp.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW &&
860 wp.type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
861 // We don't set the app token to this system window because the life cycles should be
862 // independent. If an app creates a system window and then the app goes to the stopped
863 // state, the system window should not be affected (can still show and receive input
864 // events).
865 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700866 final StringBuilder title = new StringBuilder(32);
867 title.append("Sys").append(wp.type);
tiger_huangff58e302015-10-13 21:38:19 +0800868 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700869 title.append(":").append(mAppName);
tiger_huangff58e302015-10-13 21:38:19 +0800870 }
871 wp.setTitle(title);
872 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700873 } else {
874 if (wp.token == null) {
875 wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
876 }
877 if ((curTitle == null || curTitle.length() == 0)
878 && mAppName != null) {
879 wp.setTitle(mAppName);
880 }
881 }
882 if (wp.packageName == null) {
883 wp.packageName = mContext.getPackageName();
884 }
Robert Carr13678ee2016-04-20 14:04:15 -0700885 if (mHardwareAccelerated ||
886 (mWindowAttributes.flags & FLAG_HARDWARE_ACCELERATED) != 0) {
887 wp.flags |= FLAG_HARDWARE_ACCELERATED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800888 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800889 }
890
891 /**
892 * Return the window manager allowing this Window to display its own
893 * windows.
894 *
895 * @return WindowManager The ViewManager.
896 */
897 public WindowManager getWindowManager() {
898 return mWindowManager;
899 }
900
901 /**
902 * Set the Callback interface for this window, used to intercept key
903 * events and other dynamic operations in the window.
904 *
905 * @param callback The desired Callback interface.
906 */
907 public void setCallback(Callback callback) {
908 mCallback = callback;
909 }
910
911 /**
912 * Return the current Callback interface for this window.
913 */
914 public final Callback getCallback() {
915 return mCallback;
916 }
917
Andres Morales06f5bc72015-12-15 15:21:31 -0800918 /**
Andrew Zeng8b7fb462018-08-03 13:32:04 -0700919 * Set an observer to collect frame stats for each frame rendered in this window.
Andres Morales06f5bc72015-12-15 15:21:31 -0800920 *
921 * Must be in hardware rendering mode.
Andres Morales06f5bc72015-12-15 15:21:31 -0800922 */
Andres Moralesd908c622016-04-20 13:13:34 -0700923 public final void addOnFrameMetricsAvailableListener(
924 @NonNull OnFrameMetricsAvailableListener listener,
Andres Morales910beb82016-02-02 16:19:40 -0800925 Handler handler) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800926 final View decorView = getDecorView();
927 if (decorView == null) {
928 throw new IllegalStateException("can't observe a Window without an attached view");
929 }
930
Andres Morales910beb82016-02-02 16:19:40 -0800931 if (listener == null) {
932 throw new NullPointerException("listener cannot be null");
Andres Morales06f5bc72015-12-15 15:21:31 -0800933 }
934
Andres Morales910beb82016-02-02 16:19:40 -0800935 decorView.addFrameMetricsListener(this, listener, handler);
Andres Morales06f5bc72015-12-15 15:21:31 -0800936 }
937
938 /**
939 * Remove observer and stop listening to frame stats for this window.
Andres Morales06f5bc72015-12-15 15:21:31 -0800940 */
Andres Moralesd908c622016-04-20 13:13:34 -0700941 public final void removeOnFrameMetricsAvailableListener(OnFrameMetricsAvailableListener listener) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800942 final View decorView = getDecorView();
943 if (decorView != null) {
Andres Morales910beb82016-02-02 16:19:40 -0800944 getDecorView().removeFrameMetricsListener(listener);
Andres Morales06f5bc72015-12-15 15:21:31 -0800945 }
946 }
947
Adam Powell117b6952014-05-05 18:14:56 -0700948 /** @hide */
949 public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) {
950 mOnWindowDismissedCallback = dcb;
951 }
952
953 /** @hide */
Ned Burns7d6cb912016-12-02 17:25:33 -0500954 public final void dispatchOnWindowDismissed(
955 boolean finishTask, boolean suppressWindowTransition) {
Adam Powell117b6952014-05-05 18:14:56 -0700956 if (mOnWindowDismissedCallback != null) {
Ned Burns7d6cb912016-12-02 17:25:33 -0500957 mOnWindowDismissedCallback.onWindowDismissed(finishTask, suppressWindowTransition);
Adam Powell117b6952014-05-05 18:14:56 -0700958 }
959 }
960
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700961 /** @hide */
Michael Kwan67639a52016-12-16 12:38:10 -0800962 public final void setOnWindowSwipeDismissedCallback(OnWindowSwipeDismissedCallback sdcb) {
963 mOnWindowSwipeDismissedCallback = sdcb;
964 }
965
966 /** @hide */
967 public final void dispatchOnWindowSwipeDismissed() {
968 if (mOnWindowSwipeDismissedCallback != null) {
969 mOnWindowSwipeDismissedCallback.onWindowSwipeDismissed();
970 }
971 }
972
973 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700974 public final void setWindowControllerCallback(WindowControllerCallback wccb) {
975 mWindowControllerCallback = wccb;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700976 }
977
978 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700979 public final WindowControllerCallback getWindowControllerCallback() {
980 return mWindowControllerCallback;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700981 }
982
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800983 /**
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800984 * Set a callback for changes of area where caption will draw its content.
985 *
986 * @param listener Callback that will be called when the area changes.
987 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800988 public final void setRestrictedCaptionAreaListener(OnRestrictedCaptionAreaChangedListener listener) {
989 mOnRestrictedCaptionAreaChangedListener = listener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800990 mRestrictedCaptionAreaRect = listener != null ? new Rect() : null;
991 }
992
993 /**
Dianne Hackborndc8a7f62010-05-10 11:29:34 -0700994 * Take ownership of this window's surface. The window's view hierarchy
995 * will no longer draw into the surface, though it will otherwise continue
996 * to operate (such as for receiving input events). The given SurfaceHolder
997 * callback will be used to tell you about state changes to the surface.
998 */
Dianne Hackbornd76b67c2010-07-13 17:48:30 -0700999 public abstract void takeSurface(SurfaceHolder.Callback2 callback);
RoboErik55011652014-07-09 15:05:53 -07001000
Dianne Hackborndc8a7f62010-05-10 11:29:34 -07001001 /**
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -07001002 * Take ownership of this window's InputQueue. The window will no
1003 * longer read and dispatch input events from the queue; it is your
Dianne Hackborna95e4cb2010-06-18 18:09:33 -07001004 * responsibility to do so.
1005 */
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -07001006 public abstract void takeInputQueue(InputQueue.Callback callback);
RoboErik55011652014-07-09 15:05:53 -07001007
Dianne Hackborna95e4cb2010-06-18 18:09:33 -07001008 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001009 * Return whether this window is being displayed with a floating style
1010 * (based on the {@link android.R.attr#windowIsFloating} attribute in
1011 * the style/theme).
1012 *
1013 * @return Returns true if the window is configured to be displayed floating
1014 * on top of whatever is behind it.
1015 */
1016 public abstract boolean isFloating();
1017
1018 /**
1019 * Set the width and height layout parameters of the window. The default
Dianne Hackbornc9189352010-12-15 14:57:25 -08001020 * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT
1021 * or an absolute value to make a window that is not full-screen.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001022 *
1023 * @param width The desired layout width of the window.
1024 * @param height The desired layout height of the window.
Dianne Hackbornc9189352010-12-15 14:57:25 -08001025 *
1026 * @see ViewGroup.LayoutParams#height
1027 * @see ViewGroup.LayoutParams#width
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001028 */
Dianne Hackbornc9189352010-12-15 14:57:25 -08001029 public void setLayout(int width, int height) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001030 final WindowManager.LayoutParams attrs = getAttributes();
1031 attrs.width = width;
1032 attrs.height = height;
Adrian Roosea562512014-05-05 13:33:03 +02001033 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001034 }
1035
1036 /**
1037 * Set the gravity of the window, as per the Gravity constants. This
1038 * controls how the window manager is positioned in the overall window; it
1039 * is only useful when using WRAP_CONTENT for the layout width or height.
1040 *
1041 * @param gravity The desired gravity constant.
1042 *
1043 * @see Gravity
1044 * @see #setLayout
1045 */
1046 public void setGravity(int gravity)
1047 {
1048 final WindowManager.LayoutParams attrs = getAttributes();
1049 attrs.gravity = gravity;
Adrian Roosea562512014-05-05 13:33:03 +02001050 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001051 }
1052
1053 /**
1054 * Set the type of the window, as per the WindowManager.LayoutParams
1055 * types.
1056 *
1057 * @param type The new window type (see WindowManager.LayoutParams).
1058 */
1059 public void setType(int type) {
1060 final WindowManager.LayoutParams attrs = getAttributes();
1061 attrs.type = type;
Adrian Roosea562512014-05-05 13:33:03 +02001062 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001063 }
1064
1065 /**
1066 * Set the format of window, as per the PixelFormat types. This overrides
1067 * the default format that is selected by the Window based on its
1068 * window decorations.
1069 *
1070 * @param format The new window format (see PixelFormat). Use
1071 * PixelFormat.UNKNOWN to allow the Window to select
1072 * the format.
1073 *
1074 * @see PixelFormat
1075 */
1076 public void setFormat(int format) {
1077 final WindowManager.LayoutParams attrs = getAttributes();
1078 if (format != PixelFormat.UNKNOWN) {
1079 attrs.format = format;
1080 mHaveWindowFormat = true;
1081 } else {
1082 attrs.format = mDefaultWindowFormat;
1083 mHaveWindowFormat = false;
1084 }
Adrian Roosea562512014-05-05 13:33:03 +02001085 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001086 }
1087
1088 /**
1089 * Specify custom animations to use for the window, as per
1090 * {@link WindowManager.LayoutParams#windowAnimations
1091 * WindowManager.LayoutParams.windowAnimations}. Providing anything besides
1092 * 0 here will override the animations the window would
1093 * normally retrieve from its theme.
1094 */
Tor Norbye417ee5b2015-03-10 20:57:37 -07001095 public void setWindowAnimations(@StyleRes int resId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001096 final WindowManager.LayoutParams attrs = getAttributes();
1097 attrs.windowAnimations = resId;
Adrian Roosea562512014-05-05 13:33:03 +02001098 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001099 }
1100
1101 /**
1102 * Specify an explicit soft input mode to use for the window, as per
1103 * {@link WindowManager.LayoutParams#softInputMode
1104 * WindowManager.LayoutParams.softInputMode}. Providing anything besides
1105 * "unspecified" here will override the input mode the window would
1106 * normally retrieve from its theme.
1107 */
1108 public void setSoftInputMode(int mode) {
1109 final WindowManager.LayoutParams attrs = getAttributes();
1110 if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
1111 attrs.softInputMode = mode;
1112 mHasSoftInputMode = true;
1113 } else {
1114 mHasSoftInputMode = false;
1115 }
Adrian Roosea562512014-05-05 13:33:03 +02001116 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001117 }
RoboErik55011652014-07-09 15:05:53 -07001118
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001119 /**
1120 * Convenience function to set the flag bits as specified in flags, as
1121 * per {@link #setFlags}.
1122 * @param flags The flag bits to be set.
1123 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001124 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001125 */
1126 public void addFlags(int flags) {
1127 setFlags(flags, flags);
1128 }
Adam Lesinski95c42972013-10-02 10:13:27 -07001129
Philip P. Moltmannd66dd992018-09-17 11:26:04 -07001130 /**
1131 * Add private flag bits.
1132 *
1133 * <p>Refer to the individual flags for the permissions needed.
1134 *
Philip P. Moltmann66ce2382018-10-09 13:46:11 -07001135 * @param flags The flag bits to add.
1136 *
1137 * @hide
1138 */
Philip P. Moltmann88de9652019-05-09 12:53:33 -07001139 @UnsupportedAppUsage
Philip P. Moltmann66ce2382018-10-09 13:46:11 -07001140 public void addPrivateFlags(int flags) {
1141 setPrivateFlags(flags, flags);
1142 }
1143
1144 /**
1145 * Add system flag bits.
1146 *
1147 * <p>Refer to the individual flags for the permissions needed.
1148 *
Philip P. Moltmannd66dd992018-09-17 11:26:04 -07001149 * <p>Note: Only for updateable system components (aka. mainline modules)
1150 *
1151 * @param flags The flag bits to add.
1152 *
1153 * @hide
1154 */
1155 @SystemApi
Philip P. Moltmann66ce2382018-10-09 13:46:11 -07001156 public void addSystemFlags(@WindowManager.LayoutParams.SystemFlags int flags) {
1157 addPrivateFlags(flags);
Adam Lesinski95c42972013-10-02 10:13:27 -07001158 }
RoboErik55011652014-07-09 15:05:53 -07001159
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001160 /**
1161 * Convenience function to clear the flag bits as specified in flags, as
1162 * per {@link #setFlags}.
1163 * @param flags The flag bits to be cleared.
1164 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001165 * @see #addFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001166 */
1167 public void clearFlags(int flags) {
1168 setFlags(0, flags);
1169 }
1170
1171 /**
1172 * Set the flags of the window, as per the
1173 * {@link WindowManager.LayoutParams WindowManager.LayoutParams}
1174 * flags.
RoboErik55011652014-07-09 15:05:53 -07001175 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001176 * <p>Note that some flags must be set before the window decoration is
1177 * created (by the first call to
1178 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or
1179 * {@link #getDecorView()}:
1180 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and
1181 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These
1182 * will be set for you based on the {@link android.R.attr#windowIsFloating}
1183 * attribute.
1184 *
1185 * @param flags The new window flags (see WindowManager.LayoutParams).
1186 * @param mask Which of the window flag bits to modify.
Christopher Tate193fc072012-06-04 11:27:40 -07001187 * @see #addFlags
1188 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 */
1190 public void setFlags(int flags, int mask) {
1191 final WindowManager.LayoutParams attrs = getAttributes();
1192 attrs.flags = (attrs.flags&~mask) | (flags&mask);
1193 mForcedWindowFlags |= mask;
Adrian Roosea562512014-05-05 13:33:03 +02001194 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001195 }
1196
Adam Lesinski95c42972013-10-02 10:13:27 -07001197 private void setPrivateFlags(int flags, int mask) {
1198 final WindowManager.LayoutParams attrs = getAttributes();
1199 attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
Adrian Roosea562512014-05-05 13:33:03 +02001200 dispatchWindowAttributesChanged(attrs);
1201 }
1202
1203 /**
1204 * {@hide}
1205 */
1206 protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) {
Adam Lesinski95c42972013-10-02 10:13:27 -07001207 if (mCallback != null) {
1208 mCallback.onWindowAttributesChanged(attrs);
1209 }
1210 }
1211
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001212 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001213 * <p>Sets the requested color mode of the window. The requested the color mode might
Romain Guy48327452017-01-23 17:03:35 -08001214 * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p>
1215 *
Romain Guyadae59b2017-06-20 14:45:53 -07001216 * <p>The requested color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
Romain Guy48327452017-01-23 17:03:35 -08001217 * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}.</p>
Romain Guyadae59b2017-06-20 14:45:53 -07001218 *
1219 * <p>The requested color mode is not guaranteed to be honored. Please refer to
1220 * {@link #getColorMode()} for more information.</p>
1221 *
1222 * @see #getColorMode()
1223 * @see Display#isWideColorGamut()
1224 * @see Configuration#isScreenWideColorGamut()
Romain Guy48327452017-01-23 17:03:35 -08001225 */
1226 public void setColorMode(@ActivityInfo.ColorMode int colorMode) {
1227 final WindowManager.LayoutParams attrs = getAttributes();
1228 attrs.setColorMode(colorMode);
1229 dispatchWindowAttributesChanged(attrs);
1230 }
1231
1232 /**
Galia Peycheva056b3ee2019-06-26 14:05:12 +02001233 * If {@code isPreferred} is true, this method requests that the connected display does minimal
1234 * post processing when this window is visible on the screen. Otherwise, it requests that the
1235 * display switches back to standard image processing.
1236 *
1237 * <p> By default, the display does not do minimal post processing and if this is desired, this
1238 * method should not be used. It should be used with {@code isPreferred=true} when low
1239 * latency has a higher priority than image enhancement processing (e.g. for games or video
1240 * conferencing). The display will automatically go back into standard image processing mode
1241 * when no window requesting minimal posst processing is visible on screen anymore.
1242 * {@code setPreferMinimalPostProcessing(false)} can be used if
1243 * {@code setPreferMinimalPostProcessing(true)} was previously called for this window and
1244 * minimal post processing is no longer required.
1245 *
1246 * <p>If the Display sink is connected via HDMI, the device will begin to send infoframes with
1247 * Auto Low Latency Mode enabled and Game Content Type. This will switch the connected display
1248 * to a minimal image processing mode (if available), which reduces latency, improving the user
1249 * experience for gaming or video conferencing applications. For more information, see HDMI 2.1
1250 * specification.
1251 *
1252 * <p>If the Display sink has an internal connection or uses some other protocol than HDMI,
1253 * effects may be similar but implementation-defined.
1254 *
1255 * <p>The ability to switch to a mode with minimal post proessing may be disabled by a user
1256 * setting in the system settings menu. In that case, this method does nothing.
1257 *
Galia Peychevabdd66e32020-02-27 19:16:28 +01001258 * @see android.content.pm.ActivityInfo#FLAG_PREFER_MINIMAL_POST_PROCESSING
Galia Peycheva056b3ee2019-06-26 14:05:12 +02001259 * @see android.view.Display#isMinimalPostProcessingSupported
1260 * @see android.view.WindowManager.LayoutParams#preferMinimalPostProcessing
1261 *
1262 * @param isPreferred Indicates whether minimal post processing is preferred for this window
1263 * ({@code isPreferred=true}) or not ({@code isPreferred=false}).
1264 */
1265 public void setPreferMinimalPostProcessing(boolean isPreferred) {
1266 mWindowAttributes.preferMinimalPostProcessing = isPreferred;
1267 dispatchWindowAttributesChanged(mWindowAttributes);
1268 }
1269
1270 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001271 * Returns the requested color mode of the window, one of
1272 * {@link ActivityInfo#COLOR_MODE_DEFAULT}, {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
1273 * or {@link ActivityInfo#COLOR_MODE_HDR}. If {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
1274 * was requested it is possible the window will not be put in wide color gamut mode depending
1275 * on device and display support for that mode. Use {@link #isWideColorGamut} to determine
1276 * if the window is currently in wide color gamut mode.
1277 *
1278 * @see #setColorMode(int)
1279 * @see Display#isWideColorGamut()
1280 * @see Configuration#isScreenWideColorGamut()
Romain Guy48327452017-01-23 17:03:35 -08001281 */
1282 @ActivityInfo.ColorMode
1283 public int getColorMode() {
1284 return getAttributes().getColorMode();
1285 }
1286
1287 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001288 * Returns true if this window's color mode is {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT},
1289 * the display has a wide color gamut and this device supports wide color gamut rendering.
1290 *
1291 * @see Display#isWideColorGamut()
1292 * @see Configuration#isScreenWideColorGamut()
1293 */
1294 public boolean isWideColorGamut() {
1295 return getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT
1296 && getContext().getResources().getConfiguration().isScreenWideColorGamut();
1297 }
1298
1299 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001300 * Set the amount of dim behind the window when using
1301 * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides
1302 * the default dim amount of that is selected by the Window based on
1303 * its theme.
1304 *
1305 * @param amount The new dim amount, from 0 for no dim to 1 for full dim.
1306 */
1307 public void setDimAmount(float amount) {
1308 final WindowManager.LayoutParams attrs = getAttributes();
1309 attrs.dimAmount = amount;
1310 mHaveDimAmount = true;
Adrian Roosea562512014-05-05 13:33:03 +02001311 dispatchWindowAttributesChanged(attrs);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001312 }
1313
1314 /**
Jorim Jaggi1f08f642020-01-29 13:11:46 +01001315 * Sets whether the decor view should fit root-level content views for {@link WindowInsets}.
Jorim Jaggi7fb715c2020-01-09 23:45:41 +01001316 * <p>
Jorim Jaggi1f08f642020-01-29 13:11:46 +01001317 * If set to {@code true}, the framework will inspect the now deprecated
1318 * {@link View#SYSTEM_UI_LAYOUT_FLAGS} as well the
1319 * {@link WindowManager.LayoutParams#SOFT_INPUT_ADJUST_RESIZE} flag and fits content according
1320 * to these flags.
Jorim Jaggi7fb715c2020-01-09 23:45:41 +01001321 * </p>
Jorim Jaggi7fb715c2020-01-09 23:45:41 +01001322 * <p>
Jorim Jaggi1f08f642020-01-29 13:11:46 +01001323 * If set to {@code false}, the framework will not fit the content view to the insets and will
1324 * just pass through the {@link WindowInsets} to the content view.
Jorim Jaggi7fb715c2020-01-09 23:45:41 +01001325 * </p>
Jorim Jaggi1f08f642020-01-29 13:11:46 +01001326 * @param decorFitsSystemWindows Whether the decor view should fit root-level content views for
1327 * insets.
Tiger Huang4a7835f2019-11-06 00:07:56 +08001328 */
Jorim Jaggi1f08f642020-01-29 13:11:46 +01001329 public void setDecorFitsSystemWindows(boolean decorFitsSystemWindows) {
Tiger Huang4a7835f2019-11-06 00:07:56 +08001330 }
1331
1332 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001333 * Specify custom window attributes. <strong>PLEASE NOTE:</strong> the
1334 * layout params you give here should generally be from values previously
1335 * retrieved with {@link #getAttributes()}; you probably do not want to
1336 * blindly create and apply your own, since this will blow away any values
1337 * set by the framework that you are not interested in.
1338 *
1339 * @param a The new window attributes, which will completely override any
1340 * current values.
1341 */
1342 public void setAttributes(WindowManager.LayoutParams a) {
1343 mWindowAttributes.copyFrom(a);
Adrian Roosea562512014-05-05 13:33:03 +02001344 dispatchWindowAttributesChanged(mWindowAttributes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001345 }
1346
1347 /**
1348 * Retrieve the current window attributes associated with this panel.
1349 *
1350 * @return WindowManager.LayoutParams Either the existing window
1351 * attributes object, or a freshly created one if there is none.
1352 */
1353 public final WindowManager.LayoutParams getAttributes() {
1354 return mWindowAttributes;
1355 }
1356
1357 /**
1358 * Return the window flags that have been explicitly set by the client,
1359 * so will not be modified by {@link #getDecorView}.
1360 */
1361 protected final int getForcedWindowFlags() {
1362 return mForcedWindowFlags;
1363 }
RoboErik55011652014-07-09 15:05:53 -07001364
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001365 /**
1366 * Has the app specified their own soft input mode?
1367 */
1368 protected final boolean hasSoftInputMode() {
1369 return mHasSoftInputMode;
1370 }
RoboErik55011652014-07-09 15:05:53 -07001371
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001372 /** @hide */
Mathew Inwooda570dee2018-08-17 14:56:00 +01001373 @UnsupportedAppUsage
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001374 public void setCloseOnTouchOutside(boolean close) {
1375 mCloseOnTouchOutside = close;
1376 mSetCloseOnTouchOutside = true;
1377 }
RoboErik55011652014-07-09 15:05:53 -07001378
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001379 /** @hide */
Mathew Inwooda570dee2018-08-17 14:56:00 +01001380 @UnsupportedAppUsage
Dianne Hackbornef575752011-01-18 17:35:17 -08001381 public void setCloseOnTouchOutsideIfNotSet(boolean close) {
1382 if (!mSetCloseOnTouchOutside) {
1383 mCloseOnTouchOutside = close;
1384 mSetCloseOnTouchOutside = true;
1385 }
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001386 }
RoboErik55011652014-07-09 15:05:53 -07001387
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001388 /** @hide */
Mathew Inwooda570dee2018-08-17 14:56:00 +01001389 @UnsupportedAppUsage
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001390 public abstract void alwaysReadCloseOnTouchAttr();
RoboErik55011652014-07-09 15:05:53 -07001391
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001392 /** @hide */
Mathew Inwood31755f92018-12-20 13:53:36 +00001393 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001394 public boolean shouldCloseOnTouch(Context context, MotionEvent event) {
Michael Wrightddec8fb2017-06-16 18:36:26 +01001395 final boolean isOutside =
Siarhei Vishniakou45385e22019-05-15 10:50:09 -07001396 event.getAction() == MotionEvent.ACTION_UP && isOutOfBounds(context, event)
Michael Wrightddec8fb2017-06-16 18:36:26 +01001397 || event.getAction() == MotionEvent.ACTION_OUTSIDE;
1398 if (mCloseOnTouchOutside && peekDecorView() != null && isOutside) {
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001399 return true;
1400 }
1401 return false;
1402 }
RoboErik55011652014-07-09 15:05:53 -07001403
Ruchi Kandoi43e38de2016-04-14 19:34:53 -07001404 /* Sets the Sustained Performance requirement for the calling window.
1405 * @param enable disables or enables the mode.
1406 */
1407 public void setSustainedPerformanceMode(boolean enable) {
1408 setPrivateFlags(enable
1409 ? WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE : 0,
1410 WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE);
1411 }
1412
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001413 private boolean isOutOfBounds(Context context, MotionEvent event) {
1414 final int x = (int) event.getX();
1415 final int y = (int) event.getY();
1416 final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
1417 final View decorView = getDecorView();
1418 return (x < -slop) || (y < -slop)
1419 || (x > (decorView.getWidth()+slop))
1420 || (y > (decorView.getHeight()+slop));
1421 }
RoboErik55011652014-07-09 15:05:53 -07001422
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001423 /**
1424 * Enable extended screen features. This must be called before
1425 * setContentView(). May be called as many times as desired as long as it
1426 * is before setContentView(). If not called, no extended features
1427 * will be available. You can not turn off a feature once it is requested.
1428 * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
1429 *
1430 * @param featureId The desired features, defined as constants by Window.
1431 * @return The features that are now set.
1432 */
1433 public boolean requestFeature(int featureId) {
1434 final int flag = 1<<featureId;
1435 mFeatures |= flag;
1436 mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
1437 return (mFeatures&flag) != 0;
1438 }
1439
Adam Powellf4a6ec42010-08-24 14:18:10 -07001440 /**
1441 * @hide Used internally to help resolve conflicting features.
1442 */
1443 protected void removeFeature(int featureId) {
1444 final int flag = 1<<featureId;
1445 mFeatures &= ~flag;
1446 mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag);
1447 }
1448
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001449 public final void makeActive() {
1450 if (mContainer != null) {
1451 if (mContainer.mActiveChild != null) {
1452 mContainer.mActiveChild.mIsActive = false;
1453 }
1454 mContainer.mActiveChild = this;
1455 }
1456 mIsActive = true;
1457 onActive();
1458 }
1459
1460 public final boolean isActive()
1461 {
1462 return mIsActive;
1463 }
1464
1465 /**
Alan Viverettedb7423c2017-03-31 13:13:58 -04001466 * Finds a view that was identified by the {@code android:id} XML attribute
Chris Craik6faa9e52018-01-11 10:46:10 -08001467 * that was processed in {@link android.app.Activity#onCreate}.
1468 * <p>
1469 * This will implicitly call {@link #getDecorView} with all of the associated side-effects.
Alan Viverettedb7423c2017-03-31 13:13:58 -04001470 * <p>
1471 * <strong>Note:</strong> In most cases -- depending on compiler support --
1472 * the resulting view is automatically cast to the target class type. If
1473 * the target class type is unconstrained, an explicit cast may be
1474 * necessary.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001475 *
Alan Viverettedb7423c2017-03-31 13:13:58 -04001476 * @param id the ID to search for
1477 * @return a view with given ID if found, or {@code null} otherwise
1478 * @see View#findViewById(int)
Chris Craik6faa9e52018-01-11 10:46:10 -08001479 * @see Window#requireViewById(int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001480 */
Scott Kennedyc0519552015-02-11 15:33:10 -08001481 @Nullable
Alan Viverettedb7423c2017-03-31 13:13:58 -04001482 public <T extends View> T findViewById(@IdRes int id) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001483 return getDecorView().findViewById(id);
1484 }
Chris Craik6faa9e52018-01-11 10:46:10 -08001485 /**
1486 * Finds a view that was identified by the {@code android:id} XML attribute
1487 * that was processed in {@link android.app.Activity#onCreate}, or throws an
1488 * IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy.
1489 * <p>
1490 * <strong>Note:</strong> In most cases -- depending on compiler support --
1491 * the resulting view is automatically cast to the target class type. If
1492 * the target class type is unconstrained, an explicit cast may be
1493 * necessary.
1494 *
1495 * @param id the ID to search for
1496 * @return a view with given ID
1497 * @see View#requireViewById(int)
1498 * @see Window#findViewById(int)
1499 */
1500 @NonNull
1501 public final <T extends View> T requireViewById(@IdRes int id) {
1502 T view = findViewById(id);
1503 if (view == null) {
1504 throw new IllegalArgumentException("ID does not reference a View inside this Window");
1505 }
1506 return view;
1507 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001508
1509 /**
1510 * Convenience for
1511 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1512 * to set the screen content from a layout resource. The resource will be
1513 * inflated, adding all top-level views to the screen.
1514 *
1515 * @param layoutResID Resource ID to be inflated.
1516 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1517 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001518 public abstract void setContentView(@LayoutRes int layoutResID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001519
1520 /**
1521 * Convenience for
1522 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1523 * set the screen content to an explicit view. This view is placed
1524 * directly into the screen's view hierarchy. It can itself be a complex
1525 * view hierarhcy.
1526 *
1527 * @param view The desired content to display.
1528 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1529 */
1530 public abstract void setContentView(View view);
1531
1532 /**
1533 * Set the screen content to an explicit view. This view is placed
1534 * directly into the screen's view hierarchy. It can itself be a complex
1535 * view hierarchy.
1536 *
1537 * <p>Note that calling this function "locks in" various characteristics
1538 * of the window that can not, from this point forward, be changed: the
1539 * features that have been requested with {@link #requestFeature(int)},
George Mountc3a043c2015-02-04 14:37:04 -08001540 * and certain window flags as described in {@link #setFlags(int, int)}.</p>
1541 *
1542 * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's
1543 * TransitionManager will be used to animate content from the current
1544 * content View to view.</p>
RoboErik55011652014-07-09 15:05:53 -07001545 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001546 * @param view The desired content to display.
1547 * @param params Layout parameters for the view.
George Mountc3a043c2015-02-04 14:37:04 -08001548 * @see #getTransitionManager()
1549 * @see #setTransitionManager(android.transition.TransitionManager)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001550 */
1551 public abstract void setContentView(View view, ViewGroup.LayoutParams params);
1552
1553 /**
1554 * Variation on
1555 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1556 * to add an additional content view to the screen. Added after any existing
1557 * ones in the screen -- existing views are NOT removed.
1558 *
1559 * @param view The desired content to display.
1560 * @param params Layout parameters for the view.
1561 */
1562 public abstract void addContentView(View view, ViewGroup.LayoutParams params);
1563
1564 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001565 * Remove the view that was used as the screen content.
1566 *
1567 * @hide
1568 */
1569 public abstract void clearContentView();
1570
1571 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001572 * Return the view in this Window that currently has focus, or null if
1573 * there are none. Note that this does not look in any containing
1574 * Window.
1575 *
1576 * @return View The current View with focus or null.
1577 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001578 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001579 public abstract View getCurrentFocus();
1580
1581 /**
1582 * Quick access to the {@link LayoutInflater} instance that this Window
1583 * retrieved from its Context.
1584 *
1585 * @return LayoutInflater The shared LayoutInflater.
1586 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001587 @NonNull
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001588 public abstract LayoutInflater getLayoutInflater();
1589
1590 public abstract void setTitle(CharSequence title);
1591
Alan Viverette2525d9c2013-11-15 14:42:19 -08001592 @Deprecated
Tor Norbye80756e32015-03-02 09:39:27 -08001593 public abstract void setTitleColor(@ColorInt int textColor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001594
1595 public abstract void openPanel(int featureId, KeyEvent event);
1596
1597 public abstract void closePanel(int featureId);
1598
1599 public abstract void togglePanel(int featureId, KeyEvent event);
1600
Dianne Hackbornb31e84bc2010-06-08 18:04:35 -07001601 public abstract void invalidatePanelMenu(int featureId);
RoboErik55011652014-07-09 15:05:53 -07001602
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001603 public abstract boolean performPanelShortcut(int featureId,
1604 int keyCode,
1605 KeyEvent event,
1606 int flags);
1607 public abstract boolean performPanelIdentifierAction(int featureId,
1608 int id,
1609 int flags);
1610
1611 public abstract void closeAllPanels();
1612
1613 public abstract boolean performContextMenuIdentifierAction(int id, int flags);
1614
1615 /**
1616 * Should be called when the configuration is changed.
RoboErik55011652014-07-09 15:05:53 -07001617 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001618 * @param newConfig The new configuration.
1619 */
1620 public abstract void onConfigurationChanged(Configuration newConfig);
RoboErik55011652014-07-09 15:05:53 -07001621
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001622 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001623 * Sets the window elevation.
Alan Viverette71922de2015-01-12 16:14:02 -08001624 * <p>
1625 * Changes to this property take effect immediately and will cause the
1626 * window surface to be recreated. This is an expensive operation and as a
1627 * result, this property should not be animated.
Alan Viverette79c067c52014-10-29 14:27:47 -07001628 *
1629 * @param elevation The window elevation.
1630 * @see View#setElevation(float)
1631 * @see android.R.styleable#Window_windowElevation
1632 */
1633 public void setElevation(float elevation) {}
1634
1635 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001636 * Gets the window elevation.
1637 *
1638 * @hide
1639 */
1640 public float getElevation() {
1641 return 0.0f;
1642 }
1643
1644 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001645 * Sets whether window content should be clipped to the outline of the
1646 * window background.
1647 *
1648 * @param clipToOutline Whether window content should be clipped to the
1649 * outline of the window background.
1650 * @see View#setClipToOutline(boolean)
1651 * @see android.R.styleable#Window_windowClipToOutline
1652 */
1653 public void setClipToOutline(boolean clipToOutline) {}
1654
1655 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001656 * Change the background of this window to a Drawable resource. Setting the
1657 * background to null will make the window be opaque. To make the window
1658 * transparent, you can use an empty drawable (for instance a ColorDrawable
1659 * with the color 0 or the system drawable android:drawable/empty.)
RoboErik55011652014-07-09 15:05:53 -07001660 *
Alan Viverette79c067c52014-10-29 14:27:47 -07001661 * @param resId The resource identifier of a drawable resource which will
1662 * be installed as the new background.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001663 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001664 public void setBackgroundDrawableResource(@DrawableRes int resId) {
Alan Viverette79c067c52014-10-29 14:27:47 -07001665 setBackgroundDrawable(mContext.getDrawable(resId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001666 }
1667
1668 /**
1669 * Change the background of this window to a custom Drawable. Setting the
1670 * background to null will make the window be opaque. To make the window
1671 * transparent, you can use an empty drawable (for instance a ColorDrawable
1672 * with the color 0 or the system drawable android:drawable/empty.)
1673 *
1674 * @param drawable The new Drawable to use for this window's background.
1675 */
1676 public abstract void setBackgroundDrawable(Drawable drawable);
1677
1678 /**
1679 * Set the value for a drawable feature of this window, from a resource
Tor Norbye7b9c9122013-05-30 16:48:33 -07001680 * identifier. You must have called requestFeature(featureId) before
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001681 * calling this function.
1682 *
1683 * @see android.content.res.Resources#getDrawable(int)
1684 *
1685 * @param featureId The desired drawable feature to change, defined as a
1686 * constant by Window.
1687 * @param resId Resource identifier of the desired image.
1688 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001689 public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001690
1691 /**
1692 * Set the value for a drawable feature of this window, from a URI. You
1693 * must have called requestFeature(featureId) before calling this
1694 * function.
1695 *
1696 * <p>The only URI currently supported is "content:", specifying an image
1697 * in a content provider.
1698 *
1699 * @see android.widget.ImageView#setImageURI
1700 *
1701 * @param featureId The desired drawable feature to change. Features are
1702 * constants defined by Window.
1703 * @param uri The desired URI.
1704 */
1705 public abstract void setFeatureDrawableUri(int featureId, Uri uri);
1706
1707 /**
1708 * Set an explicit Drawable value for feature of this window. You must
1709 * have called requestFeature(featureId) before calling this function.
1710 *
Alan Viverette9678e342014-10-24 15:23:58 -07001711 * @param featureId The desired drawable feature to change. Features are
1712 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001713 * @param drawable A Drawable object to display.
1714 */
1715 public abstract void setFeatureDrawable(int featureId, Drawable drawable);
1716
1717 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001718 * Set a custom alpha value for the given drawable feature, controlling how
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001719 * much the background is visible through it.
1720 *
Alan Viverette9678e342014-10-24 15:23:58 -07001721 * @param featureId The desired drawable feature to change. Features are
1722 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001723 * @param alpha The alpha amount, 0 is completely transparent and 255 is
1724 * completely opaque.
1725 */
1726 public abstract void setFeatureDrawableAlpha(int featureId, int alpha);
1727
1728 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001729 * Set the integer value for a feature. The range of the value depends on
1730 * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from
1731 * 0 to 10000. At 10000 the progress is complete and the indicator hidden.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001732 *
Alan Viverette9678e342014-10-24 15:23:58 -07001733 * @param featureId The desired feature to change. Features are constants
1734 * defined by Window.
1735 * @param value The value for the feature. The interpretation of this
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001736 * value is feature-specific.
1737 */
1738 public abstract void setFeatureInt(int featureId, int value);
1739
1740 /**
1741 * Request that key events come to this activity. Use this if your
1742 * activity has no views with focus, but the activity still wants
1743 * a chance to process key events.
1744 */
1745 public abstract void takeKeyEvents(boolean get);
1746
1747 /**
1748 * Used by custom windows, such as Dialog, to pass the key press event
1749 * further down the view hierarchy. Application developers should
1750 * not need to implement or call this.
1751 *
1752 */
1753 public abstract boolean superDispatchKeyEvent(KeyEvent event);
1754
1755 /**
Jeff Brown64da12a2011-01-04 19:57:47 -08001756 * Used by custom windows, such as Dialog, to pass the key shortcut press event
1757 * further down the view hierarchy. Application developers should
1758 * not need to implement or call this.
1759 *
1760 */
1761 public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event);
1762
1763 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001764 * Used by custom windows, such as Dialog, to pass the touch screen event
1765 * further down the view hierarchy. Application developers should
1766 * not need to implement or call this.
1767 *
1768 */
1769 public abstract boolean superDispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001770
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001771 /**
1772 * Used by custom windows, such as Dialog, to pass the trackball event
1773 * further down the view hierarchy. Application developers should
1774 * not need to implement or call this.
1775 *
1776 */
1777 public abstract boolean superDispatchTrackballEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001778
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001779 /**
Jeff Browncb1404e2011-01-15 18:14:15 -08001780 * Used by custom windows, such as Dialog, to pass the generic motion event
1781 * further down the view hierarchy. Application developers should
1782 * not need to implement or call this.
1783 *
1784 */
1785 public abstract boolean superDispatchGenericMotionEvent(MotionEvent event);
1786
1787 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001788 * Retrieve the top-level window decor view (containing the standard
1789 * window frame/decorations and the client's content inside of that), which
1790 * can be added as a window to the window manager.
RoboErik55011652014-07-09 15:05:53 -07001791 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001792 * <p><em>Note that calling this function for the first time "locks in"
1793 * various window characteristics as described in
1794 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p>
RoboErik55011652014-07-09 15:05:53 -07001795 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001796 * @return Returns the top-level window decor view.
1797 */
Siarhei Vishniakouc771e7e2018-04-19 11:43:29 -07001798 public abstract @NonNull View getDecorView();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001799
1800 /**
1801 * Retrieve the current decor view, but only if it has already been created;
1802 * otherwise returns null.
RoboErik55011652014-07-09 15:05:53 -07001803 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001804 * @return Returns the top-level window decor or null.
1805 * @see #getDecorView
1806 */
1807 public abstract View peekDecorView();
1808
1809 public abstract Bundle saveHierarchyState();
RoboErik55011652014-07-09 15:05:53 -07001810
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001811 public abstract void restoreHierarchyState(Bundle savedInstanceState);
RoboErik55011652014-07-09 15:05:53 -07001812
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001813 protected abstract void onActive();
1814
1815 /**
1816 * Return the feature bits that are enabled. This is the set of features
1817 * that were given to requestFeature(), and are being handled by this
1818 * Window itself or its container. That is, it is the set of
1819 * requested features that you can actually use.
1820 *
1821 * <p>To do: add a public version of this API that allows you to check for
1822 * features by their feature ID.
1823 *
1824 * @return int The feature bits.
1825 */
1826 protected final int getFeatures()
1827 {
1828 return mFeatures;
1829 }
RoboErik55011652014-07-09 15:05:53 -07001830
Adam Powell33b97432010-04-20 10:01:14 -07001831 /**
Bryce Leed6e6e722014-11-21 11:08:45 -08001832 * Return the feature bits set by default on a window.
1833 * @param context The context used to access resources
1834 */
1835 public static int getDefaultFeatures(Context context) {
1836 int features = 0;
1837
1838 final Resources res = context.getResources();
1839 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
1840 features |= 1 << FEATURE_OPTIONS_PANEL;
1841 }
1842
1843 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
1844 features |= 1 << FEATURE_CONTEXT_MENU;
1845 }
1846
1847 return features;
1848 }
1849
1850 /**
Adam Powell33b97432010-04-20 10:01:14 -07001851 * Query for the availability of a certain feature.
RoboErik55011652014-07-09 15:05:53 -07001852 *
Adam Powell33b97432010-04-20 10:01:14 -07001853 * @param feature The feature ID to check
1854 * @return true if the feature is enabled, false otherwise.
1855 */
1856 public boolean hasFeature(int feature) {
1857 return (getFeatures() & (1 << feature)) != 0;
1858 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001859
1860 /**
1861 * Return the feature bits that are being implemented by this Window.
1862 * This is the set of features that were given to requestFeature(), and are
1863 * being handled by only this Window itself, not by its containers.
1864 *
1865 * @return int The feature bits.
1866 */
1867 protected final int getLocalFeatures()
1868 {
1869 return mLocalFeatures;
1870 }
1871
1872 /**
1873 * Set the default format of window, as per the PixelFormat types. This
1874 * is the format that will be used unless the client specifies in explicit
1875 * format with setFormat();
1876 *
1877 * @param format The new window format (see PixelFormat).
1878 *
1879 * @see #setFormat
1880 * @see PixelFormat
1881 */
1882 protected void setDefaultWindowFormat(int format) {
1883 mDefaultWindowFormat = format;
1884 if (!mHaveWindowFormat) {
1885 final WindowManager.LayoutParams attrs = getAttributes();
1886 attrs.format = format;
Adrian Roosea562512014-05-05 13:33:03 +02001887 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001888 }
1889 }
1890
Dianne Hackborn661cd522011-08-22 00:26:20 -07001891 /** @hide */
1892 protected boolean haveDimAmount() {
1893 return mHaveDimAmount;
1894 }
1895
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001896 public abstract void setChildDrawable(int featureId, Drawable drawable);
1897
1898 public abstract void setChildInt(int featureId, int value);
1899
1900 /**
1901 * Is a keypress one of the defined shortcut keys for this window.
1902 * @param keyCode the key code from {@link android.view.KeyEvent} to check.
1903 * @param event the {@link android.view.KeyEvent} to use to help check.
1904 */
1905 public abstract boolean isShortcutKey(int keyCode, KeyEvent event);
RoboErik55011652014-07-09 15:05:53 -07001906
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001907 /**
RoboErik55011652014-07-09 15:05:53 -07001908 * @see android.app.Activity#setVolumeControlStream(int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001909 */
1910 public abstract void setVolumeControlStream(int streamType);
1911
1912 /**
1913 * @see android.app.Activity#getVolumeControlStream()
1914 */
1915 public abstract int getVolumeControlStream();
Adam Powell269248d2011-08-02 10:26:54 -07001916
1917 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001918 * Sets a {@link MediaController} to send media keys and volume changes to.
1919 * If set, this should be preferred for all media keys and volume requests
1920 * sent to this window.
1921 *
1922 * @param controller The controller for the session which should receive
1923 * media keys and volume changes.
RoboErik55011652014-07-09 15:05:53 -07001924 * @see android.app.Activity#setMediaController(android.media.session.MediaController)
1925 */
1926 public void setMediaController(MediaController controller) {
1927 }
1928
1929 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001930 * Gets the {@link MediaController} that was previously set.
1931 *
1932 * @return The controller which should receive events.
1933 * @see #setMediaController(android.media.session.MediaController)
RoboErik55011652014-07-09 15:05:53 -07001934 * @see android.app.Activity#getMediaController()
1935 */
1936 public MediaController getMediaController() {
1937 return null;
1938 }
1939
1940 /**
Adam Powell269248d2011-08-02 10:26:54 -07001941 * Set extra options that will influence the UI for this window.
1942 * @param uiOptions Flags specifying extra options for this window.
1943 */
1944 public void setUiOptions(int uiOptions) { }
Adam Powelle43fca92011-08-16 12:57:01 -07001945
1946 /**
1947 * Set extra options that will influence the UI for this window.
1948 * Only the bits filtered by mask will be modified.
1949 * @param uiOptions Flags specifying extra options for this window.
1950 * @param mask Flags specifying which options should be modified. Others will remain unchanged.
1951 */
1952 public void setUiOptions(int uiOptions, int mask) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001953
1954 /**
1955 * Set the primary icon for this window.
1956 *
1957 * @param resId resource ID of a drawable to set
1958 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001959 public void setIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001960
1961 /**
1962 * Set the default icon for this window.
1963 * This will be overridden by any other icon set operation which could come from the
1964 * theme or another explicit set.
1965 *
1966 * @hide
1967 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001968 public void setDefaultIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001969
1970 /**
1971 * Set the logo for this window. A logo is often shown in place of an
1972 * {@link #setIcon(int) icon} but is generally wider and communicates window title information
1973 * as well.
1974 *
1975 * @param resId resource ID of a drawable to set
1976 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001977 public void setLogo(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001978
1979 /**
1980 * Set the default logo for this window.
1981 * This will be overridden by any other logo set operation which could come from the
1982 * theme or another explicit set.
1983 *
1984 * @hide
1985 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001986 public void setDefaultLogo(@DrawableRes int resId) { }
keunyoung30f420f2013-08-02 14:23:10 -07001987
1988 /**
1989 * Set focus locally. The window should have the
1990 * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.
1991 * @param hasFocus Whether this window has focus or not.
1992 * @param inTouchMode Whether this window is in touch mode or not.
1993 */
1994 public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { }
1995
1996 /**
1997 * Inject an event to window locally.
1998 * @param event A key or touch event to inject to this window.
1999 */
2000 public void injectInputEvent(InputEvent event) { }
Adam Powellcfbe9be2013-11-06 14:58:58 -08002001
2002 /**
2003 * Retrieve the {@link TransitionManager} responsible for for default transitions
2004 * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
2005 *
2006 * <p>This method will return non-null after content has been initialized (e.g. by using
2007 * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p>
2008 *
2009 * @return This window's content TransitionManager or null if none is set.
George Mountc3a043c2015-02-04 14:37:04 -08002010 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08002011 */
2012 public TransitionManager getTransitionManager() {
2013 return null;
2014 }
2015
2016 /**
2017 * Set the {@link TransitionManager} to use for default transitions in this window.
2018 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
2019 *
2020 * @param tm The TransitionManager to use for scene changes.
George Mountc3a043c2015-02-04 14:37:04 -08002021 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08002022 */
2023 public void setTransitionManager(TransitionManager tm) {
2024 throw new UnsupportedOperationException();
2025 }
2026
2027 /**
2028 * Retrieve the {@link Scene} representing this window's current content.
2029 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
2030 *
2031 * <p>This method will return null if the current content is not represented by a Scene.</p>
2032 *
2033 * @return Current Scene being shown or null
2034 */
2035 public Scene getContentScene() {
2036 return null;
2037 }
2038
2039 /**
George Mount31a21722014-03-24 17:44:36 -07002040 * Sets the Transition that will be used to move Views into the initial scene. The entering
2041 * Views will be those that are regular Views or ViewGroups that have
2042 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2043 * {@link android.transition.Visibility} as entering is governed by changing visibility from
2044 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
2045 * entering Views will remain unaffected.
George Mountc03da0e2014-08-22 17:04:02 -07002046 *
George Mount31a21722014-03-24 17:44:36 -07002047 * @param transition The Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002048 * @attr ref android.R.styleable#Window_windowEnterTransition
Adam Powellcfbe9be2013-11-06 14:58:58 -08002049 */
George Mount31a21722014-03-24 17:44:36 -07002050 public void setEnterTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08002051
2052 /**
George Mount68f96d82014-07-31 13:13:10 -07002053 * Sets the Transition that will be used to move Views out of the scene when the Window is
2054 * preparing to close, for example after a call to
2055 * {@link android.app.Activity#finishAfterTransition()}. The exiting
2056 * Views will be those that are regular Views or ViewGroups that have
2057 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2058 * {@link android.transition.Visibility} as entering is governed by changing visibility from
2059 * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null,
2060 * entering Views will remain unaffected. If nothing is set, the default will be to
2061 * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
George Mountc03da0e2014-08-22 17:04:02 -07002062 *
George Mount68f96d82014-07-31 13:13:10 -07002063 * @param transition The Transition to use to move Views out of the Scene when the Window
2064 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07002065 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002066 */
2067 public void setReturnTransition(Transition transition) {}
2068
2069 /**
George Mount31a21722014-03-24 17:44:36 -07002070 * Sets the Transition that will be used to move Views out of the scene when starting a
2071 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
2072 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2073 * {@link android.transition.Visibility} as exiting is governed by changing visibility
2074 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07002075 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002076 *
George Mount31a21722014-03-24 17:44:36 -07002077 * @param transition The Transition to use to move Views out of the scene when calling a
2078 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002079 * @attr ref android.R.styleable#Window_windowExitTransition
George Mount0a778ed2013-12-13 13:35:36 -08002080 */
George Mount31a21722014-03-24 17:44:36 -07002081 public void setExitTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08002082
2083 /**
George Mount68f96d82014-07-31 13:13:10 -07002084 * Sets the Transition that will be used to move Views in to the scene when returning from
2085 * a previously-started Activity. The entering Views will be those that are regular Views
2086 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
2087 * will extend {@link android.transition.Visibility} as exiting is governed by changing
2088 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
2089 * the views will remain unaffected. If nothing is set, the default will be to use the same
2090 * transition as {@link #setExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07002091 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002092 *
George Mount68f96d82014-07-31 13:13:10 -07002093 * @param transition The Transition to use to move Views into the scene when reentering from a
2094 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002095 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002096 */
2097 public void setReenterTransition(Transition transition) {}
2098
2099 /**
George Mount31a21722014-03-24 17:44:36 -07002100 * Returns the transition used to move Views into the initial scene. The entering
2101 * Views will be those that are regular Views or ViewGroups that have
2102 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2103 * {@link android.transition.Visibility} as entering is governed by changing visibility from
2104 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
George Mount9826f632014-09-11 08:50:09 -07002105 * entering Views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07002106 *
2107 * @return the Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002108 * @attr ref android.R.styleable#Window_windowEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08002109 */
George Mount31a21722014-03-24 17:44:36 -07002110 public Transition getEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08002111
2112 /**
Chet Haaseb64e777f2016-12-09 07:17:10 -08002113 * 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 -07002114 * preparing to close, for example after a call to
2115 * {@link android.app.Activity#finishAfterTransition()}. The exiting
2116 * Views will be those that are regular Views or ViewGroups that have
2117 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2118 * {@link android.transition.Visibility} as entering is governed by changing visibility from
2119 * {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mountc03da0e2014-08-22 17:04:02 -07002120 *
George Mount68f96d82014-07-31 13:13:10 -07002121 * @return The Transition to use to move Views out of the Scene when the Window
2122 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07002123 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002124 */
2125 public Transition getReturnTransition() { return null; }
2126
2127 /**
George Mount31a21722014-03-24 17:44:36 -07002128 * Returns the Transition that will be used to move Views out of the scene when starting a
2129 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
2130 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2131 * {@link android.transition.Visibility} as exiting is governed by changing visibility
2132 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07002133 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002134 *
George Mount31a21722014-03-24 17:44:36 -07002135 * @return the Transition to use to move Views out of the scene when calling a
2136 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002137 * @attr ref android.R.styleable#Window_windowExitTransition
George Mountcb4b7d92014-02-25 10:47:55 -08002138 */
George Mount31a21722014-03-24 17:44:36 -07002139 public Transition getExitTransition() { return null; }
George Mount0a778ed2013-12-13 13:35:36 -08002140
2141 /**
George Mount68f96d82014-07-31 13:13:10 -07002142 * Returns the Transition that will be used to move Views in to the scene when returning from
2143 * a previously-started Activity. The entering Views will be those that are regular Views
2144 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
2145 * will extend {@link android.transition.Visibility} as exiting is governed by changing
2146 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mount9826f632014-09-11 08:50:09 -07002147 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002148 *
George Mount68f96d82014-07-31 13:13:10 -07002149 * @return The Transition to use to move Views into the scene when reentering from a
2150 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002151 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002152 */
2153 public Transition getReenterTransition() { return null; }
2154
2155 /**
George Mount31a21722014-03-24 17:44:36 -07002156 * Sets the Transition that will be used for shared elements transferred into the content
2157 * Scene. Typical Transitions will affect size and location, such as
George Mount990205e2014-06-24 09:36:18 -07002158 * {@link android.transition.ChangeBounds}. A null
George Mount31a21722014-03-24 17:44:36 -07002159 * value will cause transferred shared elements to blink to the final position.
George Mount9826f632014-09-11 08:50:09 -07002160 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002161 *
George Mount31a21722014-03-24 17:44:36 -07002162 * @param transition The Transition to use for shared elements transferred into the content
2163 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002164 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08002165 */
George Mount31a21722014-03-24 17:44:36 -07002166 public void setSharedElementEnterTransition(Transition transition) {}
George Mounte1803372014-02-26 19:00:52 +00002167
2168 /**
George Mount68f96d82014-07-31 13:13:10 -07002169 * Sets the Transition that will be used for shared elements transferred back to a
2170 * calling Activity. Typical Transitions will affect size and location, such as
2171 * {@link android.transition.ChangeBounds}. A null
2172 * value will cause transferred shared elements to blink to the final position.
2173 * If no value is set, the default will be to use the same value as
2174 * {@link #setSharedElementEnterTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07002175 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002176 *
George Mount68f96d82014-07-31 13:13:10 -07002177 * @param transition The Transition to use for shared elements transferred out of the content
2178 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002179 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002180 */
2181 public void setSharedElementReturnTransition(Transition transition) {}
2182
2183 /**
George Mount31a21722014-03-24 17:44:36 -07002184 * Returns the Transition that will be used for shared elements transferred into the content
George Mount9826f632014-09-11 08:50:09 -07002185 * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002186 *
George Mount31a21722014-03-24 17:44:36 -07002187 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002188 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mountcb4b7d92014-02-25 10:47:55 -08002189 */
George Mount31a21722014-03-24 17:44:36 -07002190 public Transition getSharedElementEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08002191
2192 /**
George Mount68f96d82014-07-31 13:13:10 -07002193 * Returns the Transition that will be used for shared elements transferred back to a
George Mount9826f632014-09-11 08:50:09 -07002194 * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002195 *
George Mount68f96d82014-07-31 13:13:10 -07002196 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002197 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002198 */
2199 public Transition getSharedElementReturnTransition() { return null; }
2200
2201 /**
George Mount31a21722014-03-24 17:44:36 -07002202 * Sets the Transition that will be used for shared elements after starting a new Activity
2203 * before the shared elements are transferred to the called Activity. If the shared elements
2204 * must animate during the exit transition, this Transition should be used. Upon completion,
2205 * the shared elements may be transferred to the started Activity.
George Mount9826f632014-09-11 08:50:09 -07002206 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002207 *
George Mount31a21722014-03-24 17:44:36 -07002208 * @param transition The Transition to use for shared elements in the launching Window
2209 * prior to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07002210 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mounte1803372014-02-26 19:00:52 +00002211 */
George Mount31a21722014-03-24 17:44:36 -07002212 public void setSharedElementExitTransition(Transition transition) {}
2213
2214 /**
George Mount68f96d82014-07-31 13:13:10 -07002215 * Sets the Transition that will be used for shared elements reentering from a started
2216 * Activity after it has returned the shared element to it start location. If no value
2217 * is set, this will default to
2218 * {@link #setSharedElementExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07002219 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002220 *
George Mount68f96d82014-07-31 13:13:10 -07002221 * @param transition The Transition to use for shared elements in the launching Window
2222 * after the shared element has returned to the Window.
George Mountc03da0e2014-08-22 17:04:02 -07002223 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002224 */
2225 public void setSharedElementReenterTransition(Transition transition) {}
2226
2227 /**
George Mount31a21722014-03-24 17:44:36 -07002228 * Returns the Transition to use for shared elements in the launching Window prior
2229 * to transferring to the launched Activity's Window.
George Mount9826f632014-09-11 08:50:09 -07002230 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07002231 *
2232 * @return the Transition to use for shared elements in the launching Window prior
2233 * to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07002234 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mount31a21722014-03-24 17:44:36 -07002235 */
2236 public Transition getSharedElementExitTransition() { return null; }
2237
2238 /**
George Mount68f96d82014-07-31 13:13:10 -07002239 * Returns the Transition that will be used for shared elements reentering from a started
2240 * Activity after it has returned the shared element to it start location.
George Mount9826f632014-09-11 08:50:09 -07002241 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount68f96d82014-07-31 13:13:10 -07002242 *
2243 * @return the Transition that will be used for shared elements reentering from a started
2244 * Activity after it has returned the shared element to it start location.
George Mountc03da0e2014-08-22 17:04:02 -07002245 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002246 */
2247 public Transition getSharedElementReenterTransition() { return null; }
2248
2249 /**
George Mount31a21722014-03-24 17:44:36 -07002250 * Controls how the transition set in
2251 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
2252 * transition of the calling Activity. When true, the transition will start as soon as possible.
2253 * When false, the transition will wait until the remote exiting transition completes before
George Mount5d52d312016-06-10 14:16:45 -07002254 * starting. The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002255 *
George Mount31a21722014-03-24 17:44:36 -07002256 * @param allow true to start the enter transition when possible or false to
2257 * wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002258 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002259 */
2260 public void setAllowEnterTransitionOverlap(boolean allow) {}
2261
2262 /**
2263 * Returns how the transition set in
2264 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
2265 * transition of the calling Activity. When true, the transition will start as soon as possible.
2266 * When false, the transition will wait until the remote exiting transition completes before
George Mount5d52d312016-06-10 14:16:45 -07002267 * starting. The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002268 *
George Mount31a21722014-03-24 17:44:36 -07002269 * @return true when the enter transition should start as soon as possible or false to
2270 * when it should wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002271 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002272 */
2273 public boolean getAllowEnterTransitionOverlap() { return true; }
2274
2275 /**
2276 * Controls how the transition set in
2277 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2278 * transition of the called Activity when reentering after if finishes. When true,
2279 * the transition will start as soon as possible. When false, the transition will wait
2280 * until the called Activity's exiting transition completes before starting.
George Mount5d52d312016-06-10 14:16:45 -07002281 * The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002282 *
George Mount31a21722014-03-24 17:44:36 -07002283 * @param allow true to start the transition when possible or false to wait until the
2284 * called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002285 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002286 */
George Mountc03da0e2014-08-22 17:04:02 -07002287 public void setAllowReturnTransitionOverlap(boolean allow) {}
2288
2289 /**
George Mount31a21722014-03-24 17:44:36 -07002290 * Returns how the transition set in
2291 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2292 * transition of the called Activity when reentering after if finishes. When true,
2293 * the transition will start as soon as possible. When false, the transition will wait
2294 * until the called Activity's exiting transition completes before starting.
George Mount5d52d312016-06-10 14:16:45 -07002295 * The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002296 *
George Mount31a21722014-03-24 17:44:36 -07002297 * @return true when the transition should start when possible or false when it should wait
2298 * until the called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002299 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002300 */
George Mountc03da0e2014-08-22 17:04:02 -07002301 public boolean getAllowReturnTransitionOverlap() { return true; }
2302
2303 /**
George Mounted1e01d2014-06-05 13:49:12 -07002304 * Returns the duration, in milliseconds, of the window background fade
2305 * when transitioning into or away from an Activity when called with an Activity Transition.
2306 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002307 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002308 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002309 *
George Mounted1e01d2014-06-05 13:49:12 -07002310 * @return The duration of the window background fade to opaque during enter transition.
2311 * @see #getEnterTransition()
George Mountc03da0e2014-08-22 17:04:02 -07002312 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002313 */
2314 public long getTransitionBackgroundFadeDuration() { return 0; }
2315
2316 /**
2317 * Sets the duration, in milliseconds, of the window background fade
2318 * when transitioning into or away from an Activity when called with an Activity Transition.
2319 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002320 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002321 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002322 *
George Mounted1e01d2014-06-05 13:49:12 -07002323 * @param fadeDurationMillis The duration of the window background fade to or from opaque
2324 * during enter transition.
2325 * @see #setEnterTransition(android.transition.Transition)
George Mountc03da0e2014-08-22 17:04:02 -07002326 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002327 */
2328 public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { }
2329
2330 /**
George Mountb89d5cc2014-08-18 16:50:50 -07002331 * Returns <code>true</code> when shared elements should use an Overlay during
2332 * shared element transitions or <code>false</code> when they should animate as
2333 * part of the normal View hierarchy. The default value is true.
2334 *
2335 * @return <code>true</code> when shared elements should use an Overlay during
2336 * shared element transitions or <code>false</code> when they should animate as
2337 * part of the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002338 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002339 */
2340 public boolean getSharedElementsUseOverlay() { return true; }
2341
2342 /**
2343 * Sets whether or not shared elements should use an Overlay during shared element transitions.
2344 * The default value is true.
2345 *
2346 * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should
2347 * be transitioned with an Overlay or <code>false</code>
2348 * to transition within the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002349 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002350 */
2351 public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { }
2352
2353 /**
Adrian Roos217ccd22014-05-09 14:29:04 +02002354 * @return the color of the status bar.
2355 */
Tor Norbye80756e32015-03-02 09:39:27 -08002356 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002357 public abstract int getStatusBarColor();
2358
2359 /**
John Spurlockbc4cf002015-03-24 21:51:20 -04002360 * Sets the color of the status bar to {@code color}.
Adrian Roos217ccd22014-05-09 14:29:04 +02002361 *
2362 * For this to take effect,
2363 * the window must be drawing the system bar backgrounds with
2364 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2365 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set.
2366 *
John Spurlockbc4cf002015-03-24 21:51:20 -04002367 * If {@code color} is not opaque, consider setting
Adrian Roos217ccd22014-05-09 14:29:04 +02002368 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2369 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
George Mount238010f2014-06-30 17:31:17 -07002370 * <p>
2371 * The transitionName for the view background will be "android:status:background".
2372 * </p>
Adrian Roos217ccd22014-05-09 14:29:04 +02002373 */
Tor Norbye80756e32015-03-02 09:39:27 -08002374 public abstract void setStatusBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002375
2376 /**
2377 * @return the color of the navigation bar.
2378 */
Tor Norbye80756e32015-03-02 09:39:27 -08002379 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002380 public abstract int getNavigationBarColor();
2381
2382 /**
2383 * Sets the color of the navigation bar to {@param color}.
2384 *
2385 * For this to take effect,
2386 * the window must be drawing the system bar backgrounds with
2387 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2388 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
2389 *
2390 * If {@param color} is not opaque, consider setting
2391 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2392 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
George Mount238010f2014-06-30 17:31:17 -07002393 * <p>
2394 * The transitionName for the view background will be "android:navigation:background".
2395 * </p>
Jorim Jaggia0b78d52018-01-22 19:01:42 +01002396 * @attr ref android.R.styleable#Window_navigationBarColor
Adrian Roos217ccd22014-05-09 14:29:04 +02002397 */
Tor Norbye80756e32015-03-02 09:39:27 -08002398 public abstract void setNavigationBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002399
Jorim Jaggia0b78d52018-01-22 19:01:42 +01002400 /**
2401 * Shows a thin line of the specified color between the navigation bar and the app
2402 * content.
2403 * <p>
2404 * For this to take effect,
2405 * the window must be drawing the system bar backgrounds with
2406 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2407 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
2408 *
2409 * @param dividerColor The color of the thin line.
2410 * @attr ref android.R.styleable#Window_navigationBarDividerColor
2411 */
2412 public void setNavigationBarDividerColor(@ColorInt int dividerColor) {
2413 }
2414
2415 /**
2416 * Retrieves the color of the navigation bar divider.
2417 *
2418 * @return The color of the navigation bar divider color.
2419 * @see #setNavigationBarColor(int)
2420 * @attr ref android.R.styleable#Window_navigationBarDividerColor
2421 */
2422 public @ColorInt int getNavigationBarDividerColor() {
2423 return 0;
2424 }
2425
Adrian Roos4c864592019-04-10 14:47:57 +02002426 /**
2427 * Sets whether the system should ensure that the status bar has enough
2428 * contrast when a fully transparent background is requested.
2429 *
2430 * <p>If set to this value, the system will determine whether a scrim is necessary
2431 * to ensure that the status bar has enough contrast with the contents of
2432 * this app, and set an appropriate effective bar background color accordingly.
2433 *
2434 * <p>When the status bar color has a non-zero alpha value, the value of this
2435 * property has no effect.
2436 *
Adrian Roos8c7ca4f2019-04-17 11:35:22 +02002437 * @see android.R.attr#enforceStatusBarContrast
2438 * @see #isStatusBarContrastEnforced
Adrian Roos6eb1ed32019-04-08 16:23:43 +02002439 * @see #setStatusBarColor
Adrian Roos4c864592019-04-10 14:47:57 +02002440 */
Adrian Roos8c7ca4f2019-04-17 11:35:22 +02002441 public void setStatusBarContrastEnforced(boolean ensureContrast) {
Adrian Roos4c864592019-04-10 14:47:57 +02002442 }
2443
2444 /**
2445 * Returns whether the system is ensuring that the status bar has enough contrast when a
2446 * fully transparent background is requested.
2447 *
2448 * <p>When the status bar color has a non-zero alpha value, the value of this
2449 * property has no effect.
2450 *
Adrian Roos4c864592019-04-10 14:47:57 +02002451 * @return true, if the system is ensuring contrast, false otherwise.
Adrian Roos8c7ca4f2019-04-17 11:35:22 +02002452 * @see android.R.attr#enforceStatusBarContrast
2453 * @see #setStatusBarContrastEnforced
Adrian Roos6eb1ed32019-04-08 16:23:43 +02002454 * @see #setStatusBarColor
Adrian Roos4c864592019-04-10 14:47:57 +02002455 */
Adrian Roos8c7ca4f2019-04-17 11:35:22 +02002456 public boolean isStatusBarContrastEnforced() {
Adrian Roos4c864592019-04-10 14:47:57 +02002457 return false;
2458 }
2459
2460 /**
2461 * Sets whether the system should ensure that the navigation bar has enough
2462 * contrast when a fully transparent background is requested.
2463 *
2464 * <p>If set to this value, the system will determine whether a scrim is necessary
2465 * to ensure that the navigation bar has enough contrast with the contents of
2466 * this app, and set an appropriate effective bar background color accordingly.
2467 *
2468 * <p>When the navigation bar color has a non-zero alpha value, the value of this
2469 * property has no effect.
2470 *
Adrian Roos8c7ca4f2019-04-17 11:35:22 +02002471 * @see android.R.attr#enforceNavigationBarContrast
2472 * @see #isNavigationBarContrastEnforced
Adrian Roos6eb1ed32019-04-08 16:23:43 +02002473 * @see #setNavigationBarColor
Adrian Roos4c864592019-04-10 14:47:57 +02002474 */
Adrian Roos8c7ca4f2019-04-17 11:35:22 +02002475 public void setNavigationBarContrastEnforced(boolean enforceContrast) {
Adrian Roos4c864592019-04-10 14:47:57 +02002476 }
2477
2478 /**
2479 * Returns whether the system is ensuring that the navigation bar has enough contrast when a
2480 * fully transparent background is requested.
2481 *
2482 * <p>When the navigation bar color has a non-zero alpha value, the value of this
2483 * property has no effect.
2484 *
2485 * @return true, if the system is ensuring contrast, false otherwise.
Adrian Roos8c7ca4f2019-04-17 11:35:22 +02002486 * @see android.R.attr#enforceNavigationBarContrast
2487 * @see #setNavigationBarContrastEnforced
Adrian Roos6eb1ed32019-04-08 16:23:43 +02002488 * @see #setNavigationBarColor
Adrian Roos4c864592019-04-10 14:47:57 +02002489 */
Adrian Roos8c7ca4f2019-04-17 11:35:22 +02002490 public boolean isNavigationBarContrastEnforced() {
Adrian Roos4c864592019-04-10 14:47:57 +02002491 return false;
2492 }
2493
Adam Powell5a40b712019-04-15 15:54:02 -07002494 /**
2495 * Sets a list of areas within this window's coordinate space where the system should not
2496 * intercept touch or other pointing device gestures.
2497 *
2498 * <p>This method should be used by apps that make use of
2499 * {@link #takeSurface(SurfaceHolder.Callback2)} and do not have a view hierarchy available.
2500 * Apps that do have a view hierarchy should use
2501 * {@link View#setSystemGestureExclusionRects(List)} instead. This method does not modify or
2502 * replace the gesture exclusion rects populated by individual views in this window's view
2503 * hierarchy using {@link View#setSystemGestureExclusionRects(List)}.</p>
2504 *
2505 * <p>Use this to tell the system which specific sub-areas of a view need to receive gesture
2506 * input in order to function correctly in the presence of global system gestures that may
2507 * conflict. For example, if the system wishes to capture swipe-in-from-screen-edge gestures
2508 * to provide system-level navigation functionality, a view such as a navigation drawer
2509 * container can mark the left (or starting) edge of itself as requiring gesture capture
2510 * priority using this API. The system may then choose to relax its own gesture recognition
2511 * to allow the app to consume the user's gesture. It is not necessary for an app to register
2512 * exclusion rects for broadly spanning regions such as the entirety of a
2513 * <code>ScrollView</code> or for simple press and release click targets such as
2514 * <code>Button</code>. Mark an exclusion rect when interacting with a view requires
2515 * a precision touch gesture in a small area in either the X or Y dimension, such as
2516 * an edge swipe or dragging a <code>SeekBar</code> thumb.</p>
2517 *
2518 * <p>Do not modify the provided list after this method is called.</p>
2519 *
2520 * @param rects A list of precision gesture regions that this window needs to function correctly
2521 */
2522 @SuppressWarnings("unused")
2523 public void setSystemGestureExclusionRects(@NonNull List<Rect> rects) {
2524 throw new UnsupportedOperationException("window does not support gesture exclusion rects");
2525 }
2526
2527 /**
2528 * Retrieve the list of areas within this window's coordinate space where the system should not
2529 * intercept touch or other pointing device gestures. This is the list as set by
2530 * {@link #setSystemGestureExclusionRects(List)} or an empty list if
2531 * {@link #setSystemGestureExclusionRects(List)} has not been called. It does not include
2532 * exclusion rects set by this window's view hierarchy.
2533 *
2534 * @return a list of system gesture exclusion rects specific to this window
2535 */
2536 @NonNull
2537 public List<Rect> getSystemGestureExclusionRects() {
2538 return Collections.emptyList();
2539 }
2540
Filip Gruszczynski0daf2102015-09-29 08:39:07 -07002541 /** @hide */
2542 public void setTheme(int resId) {
2543 }
Filip Gruszczynski63250652015-11-18 14:43:01 -08002544
2545 /**
2546 * Whether the caption should be displayed directly on the content rather than push the content
2547 * down. This affects only freeform windows since they display the caption.
2548 * @hide
2549 */
Andrii Kulian933076d2016-03-29 17:04:42 -07002550 public void setOverlayWithDecorCaptionEnabled(boolean enabled) {
2551 mOverlayWithDecorCaptionEnabled = enabled;
Filip Gruszczynski63250652015-11-18 14:43:01 -08002552 }
2553
2554 /** @hide */
Andrii Kulian933076d2016-03-29 17:04:42 -07002555 public boolean isOverlayWithDecorCaptionEnabled() {
2556 return mOverlayWithDecorCaptionEnabled;
Filip Gruszczynski63250652015-11-18 14:43:01 -08002557 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002558
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002559 /** @hide */
2560 public void notifyRestrictedCaptionAreaCallback(int left, int top, int right, int bottom) {
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002561 if (mOnRestrictedCaptionAreaChangedListener != null) {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002562 mRestrictedCaptionAreaRect.set(left, top, right, bottom);
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002563 mOnRestrictedCaptionAreaChangedListener.onRestrictedCaptionAreaChanged(
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002564 mRestrictedCaptionAreaRect);
2565 }
2566 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002567
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002568 /**
2569 * Set what color should the caption controls be. By default the system will try to determine
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002570 * the color from the theme. You can overwrite this by using {@link #DECOR_CAPTION_SHADE_DARK},
2571 * {@link #DECOR_CAPTION_SHADE_LIGHT}, or {@link #DECOR_CAPTION_SHADE_AUTO}.
2572 * @see #DECOR_CAPTION_SHADE_DARK
2573 * @see #DECOR_CAPTION_SHADE_LIGHT
2574 * @see #DECOR_CAPTION_SHADE_AUTO
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002575 */
2576 public abstract void setDecorCaptionShade(int decorCaptionShade);
2577
2578 /**
2579 * Set the drawable that is drawn underneath the caption during the resizing.
2580 *
2581 * During the resizing the caption might not be drawn fast enough to match the new dimensions.
2582 * There is a second caption drawn underneath it that will be fast enough. By default the
2583 * caption is constructed from the theme. You can provide a drawable, that will be drawn instead
2584 * to better match your application.
2585 */
2586 public abstract void setResizingCaptionDrawable(Drawable drawable);
Wale Ogunwaleeb6722c2015-12-08 11:43:43 -08002587
2588 /**
2589 * Called when the activity changes from fullscreen mode to multi-window mode and visa-versa.
2590 * @hide
2591 */
Andrii Kulian933076d2016-03-29 17:04:42 -07002592 public abstract void onMultiWindowModeChanged();
Jorim Jaggi4846ee32016-01-07 17:39:12 +01002593
2594 /**
Winson Chung4d8681f2017-05-23 16:22:08 -07002595 * Called when the activity changes to/from picture-in-picture mode.
2596 * @hide
2597 */
2598 public abstract void onPictureInPictureModeChanged(boolean isInPictureInPictureMode);
2599
2600 /**
Jorim Jaggi4846ee32016-01-07 17:39:12 +01002601 * Called when the activity just relaunched.
2602 * @hide
2603 */
2604 public abstract void reportActivityRelaunched();
Michael Kwanf7964be2016-11-30 16:44:33 -08002605
2606 /**
Jorim Jaggib6030952018-10-23 18:31:52 +02002607 * @return The {@link WindowInsetsController} associated with this window
2608 * @see View#getWindowInsetsController()
Jorim Jaggib6030952018-10-23 18:31:52 +02002609 */
Tarandeep Singh54554e22019-11-01 14:43:05 -07002610 public @Nullable WindowInsetsController getInsetsController() {
2611 return null;
2612 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002613}