blob: 3544a8733c683911ad68588532d4a2063e644246 [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;
Mathew Inwooda570dee2018-08-17 14:56:00 +010029import android.annotation.UnsupportedAppUsage;
Wale Ogunwale3382ab12017-07-27 08:55:03 -070030import android.app.WindowConfiguration;
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;
Skuhnece2faa52015-08-11 10:36:38 -070036import android.graphics.PixelFormat;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -080037import android.graphics.Rect;
Filip Gruszczynski14418da2015-10-04 16:43:48 -070038import android.graphics.drawable.Drawable;
RoboErik55011652014-07-09 15:05:53 -070039import android.media.session.MediaController;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040import android.net.Uri;
Mathew Inwood31755f92018-12-20 13:53:36 +000041import android.os.Build;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042import android.os.Bundle;
Andres Morales910beb82016-02-02 16:19:40 -080043import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044import android.os.IBinder;
Wale Ogunwale868a5e12015-08-02 16:19:20 -070045import android.os.RemoteException;
Adam Powellcfbe9be2013-11-06 14:58:58 -080046import android.transition.Scene;
George Mounte1803372014-02-26 19:00:52 +000047import android.transition.Transition;
Adam Powellcfbe9be2013-11-06 14:58:58 -080048import android.transition.TransitionManager;
svetoslavganov75986cf2009-05-14 22:28:01 -070049import android.view.accessibility.AccessibilityEvent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050
Clara Bayarri75e09792015-07-29 16:20:40 +010051import java.util.List;
52
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053/**
54 * Abstract base class for a top-level window look and behavior policy. An
55 * instance of this class should be used as the top-level view added to the
56 * window manager. It provides standard UI policies such as a background, title
57 * area, default key processing, etc.
58 *
59 * <p>The only existing implementation of this abstract class is
Jorim Jaggib10e33f2015-02-04 21:57:40 +010060 * android.view.PhoneWindow, which you should instantiate when needing a
61 * Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080062 */
63public abstract class Window {
64 /** Flag for the "options panel" feature. This is enabled by default. */
65 public static final int FEATURE_OPTIONS_PANEL = 0;
66 /** Flag for the "no title" feature, turning off the title at the top
67 * of the screen. */
68 public static final int FEATURE_NO_TITLE = 1;
Alan Viverette4aef7c82015-09-04 14:14:50 -040069
70 /**
71 * Flag for the progress indicator feature.
72 *
73 * @deprecated No longer supported starting in API 21.
74 */
75 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080076 public static final int FEATURE_PROGRESS = 2;
Alan Viverette4aef7c82015-09-04 14:14:50 -040077
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080078 /** Flag for having an icon on the left side of the title bar */
79 public static final int FEATURE_LEFT_ICON = 3;
80 /** Flag for having an icon on the right side of the title bar */
81 public static final int FEATURE_RIGHT_ICON = 4;
Alan Viverette4aef7c82015-09-04 14:14:50 -040082
83 /**
84 * Flag for indeterminate progress.
85 *
86 * @deprecated No longer supported starting in API 21.
87 */
88 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089 public static final int FEATURE_INDETERMINATE_PROGRESS = 5;
Alan Viverette4aef7c82015-09-04 14:14:50 -040090
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080091 /** Flag for the context menu. This is enabled by default. */
92 public static final int FEATURE_CONTEXT_MENU = 6;
93 /** Flag for custom title. You cannot combine this feature with other title features. */
94 public static final int FEATURE_CUSTOM_TITLE = 7;
Adam Powell33b97432010-04-20 10:01:14 -070095 /**
96 * Flag for enabling the Action Bar.
97 * This is enabled by default for some devices. The Action Bar
98 * replaces the title bar and provides an alternate location
99 * for an on-screen menu button on some devices.
100 */
Adam Powell5d279772010-07-27 16:34:07 -0700101 public static final int FEATURE_ACTION_BAR = 8;
102 /**
Adam Powell6b336f82010-08-10 20:13:01 -0700103 * Flag for requesting an Action Bar that overlays window content.
104 * Normally an Action Bar will sit in the space above window content, but if this
105 * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over
106 * the window content itself. This is useful if you would like your app to have more control
107 * over how the Action Bar is displayed, such as letting application content scroll beneath
108 * an Action Bar with a transparent background or otherwise displaying a transparent/translucent
109 * Action Bar over application content.
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700110 *
111 * <p>This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN
112 * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the
113 * action bar in conjunction with other screen decorations.
114 *
115 * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an
116 * ActionBar is in this mode it will adjust the insets provided to
117 * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)}
118 * to include the content covered by the action bar, so you can do layout within
119 * that space.
Adam Powell6b336f82010-08-10 20:13:01 -0700120 */
121 public static final int FEATURE_ACTION_BAR_OVERLAY = 9;
122 /**
Adam Powell5d279772010-07-27 16:34:07 -0700123 * Flag for specifying the behavior of action modes when an Action Bar is not present.
124 * If overlay is enabled, the action mode UI will be allowed to cover existing window content.
125 */
Adam Powell6b336f82010-08-10 20:13:01 -0700126 public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
Adam Powell18e905f2013-10-24 14:27:48 -0700127 /**
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800128 * Flag for requesting a decoration-free window that is dismissed by swiping from the left.
129 */
130 public static final int FEATURE_SWIPE_TO_DISMISS = 11;
Will Haldean Brown568628d2014-03-04 15:25:43 -0800131 /**
George Mountc3a043c2015-02-04 14:37:04 -0800132 * Flag for requesting that window content changes should be animated using a
133 * TransitionManager.
Adam Powell18e905f2013-10-24 14:27:48 -0700134 *
George Mountc3a043c2015-02-04 14:37:04 -0800135 * <p>The TransitionManager is set using
136 * {@link #setTransitionManager(android.transition.TransitionManager)}. If none is set,
137 * a default TransitionManager will be used.</p>
Adam Powell18e905f2013-10-24 14:27:48 -0700138 *
139 * @see #setContentView
140 */
Will Haldean Brown568628d2014-03-04 15:25:43 -0800141 public static final int FEATURE_CONTENT_TRANSITIONS = 12;
Adam Powell4b6d93f2012-09-18 18:34:08 -0700142
143 /**
George Mount9826f632014-09-11 08:50:09 -0700144 * Enables Activities to run Activity Transitions either through sending or receiving
145 * ActivityOptions bundle created with
146 * {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity,
147 * android.util.Pair[])} or {@link android.app.ActivityOptions#makeSceneTransitionAnimation(
148 * android.app.Activity, View, String)}.
149 */
150 public static final int FEATURE_ACTIVITY_TRANSITIONS = 13;
151
152 /**
Adam Powell4b6d93f2012-09-18 18:34:08 -0700153 * Max value used as a feature ID
154 * @hide
155 */
Mathew Inwooda570dee2018-08-17 14:56:00 +0100156 @UnsupportedAppUsage
George Mount9826f632014-09-11 08:50:09 -0700157 public static final int FEATURE_MAX = FEATURE_ACTIVITY_TRANSITIONS;
Adam Powell4b6d93f2012-09-18 18:34:08 -0700158
Alan Viverette4aef7c82015-09-04 14:14:50 -0400159 /**
160 * Flag for setting the progress bar's visibility to VISIBLE.
161 *
162 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
163 * supported starting in API 21.
164 */
165 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800166 public static final int PROGRESS_VISIBILITY_ON = -1;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400167
168 /**
169 * Flag for setting the progress bar's visibility to GONE.
170 *
171 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
172 * supported starting in API 21.
173 */
174 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800175 public static final int PROGRESS_VISIBILITY_OFF = -2;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400176
177 /**
178 * Flag for setting the progress bar's indeterminate mode on.
179 *
180 * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
181 * are no longer supported starting in API 21.
182 */
183 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800184 public static final int PROGRESS_INDETERMINATE_ON = -3;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400185
186 /**
187 * Flag for setting the progress bar's indeterminate mode off.
188 *
189 * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods
190 * are no longer supported starting in API 21.
191 */
192 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 public static final int PROGRESS_INDETERMINATE_OFF = -4;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400194
195 /**
196 * Starting value for the (primary) progress.
197 *
198 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
199 * supported starting in API 21.
200 */
201 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800202 public static final int PROGRESS_START = 0;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400203
204 /**
205 * Ending value for the (primary) progress.
206 *
207 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
208 * supported starting in API 21.
209 */
210 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 public static final int PROGRESS_END = 10000;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400212
213 /**
214 * Lowest possible value for the secondary progress.
215 *
216 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
217 * supported starting in API 21.
218 */
219 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800220 public static final int PROGRESS_SECONDARY_START = 20000;
Alan Viverette4aef7c82015-09-04 14:14:50 -0400221
222 /**
223 * Highest possible value for the secondary progress.
224 *
225 * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer
226 * supported starting in API 21.
227 */
228 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800229 public static final int PROGRESS_SECONDARY_END = 30000;
George Mount238010f2014-06-30 17:31:17 -0700230
231 /**
232 * The transitionName for the status bar background View when a custom background is used.
233 * @see android.view.Window#setStatusBarColor(int)
234 */
235 public static final String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background";
236
237 /**
238 * The transitionName for the navigation bar background View when a custom background is used.
239 * @see android.view.Window#setNavigationBarColor(int)
240 */
241 public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME =
242 "android:navigation:background";
243
Bryce Leeaa1008c2015-01-13 09:26:46 -0800244 /**
245 * The default features enabled.
246 * @deprecated use {@link #getDefaultFeatures(android.content.Context)} instead.
247 */
Bryce Leed6e6e722014-11-21 11:08:45 -0800248 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800249 @SuppressWarnings({"PointlessBitwiseExpression"})
250 protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) |
251 (1 << FEATURE_CONTEXT_MENU);
252
253 /**
254 * The ID that the main layout in the XML layout file should have.
255 */
256 public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content;
257
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800258 /**
259 * Flag for letting the theme drive the color of the window caption controls. Use with
260 * {@link #setDecorCaptionShade(int)}. This is the default value.
261 */
262 public static final int DECOR_CAPTION_SHADE_AUTO = 0;
263 /**
264 * Flag for setting light-color controls on the window caption. Use with
265 * {@link #setDecorCaptionShade(int)}.
266 */
267 public static final int DECOR_CAPTION_SHADE_LIGHT = 1;
268 /**
269 * Flag for setting dark-color controls on the window caption. Use with
270 * {@link #setDecorCaptionShade(int)}.
271 */
272 public static final int DECOR_CAPTION_SHADE_DARK = 2;
273
Mathew Inwooda570dee2018-08-17 14:56:00 +0100274 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800275 private final Context mContext;
RoboErik55011652014-07-09 15:05:53 -0700276
Mathew Inwooda570dee2018-08-17 14:56:00 +0100277 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800278 private TypedArray mWindowStyle;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100279 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 private Callback mCallback;
Adam Powell117b6952014-05-05 18:14:56 -0700281 private OnWindowDismissedCallback mOnWindowDismissedCallback;
Michael Kwan67639a52016-12-16 12:38:10 -0800282 private OnWindowSwipeDismissedCallback mOnWindowSwipeDismissedCallback;
Skuhnece2faa52015-08-11 10:36:38 -0700283 private WindowControllerCallback mWindowControllerCallback;
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800284 private OnRestrictedCaptionAreaChangedListener mOnRestrictedCaptionAreaChangedListener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800285 private Rect mRestrictedCaptionAreaRect;
Mathew Inwood31755f92018-12-20 13:53:36 +0000286 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287 private WindowManager mWindowManager;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100288 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289 private IBinder mAppToken;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100290 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800291 private String mAppName;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100292 @UnsupportedAppUsage
Jeff Brownd32460c2012-07-20 16:15:36 -0700293 private boolean mHardwareAccelerated;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800294 private Window mContainer;
295 private Window mActiveChild;
296 private boolean mIsActive = false;
297 private boolean mHasChildren = false;
Dianne Hackborncfaf8872011-01-18 13:57:54 -0800298 private boolean mCloseOnTouchOutside = false;
299 private boolean mSetCloseOnTouchOutside = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800300 private int mForcedWindowFlags = 0;
301
Mathew Inwooda570dee2018-08-17 14:56:00 +0100302 @UnsupportedAppUsage
Bryce Leed6e6e722014-11-21 11:08:45 -0800303 private int mFeatures;
Mathew Inwooda570dee2018-08-17 14:56:00 +0100304 @UnsupportedAppUsage
Bryce Leed6e6e722014-11-21 11:08:45 -0800305 private int mLocalFeatures;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800306
307 private boolean mHaveWindowFormat = false;
Dianne Hackborn661cd522011-08-22 00:26:20 -0700308 private boolean mHaveDimAmount = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800309 private int mDefaultWindowFormat = PixelFormat.OPAQUE;
310
311 private boolean mHasSoftInputMode = false;
RoboErik55011652014-07-09 15:05:53 -0700312
Mathew Inwooda570dee2018-08-17 14:56:00 +0100313 @UnsupportedAppUsage
Dianne Hackborn291905e2010-08-17 15:17:15 -0700314 private boolean mDestroyed;
315
Andrii Kulian933076d2016-03-29 17:04:42 -0700316 private boolean mOverlayWithDecorCaptionEnabled = false;
Michael Kwanf7964be2016-11-30 16:44:33 -0800317 private boolean mCloseOnSwipeEnabled = false;
Filip Gruszczynski63250652015-11-18 14:43:01 -0800318
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800319 // The current window attributes.
Mathew Inwooda570dee2018-08-17 14:56:00 +0100320 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 private final WindowManager.LayoutParams mWindowAttributes =
322 new WindowManager.LayoutParams();
323
324 /**
325 * API from a Window back to its caller. This allows the client to
326 * intercept key dispatching, panels and menus, etc.
327 */
328 public interface Callback {
329 /**
330 * Called to process key events. At the very least your
331 * implementation must call
332 * {@link android.view.Window#superDispatchKeyEvent} to do the
333 * standard key processing.
334 *
335 * @param event The key event.
336 *
337 * @return boolean Return true if this event was consumed.
338 */
339 public boolean dispatchKeyEvent(KeyEvent event);
340
341 /**
Jeff Brown64da12a2011-01-04 19:57:47 -0800342 * Called to process a key shortcut event.
343 * At the very least your implementation must call
344 * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the
345 * standard key shortcut processing.
346 *
347 * @param event The key shortcut event.
348 * @return True if this event was consumed.
349 */
350 public boolean dispatchKeyShortcutEvent(KeyEvent event);
351
352 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800353 * Called to process touch screen events. At the very least your
354 * implementation must call
355 * {@link android.view.Window#superDispatchTouchEvent} to do the
356 * standard touch screen processing.
357 *
358 * @param event The touch screen event.
359 *
360 * @return boolean Return true if this event was consumed.
361 */
362 public boolean dispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -0700363
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800364 /**
365 * Called to process trackball events. At the very least your
366 * implementation must call
367 * {@link android.view.Window#superDispatchTrackballEvent} to do the
368 * standard trackball processing.
369 *
370 * @param event The trackball event.
371 *
372 * @return boolean Return true if this event was consumed.
373 */
374 public boolean dispatchTrackballEvent(MotionEvent event);
svetoslavganov75986cf2009-05-14 22:28:01 -0700375
376 /**
Jeff Browncb1404e2011-01-15 18:14:15 -0800377 * Called to process generic motion events. At the very least your
378 * implementation must call
379 * {@link android.view.Window#superDispatchGenericMotionEvent} to do the
380 * standard processing.
381 *
382 * @param event The generic motion event.
383 *
384 * @return boolean Return true if this event was consumed.
385 */
386 public boolean dispatchGenericMotionEvent(MotionEvent event);
387
388 /**
svetoslavganov75986cf2009-05-14 22:28:01 -0700389 * Called to process population of {@link AccessibilityEvent}s.
390 *
391 * @param event The event.
392 *
393 * @return boolean Return true if event population was completed.
394 */
395 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event);
396
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800397 /**
398 * Instantiate the view to display in the panel for 'featureId'.
399 * You can return null, in which case the default content (typically
400 * a menu) will be created for you.
401 *
402 * @param featureId Which panel is being created.
403 *
404 * @return view The top-level view to place in the panel.
405 *
406 * @see #onPreparePanel
407 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700408 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800409 public View onCreatePanelView(int featureId);
410
411 /**
412 * Initialize the contents of the menu for panel 'featureId'. This is
413 * called if onCreatePanelView() returns null, giving you a standard
414 * menu in which you can place your items. It is only called once for
415 * the panel, the first time it is shown.
416 *
417 * <p>You can safely hold on to <var>menu</var> (and any items created
418 * from it), making modifications to it as desired, until the next
419 * time onCreatePanelMenu() is called for this feature.
420 *
421 * @param featureId The panel being created.
422 * @param menu The menu inside the panel.
423 *
424 * @return boolean You must return true for the panel to be displayed;
425 * if you return false it will not be shown.
426 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700427 boolean onCreatePanelMenu(int featureId, @NonNull Menu menu);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800428
429 /**
430 * Prepare a panel to be displayed. This is called right before the
431 * panel window is shown, every time it is shown.
432 *
433 * @param featureId The panel that is being displayed.
434 * @param view The View that was returned by onCreatePanelView().
435 * @param menu If onCreatePanelView() returned null, this is the Menu
436 * being displayed in the panel.
437 *
438 * @return boolean You must return true for the panel to be displayed;
439 * if you return false it will not be shown.
440 *
441 * @see #onCreatePanelView
442 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700443 boolean onPreparePanel(int featureId, @Nullable View view, @NonNull Menu menu);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800444
445 /**
446 * Called when a panel's menu is opened by the user. This may also be
447 * called when the menu is changing from one type to another (for
448 * example, from the icon menu to the expanded menu).
RoboErik55011652014-07-09 15:05:53 -0700449 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800450 * @param featureId The panel that the menu is in.
451 * @param menu The menu that is opened.
452 * @return Return true to allow the menu to open, or false to prevent
453 * the menu from opening.
454 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700455 boolean onMenuOpened(int featureId, @NonNull Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700456
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800457 /**
458 * Called when a panel's menu item has been selected by the user.
459 *
460 * @param featureId The panel that the menu is in.
461 * @param item The menu item that was selected.
462 *
463 * @return boolean Return true to finish processing of selection, or
464 * false to perform the normal menu handling (calling its
465 * Runnable or sending a Message to its target Handler).
466 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700467 boolean onMenuItemSelected(int featureId, @NonNull MenuItem item);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800468
469 /**
470 * This is called whenever the current window attributes change.
471 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800472 */
473 public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
474
475 /**
476 * This hook is called whenever the content view of the screen changes
477 * (due to a call to
478 * {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams)
479 * Window.setContentView} or
480 * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams)
481 * Window.addContentView}).
482 */
483 public void onContentChanged();
484
485 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700486 * This hook is called whenever the window focus changes. See
487 * {@link View#onWindowFocusChanged(boolean)
Svetoslav3a0d8782014-12-04 12:50:11 -0800488 * View.onWindowFocusChangedNotLocked(boolean)} for more information.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800489 *
490 * @param hasFocus Whether the window now has focus.
491 */
492 public void onWindowFocusChanged(boolean hasFocus);
493
494 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700495 * Called when the window has been attached to the window manager.
496 * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
497 * for more information.
498 */
499 public void onAttachedToWindow();
RoboErik55011652014-07-09 15:05:53 -0700500
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700501 /**
Chet Haasee7bf2192017-08-18 15:24:56 -0700502 * Called when the window has been detached from the window manager.
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700503 * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
504 * for more information.
505 */
506 public void onDetachedFromWindow();
RoboErik55011652014-07-09 15:05:53 -0700507
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700508 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800509 * Called when a panel is being closed. If another logical subsequent
510 * panel is being opened (and this panel is being closed to make room for the subsequent
511 * panel), this method will NOT be called.
RoboErik55011652014-07-09 15:05:53 -0700512 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800513 * @param featureId The panel that is being displayed.
514 * @param menu If onCreatePanelView() returned null, this is the Menu
515 * being displayed in the panel.
516 */
Ian Lake0b71b8e2018-09-13 13:56:26 -0700517 void onPanelClosed(int featureId, @NonNull Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700518
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519 /**
520 * Called when the user signals the desire to start a search.
RoboErik55011652014-07-09 15:05:53 -0700521 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800522 * @return true if search launched, false if activity refuses (blocks)
RoboErik55011652014-07-09 15:05:53 -0700523 *
524 * @see android.app.Activity#onSearchRequested()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800525 */
526 public boolean onSearchRequested();
Adam Powell6e346362010-07-23 10:18:23 -0700527
528 /**
Tim Kilbourn6a975b32015-04-09 17:14:34 -0700529 * Called when the user signals the desire to start a search.
530 *
531 * @param searchEvent A {@link SearchEvent} describing the signal to
532 * start a search.
533 * @return true if search launched, false if activity refuses (blocks)
534 */
535 public boolean onSearchRequested(SearchEvent searchEvent);
536
537 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800538 * Called when an action mode is being started for this window. Gives the
539 * callback an opportunity to handle the action mode in its own unique and
540 * beautiful way. If this method returns null the system can choose a way
Clara Bayarri4423d912015-03-02 19:42:48 +0000541 * to present the mode or choose not to start the mode at all. This is equivalent
542 * to {@link #onWindowStartingActionMode(android.view.ActionMode.Callback, int)}
543 * with type {@link ActionMode#TYPE_PRIMARY}.
Adam Powell6e346362010-07-23 10:18:23 -0700544 *
545 * @param callback Callback to control the lifecycle of this action mode
Adam Powelldebf3be2010-11-15 18:58:48 -0800546 * @return The ActionMode that was started, or null if the system should present it
Adam Powell6e346362010-07-23 10:18:23 -0700547 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700548 @Nullable
Adam Powelldebf3be2010-11-15 18:58:48 -0800549 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
550
551 /**
Clara Bayarri4423d912015-03-02 19:42:48 +0000552 * Called when an action mode is being started for this window. Gives the
553 * callback an opportunity to handle the action mode in its own unique and
554 * beautiful way. If this method returns null the system can choose a way
555 * to present the mode or choose not to start the mode at all.
556 *
557 * @param callback Callback to control the lifecycle of this action mode
558 * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
559 * @return The ActionMode that was started, or null if the system should present it
560 */
561 @Nullable
562 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);
563
564 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800565 * Called when an action mode has been started. The appropriate mode callback
566 * method will have already been invoked.
567 *
568 * @param mode The new mode that has just been started.
569 */
570 public void onActionModeStarted(ActionMode mode);
571
572 /**
573 * Called when an action mode has been finished. The appropriate mode callback
574 * method will have already been invoked.
575 *
576 * @param mode The mode that was just finished.
577 */
578 public void onActionModeFinished(ActionMode mode);
Clara Bayarri75e09792015-07-29 16:20:40 +0100579
580 /**
581 * Called when Keyboard Shortcuts are requested for the current window.
582 *
583 * @param data The data list to populate with shortcuts.
584 * @param menu The current menu, which may be null.
Clara Bayarrifcd7e802016-03-10 12:58:18 +0000585 * @param deviceId The id for the connected device the shortcuts should be provided for.
Clara Bayarri75e09792015-07-29 16:20:40 +0100586 */
Sunny Goyal2a6d9aa2016-03-16 17:12:46 -0700587 default public void onProvideKeyboardShortcuts(
Clara Bayarrifcd7e802016-03-10 12:58:18 +0000588 List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) { };
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800589
590 /**
591 * Called when pointer capture is enabled or disabled for the current window.
592 *
593 * @param hasCapture True if the window has pointer capture.
594 */
595 default public void onPointerCaptureChanged(boolean hasCapture) { };
Adam Powell117b6952014-05-05 18:14:56 -0700596 }
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800597
Adam Powell117b6952014-05-05 18:14:56 -0700598 /** @hide */
599 public interface OnWindowDismissedCallback {
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800600 /**
601 * Called when a window is dismissed. This informs the callback that the
602 * window is gone, and it should finish itself.
Wale Ogunwaleba7881c2015-08-01 19:28:29 -0700603 * @param finishTask True if the task should also be finished.
Ned Burns7d6cb912016-12-02 17:25:33 -0500604 * @param suppressWindowTransition True if the resulting exit and enter window transition
605 * animations should be suppressed.
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800606 */
Ned Burns7d6cb912016-12-02 17:25:33 -0500607 void onWindowDismissed(boolean finishTask, boolean suppressWindowTransition);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800608 }
609
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700610 /** @hide */
Michael Kwan67639a52016-12-16 12:38:10 -0800611 public interface OnWindowSwipeDismissedCallback {
612 /**
613 * Called when a window is swipe dismissed. This informs the callback that the
614 * window is gone, and it should finish itself.
615 * @param finishTask True if the task should also be finished.
616 * @param suppressWindowTransition True if the resulting exit and enter window transition
617 * animations should be suppressed.
618 */
619 void onWindowSwipeDismissed();
620 }
621
622 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700623 public interface WindowControllerCallback {
624 /**
Yunfan Chend967af82019-01-17 18:30:18 +0900625 * Moves the activity between {@link WindowConfiguration#WINDOWING_MODE_FREEFORM} windowing
626 * mode and {@link WindowConfiguration#WINDOWING_MODE_FULLSCREEN}.
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700627 */
Yunfan Chend967af82019-01-17 18:30:18 +0900628 void toggleFreeformWindowingMode() throws RemoteException;
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700629
Jaewan Kimd98dcab2016-05-03 02:52:18 +0900630 /**
631 * Puts the activity in picture-in-picture mode if the activity supports.
632 * @see android.R.attr#supportsPictureInPicture
633 */
634 void enterPictureInPictureModeIfPossible();
635
Winson Chung4d8681f2017-05-23 16:22:08 -0700636 /** Returns whether the window belongs to the task root. */
637 boolean isTaskRoot();
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700638 }
639
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800640 /**
641 * Callback for clients that want to be aware of where caption draws content.
642 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800643 public interface OnRestrictedCaptionAreaChangedListener {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800644 /**
645 * Called when the area where caption draws content changes.
646 *
647 * @param rect The area where caption content is positioned, relative to the top view.
648 */
649 void onRestrictedCaptionAreaChanged(Rect rect);
650 }
651
Andres Morales910beb82016-02-02 16:19:40 -0800652 /**
653 * Callback for clients that want frame timing information for each
654 * frame rendered by the Window.
655 */
Andres Moralesd908c622016-04-20 13:13:34 -0700656 public interface OnFrameMetricsAvailableListener {
Andres Morales910beb82016-02-02 16:19:40 -0800657 /**
658 * Called when information is available for the previously rendered frame.
659 *
660 * Reports can be dropped if this callback takes too
661 * long to execute, as the report producer cannot wait for the consumer to
662 * complete.
663 *
664 * It is highly recommended that clients copy the passed in FrameMetrics
665 * via {@link FrameMetrics#FrameMetrics(FrameMetrics)} within this method and defer
666 * additional computation or storage to another thread to avoid unnecessarily
667 * dropping reports.
668 *
669 * @param window The {@link Window} on which the frame was displayed.
670 * @param frameMetrics the available metrics. This object is reused on every call
671 * and thus <strong>this reference is not valid outside the scope of this method</strong>.
672 * @param dropCountSinceLastInvocation the number of reports dropped since the last time
673 * this callback was invoked.
674 */
Andres Moralesd908c622016-04-20 13:13:34 -0700675 void onFrameMetricsAvailable(Window window, FrameMetrics frameMetrics,
Andres Morales910beb82016-02-02 16:19:40 -0800676 int dropCountSinceLastInvocation);
677 }
678
679
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800680 public Window(Context context) {
681 mContext = context;
Bryce Leed6e6e722014-11-21 11:08:45 -0800682 mFeatures = mLocalFeatures = getDefaultFeatures(context);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800683 }
684
685 /**
686 * Return the Context this window policy is running in, for retrieving
687 * resources and other information.
688 *
689 * @return Context The Context that was supplied to the constructor.
690 */
691 public final Context getContext() {
692 return mContext;
693 }
694
695 /**
696 * Return the {@link android.R.styleable#Window} attributes from this
697 * window's theme.
698 */
699 public final TypedArray getWindowStyle() {
700 synchronized (this) {
701 if (mWindowStyle == null) {
702 mWindowStyle = mContext.obtainStyledAttributes(
703 com.android.internal.R.styleable.Window);
704 }
705 return mWindowStyle;
706 }
707 }
RoboErik55011652014-07-09 15:05:53 -0700708
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800709 /**
710 * Set the container for this window. If not set, the DecorWindow
711 * operates as a top-level window; otherwise, it negotiates with the
712 * container to display itself appropriately.
713 *
714 * @param container The desired containing Window.
715 */
716 public void setContainer(Window container) {
717 mContainer = container;
718 if (container != null) {
719 // Embedded screens never have a title.
720 mFeatures |= 1<<FEATURE_NO_TITLE;
721 mLocalFeatures |= 1<<FEATURE_NO_TITLE;
722 container.mHasChildren = true;
723 }
724 }
725
726 /**
727 * Return the container for this Window.
728 *
729 * @return Window The containing window, or null if this is a
730 * top-level window.
731 */
732 public final Window getContainer() {
733 return mContainer;
734 }
735
736 public final boolean hasChildren() {
737 return mHasChildren;
738 }
RoboErik55011652014-07-09 15:05:53 -0700739
Dianne Hackborn291905e2010-08-17 15:17:15 -0700740 /** @hide */
741 public final void destroy() {
742 mDestroyed = true;
743 }
744
745 /** @hide */
Mathew Inwooda570dee2018-08-17 14:56:00 +0100746 @UnsupportedAppUsage
Dianne Hackborn291905e2010-08-17 15:17:15 -0700747 public final boolean isDestroyed() {
748 return mDestroyed;
749 }
750
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800751 /**
752 * Set the window manager for use by this Window to, for example,
753 * display panels. This is <em>not</em> used for displaying the
754 * Window itself -- that must be done by the client.
755 *
Jeff Brown98365d72012-08-19 20:30:52 -0700756 * @param wm The window manager for adding new windows.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800757 */
Romain Guy529b60a2010-08-03 18:05:47 -0700758 public void setWindowManager(WindowManager wm, IBinder appToken, String appName) {
759 setWindowManager(wm, appToken, appName, false);
760 }
761
762 /**
763 * Set the window manager for use by this Window to, for example,
764 * display panels. This is <em>not</em> used for displaying the
765 * Window itself -- that must be done by the client.
766 *
Jeff Brown98365d72012-08-19 20:30:52 -0700767 * @param wm The window manager for adding new windows.
Romain Guy529b60a2010-08-03 18:05:47 -0700768 */
769 public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
770 boolean hardwareAccelerated) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800771 mAppToken = appToken;
772 mAppName = appName;
John Recke22d4d72018-03-02 15:49:48 -0800773 mHardwareAccelerated = hardwareAccelerated;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800774 if (wm == null) {
Jeff Brown98365d72012-08-19 20:30:52 -0700775 wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800776 }
Jeff Brown98365d72012-08-19 20:30:52 -0700777 mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
Dianne Hackborn5fd21692011-06-07 14:09:47 -0700778 }
779
Jeff Brownd32460c2012-07-20 16:15:36 -0700780 void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) {
781 CharSequence curTitle = wp.getTitle();
782 if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
tiger_huangff58e302015-10-13 21:38:19 +0800783 wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
Jeff Brownd32460c2012-07-20 16:15:36 -0700784 if (wp.token == null) {
785 View decor = peekDecorView();
786 if (decor != null) {
787 wp.token = decor.getWindowToken();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800788 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800789 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700790 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700791 final StringBuilder title = new StringBuilder(32);
Jeff Brownd32460c2012-07-20 16:15:36 -0700792 if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700793 title.append("Media");
Jeff Brownd32460c2012-07-20 16:15:36 -0700794 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700795 title.append("MediaOvr");
Jeff Brownd32460c2012-07-20 16:15:36 -0700796 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700797 title.append("Panel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700798 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700799 title.append("SubPanel");
Wale Ogunwale0a4dc222015-04-14 12:58:42 -0700800 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700801 title.append("AboveSubPanel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700802 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700803 title.append("AtchDlg");
Jeff Brownd32460c2012-07-20 16:15:36 -0700804 } else {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700805 title.append(wp.type);
Jeff Brownd32460c2012-07-20 16:15:36 -0700806 }
807 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700808 title.append(":").append(mAppName);
Jeff Brownd32460c2012-07-20 16:15:36 -0700809 }
810 wp.setTitle(title);
Romain Guy529b60a2010-08-03 18:05:47 -0700811 }
tiger_huangff58e302015-10-13 21:38:19 +0800812 } else if (wp.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW &&
813 wp.type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
814 // We don't set the app token to this system window because the life cycles should be
815 // independent. If an app creates a system window and then the app goes to the stopped
816 // state, the system window should not be affected (can still show and receive input
817 // events).
818 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700819 final StringBuilder title = new StringBuilder(32);
820 title.append("Sys").append(wp.type);
tiger_huangff58e302015-10-13 21:38:19 +0800821 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700822 title.append(":").append(mAppName);
tiger_huangff58e302015-10-13 21:38:19 +0800823 }
824 wp.setTitle(title);
825 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700826 } else {
827 if (wp.token == null) {
828 wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
829 }
830 if ((curTitle == null || curTitle.length() == 0)
831 && mAppName != null) {
832 wp.setTitle(mAppName);
833 }
834 }
835 if (wp.packageName == null) {
836 wp.packageName = mContext.getPackageName();
837 }
Robert Carr13678ee2016-04-20 14:04:15 -0700838 if (mHardwareAccelerated ||
839 (mWindowAttributes.flags & FLAG_HARDWARE_ACCELERATED) != 0) {
840 wp.flags |= FLAG_HARDWARE_ACCELERATED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800841 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800842 }
843
844 /**
845 * Return the window manager allowing this Window to display its own
846 * windows.
847 *
848 * @return WindowManager The ViewManager.
849 */
850 public WindowManager getWindowManager() {
851 return mWindowManager;
852 }
853
854 /**
855 * Set the Callback interface for this window, used to intercept key
856 * events and other dynamic operations in the window.
857 *
858 * @param callback The desired Callback interface.
859 */
860 public void setCallback(Callback callback) {
861 mCallback = callback;
862 }
863
864 /**
865 * Return the current Callback interface for this window.
866 */
867 public final Callback getCallback() {
868 return mCallback;
869 }
870
Andres Morales06f5bc72015-12-15 15:21:31 -0800871 /**
Andrew Zeng8b7fb462018-08-03 13:32:04 -0700872 * Set an observer to collect frame stats for each frame rendered in this window.
Andres Morales06f5bc72015-12-15 15:21:31 -0800873 *
874 * Must be in hardware rendering mode.
Andres Morales06f5bc72015-12-15 15:21:31 -0800875 */
Andres Moralesd908c622016-04-20 13:13:34 -0700876 public final void addOnFrameMetricsAvailableListener(
877 @NonNull OnFrameMetricsAvailableListener listener,
Andres Morales910beb82016-02-02 16:19:40 -0800878 Handler handler) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800879 final View decorView = getDecorView();
880 if (decorView == null) {
881 throw new IllegalStateException("can't observe a Window without an attached view");
882 }
883
Andres Morales910beb82016-02-02 16:19:40 -0800884 if (listener == null) {
885 throw new NullPointerException("listener cannot be null");
Andres Morales06f5bc72015-12-15 15:21:31 -0800886 }
887
Andres Morales910beb82016-02-02 16:19:40 -0800888 decorView.addFrameMetricsListener(this, listener, handler);
Andres Morales06f5bc72015-12-15 15:21:31 -0800889 }
890
891 /**
892 * Remove observer and stop listening to frame stats for this window.
Andres Morales06f5bc72015-12-15 15:21:31 -0800893 */
Andres Moralesd908c622016-04-20 13:13:34 -0700894 public final void removeOnFrameMetricsAvailableListener(OnFrameMetricsAvailableListener listener) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800895 final View decorView = getDecorView();
896 if (decorView != null) {
Andres Morales910beb82016-02-02 16:19:40 -0800897 getDecorView().removeFrameMetricsListener(listener);
Andres Morales06f5bc72015-12-15 15:21:31 -0800898 }
899 }
900
Adam Powell117b6952014-05-05 18:14:56 -0700901 /** @hide */
902 public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) {
903 mOnWindowDismissedCallback = dcb;
904 }
905
906 /** @hide */
Ned Burns7d6cb912016-12-02 17:25:33 -0500907 public final void dispatchOnWindowDismissed(
908 boolean finishTask, boolean suppressWindowTransition) {
Adam Powell117b6952014-05-05 18:14:56 -0700909 if (mOnWindowDismissedCallback != null) {
Ned Burns7d6cb912016-12-02 17:25:33 -0500910 mOnWindowDismissedCallback.onWindowDismissed(finishTask, suppressWindowTransition);
Adam Powell117b6952014-05-05 18:14:56 -0700911 }
912 }
913
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700914 /** @hide */
Michael Kwan67639a52016-12-16 12:38:10 -0800915 public final void setOnWindowSwipeDismissedCallback(OnWindowSwipeDismissedCallback sdcb) {
916 mOnWindowSwipeDismissedCallback = sdcb;
917 }
918
919 /** @hide */
920 public final void dispatchOnWindowSwipeDismissed() {
921 if (mOnWindowSwipeDismissedCallback != null) {
922 mOnWindowSwipeDismissedCallback.onWindowSwipeDismissed();
923 }
924 }
925
926 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700927 public final void setWindowControllerCallback(WindowControllerCallback wccb) {
928 mWindowControllerCallback = wccb;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700929 }
930
931 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700932 public final WindowControllerCallback getWindowControllerCallback() {
933 return mWindowControllerCallback;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700934 }
935
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800936 /**
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800937 * Set a callback for changes of area where caption will draw its content.
938 *
939 * @param listener Callback that will be called when the area changes.
940 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800941 public final void setRestrictedCaptionAreaListener(OnRestrictedCaptionAreaChangedListener listener) {
942 mOnRestrictedCaptionAreaChangedListener = listener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800943 mRestrictedCaptionAreaRect = listener != null ? new Rect() : null;
944 }
945
946 /**
Dianne Hackborndc8a7f62010-05-10 11:29:34 -0700947 * Take ownership of this window's surface. The window's view hierarchy
948 * will no longer draw into the surface, though it will otherwise continue
949 * to operate (such as for receiving input events). The given SurfaceHolder
950 * callback will be used to tell you about state changes to the surface.
951 */
Dianne Hackbornd76b67c2010-07-13 17:48:30 -0700952 public abstract void takeSurface(SurfaceHolder.Callback2 callback);
RoboErik55011652014-07-09 15:05:53 -0700953
Dianne Hackborndc8a7f62010-05-10 11:29:34 -0700954 /**
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -0700955 * Take ownership of this window's InputQueue. The window will no
956 * longer read and dispatch input events from the queue; it is your
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700957 * responsibility to do so.
958 */
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -0700959 public abstract void takeInputQueue(InputQueue.Callback callback);
RoboErik55011652014-07-09 15:05:53 -0700960
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700961 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800962 * Return whether this window is being displayed with a floating style
963 * (based on the {@link android.R.attr#windowIsFloating} attribute in
964 * the style/theme).
965 *
966 * @return Returns true if the window is configured to be displayed floating
967 * on top of whatever is behind it.
968 */
969 public abstract boolean isFloating();
970
971 /**
972 * Set the width and height layout parameters of the window. The default
Dianne Hackbornc9189352010-12-15 14:57:25 -0800973 * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT
974 * or an absolute value to make a window that is not full-screen.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800975 *
976 * @param width The desired layout width of the window.
977 * @param height The desired layout height of the window.
Dianne Hackbornc9189352010-12-15 14:57:25 -0800978 *
979 * @see ViewGroup.LayoutParams#height
980 * @see ViewGroup.LayoutParams#width
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800981 */
Dianne Hackbornc9189352010-12-15 14:57:25 -0800982 public void setLayout(int width, int height) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800983 final WindowManager.LayoutParams attrs = getAttributes();
984 attrs.width = width;
985 attrs.height = height;
Adrian Roosea562512014-05-05 13:33:03 +0200986 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800987 }
988
989 /**
990 * Set the gravity of the window, as per the Gravity constants. This
991 * controls how the window manager is positioned in the overall window; it
992 * is only useful when using WRAP_CONTENT for the layout width or height.
993 *
994 * @param gravity The desired gravity constant.
995 *
996 * @see Gravity
997 * @see #setLayout
998 */
999 public void setGravity(int gravity)
1000 {
1001 final WindowManager.LayoutParams attrs = getAttributes();
1002 attrs.gravity = gravity;
Adrian Roosea562512014-05-05 13:33:03 +02001003 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001004 }
1005
1006 /**
1007 * Set the type of the window, as per the WindowManager.LayoutParams
1008 * types.
1009 *
1010 * @param type The new window type (see WindowManager.LayoutParams).
1011 */
1012 public void setType(int type) {
1013 final WindowManager.LayoutParams attrs = getAttributes();
1014 attrs.type = type;
Adrian Roosea562512014-05-05 13:33:03 +02001015 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001016 }
1017
1018 /**
1019 * Set the format of window, as per the PixelFormat types. This overrides
1020 * the default format that is selected by the Window based on its
1021 * window decorations.
1022 *
1023 * @param format The new window format (see PixelFormat). Use
1024 * PixelFormat.UNKNOWN to allow the Window to select
1025 * the format.
1026 *
1027 * @see PixelFormat
1028 */
1029 public void setFormat(int format) {
1030 final WindowManager.LayoutParams attrs = getAttributes();
1031 if (format != PixelFormat.UNKNOWN) {
1032 attrs.format = format;
1033 mHaveWindowFormat = true;
1034 } else {
1035 attrs.format = mDefaultWindowFormat;
1036 mHaveWindowFormat = false;
1037 }
Adrian Roosea562512014-05-05 13:33:03 +02001038 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001039 }
1040
1041 /**
1042 * Specify custom animations to use for the window, as per
1043 * {@link WindowManager.LayoutParams#windowAnimations
1044 * WindowManager.LayoutParams.windowAnimations}. Providing anything besides
1045 * 0 here will override the animations the window would
1046 * normally retrieve from its theme.
1047 */
Tor Norbye417ee5b2015-03-10 20:57:37 -07001048 public void setWindowAnimations(@StyleRes int resId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001049 final WindowManager.LayoutParams attrs = getAttributes();
1050 attrs.windowAnimations = resId;
Adrian Roosea562512014-05-05 13:33:03 +02001051 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001052 }
1053
1054 /**
1055 * Specify an explicit soft input mode to use for the window, as per
1056 * {@link WindowManager.LayoutParams#softInputMode
1057 * WindowManager.LayoutParams.softInputMode}. Providing anything besides
1058 * "unspecified" here will override the input mode the window would
1059 * normally retrieve from its theme.
1060 */
1061 public void setSoftInputMode(int mode) {
1062 final WindowManager.LayoutParams attrs = getAttributes();
1063 if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
1064 attrs.softInputMode = mode;
1065 mHasSoftInputMode = true;
1066 } else {
1067 mHasSoftInputMode = false;
1068 }
Adrian Roosea562512014-05-05 13:33:03 +02001069 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001070 }
RoboErik55011652014-07-09 15:05:53 -07001071
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001072 /**
1073 * Convenience function to set the flag bits as specified in flags, as
1074 * per {@link #setFlags}.
1075 * @param flags The flag bits to be set.
1076 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001077 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001078 */
1079 public void addFlags(int flags) {
1080 setFlags(flags, flags);
1081 }
Adam Lesinski95c42972013-10-02 10:13:27 -07001082
Philip P. Moltmannd66dd992018-09-17 11:26:04 -07001083 /**
1084 * Add private flag bits.
1085 *
1086 * <p>Refer to the individual flags for the permissions needed.
1087 *
Philip P. Moltmann66ce2382018-10-09 13:46:11 -07001088 * @param flags The flag bits to add.
1089 *
1090 * @hide
1091 */
1092 public void addPrivateFlags(int flags) {
1093 setPrivateFlags(flags, flags);
1094 }
1095
1096 /**
1097 * Add system flag bits.
1098 *
1099 * <p>Refer to the individual flags for the permissions needed.
1100 *
Philip P. Moltmannd66dd992018-09-17 11:26:04 -07001101 * <p>Note: Only for updateable system components (aka. mainline modules)
1102 *
1103 * @param flags The flag bits to add.
1104 *
1105 * @hide
1106 */
1107 @SystemApi
Philip P. Moltmann66ce2382018-10-09 13:46:11 -07001108 public void addSystemFlags(@WindowManager.LayoutParams.SystemFlags int flags) {
1109 addPrivateFlags(flags);
Adam Lesinski95c42972013-10-02 10:13:27 -07001110 }
RoboErik55011652014-07-09 15:05:53 -07001111
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001112 /**
1113 * Convenience function to clear the flag bits as specified in flags, as
1114 * per {@link #setFlags}.
1115 * @param flags The flag bits to be cleared.
1116 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001117 * @see #addFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001118 */
1119 public void clearFlags(int flags) {
1120 setFlags(0, flags);
1121 }
1122
1123 /**
1124 * Set the flags of the window, as per the
1125 * {@link WindowManager.LayoutParams WindowManager.LayoutParams}
1126 * flags.
RoboErik55011652014-07-09 15:05:53 -07001127 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001128 * <p>Note that some flags must be set before the window decoration is
1129 * created (by the first call to
1130 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or
1131 * {@link #getDecorView()}:
1132 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and
1133 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These
1134 * will be set for you based on the {@link android.R.attr#windowIsFloating}
1135 * attribute.
1136 *
1137 * @param flags The new window flags (see WindowManager.LayoutParams).
1138 * @param mask Which of the window flag bits to modify.
Christopher Tate193fc072012-06-04 11:27:40 -07001139 * @see #addFlags
1140 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001141 */
1142 public void setFlags(int flags, int mask) {
1143 final WindowManager.LayoutParams attrs = getAttributes();
1144 attrs.flags = (attrs.flags&~mask) | (flags&mask);
1145 mForcedWindowFlags |= mask;
Adrian Roosea562512014-05-05 13:33:03 +02001146 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001147 }
1148
Adam Lesinski95c42972013-10-02 10:13:27 -07001149 private void setPrivateFlags(int flags, int mask) {
1150 final WindowManager.LayoutParams attrs = getAttributes();
1151 attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
Adrian Roosea562512014-05-05 13:33:03 +02001152 dispatchWindowAttributesChanged(attrs);
1153 }
1154
1155 /**
1156 * {@hide}
1157 */
Mathew Inwooda570dee2018-08-17 14:56:00 +01001158 @UnsupportedAppUsage
Wale Ogunwale393b1c12014-10-18 16:22:01 -07001159 protected void setNeedsMenuKey(int value) {
1160 final WindowManager.LayoutParams attrs = getAttributes();
1161 attrs.needsMenuKey = value;
1162 dispatchWindowAttributesChanged(attrs);
1163 }
1164
1165 /**
1166 * {@hide}
1167 */
Adrian Roosea562512014-05-05 13:33:03 +02001168 protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) {
Adam Lesinski95c42972013-10-02 10:13:27 -07001169 if (mCallback != null) {
1170 mCallback.onWindowAttributesChanged(attrs);
1171 }
1172 }
1173
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001174 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001175 * <p>Sets the requested color mode of the window. The requested the color mode might
Romain Guy48327452017-01-23 17:03:35 -08001176 * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p>
1177 *
Romain Guyadae59b2017-06-20 14:45:53 -07001178 * <p>The requested color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
Romain Guy48327452017-01-23 17:03:35 -08001179 * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}.</p>
Romain Guyadae59b2017-06-20 14:45:53 -07001180 *
1181 * <p>The requested color mode is not guaranteed to be honored. Please refer to
1182 * {@link #getColorMode()} for more information.</p>
1183 *
1184 * @see #getColorMode()
1185 * @see Display#isWideColorGamut()
1186 * @see Configuration#isScreenWideColorGamut()
Romain Guy48327452017-01-23 17:03:35 -08001187 */
1188 public void setColorMode(@ActivityInfo.ColorMode int colorMode) {
1189 final WindowManager.LayoutParams attrs = getAttributes();
1190 attrs.setColorMode(colorMode);
1191 dispatchWindowAttributesChanged(attrs);
1192 }
1193
1194 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001195 * Returns the requested color mode of the window, one of
1196 * {@link ActivityInfo#COLOR_MODE_DEFAULT}, {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
1197 * or {@link ActivityInfo#COLOR_MODE_HDR}. If {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
1198 * was requested it is possible the window will not be put in wide color gamut mode depending
1199 * on device and display support for that mode. Use {@link #isWideColorGamut} to determine
1200 * if the window is currently in wide color gamut mode.
1201 *
1202 * @see #setColorMode(int)
1203 * @see Display#isWideColorGamut()
1204 * @see Configuration#isScreenWideColorGamut()
Romain Guy48327452017-01-23 17:03:35 -08001205 */
1206 @ActivityInfo.ColorMode
1207 public int getColorMode() {
1208 return getAttributes().getColorMode();
1209 }
1210
1211 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001212 * Returns true if this window's color mode is {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT},
1213 * the display has a wide color gamut and this device supports wide color gamut rendering.
1214 *
1215 * @see Display#isWideColorGamut()
1216 * @see Configuration#isScreenWideColorGamut()
1217 */
1218 public boolean isWideColorGamut() {
1219 return getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT
1220 && getContext().getResources().getConfiguration().isScreenWideColorGamut();
1221 }
1222
1223 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001224 * Set the amount of dim behind the window when using
1225 * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides
1226 * the default dim amount of that is selected by the Window based on
1227 * its theme.
1228 *
1229 * @param amount The new dim amount, from 0 for no dim to 1 for full dim.
1230 */
1231 public void setDimAmount(float amount) {
1232 final WindowManager.LayoutParams attrs = getAttributes();
1233 attrs.dimAmount = amount;
1234 mHaveDimAmount = true;
Adrian Roosea562512014-05-05 13:33:03 +02001235 dispatchWindowAttributesChanged(attrs);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001236 }
1237
1238 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001239 * Specify custom window attributes. <strong>PLEASE NOTE:</strong> the
1240 * layout params you give here should generally be from values previously
1241 * retrieved with {@link #getAttributes()}; you probably do not want to
1242 * blindly create and apply your own, since this will blow away any values
1243 * set by the framework that you are not interested in.
1244 *
1245 * @param a The new window attributes, which will completely override any
1246 * current values.
1247 */
1248 public void setAttributes(WindowManager.LayoutParams a) {
1249 mWindowAttributes.copyFrom(a);
Adrian Roosea562512014-05-05 13:33:03 +02001250 dispatchWindowAttributesChanged(mWindowAttributes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001251 }
1252
1253 /**
1254 * Retrieve the current window attributes associated with this panel.
1255 *
1256 * @return WindowManager.LayoutParams Either the existing window
1257 * attributes object, or a freshly created one if there is none.
1258 */
1259 public final WindowManager.LayoutParams getAttributes() {
1260 return mWindowAttributes;
1261 }
1262
1263 /**
1264 * Return the window flags that have been explicitly set by the client,
1265 * so will not be modified by {@link #getDecorView}.
1266 */
1267 protected final int getForcedWindowFlags() {
1268 return mForcedWindowFlags;
1269 }
RoboErik55011652014-07-09 15:05:53 -07001270
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001271 /**
1272 * Has the app specified their own soft input mode?
1273 */
1274 protected final boolean hasSoftInputMode() {
1275 return mHasSoftInputMode;
1276 }
RoboErik55011652014-07-09 15:05:53 -07001277
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001278 /** @hide */
Mathew Inwooda570dee2018-08-17 14:56:00 +01001279 @UnsupportedAppUsage
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001280 public void setCloseOnTouchOutside(boolean close) {
1281 mCloseOnTouchOutside = close;
1282 mSetCloseOnTouchOutside = true;
1283 }
RoboErik55011652014-07-09 15:05:53 -07001284
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001285 /** @hide */
Mathew Inwooda570dee2018-08-17 14:56:00 +01001286 @UnsupportedAppUsage
Dianne Hackbornef575752011-01-18 17:35:17 -08001287 public void setCloseOnTouchOutsideIfNotSet(boolean close) {
1288 if (!mSetCloseOnTouchOutside) {
1289 mCloseOnTouchOutside = close;
1290 mSetCloseOnTouchOutside = true;
1291 }
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001292 }
RoboErik55011652014-07-09 15:05:53 -07001293
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001294 /** @hide */
Mathew Inwooda570dee2018-08-17 14:56:00 +01001295 @UnsupportedAppUsage
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001296 public abstract void alwaysReadCloseOnTouchAttr();
RoboErik55011652014-07-09 15:05:53 -07001297
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001298 /** @hide */
Mathew Inwood31755f92018-12-20 13:53:36 +00001299 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001300 public boolean shouldCloseOnTouch(Context context, MotionEvent event) {
Michael Wrightddec8fb2017-06-16 18:36:26 +01001301 final boolean isOutside =
1302 event.getAction() == MotionEvent.ACTION_DOWN && isOutOfBounds(context, event)
1303 || event.getAction() == MotionEvent.ACTION_OUTSIDE;
1304 if (mCloseOnTouchOutside && peekDecorView() != null && isOutside) {
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001305 return true;
1306 }
1307 return false;
1308 }
RoboErik55011652014-07-09 15:05:53 -07001309
Ruchi Kandoi43e38de2016-04-14 19:34:53 -07001310 /* Sets the Sustained Performance requirement for the calling window.
1311 * @param enable disables or enables the mode.
1312 */
1313 public void setSustainedPerformanceMode(boolean enable) {
1314 setPrivateFlags(enable
1315 ? WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE : 0,
1316 WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE);
1317 }
1318
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001319 private boolean isOutOfBounds(Context context, MotionEvent event) {
1320 final int x = (int) event.getX();
1321 final int y = (int) event.getY();
1322 final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
1323 final View decorView = getDecorView();
1324 return (x < -slop) || (y < -slop)
1325 || (x > (decorView.getWidth()+slop))
1326 || (y > (decorView.getHeight()+slop));
1327 }
RoboErik55011652014-07-09 15:05:53 -07001328
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001329 /**
1330 * Enable extended screen features. This must be called before
1331 * setContentView(). May be called as many times as desired as long as it
1332 * is before setContentView(). If not called, no extended features
1333 * will be available. You can not turn off a feature once it is requested.
1334 * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
1335 *
1336 * @param featureId The desired features, defined as constants by Window.
1337 * @return The features that are now set.
1338 */
1339 public boolean requestFeature(int featureId) {
1340 final int flag = 1<<featureId;
1341 mFeatures |= flag;
1342 mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
1343 return (mFeatures&flag) != 0;
1344 }
1345
Adam Powellf4a6ec42010-08-24 14:18:10 -07001346 /**
1347 * @hide Used internally to help resolve conflicting features.
1348 */
1349 protected void removeFeature(int featureId) {
1350 final int flag = 1<<featureId;
1351 mFeatures &= ~flag;
1352 mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag);
1353 }
1354
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001355 public final void makeActive() {
1356 if (mContainer != null) {
1357 if (mContainer.mActiveChild != null) {
1358 mContainer.mActiveChild.mIsActive = false;
1359 }
1360 mContainer.mActiveChild = this;
1361 }
1362 mIsActive = true;
1363 onActive();
1364 }
1365
1366 public final boolean isActive()
1367 {
1368 return mIsActive;
1369 }
1370
1371 /**
Alan Viverettedb7423c2017-03-31 13:13:58 -04001372 * Finds a view that was identified by the {@code android:id} XML attribute
Chris Craik6faa9e52018-01-11 10:46:10 -08001373 * that was processed in {@link android.app.Activity#onCreate}.
1374 * <p>
1375 * This will implicitly call {@link #getDecorView} with all of the associated side-effects.
Alan Viverettedb7423c2017-03-31 13:13:58 -04001376 * <p>
1377 * <strong>Note:</strong> In most cases -- depending on compiler support --
1378 * the resulting view is automatically cast to the target class type. If
1379 * the target class type is unconstrained, an explicit cast may be
1380 * necessary.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001381 *
Alan Viverettedb7423c2017-03-31 13:13:58 -04001382 * @param id the ID to search for
1383 * @return a view with given ID if found, or {@code null} otherwise
1384 * @see View#findViewById(int)
Chris Craik6faa9e52018-01-11 10:46:10 -08001385 * @see Window#requireViewById(int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001386 */
Scott Kennedyc0519552015-02-11 15:33:10 -08001387 @Nullable
Alan Viverettedb7423c2017-03-31 13:13:58 -04001388 public <T extends View> T findViewById(@IdRes int id) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001389 return getDecorView().findViewById(id);
1390 }
Chris Craik6faa9e52018-01-11 10:46:10 -08001391 /**
1392 * Finds a view that was identified by the {@code android:id} XML attribute
1393 * that was processed in {@link android.app.Activity#onCreate}, or throws an
1394 * IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy.
1395 * <p>
1396 * <strong>Note:</strong> In most cases -- depending on compiler support --
1397 * the resulting view is automatically cast to the target class type. If
1398 * the target class type is unconstrained, an explicit cast may be
1399 * necessary.
1400 *
1401 * @param id the ID to search for
1402 * @return a view with given ID
1403 * @see View#requireViewById(int)
1404 * @see Window#findViewById(int)
1405 */
1406 @NonNull
1407 public final <T extends View> T requireViewById(@IdRes int id) {
1408 T view = findViewById(id);
1409 if (view == null) {
1410 throw new IllegalArgumentException("ID does not reference a View inside this Window");
1411 }
1412 return view;
1413 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001414
1415 /**
1416 * Convenience for
1417 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1418 * to set the screen content from a layout resource. The resource will be
1419 * inflated, adding all top-level views to the screen.
1420 *
1421 * @param layoutResID Resource ID to be inflated.
1422 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1423 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001424 public abstract void setContentView(@LayoutRes int layoutResID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001425
1426 /**
1427 * Convenience for
1428 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1429 * set the screen content to an explicit view. This view is placed
1430 * directly into the screen's view hierarchy. It can itself be a complex
1431 * view hierarhcy.
1432 *
1433 * @param view The desired content to display.
1434 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1435 */
1436 public abstract void setContentView(View view);
1437
1438 /**
1439 * Set the screen content to an explicit view. This view is placed
1440 * directly into the screen's view hierarchy. It can itself be a complex
1441 * view hierarchy.
1442 *
1443 * <p>Note that calling this function "locks in" various characteristics
1444 * of the window that can not, from this point forward, be changed: the
1445 * features that have been requested with {@link #requestFeature(int)},
George Mountc3a043c2015-02-04 14:37:04 -08001446 * and certain window flags as described in {@link #setFlags(int, int)}.</p>
1447 *
1448 * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's
1449 * TransitionManager will be used to animate content from the current
1450 * content View to view.</p>
RoboErik55011652014-07-09 15:05:53 -07001451 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001452 * @param view The desired content to display.
1453 * @param params Layout parameters for the view.
George Mountc3a043c2015-02-04 14:37:04 -08001454 * @see #getTransitionManager()
1455 * @see #setTransitionManager(android.transition.TransitionManager)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001456 */
1457 public abstract void setContentView(View view, ViewGroup.LayoutParams params);
1458
1459 /**
1460 * Variation on
1461 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1462 * to add an additional content view to the screen. Added after any existing
1463 * ones in the screen -- existing views are NOT removed.
1464 *
1465 * @param view The desired content to display.
1466 * @param params Layout parameters for the view.
1467 */
1468 public abstract void addContentView(View view, ViewGroup.LayoutParams params);
1469
1470 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001471 * Remove the view that was used as the screen content.
1472 *
1473 * @hide
1474 */
1475 public abstract void clearContentView();
1476
1477 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001478 * Return the view in this Window that currently has focus, or null if
1479 * there are none. Note that this does not look in any containing
1480 * Window.
1481 *
1482 * @return View The current View with focus or null.
1483 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001484 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001485 public abstract View getCurrentFocus();
1486
1487 /**
1488 * Quick access to the {@link LayoutInflater} instance that this Window
1489 * retrieved from its Context.
1490 *
1491 * @return LayoutInflater The shared LayoutInflater.
1492 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001493 @NonNull
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001494 public abstract LayoutInflater getLayoutInflater();
1495
1496 public abstract void setTitle(CharSequence title);
1497
Alan Viverette2525d9c2013-11-15 14:42:19 -08001498 @Deprecated
Tor Norbye80756e32015-03-02 09:39:27 -08001499 public abstract void setTitleColor(@ColorInt int textColor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001500
1501 public abstract void openPanel(int featureId, KeyEvent event);
1502
1503 public abstract void closePanel(int featureId);
1504
1505 public abstract void togglePanel(int featureId, KeyEvent event);
1506
Dianne Hackbornb31e84bc2010-06-08 18:04:35 -07001507 public abstract void invalidatePanelMenu(int featureId);
RoboErik55011652014-07-09 15:05:53 -07001508
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001509 public abstract boolean performPanelShortcut(int featureId,
1510 int keyCode,
1511 KeyEvent event,
1512 int flags);
1513 public abstract boolean performPanelIdentifierAction(int featureId,
1514 int id,
1515 int flags);
1516
1517 public abstract void closeAllPanels();
1518
1519 public abstract boolean performContextMenuIdentifierAction(int id, int flags);
1520
1521 /**
1522 * Should be called when the configuration is changed.
RoboErik55011652014-07-09 15:05:53 -07001523 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001524 * @param newConfig The new configuration.
1525 */
1526 public abstract void onConfigurationChanged(Configuration newConfig);
RoboErik55011652014-07-09 15:05:53 -07001527
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001528 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001529 * Sets the window elevation.
Alan Viverette71922de2015-01-12 16:14:02 -08001530 * <p>
1531 * Changes to this property take effect immediately and will cause the
1532 * window surface to be recreated. This is an expensive operation and as a
1533 * result, this property should not be animated.
Alan Viverette79c067c52014-10-29 14:27:47 -07001534 *
1535 * @param elevation The window elevation.
1536 * @see View#setElevation(float)
1537 * @see android.R.styleable#Window_windowElevation
1538 */
1539 public void setElevation(float elevation) {}
1540
1541 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001542 * Gets the window elevation.
1543 *
1544 * @hide
1545 */
1546 public float getElevation() {
1547 return 0.0f;
1548 }
1549
1550 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001551 * Sets whether window content should be clipped to the outline of the
1552 * window background.
1553 *
1554 * @param clipToOutline Whether window content should be clipped to the
1555 * outline of the window background.
1556 * @see View#setClipToOutline(boolean)
1557 * @see android.R.styleable#Window_windowClipToOutline
1558 */
1559 public void setClipToOutline(boolean clipToOutline) {}
1560
1561 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001562 * Change the background of this window to a Drawable resource. Setting the
1563 * background to null will make the window be opaque. To make the window
1564 * transparent, you can use an empty drawable (for instance a ColorDrawable
1565 * with the color 0 or the system drawable android:drawable/empty.)
RoboErik55011652014-07-09 15:05:53 -07001566 *
Alan Viverette79c067c52014-10-29 14:27:47 -07001567 * @param resId The resource identifier of a drawable resource which will
1568 * be installed as the new background.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001569 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001570 public void setBackgroundDrawableResource(@DrawableRes int resId) {
Alan Viverette79c067c52014-10-29 14:27:47 -07001571 setBackgroundDrawable(mContext.getDrawable(resId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001572 }
1573
1574 /**
1575 * Change the background of this window to a custom Drawable. Setting the
1576 * background to null will make the window be opaque. To make the window
1577 * transparent, you can use an empty drawable (for instance a ColorDrawable
1578 * with the color 0 or the system drawable android:drawable/empty.)
1579 *
1580 * @param drawable The new Drawable to use for this window's background.
1581 */
1582 public abstract void setBackgroundDrawable(Drawable drawable);
1583
1584 /**
1585 * Set the value for a drawable feature of this window, from a resource
Tor Norbye7b9c9122013-05-30 16:48:33 -07001586 * identifier. You must have called requestFeature(featureId) before
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001587 * calling this function.
1588 *
1589 * @see android.content.res.Resources#getDrawable(int)
1590 *
1591 * @param featureId The desired drawable feature to change, defined as a
1592 * constant by Window.
1593 * @param resId Resource identifier of the desired image.
1594 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001595 public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001596
1597 /**
1598 * Set the value for a drawable feature of this window, from a URI. You
1599 * must have called requestFeature(featureId) before calling this
1600 * function.
1601 *
1602 * <p>The only URI currently supported is "content:", specifying an image
1603 * in a content provider.
1604 *
1605 * @see android.widget.ImageView#setImageURI
1606 *
1607 * @param featureId The desired drawable feature to change. Features are
1608 * constants defined by Window.
1609 * @param uri The desired URI.
1610 */
1611 public abstract void setFeatureDrawableUri(int featureId, Uri uri);
1612
1613 /**
1614 * Set an explicit Drawable value for feature of this window. You must
1615 * have called requestFeature(featureId) before calling this function.
1616 *
Alan Viverette9678e342014-10-24 15:23:58 -07001617 * @param featureId The desired drawable feature to change. Features are
1618 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001619 * @param drawable A Drawable object to display.
1620 */
1621 public abstract void setFeatureDrawable(int featureId, Drawable drawable);
1622
1623 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001624 * Set a custom alpha value for the given drawable feature, controlling how
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001625 * much the background is visible through it.
1626 *
Alan Viverette9678e342014-10-24 15:23:58 -07001627 * @param featureId The desired drawable feature to change. Features are
1628 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001629 * @param alpha The alpha amount, 0 is completely transparent and 255 is
1630 * completely opaque.
1631 */
1632 public abstract void setFeatureDrawableAlpha(int featureId, int alpha);
1633
1634 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001635 * Set the integer value for a feature. The range of the value depends on
1636 * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from
1637 * 0 to 10000. At 10000 the progress is complete and the indicator hidden.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001638 *
Alan Viverette9678e342014-10-24 15:23:58 -07001639 * @param featureId The desired feature to change. Features are constants
1640 * defined by Window.
1641 * @param value The value for the feature. The interpretation of this
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001642 * value is feature-specific.
1643 */
1644 public abstract void setFeatureInt(int featureId, int value);
1645
1646 /**
1647 * Request that key events come to this activity. Use this if your
1648 * activity has no views with focus, but the activity still wants
1649 * a chance to process key events.
1650 */
1651 public abstract void takeKeyEvents(boolean get);
1652
1653 /**
1654 * Used by custom windows, such as Dialog, to pass the key press event
1655 * further down the view hierarchy. Application developers should
1656 * not need to implement or call this.
1657 *
1658 */
1659 public abstract boolean superDispatchKeyEvent(KeyEvent event);
1660
1661 /**
Jeff Brown64da12a2011-01-04 19:57:47 -08001662 * Used by custom windows, such as Dialog, to pass the key shortcut press event
1663 * further down the view hierarchy. Application developers should
1664 * not need to implement or call this.
1665 *
1666 */
1667 public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event);
1668
1669 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001670 * Used by custom windows, such as Dialog, to pass the touch screen event
1671 * further down the view hierarchy. Application developers should
1672 * not need to implement or call this.
1673 *
1674 */
1675 public abstract boolean superDispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001676
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001677 /**
1678 * Used by custom windows, such as Dialog, to pass the trackball event
1679 * further down the view hierarchy. Application developers should
1680 * not need to implement or call this.
1681 *
1682 */
1683 public abstract boolean superDispatchTrackballEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001684
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001685 /**
Jeff Browncb1404e2011-01-15 18:14:15 -08001686 * Used by custom windows, such as Dialog, to pass the generic motion event
1687 * further down the view hierarchy. Application developers should
1688 * not need to implement or call this.
1689 *
1690 */
1691 public abstract boolean superDispatchGenericMotionEvent(MotionEvent event);
1692
1693 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001694 * Retrieve the top-level window decor view (containing the standard
1695 * window frame/decorations and the client's content inside of that), which
1696 * can be added as a window to the window manager.
RoboErik55011652014-07-09 15:05:53 -07001697 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001698 * <p><em>Note that calling this function for the first time "locks in"
1699 * various window characteristics as described in
1700 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p>
RoboErik55011652014-07-09 15:05:53 -07001701 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001702 * @return Returns the top-level window decor view.
1703 */
Siarhei Vishniakouc771e7e2018-04-19 11:43:29 -07001704 public abstract @NonNull View getDecorView();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001705
1706 /**
1707 * Retrieve the current decor view, but only if it has already been created;
1708 * otherwise returns null.
RoboErik55011652014-07-09 15:05:53 -07001709 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001710 * @return Returns the top-level window decor or null.
1711 * @see #getDecorView
1712 */
1713 public abstract View peekDecorView();
1714
1715 public abstract Bundle saveHierarchyState();
RoboErik55011652014-07-09 15:05:53 -07001716
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001717 public abstract void restoreHierarchyState(Bundle savedInstanceState);
RoboErik55011652014-07-09 15:05:53 -07001718
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001719 protected abstract void onActive();
1720
1721 /**
1722 * Return the feature bits that are enabled. This is the set of features
1723 * that were given to requestFeature(), and are being handled by this
1724 * Window itself or its container. That is, it is the set of
1725 * requested features that you can actually use.
1726 *
1727 * <p>To do: add a public version of this API that allows you to check for
1728 * features by their feature ID.
1729 *
1730 * @return int The feature bits.
1731 */
1732 protected final int getFeatures()
1733 {
1734 return mFeatures;
1735 }
RoboErik55011652014-07-09 15:05:53 -07001736
Adam Powell33b97432010-04-20 10:01:14 -07001737 /**
Bryce Leed6e6e722014-11-21 11:08:45 -08001738 * Return the feature bits set by default on a window.
1739 * @param context The context used to access resources
1740 */
1741 public static int getDefaultFeatures(Context context) {
1742 int features = 0;
1743
1744 final Resources res = context.getResources();
1745 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
1746 features |= 1 << FEATURE_OPTIONS_PANEL;
1747 }
1748
1749 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
1750 features |= 1 << FEATURE_CONTEXT_MENU;
1751 }
1752
1753 return features;
1754 }
1755
1756 /**
Adam Powell33b97432010-04-20 10:01:14 -07001757 * Query for the availability of a certain feature.
RoboErik55011652014-07-09 15:05:53 -07001758 *
Adam Powell33b97432010-04-20 10:01:14 -07001759 * @param feature The feature ID to check
1760 * @return true if the feature is enabled, false otherwise.
1761 */
1762 public boolean hasFeature(int feature) {
1763 return (getFeatures() & (1 << feature)) != 0;
1764 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001765
1766 /**
1767 * Return the feature bits that are being implemented by this Window.
1768 * This is the set of features that were given to requestFeature(), and are
1769 * being handled by only this Window itself, not by its containers.
1770 *
1771 * @return int The feature bits.
1772 */
1773 protected final int getLocalFeatures()
1774 {
1775 return mLocalFeatures;
1776 }
1777
1778 /**
1779 * Set the default format of window, as per the PixelFormat types. This
1780 * is the format that will be used unless the client specifies in explicit
1781 * format with setFormat();
1782 *
1783 * @param format The new window format (see PixelFormat).
1784 *
1785 * @see #setFormat
1786 * @see PixelFormat
1787 */
1788 protected void setDefaultWindowFormat(int format) {
1789 mDefaultWindowFormat = format;
1790 if (!mHaveWindowFormat) {
1791 final WindowManager.LayoutParams attrs = getAttributes();
1792 attrs.format = format;
Adrian Roosea562512014-05-05 13:33:03 +02001793 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001794 }
1795 }
1796
Dianne Hackborn661cd522011-08-22 00:26:20 -07001797 /** @hide */
1798 protected boolean haveDimAmount() {
1799 return mHaveDimAmount;
1800 }
1801
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001802 public abstract void setChildDrawable(int featureId, Drawable drawable);
1803
1804 public abstract void setChildInt(int featureId, int value);
1805
1806 /**
1807 * Is a keypress one of the defined shortcut keys for this window.
1808 * @param keyCode the key code from {@link android.view.KeyEvent} to check.
1809 * @param event the {@link android.view.KeyEvent} to use to help check.
1810 */
1811 public abstract boolean isShortcutKey(int keyCode, KeyEvent event);
RoboErik55011652014-07-09 15:05:53 -07001812
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001813 /**
RoboErik55011652014-07-09 15:05:53 -07001814 * @see android.app.Activity#setVolumeControlStream(int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001815 */
1816 public abstract void setVolumeControlStream(int streamType);
1817
1818 /**
1819 * @see android.app.Activity#getVolumeControlStream()
1820 */
1821 public abstract int getVolumeControlStream();
Adam Powell269248d2011-08-02 10:26:54 -07001822
1823 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001824 * Sets a {@link MediaController} to send media keys and volume changes to.
1825 * If set, this should be preferred for all media keys and volume requests
1826 * sent to this window.
1827 *
1828 * @param controller The controller for the session which should receive
1829 * media keys and volume changes.
RoboErik55011652014-07-09 15:05:53 -07001830 * @see android.app.Activity#setMediaController(android.media.session.MediaController)
1831 */
1832 public void setMediaController(MediaController controller) {
1833 }
1834
1835 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001836 * Gets the {@link MediaController} that was previously set.
1837 *
1838 * @return The controller which should receive events.
1839 * @see #setMediaController(android.media.session.MediaController)
RoboErik55011652014-07-09 15:05:53 -07001840 * @see android.app.Activity#getMediaController()
1841 */
1842 public MediaController getMediaController() {
1843 return null;
1844 }
1845
1846 /**
Adam Powell269248d2011-08-02 10:26:54 -07001847 * Set extra options that will influence the UI for this window.
1848 * @param uiOptions Flags specifying extra options for this window.
1849 */
1850 public void setUiOptions(int uiOptions) { }
Adam Powelle43fca92011-08-16 12:57:01 -07001851
1852 /**
1853 * Set extra options that will influence the UI for this window.
1854 * Only the bits filtered by mask will be modified.
1855 * @param uiOptions Flags specifying extra options for this window.
1856 * @param mask Flags specifying which options should be modified. Others will remain unchanged.
1857 */
1858 public void setUiOptions(int uiOptions, int mask) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001859
1860 /**
1861 * Set the primary icon for this window.
1862 *
1863 * @param resId resource ID of a drawable to set
1864 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001865 public void setIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001866
1867 /**
1868 * Set the default icon for this window.
1869 * This will be overridden by any other icon set operation which could come from the
1870 * theme or another explicit set.
1871 *
1872 * @hide
1873 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001874 public void setDefaultIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001875
1876 /**
1877 * Set the logo for this window. A logo is often shown in place of an
1878 * {@link #setIcon(int) icon} but is generally wider and communicates window title information
1879 * as well.
1880 *
1881 * @param resId resource ID of a drawable to set
1882 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001883 public void setLogo(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001884
1885 /**
1886 * Set the default logo for this window.
1887 * This will be overridden by any other logo set operation which could come from the
1888 * theme or another explicit set.
1889 *
1890 * @hide
1891 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001892 public void setDefaultLogo(@DrawableRes int resId) { }
keunyoung30f420f2013-08-02 14:23:10 -07001893
1894 /**
1895 * Set focus locally. The window should have the
1896 * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.
1897 * @param hasFocus Whether this window has focus or not.
1898 * @param inTouchMode Whether this window is in touch mode or not.
1899 */
1900 public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { }
1901
1902 /**
1903 * Inject an event to window locally.
1904 * @param event A key or touch event to inject to this window.
1905 */
1906 public void injectInputEvent(InputEvent event) { }
Adam Powellcfbe9be2013-11-06 14:58:58 -08001907
1908 /**
1909 * Retrieve the {@link TransitionManager} responsible for for default transitions
1910 * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1911 *
1912 * <p>This method will return non-null after content has been initialized (e.g. by using
1913 * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p>
1914 *
1915 * @return This window's content TransitionManager or null if none is set.
George Mountc3a043c2015-02-04 14:37:04 -08001916 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08001917 */
1918 public TransitionManager getTransitionManager() {
1919 return null;
1920 }
1921
1922 /**
1923 * Set the {@link TransitionManager} to use for default transitions in this window.
1924 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1925 *
1926 * @param tm The TransitionManager to use for scene changes.
George Mountc3a043c2015-02-04 14:37:04 -08001927 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08001928 */
1929 public void setTransitionManager(TransitionManager tm) {
1930 throw new UnsupportedOperationException();
1931 }
1932
1933 /**
1934 * Retrieve the {@link Scene} representing this window's current content.
1935 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1936 *
1937 * <p>This method will return null if the current content is not represented by a Scene.</p>
1938 *
1939 * @return Current Scene being shown or null
1940 */
1941 public Scene getContentScene() {
1942 return null;
1943 }
1944
1945 /**
George Mount31a21722014-03-24 17:44:36 -07001946 * Sets the Transition that will be used to move Views into the initial scene. The entering
1947 * Views will be those that are regular Views or ViewGroups that have
1948 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1949 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1950 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1951 * entering Views will remain unaffected.
George Mountc03da0e2014-08-22 17:04:02 -07001952 *
George Mount31a21722014-03-24 17:44:36 -07001953 * @param transition The Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001954 * @attr ref android.R.styleable#Window_windowEnterTransition
Adam Powellcfbe9be2013-11-06 14:58:58 -08001955 */
George Mount31a21722014-03-24 17:44:36 -07001956 public void setEnterTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08001957
1958 /**
George Mount68f96d82014-07-31 13:13:10 -07001959 * Sets the Transition that will be used to move Views out of the scene when the Window is
1960 * preparing to close, for example after a call to
1961 * {@link android.app.Activity#finishAfterTransition()}. The exiting
1962 * Views will be those that are regular Views or ViewGroups that have
1963 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1964 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1965 * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null,
1966 * entering Views will remain unaffected. If nothing is set, the default will be to
1967 * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
George Mountc03da0e2014-08-22 17:04:02 -07001968 *
George Mount68f96d82014-07-31 13:13:10 -07001969 * @param transition The Transition to use to move Views out of the Scene when the Window
1970 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07001971 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07001972 */
1973 public void setReturnTransition(Transition transition) {}
1974
1975 /**
George Mount31a21722014-03-24 17:44:36 -07001976 * Sets the Transition that will be used to move Views out of the scene when starting a
1977 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1978 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1979 * {@link android.transition.Visibility} as exiting is governed by changing visibility
1980 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07001981 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001982 *
George Mount31a21722014-03-24 17:44:36 -07001983 * @param transition The Transition to use to move Views out of the scene when calling a
1984 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07001985 * @attr ref android.R.styleable#Window_windowExitTransition
George Mount0a778ed2013-12-13 13:35:36 -08001986 */
George Mount31a21722014-03-24 17:44:36 -07001987 public void setExitTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08001988
1989 /**
George Mount68f96d82014-07-31 13:13:10 -07001990 * Sets the Transition that will be used to move Views in to the scene when returning from
1991 * a previously-started Activity. The entering Views will be those that are regular Views
1992 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1993 * will extend {@link android.transition.Visibility} as exiting is governed by changing
1994 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
1995 * the views will remain unaffected. If nothing is set, the default will be to use the same
1996 * transition as {@link #setExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07001997 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001998 *
George Mount68f96d82014-07-31 13:13:10 -07001999 * @param transition The Transition to use to move Views into the scene when reentering from a
2000 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002001 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002002 */
2003 public void setReenterTransition(Transition transition) {}
2004
2005 /**
George Mount31a21722014-03-24 17:44:36 -07002006 * Returns the transition used to move Views into the initial scene. The entering
2007 * Views will be those that are regular Views or ViewGroups that have
2008 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2009 * {@link android.transition.Visibility} as entering is governed by changing visibility from
2010 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
George Mount9826f632014-09-11 08:50:09 -07002011 * entering Views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07002012 *
2013 * @return the Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002014 * @attr ref android.R.styleable#Window_windowEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08002015 */
George Mount31a21722014-03-24 17:44:36 -07002016 public Transition getEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08002017
2018 /**
Chet Haaseb64e777f2016-12-09 07:17:10 -08002019 * 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 -07002020 * preparing to close, for example after a call to
2021 * {@link android.app.Activity#finishAfterTransition()}. The exiting
2022 * Views will be those that are regular Views or ViewGroups that have
2023 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2024 * {@link android.transition.Visibility} as entering is governed by changing visibility from
2025 * {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mountc03da0e2014-08-22 17:04:02 -07002026 *
George Mount68f96d82014-07-31 13:13:10 -07002027 * @return The Transition to use to move Views out of the Scene when the Window
2028 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07002029 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002030 */
2031 public Transition getReturnTransition() { return null; }
2032
2033 /**
George Mount31a21722014-03-24 17:44:36 -07002034 * Returns the Transition that will be used to move Views out of the scene when starting a
2035 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
2036 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2037 * {@link android.transition.Visibility} as exiting is governed by changing visibility
2038 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07002039 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002040 *
George Mount31a21722014-03-24 17:44:36 -07002041 * @return the Transition to use to move Views out of the scene when calling a
2042 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002043 * @attr ref android.R.styleable#Window_windowExitTransition
George Mountcb4b7d92014-02-25 10:47:55 -08002044 */
George Mount31a21722014-03-24 17:44:36 -07002045 public Transition getExitTransition() { return null; }
George Mount0a778ed2013-12-13 13:35:36 -08002046
2047 /**
George Mount68f96d82014-07-31 13:13:10 -07002048 * Returns the Transition that will be used to move Views in to the scene when returning from
2049 * a previously-started Activity. The entering Views will be those that are regular Views
2050 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
2051 * will extend {@link android.transition.Visibility} as exiting is governed by changing
2052 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mount9826f632014-09-11 08:50:09 -07002053 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002054 *
George Mount68f96d82014-07-31 13:13:10 -07002055 * @return The Transition to use to move Views into the scene when reentering from a
2056 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002057 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002058 */
2059 public Transition getReenterTransition() { return null; }
2060
2061 /**
George Mount31a21722014-03-24 17:44:36 -07002062 * Sets the Transition that will be used for shared elements transferred into the content
2063 * Scene. Typical Transitions will affect size and location, such as
George Mount990205e2014-06-24 09:36:18 -07002064 * {@link android.transition.ChangeBounds}. A null
George Mount31a21722014-03-24 17:44:36 -07002065 * value will cause transferred shared elements to blink to the final position.
George Mount9826f632014-09-11 08:50:09 -07002066 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002067 *
George Mount31a21722014-03-24 17:44:36 -07002068 * @param transition The Transition to use for shared elements transferred into the content
2069 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002070 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08002071 */
George Mount31a21722014-03-24 17:44:36 -07002072 public void setSharedElementEnterTransition(Transition transition) {}
George Mounte1803372014-02-26 19:00:52 +00002073
2074 /**
George Mount68f96d82014-07-31 13:13:10 -07002075 * Sets the Transition that will be used for shared elements transferred back to a
2076 * calling Activity. Typical Transitions will affect size and location, such as
2077 * {@link android.transition.ChangeBounds}. A null
2078 * value will cause transferred shared elements to blink to the final position.
2079 * If no value is set, the default will be to use the same value as
2080 * {@link #setSharedElementEnterTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07002081 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002082 *
George Mount68f96d82014-07-31 13:13:10 -07002083 * @param transition The Transition to use for shared elements transferred out of the content
2084 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002085 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002086 */
2087 public void setSharedElementReturnTransition(Transition transition) {}
2088
2089 /**
George Mount31a21722014-03-24 17:44:36 -07002090 * Returns the Transition that will be used for shared elements transferred into the content
George Mount9826f632014-09-11 08:50:09 -07002091 * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002092 *
George Mount31a21722014-03-24 17:44:36 -07002093 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002094 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mountcb4b7d92014-02-25 10:47:55 -08002095 */
George Mount31a21722014-03-24 17:44:36 -07002096 public Transition getSharedElementEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08002097
2098 /**
George Mount68f96d82014-07-31 13:13:10 -07002099 * Returns the Transition that will be used for shared elements transferred back to a
George Mount9826f632014-09-11 08:50:09 -07002100 * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002101 *
George Mount68f96d82014-07-31 13:13:10 -07002102 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002103 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002104 */
2105 public Transition getSharedElementReturnTransition() { return null; }
2106
2107 /**
George Mount31a21722014-03-24 17:44:36 -07002108 * Sets the Transition that will be used for shared elements after starting a new Activity
2109 * before the shared elements are transferred to the called Activity. If the shared elements
2110 * must animate during the exit transition, this Transition should be used. Upon completion,
2111 * the shared elements may be transferred to the started Activity.
George Mount9826f632014-09-11 08:50:09 -07002112 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002113 *
George Mount31a21722014-03-24 17:44:36 -07002114 * @param transition The Transition to use for shared elements in the launching Window
2115 * prior to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07002116 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mounte1803372014-02-26 19:00:52 +00002117 */
George Mount31a21722014-03-24 17:44:36 -07002118 public void setSharedElementExitTransition(Transition transition) {}
2119
2120 /**
George Mount68f96d82014-07-31 13:13:10 -07002121 * Sets the Transition that will be used for shared elements reentering from a started
2122 * Activity after it has returned the shared element to it start location. If no value
2123 * is set, this will default to
2124 * {@link #setSharedElementExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07002125 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002126 *
George Mount68f96d82014-07-31 13:13:10 -07002127 * @param transition The Transition to use for shared elements in the launching Window
2128 * after the shared element has returned to the Window.
George Mountc03da0e2014-08-22 17:04:02 -07002129 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002130 */
2131 public void setSharedElementReenterTransition(Transition transition) {}
2132
2133 /**
George Mount31a21722014-03-24 17:44:36 -07002134 * Returns the Transition to use for shared elements in the launching Window prior
2135 * to transferring to the launched Activity's Window.
George Mount9826f632014-09-11 08:50:09 -07002136 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07002137 *
2138 * @return the Transition to use for shared elements in the launching Window prior
2139 * to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07002140 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mount31a21722014-03-24 17:44:36 -07002141 */
2142 public Transition getSharedElementExitTransition() { return null; }
2143
2144 /**
George Mount68f96d82014-07-31 13:13:10 -07002145 * Returns the Transition that will be used for shared elements reentering from a started
2146 * Activity after it has returned the shared element to it start location.
George Mount9826f632014-09-11 08:50:09 -07002147 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount68f96d82014-07-31 13:13:10 -07002148 *
2149 * @return the Transition that will be used for shared elements reentering from a started
2150 * Activity after it has returned the shared element to it start location.
George Mountc03da0e2014-08-22 17:04:02 -07002151 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002152 */
2153 public Transition getSharedElementReenterTransition() { return null; }
2154
2155 /**
George Mount31a21722014-03-24 17:44:36 -07002156 * Controls how the transition set in
2157 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
2158 * transition of the calling Activity. When true, the transition will start as soon as possible.
2159 * When false, the transition will wait until the remote exiting transition completes before
George Mount5d52d312016-06-10 14:16:45 -07002160 * starting. The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002161 *
George Mount31a21722014-03-24 17:44:36 -07002162 * @param allow true to start the enter transition when possible or false to
2163 * wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002164 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002165 */
2166 public void setAllowEnterTransitionOverlap(boolean allow) {}
2167
2168 /**
2169 * Returns how the transition set in
2170 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
2171 * transition of the calling Activity. When true, the transition will start as soon as possible.
2172 * When false, the transition will wait until the remote exiting transition completes before
George Mount5d52d312016-06-10 14:16:45 -07002173 * starting. The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002174 *
George Mount31a21722014-03-24 17:44:36 -07002175 * @return true when the enter transition should start as soon as possible or false to
2176 * when it should wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002177 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002178 */
2179 public boolean getAllowEnterTransitionOverlap() { return true; }
2180
2181 /**
2182 * Controls how the transition set in
2183 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2184 * transition of the called Activity when reentering after if finishes. When true,
2185 * the transition will start as soon as possible. When false, the transition will wait
2186 * until the called Activity's exiting transition completes before starting.
George Mount5d52d312016-06-10 14:16:45 -07002187 * The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002188 *
George Mount31a21722014-03-24 17:44:36 -07002189 * @param allow true to start the transition when possible or false to wait until the
2190 * called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002191 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002192 */
George Mountc03da0e2014-08-22 17:04:02 -07002193 public void setAllowReturnTransitionOverlap(boolean allow) {}
2194
2195 /**
George Mount31a21722014-03-24 17:44:36 -07002196 * Returns how the transition set in
2197 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2198 * transition of the called Activity when reentering after if finishes. When true,
2199 * the transition will start as soon as possible. When false, the transition will wait
2200 * until the called Activity's exiting transition completes before starting.
George Mount5d52d312016-06-10 14:16:45 -07002201 * The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002202 *
George Mount31a21722014-03-24 17:44:36 -07002203 * @return true when the transition should start when possible or false when it should wait
2204 * until the called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002205 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002206 */
George Mountc03da0e2014-08-22 17:04:02 -07002207 public boolean getAllowReturnTransitionOverlap() { return true; }
2208
2209 /**
George Mounted1e01d2014-06-05 13:49:12 -07002210 * Returns the duration, in milliseconds, of the window background fade
2211 * when transitioning into or away from an Activity when called with an Activity Transition.
2212 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002213 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002214 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002215 *
George Mounted1e01d2014-06-05 13:49:12 -07002216 * @return The duration of the window background fade to opaque during enter transition.
2217 * @see #getEnterTransition()
George Mountc03da0e2014-08-22 17:04:02 -07002218 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002219 */
2220 public long getTransitionBackgroundFadeDuration() { return 0; }
2221
2222 /**
2223 * Sets the duration, in milliseconds, of the window background fade
2224 * when transitioning into or away from an Activity when called with an Activity Transition.
2225 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002226 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002227 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002228 *
George Mounted1e01d2014-06-05 13:49:12 -07002229 * @param fadeDurationMillis The duration of the window background fade to or from opaque
2230 * during enter transition.
2231 * @see #setEnterTransition(android.transition.Transition)
George Mountc03da0e2014-08-22 17:04:02 -07002232 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002233 */
2234 public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { }
2235
2236 /**
George Mountb89d5cc2014-08-18 16:50:50 -07002237 * Returns <code>true</code> when shared elements should use an Overlay during
2238 * shared element transitions or <code>false</code> when they should animate as
2239 * part of the normal View hierarchy. The default value is true.
2240 *
2241 * @return <code>true</code> when shared elements should use an Overlay during
2242 * shared element transitions or <code>false</code> when they should animate as
2243 * part of the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002244 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002245 */
2246 public boolean getSharedElementsUseOverlay() { return true; }
2247
2248 /**
2249 * Sets whether or not shared elements should use an Overlay during shared element transitions.
2250 * The default value is true.
2251 *
2252 * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should
2253 * be transitioned with an Overlay or <code>false</code>
2254 * to transition within the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002255 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002256 */
2257 public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { }
2258
2259 /**
Adrian Roos217ccd22014-05-09 14:29:04 +02002260 * @return the color of the status bar.
2261 */
Tor Norbye80756e32015-03-02 09:39:27 -08002262 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002263 public abstract int getStatusBarColor();
2264
2265 /**
John Spurlockbc4cf002015-03-24 21:51:20 -04002266 * Sets the color of the status bar to {@code color}.
Adrian Roos217ccd22014-05-09 14:29:04 +02002267 *
2268 * For this to take effect,
2269 * the window must be drawing the system bar backgrounds with
2270 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2271 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set.
2272 *
John Spurlockbc4cf002015-03-24 21:51:20 -04002273 * If {@code color} is not opaque, consider setting
Adrian Roos217ccd22014-05-09 14:29:04 +02002274 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2275 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
George Mount238010f2014-06-30 17:31:17 -07002276 * <p>
2277 * The transitionName for the view background will be "android:status:background".
2278 * </p>
Adrian Roos217ccd22014-05-09 14:29:04 +02002279 */
Tor Norbye80756e32015-03-02 09:39:27 -08002280 public abstract void setStatusBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002281
2282 /**
2283 * @return the color of the navigation bar.
2284 */
Tor Norbye80756e32015-03-02 09:39:27 -08002285 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002286 public abstract int getNavigationBarColor();
2287
2288 /**
2289 * Sets the color of the navigation bar to {@param color}.
2290 *
2291 * For this to take effect,
2292 * the window must be drawing the system bar backgrounds with
2293 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2294 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
2295 *
2296 * If {@param color} is not opaque, consider setting
2297 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2298 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
George Mount238010f2014-06-30 17:31:17 -07002299 * <p>
2300 * The transitionName for the view background will be "android:navigation:background".
2301 * </p>
Jorim Jaggia0b78d52018-01-22 19:01:42 +01002302 * @attr ref android.R.styleable#Window_navigationBarColor
Adrian Roos217ccd22014-05-09 14:29:04 +02002303 */
Tor Norbye80756e32015-03-02 09:39:27 -08002304 public abstract void setNavigationBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002305
Jorim Jaggia0b78d52018-01-22 19:01:42 +01002306 /**
2307 * Shows a thin line of the specified color between the navigation bar and the app
2308 * content.
2309 * <p>
2310 * For this to take effect,
2311 * the window must be drawing the system bar backgrounds with
2312 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2313 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
2314 *
2315 * @param dividerColor The color of the thin line.
2316 * @attr ref android.R.styleable#Window_navigationBarDividerColor
2317 */
2318 public void setNavigationBarDividerColor(@ColorInt int dividerColor) {
2319 }
2320
2321 /**
2322 * Retrieves the color of the navigation bar divider.
2323 *
2324 * @return The color of the navigation bar divider color.
2325 * @see #setNavigationBarColor(int)
2326 * @attr ref android.R.styleable#Window_navigationBarDividerColor
2327 */
2328 public @ColorInt int getNavigationBarDividerColor() {
2329 return 0;
2330 }
2331
Filip Gruszczynski0daf2102015-09-29 08:39:07 -07002332 /** @hide */
2333 public void setTheme(int resId) {
2334 }
Filip Gruszczynski63250652015-11-18 14:43:01 -08002335
2336 /**
2337 * Whether the caption should be displayed directly on the content rather than push the content
2338 * down. This affects only freeform windows since they display the caption.
2339 * @hide
2340 */
Andrii Kulian933076d2016-03-29 17:04:42 -07002341 public void setOverlayWithDecorCaptionEnabled(boolean enabled) {
2342 mOverlayWithDecorCaptionEnabled = enabled;
Filip Gruszczynski63250652015-11-18 14:43:01 -08002343 }
2344
2345 /** @hide */
Andrii Kulian933076d2016-03-29 17:04:42 -07002346 public boolean isOverlayWithDecorCaptionEnabled() {
2347 return mOverlayWithDecorCaptionEnabled;
Filip Gruszczynski63250652015-11-18 14:43:01 -08002348 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002349
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002350 /** @hide */
2351 public void notifyRestrictedCaptionAreaCallback(int left, int top, int right, int bottom) {
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002352 if (mOnRestrictedCaptionAreaChangedListener != null) {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002353 mRestrictedCaptionAreaRect.set(left, top, right, bottom);
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002354 mOnRestrictedCaptionAreaChangedListener.onRestrictedCaptionAreaChanged(
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002355 mRestrictedCaptionAreaRect);
2356 }
2357 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002358
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002359 /**
2360 * Set what color should the caption controls be. By default the system will try to determine
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002361 * the color from the theme. You can overwrite this by using {@link #DECOR_CAPTION_SHADE_DARK},
2362 * {@link #DECOR_CAPTION_SHADE_LIGHT}, or {@link #DECOR_CAPTION_SHADE_AUTO}.
2363 * @see #DECOR_CAPTION_SHADE_DARK
2364 * @see #DECOR_CAPTION_SHADE_LIGHT
2365 * @see #DECOR_CAPTION_SHADE_AUTO
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002366 */
2367 public abstract void setDecorCaptionShade(int decorCaptionShade);
2368
2369 /**
2370 * Set the drawable that is drawn underneath the caption during the resizing.
2371 *
2372 * During the resizing the caption might not be drawn fast enough to match the new dimensions.
2373 * There is a second caption drawn underneath it that will be fast enough. By default the
2374 * caption is constructed from the theme. You can provide a drawable, that will be drawn instead
2375 * to better match your application.
2376 */
2377 public abstract void setResizingCaptionDrawable(Drawable drawable);
Wale Ogunwaleeb6722c2015-12-08 11:43:43 -08002378
2379 /**
2380 * Called when the activity changes from fullscreen mode to multi-window mode and visa-versa.
2381 * @hide
2382 */
Andrii Kulian933076d2016-03-29 17:04:42 -07002383 public abstract void onMultiWindowModeChanged();
Jorim Jaggi4846ee32016-01-07 17:39:12 +01002384
2385 /**
Winson Chung4d8681f2017-05-23 16:22:08 -07002386 * Called when the activity changes to/from picture-in-picture mode.
2387 * @hide
2388 */
2389 public abstract void onPictureInPictureModeChanged(boolean isInPictureInPictureMode);
2390
2391 /**
Jorim Jaggi4846ee32016-01-07 17:39:12 +01002392 * Called when the activity just relaunched.
2393 * @hide
2394 */
2395 public abstract void reportActivityRelaunched();
Michael Kwanf7964be2016-11-30 16:44:33 -08002396
2397 /**
2398 * Called to set flag to check if the close on swipe is enabled. This will only function if
2399 * FEATURE_SWIPE_TO_DISMISS has been set.
2400 * @hide
2401 */
2402 public void setCloseOnSwipeEnabled(boolean closeOnSwipeEnabled) {
2403 mCloseOnSwipeEnabled = closeOnSwipeEnabled;
2404 }
2405
2406 /**
2407 * @return {@code true} if the close on swipe is enabled.
2408 * @hide
2409 */
2410 public boolean isCloseOnSwipeEnabled() {
2411 return mCloseOnSwipeEnabled;
2412 }
Jorim Jaggib6030952018-10-23 18:31:52 +02002413
2414 /**
2415 * @return The {@link WindowInsetsController} associated with this window
2416 * @see View#getWindowInsetsController()
2417 * @hide pending unhide
2418 */
2419 public abstract @NonNull WindowInsetsController getInsetsController();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002420}