blob: ef9e0eadd6a5ec2d1ea0487d5aa2d183fa5557c0 [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;
Mathew Inwoode5ad5982018-08-17 15:07:52 +010028import android.annotation.UnsupportedAppUsage;
Wale Ogunwale3382ab12017-07-27 08:55:03 -070029import android.app.WindowConfiguration;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.content.Context;
Romain Guy48327452017-01-23 17:03:35 -080031import android.content.pm.ActivityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.content.res.Configuration;
Bryce Leed6e6e722014-11-21 11:08:45 -080033import android.content.res.Resources;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.content.res.TypedArray;
Skuhnece2faa52015-08-11 10:36:38 -070035import android.graphics.PixelFormat;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -080036import android.graphics.Rect;
Filip Gruszczynski14418da2015-10-04 16:43:48 -070037import android.graphics.drawable.Drawable;
RoboErik55011652014-07-09 15:05:53 -070038import android.media.session.MediaController;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039import android.net.Uri;
Mathew Inwood55418ea2018-12-20 15:30:45 +000040import android.os.Build;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041import android.os.Bundle;
Andres Morales910beb82016-02-02 16:19:40 -080042import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043import android.os.IBinder;
Wale Ogunwale868a5e12015-08-02 16:19:20 -070044import android.os.RemoteException;
Romain Guy9622e202011-09-29 16:37:27 -070045import android.os.SystemProperties;
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 Inwoode5ad5982018-08-17 15:07:52 +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
Jeff Brownd32460c2012-07-20 16:15:36 -0700258 private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw";
259
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800260 /**
261 * Flag for letting the theme drive the color of the window caption controls. Use with
262 * {@link #setDecorCaptionShade(int)}. This is the default value.
263 */
264 public static final int DECOR_CAPTION_SHADE_AUTO = 0;
265 /**
266 * Flag for setting light-color controls on the window caption. Use with
267 * {@link #setDecorCaptionShade(int)}.
268 */
269 public static final int DECOR_CAPTION_SHADE_LIGHT = 1;
270 /**
271 * Flag for setting dark-color controls on the window caption. Use with
272 * {@link #setDecorCaptionShade(int)}.
273 */
274 public static final int DECOR_CAPTION_SHADE_DARK = 2;
275
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100276 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800277 private final Context mContext;
RoboErik55011652014-07-09 15:05:53 -0700278
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100279 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 private TypedArray mWindowStyle;
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100281 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800282 private Callback mCallback;
Adam Powell117b6952014-05-05 18:14:56 -0700283 private OnWindowDismissedCallback mOnWindowDismissedCallback;
Michael Kwan67639a52016-12-16 12:38:10 -0800284 private OnWindowSwipeDismissedCallback mOnWindowSwipeDismissedCallback;
Skuhnece2faa52015-08-11 10:36:38 -0700285 private WindowControllerCallback mWindowControllerCallback;
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800286 private OnRestrictedCaptionAreaChangedListener mOnRestrictedCaptionAreaChangedListener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800287 private Rect mRestrictedCaptionAreaRect;
Mathew Inwood55418ea2018-12-20 15:30:45 +0000288 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289 private WindowManager mWindowManager;
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100290 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800291 private IBinder mAppToken;
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100292 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 private String mAppName;
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100294 @UnsupportedAppUsage
Jeff Brownd32460c2012-07-20 16:15:36 -0700295 private boolean mHardwareAccelerated;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800296 private Window mContainer;
297 private Window mActiveChild;
298 private boolean mIsActive = false;
299 private boolean mHasChildren = false;
Dianne Hackborncfaf8872011-01-18 13:57:54 -0800300 private boolean mCloseOnTouchOutside = false;
301 private boolean mSetCloseOnTouchOutside = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800302 private int mForcedWindowFlags = 0;
303
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100304 @UnsupportedAppUsage
Bryce Leed6e6e722014-11-21 11:08:45 -0800305 private int mFeatures;
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100306 @UnsupportedAppUsage
Bryce Leed6e6e722014-11-21 11:08:45 -0800307 private int mLocalFeatures;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800308
309 private boolean mHaveWindowFormat = false;
Dianne Hackborn661cd522011-08-22 00:26:20 -0700310 private boolean mHaveDimAmount = false;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800311 private int mDefaultWindowFormat = PixelFormat.OPAQUE;
312
313 private boolean mHasSoftInputMode = false;
RoboErik55011652014-07-09 15:05:53 -0700314
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100315 @UnsupportedAppUsage
Dianne Hackborn291905e2010-08-17 15:17:15 -0700316 private boolean mDestroyed;
317
Andrii Kulian933076d2016-03-29 17:04:42 -0700318 private boolean mOverlayWithDecorCaptionEnabled = false;
Michael Kwanf7964be2016-11-30 16:44:33 -0800319 private boolean mCloseOnSwipeEnabled = false;
Filip Gruszczynski63250652015-11-18 14:43:01 -0800320
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 // The current window attributes.
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100322 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800323 private final WindowManager.LayoutParams mWindowAttributes =
324 new WindowManager.LayoutParams();
325
326 /**
327 * API from a Window back to its caller. This allows the client to
328 * intercept key dispatching, panels and menus, etc.
329 */
330 public interface Callback {
331 /**
332 * Called to process key events. At the very least your
333 * implementation must call
334 * {@link android.view.Window#superDispatchKeyEvent} to do the
335 * standard key processing.
336 *
337 * @param event The key event.
338 *
339 * @return boolean Return true if this event was consumed.
340 */
341 public boolean dispatchKeyEvent(KeyEvent event);
342
343 /**
Jeff Brown64da12a2011-01-04 19:57:47 -0800344 * Called to process a key shortcut event.
345 * At the very least your implementation must call
346 * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the
347 * standard key shortcut processing.
348 *
349 * @param event The key shortcut event.
350 * @return True if this event was consumed.
351 */
352 public boolean dispatchKeyShortcutEvent(KeyEvent event);
353
354 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800355 * Called to process touch screen events. At the very least your
356 * implementation must call
357 * {@link android.view.Window#superDispatchTouchEvent} to do the
358 * standard touch screen processing.
359 *
360 * @param event The touch screen event.
361 *
362 * @return boolean Return true if this event was consumed.
363 */
364 public boolean dispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -0700365
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800366 /**
367 * Called to process trackball events. At the very least your
368 * implementation must call
369 * {@link android.view.Window#superDispatchTrackballEvent} to do the
370 * standard trackball processing.
371 *
372 * @param event The trackball event.
373 *
374 * @return boolean Return true if this event was consumed.
375 */
376 public boolean dispatchTrackballEvent(MotionEvent event);
svetoslavganov75986cf2009-05-14 22:28:01 -0700377
378 /**
Jeff Browncb1404e2011-01-15 18:14:15 -0800379 * Called to process generic motion events. At the very least your
380 * implementation must call
381 * {@link android.view.Window#superDispatchGenericMotionEvent} to do the
382 * standard processing.
383 *
384 * @param event The generic motion event.
385 *
386 * @return boolean Return true if this event was consumed.
387 */
388 public boolean dispatchGenericMotionEvent(MotionEvent event);
389
390 /**
svetoslavganov75986cf2009-05-14 22:28:01 -0700391 * Called to process population of {@link AccessibilityEvent}s.
392 *
393 * @param event The event.
394 *
395 * @return boolean Return true if event population was completed.
396 */
397 public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event);
398
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800399 /**
400 * Instantiate the view to display in the panel for 'featureId'.
401 * You can return null, in which case the default content (typically
402 * a menu) will be created for you.
403 *
404 * @param featureId Which panel is being created.
405 *
406 * @return view The top-level view to place in the panel.
407 *
408 * @see #onPreparePanel
409 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700410 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800411 public View onCreatePanelView(int featureId);
412
413 /**
414 * Initialize the contents of the menu for panel 'featureId'. This is
415 * called if onCreatePanelView() returns null, giving you a standard
416 * menu in which you can place your items. It is only called once for
417 * the panel, the first time it is shown.
418 *
419 * <p>You can safely hold on to <var>menu</var> (and any items created
420 * from it), making modifications to it as desired, until the next
421 * time onCreatePanelMenu() is called for this feature.
422 *
423 * @param featureId The panel being created.
424 * @param menu The menu inside the panel.
425 *
426 * @return boolean You must return true for the panel to be displayed;
427 * if you return false it will not be shown.
428 */
429 public boolean onCreatePanelMenu(int featureId, Menu menu);
430
431 /**
432 * Prepare a panel to be displayed. This is called right before the
433 * panel window is shown, every time it is shown.
434 *
435 * @param featureId The panel that is being displayed.
436 * @param view The View that was returned by onCreatePanelView().
437 * @param menu If onCreatePanelView() returned null, this is the Menu
438 * being displayed in the panel.
439 *
440 * @return boolean You must return true for the panel to be displayed;
441 * if you return false it will not be shown.
442 *
443 * @see #onCreatePanelView
444 */
445 public boolean onPreparePanel(int featureId, View view, Menu menu);
446
447 /**
448 * Called when a panel's menu is opened by the user. This may also be
449 * called when the menu is changing from one type to another (for
450 * example, from the icon menu to the expanded menu).
RoboErik55011652014-07-09 15:05:53 -0700451 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800452 * @param featureId The panel that the menu is in.
453 * @param menu The menu that is opened.
454 * @return Return true to allow the menu to open, or false to prevent
455 * the menu from opening.
456 */
457 public boolean onMenuOpened(int featureId, Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700458
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800459 /**
460 * Called when a panel's menu item has been selected by the user.
461 *
462 * @param featureId The panel that the menu is in.
463 * @param item The menu item that was selected.
464 *
465 * @return boolean Return true to finish processing of selection, or
466 * false to perform the normal menu handling (calling its
467 * Runnable or sending a Message to its target Handler).
468 */
469 public boolean onMenuItemSelected(int featureId, MenuItem item);
470
471 /**
472 * This is called whenever the current window attributes change.
473 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800474 */
475 public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
476
477 /**
478 * This hook is called whenever the content view of the screen changes
479 * (due to a call to
480 * {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams)
481 * Window.setContentView} or
482 * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams)
483 * Window.addContentView}).
484 */
485 public void onContentChanged();
486
487 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700488 * This hook is called whenever the window focus changes. See
489 * {@link View#onWindowFocusChanged(boolean)
Svetoslav3a0d8782014-12-04 12:50:11 -0800490 * View.onWindowFocusChangedNotLocked(boolean)} for more information.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800491 *
492 * @param hasFocus Whether the window now has focus.
493 */
494 public void onWindowFocusChanged(boolean hasFocus);
495
496 /**
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700497 * Called when the window has been attached to the window manager.
498 * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
499 * for more information.
500 */
501 public void onAttachedToWindow();
RoboErik55011652014-07-09 15:05:53 -0700502
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700503 /**
Chet Haasee7bf2192017-08-18 15:24:56 -0700504 * Called when the window has been detached from the window manager.
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700505 * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
506 * for more information.
507 */
508 public void onDetachedFromWindow();
RoboErik55011652014-07-09 15:05:53 -0700509
Dianne Hackborn3be63c02009-08-20 19:31:38 -0700510 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800511 * Called when a panel is being closed. If another logical subsequent
512 * panel is being opened (and this panel is being closed to make room for the subsequent
513 * panel), this method will NOT be called.
RoboErik55011652014-07-09 15:05:53 -0700514 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800515 * @param featureId The panel that is being displayed.
516 * @param menu If onCreatePanelView() returned null, this is the Menu
517 * being displayed in the panel.
518 */
519 public void onPanelClosed(int featureId, Menu menu);
RoboErik55011652014-07-09 15:05:53 -0700520
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800521 /**
522 * Called when the user signals the desire to start a search.
RoboErik55011652014-07-09 15:05:53 -0700523 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800524 * @return true if search launched, false if activity refuses (blocks)
RoboErik55011652014-07-09 15:05:53 -0700525 *
526 * @see android.app.Activity#onSearchRequested()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800527 */
528 public boolean onSearchRequested();
Adam Powell6e346362010-07-23 10:18:23 -0700529
530 /**
Tim Kilbourn6a975b32015-04-09 17:14:34 -0700531 * Called when the user signals the desire to start a search.
532 *
533 * @param searchEvent A {@link SearchEvent} describing the signal to
534 * start a search.
535 * @return true if search launched, false if activity refuses (blocks)
536 */
537 public boolean onSearchRequested(SearchEvent searchEvent);
538
539 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800540 * Called when an action mode is being started for this window. Gives the
541 * callback an opportunity to handle the action mode in its own unique and
542 * beautiful way. If this method returns null the system can choose a way
Clara Bayarri4423d912015-03-02 19:42:48 +0000543 * to present the mode or choose not to start the mode at all. This is equivalent
544 * to {@link #onWindowStartingActionMode(android.view.ActionMode.Callback, int)}
545 * with type {@link ActionMode#TYPE_PRIMARY}.
Adam Powell6e346362010-07-23 10:18:23 -0700546 *
547 * @param callback Callback to control the lifecycle of this action mode
Adam Powelldebf3be2010-11-15 18:58:48 -0800548 * @return The ActionMode that was started, or null if the system should present it
Adam Powell6e346362010-07-23 10:18:23 -0700549 */
Tor Norbyed9273d62013-05-30 15:59:53 -0700550 @Nullable
Adam Powelldebf3be2010-11-15 18:58:48 -0800551 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
552
553 /**
Clara Bayarri4423d912015-03-02 19:42:48 +0000554 * Called when an action mode is being started for this window. Gives the
555 * callback an opportunity to handle the action mode in its own unique and
556 * beautiful way. If this method returns null the system can choose a way
557 * to present the mode or choose not to start the mode at all.
558 *
559 * @param callback Callback to control the lifecycle of this action mode
560 * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
561 * @return The ActionMode that was started, or null if the system should present it
562 */
563 @Nullable
564 public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);
565
566 /**
Adam Powelldebf3be2010-11-15 18:58:48 -0800567 * Called when an action mode has been started. The appropriate mode callback
568 * method will have already been invoked.
569 *
570 * @param mode The new mode that has just been started.
571 */
572 public void onActionModeStarted(ActionMode mode);
573
574 /**
575 * Called when an action mode has been finished. The appropriate mode callback
576 * method will have already been invoked.
577 *
578 * @param mode The mode that was just finished.
579 */
580 public void onActionModeFinished(ActionMode mode);
Clara Bayarri75e09792015-07-29 16:20:40 +0100581
582 /**
583 * Called when Keyboard Shortcuts are requested for the current window.
584 *
585 * @param data The data list to populate with shortcuts.
586 * @param menu The current menu, which may be null.
Clara Bayarrifcd7e802016-03-10 12:58:18 +0000587 * @param deviceId The id for the connected device the shortcuts should be provided for.
Clara Bayarri75e09792015-07-29 16:20:40 +0100588 */
Sunny Goyal2a6d9aa2016-03-16 17:12:46 -0700589 default public void onProvideKeyboardShortcuts(
Clara Bayarrifcd7e802016-03-10 12:58:18 +0000590 List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) { };
Vladislav Kaznacheev3787de12016-12-21 10:36:35 -0800591
592 /**
593 * Called when pointer capture is enabled or disabled for the current window.
594 *
595 * @param hasCapture True if the window has pointer capture.
596 */
597 default public void onPointerCaptureChanged(boolean hasCapture) { };
Adam Powell117b6952014-05-05 18:14:56 -0700598 }
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800599
Adam Powell117b6952014-05-05 18:14:56 -0700600 /** @hide */
601 public interface OnWindowDismissedCallback {
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800602 /**
603 * Called when a window is dismissed. This informs the callback that the
604 * window is gone, and it should finish itself.
Wale Ogunwaleba7881c2015-08-01 19:28:29 -0700605 * @param finishTask True if the task should also be finished.
Ned Burns7d6cb912016-12-02 17:25:33 -0500606 * @param suppressWindowTransition True if the resulting exit and enter window transition
607 * animations should be suppressed.
Will Haldean Brownca6234e2014-02-12 10:23:41 -0800608 */
Ned Burns7d6cb912016-12-02 17:25:33 -0500609 void onWindowDismissed(boolean finishTask, boolean suppressWindowTransition);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800610 }
611
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700612 /** @hide */
Michael Kwan67639a52016-12-16 12:38:10 -0800613 public interface OnWindowSwipeDismissedCallback {
614 /**
615 * Called when a window is swipe dismissed. This informs the callback that the
616 * window is gone, and it should finish itself.
617 * @param finishTask True if the task should also be finished.
618 * @param suppressWindowTransition True if the resulting exit and enter window transition
619 * animations should be suppressed.
620 */
621 void onWindowSwipeDismissed();
622 }
623
624 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700625 public interface WindowControllerCallback {
626 /**
Filip Gruszczynski411c06f2016-01-07 09:44:44 -0800627 * Moves the activity from
Wale Ogunwale3382ab12017-07-27 08:55:03 -0700628 * Moves the activity from {@link WindowConfiguration#WINDOWING_MODE_FREEFORM} windowing
629 * mode to {@link WindowConfiguration#WINDOWING_MODE_FULLSCREEN}.
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700630 */
Filip Gruszczynski411c06f2016-01-07 09:44:44 -0800631 void exitFreeformMode() throws RemoteException;
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700632
Jaewan Kimd98dcab2016-05-03 02:52:18 +0900633 /**
634 * Puts the activity in picture-in-picture mode if the activity supports.
635 * @see android.R.attr#supportsPictureInPicture
636 */
637 void enterPictureInPictureModeIfPossible();
638
Winson Chung4d8681f2017-05-23 16:22:08 -0700639 /** Returns whether the window belongs to the task root. */
640 boolean isTaskRoot();
Wale Ogunwale868a5e12015-08-02 16:19:20 -0700641 }
642
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800643 /**
644 * Callback for clients that want to be aware of where caption draws content.
645 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800646 public interface OnRestrictedCaptionAreaChangedListener {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800647 /**
648 * Called when the area where caption draws content changes.
649 *
650 * @param rect The area where caption content is positioned, relative to the top view.
651 */
652 void onRestrictedCaptionAreaChanged(Rect rect);
653 }
654
Andres Morales910beb82016-02-02 16:19:40 -0800655 /**
656 * Callback for clients that want frame timing information for each
657 * frame rendered by the Window.
658 */
Andres Moralesd908c622016-04-20 13:13:34 -0700659 public interface OnFrameMetricsAvailableListener {
Andres Morales910beb82016-02-02 16:19:40 -0800660 /**
661 * Called when information is available for the previously rendered frame.
662 *
663 * Reports can be dropped if this callback takes too
664 * long to execute, as the report producer cannot wait for the consumer to
665 * complete.
666 *
667 * It is highly recommended that clients copy the passed in FrameMetrics
668 * via {@link FrameMetrics#FrameMetrics(FrameMetrics)} within this method and defer
669 * additional computation or storage to another thread to avoid unnecessarily
670 * dropping reports.
671 *
672 * @param window The {@link Window} on which the frame was displayed.
673 * @param frameMetrics the available metrics. This object is reused on every call
674 * and thus <strong>this reference is not valid outside the scope of this method</strong>.
675 * @param dropCountSinceLastInvocation the number of reports dropped since the last time
676 * this callback was invoked.
677 */
Andres Moralesd908c622016-04-20 13:13:34 -0700678 void onFrameMetricsAvailable(Window window, FrameMetrics frameMetrics,
Andres Morales910beb82016-02-02 16:19:40 -0800679 int dropCountSinceLastInvocation);
680 }
681
682
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800683 public Window(Context context) {
684 mContext = context;
Bryce Leed6e6e722014-11-21 11:08:45 -0800685 mFeatures = mLocalFeatures = getDefaultFeatures(context);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800686 }
687
688 /**
689 * Return the Context this window policy is running in, for retrieving
690 * resources and other information.
691 *
692 * @return Context The Context that was supplied to the constructor.
693 */
694 public final Context getContext() {
695 return mContext;
696 }
697
698 /**
699 * Return the {@link android.R.styleable#Window} attributes from this
700 * window's theme.
701 */
702 public final TypedArray getWindowStyle() {
703 synchronized (this) {
704 if (mWindowStyle == null) {
705 mWindowStyle = mContext.obtainStyledAttributes(
706 com.android.internal.R.styleable.Window);
707 }
708 return mWindowStyle;
709 }
710 }
RoboErik55011652014-07-09 15:05:53 -0700711
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800712 /**
713 * Set the container for this window. If not set, the DecorWindow
714 * operates as a top-level window; otherwise, it negotiates with the
715 * container to display itself appropriately.
716 *
717 * @param container The desired containing Window.
718 */
719 public void setContainer(Window container) {
720 mContainer = container;
721 if (container != null) {
722 // Embedded screens never have a title.
723 mFeatures |= 1<<FEATURE_NO_TITLE;
724 mLocalFeatures |= 1<<FEATURE_NO_TITLE;
725 container.mHasChildren = true;
726 }
727 }
728
729 /**
730 * Return the container for this Window.
731 *
732 * @return Window The containing window, or null if this is a
733 * top-level window.
734 */
735 public final Window getContainer() {
736 return mContainer;
737 }
738
739 public final boolean hasChildren() {
740 return mHasChildren;
741 }
RoboErik55011652014-07-09 15:05:53 -0700742
Dianne Hackborn291905e2010-08-17 15:17:15 -0700743 /** @hide */
744 public final void destroy() {
745 mDestroyed = true;
746 }
747
748 /** @hide */
Mathew Inwoode5ad5982018-08-17 15:07:52 +0100749 @UnsupportedAppUsage
Dianne Hackborn291905e2010-08-17 15:17:15 -0700750 public final boolean isDestroyed() {
751 return mDestroyed;
752 }
753
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800754 /**
755 * Set the window manager for use by this Window to, for example,
756 * display panels. This is <em>not</em> used for displaying the
757 * Window itself -- that must be done by the client.
758 *
Jeff Brown98365d72012-08-19 20:30:52 -0700759 * @param wm The window manager for adding new windows.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800760 */
Romain Guy529b60a2010-08-03 18:05:47 -0700761 public void setWindowManager(WindowManager wm, IBinder appToken, String appName) {
762 setWindowManager(wm, appToken, appName, false);
763 }
764
765 /**
766 * Set the window manager for use by this Window to, for example,
767 * display panels. This is <em>not</em> used for displaying the
768 * Window itself -- that must be done by the client.
769 *
Jeff Brown98365d72012-08-19 20:30:52 -0700770 * @param wm The window manager for adding new windows.
Romain Guy529b60a2010-08-03 18:05:47 -0700771 */
772 public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
773 boolean hardwareAccelerated) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800774 mAppToken = appToken;
775 mAppName = appName;
Jeff Brownd32460c2012-07-20 16:15:36 -0700776 mHardwareAccelerated = hardwareAccelerated
777 || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800778 if (wm == null) {
Jeff Brown98365d72012-08-19 20:30:52 -0700779 wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800780 }
Jeff Brown98365d72012-08-19 20:30:52 -0700781 mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
Dianne Hackborn5fd21692011-06-07 14:09:47 -0700782 }
783
Jeff Brownd32460c2012-07-20 16:15:36 -0700784 void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) {
785 CharSequence curTitle = wp.getTitle();
786 if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
tiger_huangff58e302015-10-13 21:38:19 +0800787 wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
Jeff Brownd32460c2012-07-20 16:15:36 -0700788 if (wp.token == null) {
789 View decor = peekDecorView();
790 if (decor != null) {
791 wp.token = decor.getWindowToken();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800792 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800793 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700794 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700795 final StringBuilder title = new StringBuilder(32);
Jeff Brownd32460c2012-07-20 16:15:36 -0700796 if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700797 title.append("Media");
Jeff Brownd32460c2012-07-20 16:15:36 -0700798 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700799 title.append("MediaOvr");
Jeff Brownd32460c2012-07-20 16:15:36 -0700800 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700801 title.append("Panel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700802 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700803 title.append("SubPanel");
Wale Ogunwale0a4dc222015-04-14 12:58:42 -0700804 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700805 title.append("AboveSubPanel");
Jeff Brownd32460c2012-07-20 16:15:36 -0700806 } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700807 title.append("AtchDlg");
Jeff Brownd32460c2012-07-20 16:15:36 -0700808 } else {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700809 title.append(wp.type);
Jeff Brownd32460c2012-07-20 16:15:36 -0700810 }
811 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700812 title.append(":").append(mAppName);
Jeff Brownd32460c2012-07-20 16:15:36 -0700813 }
814 wp.setTitle(title);
Romain Guy529b60a2010-08-03 18:05:47 -0700815 }
tiger_huangff58e302015-10-13 21:38:19 +0800816 } else if (wp.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW &&
817 wp.type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) {
818 // We don't set the app token to this system window because the life cycles should be
819 // independent. If an app creates a system window and then the app goes to the stopped
820 // state, the system window should not be affected (can still show and receive input
821 // events).
822 if (curTitle == null || curTitle.length() == 0) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700823 final StringBuilder title = new StringBuilder(32);
824 title.append("Sys").append(wp.type);
tiger_huangff58e302015-10-13 21:38:19 +0800825 if (mAppName != null) {
Wale Ogunwale9b344422015-10-16 09:07:45 -0700826 title.append(":").append(mAppName);
tiger_huangff58e302015-10-13 21:38:19 +0800827 }
828 wp.setTitle(title);
829 }
Jeff Brownd32460c2012-07-20 16:15:36 -0700830 } else {
831 if (wp.token == null) {
832 wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
833 }
834 if ((curTitle == null || curTitle.length() == 0)
835 && mAppName != null) {
836 wp.setTitle(mAppName);
837 }
838 }
839 if (wp.packageName == null) {
840 wp.packageName = mContext.getPackageName();
841 }
Robert Carr13678ee2016-04-20 14:04:15 -0700842 if (mHardwareAccelerated ||
843 (mWindowAttributes.flags & FLAG_HARDWARE_ACCELERATED) != 0) {
844 wp.flags |= FLAG_HARDWARE_ACCELERATED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800845 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800846 }
847
848 /**
849 * Return the window manager allowing this Window to display its own
850 * windows.
851 *
852 * @return WindowManager The ViewManager.
853 */
854 public WindowManager getWindowManager() {
855 return mWindowManager;
856 }
857
858 /**
859 * Set the Callback interface for this window, used to intercept key
860 * events and other dynamic operations in the window.
861 *
862 * @param callback The desired Callback interface.
863 */
864 public void setCallback(Callback callback) {
865 mCallback = callback;
866 }
867
868 /**
869 * Return the current Callback interface for this window.
870 */
871 public final Callback getCallback() {
872 return mCallback;
873 }
874
Andres Morales06f5bc72015-12-15 15:21:31 -0800875 /**
876 * Set an observer to collect frame stats for each frame rendererd in this window.
877 *
878 * Must be in hardware rendering mode.
Andres Morales06f5bc72015-12-15 15:21:31 -0800879 */
Andres Moralesd908c622016-04-20 13:13:34 -0700880 public final void addOnFrameMetricsAvailableListener(
881 @NonNull OnFrameMetricsAvailableListener listener,
Andres Morales910beb82016-02-02 16:19:40 -0800882 Handler handler) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800883 final View decorView = getDecorView();
884 if (decorView == null) {
885 throw new IllegalStateException("can't observe a Window without an attached view");
886 }
887
Andres Morales910beb82016-02-02 16:19:40 -0800888 if (listener == null) {
889 throw new NullPointerException("listener cannot be null");
Andres Morales06f5bc72015-12-15 15:21:31 -0800890 }
891
Andres Morales910beb82016-02-02 16:19:40 -0800892 decorView.addFrameMetricsListener(this, listener, handler);
Andres Morales06f5bc72015-12-15 15:21:31 -0800893 }
894
895 /**
896 * Remove observer and stop listening to frame stats for this window.
Andres Morales06f5bc72015-12-15 15:21:31 -0800897 */
Andres Moralesd908c622016-04-20 13:13:34 -0700898 public final void removeOnFrameMetricsAvailableListener(OnFrameMetricsAvailableListener listener) {
Andres Morales06f5bc72015-12-15 15:21:31 -0800899 final View decorView = getDecorView();
900 if (decorView != null) {
Andres Morales910beb82016-02-02 16:19:40 -0800901 getDecorView().removeFrameMetricsListener(listener);
Andres Morales06f5bc72015-12-15 15:21:31 -0800902 }
903 }
904
Adam Powell117b6952014-05-05 18:14:56 -0700905 /** @hide */
906 public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) {
907 mOnWindowDismissedCallback = dcb;
908 }
909
910 /** @hide */
Ned Burns7d6cb912016-12-02 17:25:33 -0500911 public final void dispatchOnWindowDismissed(
912 boolean finishTask, boolean suppressWindowTransition) {
Adam Powell117b6952014-05-05 18:14:56 -0700913 if (mOnWindowDismissedCallback != null) {
Ned Burns7d6cb912016-12-02 17:25:33 -0500914 mOnWindowDismissedCallback.onWindowDismissed(finishTask, suppressWindowTransition);
Adam Powell117b6952014-05-05 18:14:56 -0700915 }
916 }
917
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700918 /** @hide */
Michael Kwan67639a52016-12-16 12:38:10 -0800919 public final void setOnWindowSwipeDismissedCallback(OnWindowSwipeDismissedCallback sdcb) {
920 mOnWindowSwipeDismissedCallback = sdcb;
921 }
922
923 /** @hide */
924 public final void dispatchOnWindowSwipeDismissed() {
925 if (mOnWindowSwipeDismissedCallback != null) {
926 mOnWindowSwipeDismissedCallback.onWindowSwipeDismissed();
927 }
928 }
929
930 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700931 public final void setWindowControllerCallback(WindowControllerCallback wccb) {
932 mWindowControllerCallback = wccb;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700933 }
934
935 /** @hide */
Skuhnece2faa52015-08-11 10:36:38 -0700936 public final WindowControllerCallback getWindowControllerCallback() {
937 return mWindowControllerCallback;
Stefan Kuhne9bad7412015-08-07 10:35:52 -0700938 }
939
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800940 /**
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800941 * Set a callback for changes of area where caption will draw its content.
942 *
943 * @param listener Callback that will be called when the area changes.
944 */
Wale Ogunwalea504ca32016-01-30 16:02:13 -0800945 public final void setRestrictedCaptionAreaListener(OnRestrictedCaptionAreaChangedListener listener) {
946 mOnRestrictedCaptionAreaChangedListener = listener;
Filip Gruszczynski3dec0812015-12-09 08:42:41 -0800947 mRestrictedCaptionAreaRect = listener != null ? new Rect() : null;
948 }
949
950 /**
Dianne Hackborndc8a7f62010-05-10 11:29:34 -0700951 * Take ownership of this window's surface. The window's view hierarchy
952 * will no longer draw into the surface, though it will otherwise continue
953 * to operate (such as for receiving input events). The given SurfaceHolder
954 * callback will be used to tell you about state changes to the surface.
955 */
Dianne Hackbornd76b67c2010-07-13 17:48:30 -0700956 public abstract void takeSurface(SurfaceHolder.Callback2 callback);
RoboErik55011652014-07-09 15:05:53 -0700957
Dianne Hackborndc8a7f62010-05-10 11:29:34 -0700958 /**
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -0700959 * Take ownership of this window's InputQueue. The window will no
960 * longer read and dispatch input events from the queue; it is your
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700961 * responsibility to do so.
962 */
Dianne Hackborn1e4b9f32010-06-23 14:10:57 -0700963 public abstract void takeInputQueue(InputQueue.Callback callback);
RoboErik55011652014-07-09 15:05:53 -0700964
Dianne Hackborna95e4cb2010-06-18 18:09:33 -0700965 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800966 * Return whether this window is being displayed with a floating style
967 * (based on the {@link android.R.attr#windowIsFloating} attribute in
968 * the style/theme).
969 *
970 * @return Returns true if the window is configured to be displayed floating
971 * on top of whatever is behind it.
972 */
973 public abstract boolean isFloating();
974
975 /**
976 * Set the width and height layout parameters of the window. The default
Dianne Hackbornc9189352010-12-15 14:57:25 -0800977 * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT
978 * or an absolute value to make a window that is not full-screen.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800979 *
980 * @param width The desired layout width of the window.
981 * @param height The desired layout height of the window.
Dianne Hackbornc9189352010-12-15 14:57:25 -0800982 *
983 * @see ViewGroup.LayoutParams#height
984 * @see ViewGroup.LayoutParams#width
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800985 */
Dianne Hackbornc9189352010-12-15 14:57:25 -0800986 public void setLayout(int width, int height) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800987 final WindowManager.LayoutParams attrs = getAttributes();
988 attrs.width = width;
989 attrs.height = height;
Adrian Roosea562512014-05-05 13:33:03 +0200990 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800991 }
992
993 /**
994 * Set the gravity of the window, as per the Gravity constants. This
995 * controls how the window manager is positioned in the overall window; it
996 * is only useful when using WRAP_CONTENT for the layout width or height.
997 *
998 * @param gravity The desired gravity constant.
999 *
1000 * @see Gravity
1001 * @see #setLayout
1002 */
1003 public void setGravity(int gravity)
1004 {
1005 final WindowManager.LayoutParams attrs = getAttributes();
1006 attrs.gravity = gravity;
Adrian Roosea562512014-05-05 13:33:03 +02001007 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001008 }
1009
1010 /**
1011 * Set the type of the window, as per the WindowManager.LayoutParams
1012 * types.
1013 *
1014 * @param type The new window type (see WindowManager.LayoutParams).
1015 */
1016 public void setType(int type) {
1017 final WindowManager.LayoutParams attrs = getAttributes();
1018 attrs.type = type;
Adrian Roosea562512014-05-05 13:33:03 +02001019 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001020 }
1021
1022 /**
1023 * Set the format of window, as per the PixelFormat types. This overrides
1024 * the default format that is selected by the Window based on its
1025 * window decorations.
1026 *
1027 * @param format The new window format (see PixelFormat). Use
1028 * PixelFormat.UNKNOWN to allow the Window to select
1029 * the format.
1030 *
1031 * @see PixelFormat
1032 */
1033 public void setFormat(int format) {
1034 final WindowManager.LayoutParams attrs = getAttributes();
1035 if (format != PixelFormat.UNKNOWN) {
1036 attrs.format = format;
1037 mHaveWindowFormat = true;
1038 } else {
1039 attrs.format = mDefaultWindowFormat;
1040 mHaveWindowFormat = false;
1041 }
Adrian Roosea562512014-05-05 13:33:03 +02001042 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001043 }
1044
1045 /**
1046 * Specify custom animations to use for the window, as per
1047 * {@link WindowManager.LayoutParams#windowAnimations
1048 * WindowManager.LayoutParams.windowAnimations}. Providing anything besides
1049 * 0 here will override the animations the window would
1050 * normally retrieve from its theme.
1051 */
Tor Norbye417ee5b2015-03-10 20:57:37 -07001052 public void setWindowAnimations(@StyleRes int resId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001053 final WindowManager.LayoutParams attrs = getAttributes();
1054 attrs.windowAnimations = resId;
Adrian Roosea562512014-05-05 13:33:03 +02001055 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001056 }
1057
1058 /**
1059 * Specify an explicit soft input mode to use for the window, as per
1060 * {@link WindowManager.LayoutParams#softInputMode
1061 * WindowManager.LayoutParams.softInputMode}. Providing anything besides
1062 * "unspecified" here will override the input mode the window would
1063 * normally retrieve from its theme.
1064 */
1065 public void setSoftInputMode(int mode) {
1066 final WindowManager.LayoutParams attrs = getAttributes();
1067 if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
1068 attrs.softInputMode = mode;
1069 mHasSoftInputMode = true;
1070 } else {
1071 mHasSoftInputMode = false;
1072 }
Adrian Roosea562512014-05-05 13:33:03 +02001073 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001074 }
RoboErik55011652014-07-09 15:05:53 -07001075
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001076 /**
1077 * Convenience function to set the flag bits as specified in flags, as
1078 * per {@link #setFlags}.
1079 * @param flags The flag bits to be set.
1080 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001081 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001082 */
1083 public void addFlags(int flags) {
1084 setFlags(flags, flags);
1085 }
Adam Lesinski95c42972013-10-02 10:13:27 -07001086
1087 /** @hide */
Mathew Inwoode5ad5982018-08-17 15:07:52 +01001088 @UnsupportedAppUsage
Adam Lesinski95c42972013-10-02 10:13:27 -07001089 public void addPrivateFlags(int flags) {
1090 setPrivateFlags(flags, flags);
1091 }
RoboErik55011652014-07-09 15:05:53 -07001092
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001093 /**
1094 * Convenience function to clear the flag bits as specified in flags, as
1095 * per {@link #setFlags}.
1096 * @param flags The flag bits to be cleared.
1097 * @see #setFlags
Christopher Tate193fc072012-06-04 11:27:40 -07001098 * @see #addFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001099 */
1100 public void clearFlags(int flags) {
1101 setFlags(0, flags);
1102 }
1103
1104 /**
1105 * Set the flags of the window, as per the
1106 * {@link WindowManager.LayoutParams WindowManager.LayoutParams}
1107 * flags.
RoboErik55011652014-07-09 15:05:53 -07001108 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001109 * <p>Note that some flags must be set before the window decoration is
1110 * created (by the first call to
1111 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or
1112 * {@link #getDecorView()}:
1113 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and
1114 * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These
1115 * will be set for you based on the {@link android.R.attr#windowIsFloating}
1116 * attribute.
1117 *
1118 * @param flags The new window flags (see WindowManager.LayoutParams).
1119 * @param mask Which of the window flag bits to modify.
Christopher Tate193fc072012-06-04 11:27:40 -07001120 * @see #addFlags
1121 * @see #clearFlags
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001122 */
1123 public void setFlags(int flags, int mask) {
1124 final WindowManager.LayoutParams attrs = getAttributes();
1125 attrs.flags = (attrs.flags&~mask) | (flags&mask);
1126 mForcedWindowFlags |= mask;
Adrian Roosea562512014-05-05 13:33:03 +02001127 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001128 }
1129
Adam Lesinski95c42972013-10-02 10:13:27 -07001130 private void setPrivateFlags(int flags, int mask) {
1131 final WindowManager.LayoutParams attrs = getAttributes();
1132 attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
Adrian Roosea562512014-05-05 13:33:03 +02001133 dispatchWindowAttributesChanged(attrs);
1134 }
1135
1136 /**
1137 * {@hide}
1138 */
Mathew Inwoode5ad5982018-08-17 15:07:52 +01001139 @UnsupportedAppUsage
Wale Ogunwale393b1c12014-10-18 16:22:01 -07001140 protected void setNeedsMenuKey(int value) {
1141 final WindowManager.LayoutParams attrs = getAttributes();
1142 attrs.needsMenuKey = value;
1143 dispatchWindowAttributesChanged(attrs);
1144 }
1145
1146 /**
1147 * {@hide}
1148 */
Adrian Roosea562512014-05-05 13:33:03 +02001149 protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) {
Adam Lesinski95c42972013-10-02 10:13:27 -07001150 if (mCallback != null) {
1151 mCallback.onWindowAttributesChanged(attrs);
1152 }
1153 }
1154
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001155 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001156 * <p>Sets the requested color mode of the window. The requested the color mode might
Romain Guy48327452017-01-23 17:03:35 -08001157 * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p>
1158 *
Romain Guyadae59b2017-06-20 14:45:53 -07001159 * <p>The requested color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
Romain Guy48327452017-01-23 17:03:35 -08001160 * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}.</p>
Romain Guyadae59b2017-06-20 14:45:53 -07001161 *
1162 * <p>The requested color mode is not guaranteed to be honored. Please refer to
1163 * {@link #getColorMode()} for more information.</p>
1164 *
1165 * @see #getColorMode()
1166 * @see Display#isWideColorGamut()
1167 * @see Configuration#isScreenWideColorGamut()
Romain Guy48327452017-01-23 17:03:35 -08001168 */
1169 public void setColorMode(@ActivityInfo.ColorMode int colorMode) {
1170 final WindowManager.LayoutParams attrs = getAttributes();
1171 attrs.setColorMode(colorMode);
1172 dispatchWindowAttributesChanged(attrs);
1173 }
1174
1175 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001176 * Returns the requested color mode of the window, one of
1177 * {@link ActivityInfo#COLOR_MODE_DEFAULT}, {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
1178 * or {@link ActivityInfo#COLOR_MODE_HDR}. If {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
1179 * was requested it is possible the window will not be put in wide color gamut mode depending
1180 * on device and display support for that mode. Use {@link #isWideColorGamut} to determine
1181 * if the window is currently in wide color gamut mode.
1182 *
1183 * @see #setColorMode(int)
1184 * @see Display#isWideColorGamut()
1185 * @see Configuration#isScreenWideColorGamut()
Romain Guy48327452017-01-23 17:03:35 -08001186 */
1187 @ActivityInfo.ColorMode
1188 public int getColorMode() {
1189 return getAttributes().getColorMode();
1190 }
1191
1192 /**
Romain Guyadae59b2017-06-20 14:45:53 -07001193 * Returns true if this window's color mode is {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT},
1194 * the display has a wide color gamut and this device supports wide color gamut rendering.
1195 *
1196 * @see Display#isWideColorGamut()
1197 * @see Configuration#isScreenWideColorGamut()
1198 */
1199 public boolean isWideColorGamut() {
1200 return getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT
1201 && getContext().getResources().getConfiguration().isScreenWideColorGamut();
1202 }
1203
1204 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001205 * Set the amount of dim behind the window when using
1206 * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides
1207 * the default dim amount of that is selected by the Window based on
1208 * its theme.
1209 *
1210 * @param amount The new dim amount, from 0 for no dim to 1 for full dim.
1211 */
1212 public void setDimAmount(float amount) {
1213 final WindowManager.LayoutParams attrs = getAttributes();
1214 attrs.dimAmount = amount;
1215 mHaveDimAmount = true;
Adrian Roosea562512014-05-05 13:33:03 +02001216 dispatchWindowAttributesChanged(attrs);
Dianne Hackborn661cd522011-08-22 00:26:20 -07001217 }
1218
1219 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001220 * Specify custom window attributes. <strong>PLEASE NOTE:</strong> the
1221 * layout params you give here should generally be from values previously
1222 * retrieved with {@link #getAttributes()}; you probably do not want to
1223 * blindly create and apply your own, since this will blow away any values
1224 * set by the framework that you are not interested in.
1225 *
1226 * @param a The new window attributes, which will completely override any
1227 * current values.
1228 */
1229 public void setAttributes(WindowManager.LayoutParams a) {
1230 mWindowAttributes.copyFrom(a);
Adrian Roosea562512014-05-05 13:33:03 +02001231 dispatchWindowAttributesChanged(mWindowAttributes);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001232 }
1233
1234 /**
1235 * Retrieve the current window attributes associated with this panel.
1236 *
1237 * @return WindowManager.LayoutParams Either the existing window
1238 * attributes object, or a freshly created one if there is none.
1239 */
1240 public final WindowManager.LayoutParams getAttributes() {
1241 return mWindowAttributes;
1242 }
1243
1244 /**
1245 * Return the window flags that have been explicitly set by the client,
1246 * so will not be modified by {@link #getDecorView}.
1247 */
1248 protected final int getForcedWindowFlags() {
1249 return mForcedWindowFlags;
1250 }
RoboErik55011652014-07-09 15:05:53 -07001251
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001252 /**
1253 * Has the app specified their own soft input mode?
1254 */
1255 protected final boolean hasSoftInputMode() {
1256 return mHasSoftInputMode;
1257 }
RoboErik55011652014-07-09 15:05:53 -07001258
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001259 /** @hide */
Mathew Inwoode5ad5982018-08-17 15:07:52 +01001260 @UnsupportedAppUsage
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001261 public void setCloseOnTouchOutside(boolean close) {
1262 mCloseOnTouchOutside = close;
1263 mSetCloseOnTouchOutside = true;
1264 }
RoboErik55011652014-07-09 15:05:53 -07001265
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001266 /** @hide */
Mathew Inwoode5ad5982018-08-17 15:07:52 +01001267 @UnsupportedAppUsage
Dianne Hackbornef575752011-01-18 17:35:17 -08001268 public void setCloseOnTouchOutsideIfNotSet(boolean close) {
1269 if (!mSetCloseOnTouchOutside) {
1270 mCloseOnTouchOutside = close;
1271 mSetCloseOnTouchOutside = true;
1272 }
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001273 }
RoboErik55011652014-07-09 15:05:53 -07001274
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001275 /** @hide */
Mathew Inwoode5ad5982018-08-17 15:07:52 +01001276 @UnsupportedAppUsage
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001277 public abstract void alwaysReadCloseOnTouchAttr();
RoboErik55011652014-07-09 15:05:53 -07001278
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001279 /** @hide */
Mathew Inwood55418ea2018-12-20 15:30:45 +00001280 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001281 public boolean shouldCloseOnTouch(Context context, MotionEvent event) {
Michael Wrightddec8fb2017-06-16 18:36:26 +01001282 final boolean isOutside =
1283 event.getAction() == MotionEvent.ACTION_DOWN && isOutOfBounds(context, event)
1284 || event.getAction() == MotionEvent.ACTION_OUTSIDE;
1285 if (mCloseOnTouchOutside && peekDecorView() != null && isOutside) {
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001286 return true;
1287 }
1288 return false;
1289 }
RoboErik55011652014-07-09 15:05:53 -07001290
Ruchi Kandoi43e38de2016-04-14 19:34:53 -07001291 /* Sets the Sustained Performance requirement for the calling window.
1292 * @param enable disables or enables the mode.
1293 */
1294 public void setSustainedPerformanceMode(boolean enable) {
1295 setPrivateFlags(enable
1296 ? WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE : 0,
1297 WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE);
1298 }
1299
Dianne Hackborncfaf8872011-01-18 13:57:54 -08001300 private boolean isOutOfBounds(Context context, MotionEvent event) {
1301 final int x = (int) event.getX();
1302 final int y = (int) event.getY();
1303 final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
1304 final View decorView = getDecorView();
1305 return (x < -slop) || (y < -slop)
1306 || (x > (decorView.getWidth()+slop))
1307 || (y > (decorView.getHeight()+slop));
1308 }
RoboErik55011652014-07-09 15:05:53 -07001309
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001310 /**
1311 * Enable extended screen features. This must be called before
1312 * setContentView(). May be called as many times as desired as long as it
1313 * is before setContentView(). If not called, no extended features
1314 * will be available. You can not turn off a feature once it is requested.
1315 * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
1316 *
1317 * @param featureId The desired features, defined as constants by Window.
1318 * @return The features that are now set.
1319 */
1320 public boolean requestFeature(int featureId) {
1321 final int flag = 1<<featureId;
1322 mFeatures |= flag;
1323 mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag;
1324 return (mFeatures&flag) != 0;
1325 }
1326
Adam Powellf4a6ec42010-08-24 14:18:10 -07001327 /**
1328 * @hide Used internally to help resolve conflicting features.
1329 */
1330 protected void removeFeature(int featureId) {
1331 final int flag = 1<<featureId;
1332 mFeatures &= ~flag;
1333 mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag);
1334 }
1335
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001336 public final void makeActive() {
1337 if (mContainer != null) {
1338 if (mContainer.mActiveChild != null) {
1339 mContainer.mActiveChild.mIsActive = false;
1340 }
1341 mContainer.mActiveChild = this;
1342 }
1343 mIsActive = true;
1344 onActive();
1345 }
1346
1347 public final boolean isActive()
1348 {
1349 return mIsActive;
1350 }
1351
1352 /**
Alan Viverettedb7423c2017-03-31 13:13:58 -04001353 * Finds a view that was identified by the {@code android:id} XML attribute
Chris Craik6faa9e52018-01-11 10:46:10 -08001354 * that was processed in {@link android.app.Activity#onCreate}.
1355 * <p>
1356 * This will implicitly call {@link #getDecorView} with all of the associated side-effects.
Alan Viverettedb7423c2017-03-31 13:13:58 -04001357 * <p>
1358 * <strong>Note:</strong> In most cases -- depending on compiler support --
1359 * the resulting view is automatically cast to the target class type. If
1360 * the target class type is unconstrained, an explicit cast may be
1361 * necessary.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001362 *
Alan Viverettedb7423c2017-03-31 13:13:58 -04001363 * @param id the ID to search for
1364 * @return a view with given ID if found, or {@code null} otherwise
1365 * @see View#findViewById(int)
Chris Craik6faa9e52018-01-11 10:46:10 -08001366 * @see Window#requireViewById(int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001367 */
Scott Kennedyc0519552015-02-11 15:33:10 -08001368 @Nullable
Alan Viverettedb7423c2017-03-31 13:13:58 -04001369 public <T extends View> T findViewById(@IdRes int id) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001370 return getDecorView().findViewById(id);
1371 }
Chris Craik6faa9e52018-01-11 10:46:10 -08001372 /**
1373 * Finds a view that was identified by the {@code android:id} XML attribute
1374 * that was processed in {@link android.app.Activity#onCreate}, or throws an
1375 * IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy.
1376 * <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.
1381 *
1382 * @param id the ID to search for
1383 * @return a view with given ID
1384 * @see View#requireViewById(int)
1385 * @see Window#findViewById(int)
1386 */
1387 @NonNull
1388 public final <T extends View> T requireViewById(@IdRes int id) {
1389 T view = findViewById(id);
1390 if (view == null) {
1391 throw new IllegalArgumentException("ID does not reference a View inside this Window");
1392 }
1393 return view;
1394 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001395
1396 /**
1397 * Convenience for
1398 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1399 * to set the screen content from a layout resource. The resource will be
1400 * inflated, adding all top-level views to the screen.
1401 *
1402 * @param layoutResID Resource ID to be inflated.
1403 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1404 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001405 public abstract void setContentView(@LayoutRes int layoutResID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001406
1407 /**
1408 * Convenience for
1409 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1410 * set the screen content to an explicit view. This view is placed
1411 * directly into the screen's view hierarchy. It can itself be a complex
1412 * view hierarhcy.
1413 *
1414 * @param view The desired content to display.
1415 * @see #setContentView(View, android.view.ViewGroup.LayoutParams)
1416 */
1417 public abstract void setContentView(View view);
1418
1419 /**
1420 * Set the screen content to an explicit view. This view is placed
1421 * directly into the screen's view hierarchy. It can itself be a complex
1422 * view hierarchy.
1423 *
1424 * <p>Note that calling this function "locks in" various characteristics
1425 * of the window that can not, from this point forward, be changed: the
1426 * features that have been requested with {@link #requestFeature(int)},
George Mountc3a043c2015-02-04 14:37:04 -08001427 * and certain window flags as described in {@link #setFlags(int, int)}.</p>
1428 *
1429 * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's
1430 * TransitionManager will be used to animate content from the current
1431 * content View to view.</p>
RoboErik55011652014-07-09 15:05:53 -07001432 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001433 * @param view The desired content to display.
1434 * @param params Layout parameters for the view.
George Mountc3a043c2015-02-04 14:37:04 -08001435 * @see #getTransitionManager()
1436 * @see #setTransitionManager(android.transition.TransitionManager)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001437 */
1438 public abstract void setContentView(View view, ViewGroup.LayoutParams params);
1439
1440 /**
1441 * Variation on
1442 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
1443 * to add an additional content view to the screen. Added after any existing
1444 * ones in the screen -- existing views are NOT removed.
1445 *
1446 * @param view The desired content to display.
1447 * @param params Layout parameters for the view.
1448 */
1449 public abstract void addContentView(View view, ViewGroup.LayoutParams params);
1450
1451 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001452 * Remove the view that was used as the screen content.
1453 *
1454 * @hide
1455 */
1456 public abstract void clearContentView();
1457
1458 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001459 * Return the view in this Window that currently has focus, or null if
1460 * there are none. Note that this does not look in any containing
1461 * Window.
1462 *
1463 * @return View The current View with focus or null.
1464 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001465 @Nullable
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001466 public abstract View getCurrentFocus();
1467
1468 /**
1469 * Quick access to the {@link LayoutInflater} instance that this Window
1470 * retrieved from its Context.
1471 *
1472 * @return LayoutInflater The shared LayoutInflater.
1473 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001474 @NonNull
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001475 public abstract LayoutInflater getLayoutInflater();
1476
1477 public abstract void setTitle(CharSequence title);
1478
Alan Viverette2525d9c2013-11-15 14:42:19 -08001479 @Deprecated
Tor Norbye80756e32015-03-02 09:39:27 -08001480 public abstract void setTitleColor(@ColorInt int textColor);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001481
1482 public abstract void openPanel(int featureId, KeyEvent event);
1483
1484 public abstract void closePanel(int featureId);
1485
1486 public abstract void togglePanel(int featureId, KeyEvent event);
1487
Dianne Hackbornb31e84bc2010-06-08 18:04:35 -07001488 public abstract void invalidatePanelMenu(int featureId);
RoboErik55011652014-07-09 15:05:53 -07001489
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001490 public abstract boolean performPanelShortcut(int featureId,
1491 int keyCode,
1492 KeyEvent event,
1493 int flags);
1494 public abstract boolean performPanelIdentifierAction(int featureId,
1495 int id,
1496 int flags);
1497
1498 public abstract void closeAllPanels();
1499
1500 public abstract boolean performContextMenuIdentifierAction(int id, int flags);
1501
1502 /**
1503 * Should be called when the configuration is changed.
RoboErik55011652014-07-09 15:05:53 -07001504 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001505 * @param newConfig The new configuration.
1506 */
1507 public abstract void onConfigurationChanged(Configuration newConfig);
RoboErik55011652014-07-09 15:05:53 -07001508
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001509 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001510 * Sets the window elevation.
Alan Viverette71922de2015-01-12 16:14:02 -08001511 * <p>
1512 * Changes to this property take effect immediately and will cause the
1513 * window surface to be recreated. This is an expensive operation and as a
1514 * result, this property should not be animated.
Alan Viverette79c067c52014-10-29 14:27:47 -07001515 *
1516 * @param elevation The window elevation.
1517 * @see View#setElevation(float)
1518 * @see android.R.styleable#Window_windowElevation
1519 */
1520 public void setElevation(float elevation) {}
1521
1522 /**
Filip Gruszczynskia59ac9c2015-09-10 18:28:48 -07001523 * Gets the window elevation.
1524 *
1525 * @hide
1526 */
1527 public float getElevation() {
1528 return 0.0f;
1529 }
1530
1531 /**
Alan Viverette79c067c52014-10-29 14:27:47 -07001532 * Sets whether window content should be clipped to the outline of the
1533 * window background.
1534 *
1535 * @param clipToOutline Whether window content should be clipped to the
1536 * outline of the window background.
1537 * @see View#setClipToOutline(boolean)
1538 * @see android.R.styleable#Window_windowClipToOutline
1539 */
1540 public void setClipToOutline(boolean clipToOutline) {}
1541
1542 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001543 * Change the background of this window to a Drawable resource. Setting the
1544 * background to null will make the window be opaque. To make the window
1545 * transparent, you can use an empty drawable (for instance a ColorDrawable
1546 * with the color 0 or the system drawable android:drawable/empty.)
RoboErik55011652014-07-09 15:05:53 -07001547 *
Alan Viverette79c067c52014-10-29 14:27:47 -07001548 * @param resId The resource identifier of a drawable resource which will
1549 * be installed as the new background.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001550 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001551 public void setBackgroundDrawableResource(@DrawableRes int resId) {
Alan Viverette79c067c52014-10-29 14:27:47 -07001552 setBackgroundDrawable(mContext.getDrawable(resId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001553 }
1554
1555 /**
1556 * Change the background of this window to a custom Drawable. Setting the
1557 * background to null will make the window be opaque. To make the window
1558 * transparent, you can use an empty drawable (for instance a ColorDrawable
1559 * with the color 0 or the system drawable android:drawable/empty.)
1560 *
1561 * @param drawable The new Drawable to use for this window's background.
1562 */
1563 public abstract void setBackgroundDrawable(Drawable drawable);
1564
1565 /**
1566 * Set the value for a drawable feature of this window, from a resource
Tor Norbye7b9c9122013-05-30 16:48:33 -07001567 * identifier. You must have called requestFeature(featureId) before
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001568 * calling this function.
1569 *
1570 * @see android.content.res.Resources#getDrawable(int)
1571 *
1572 * @param featureId The desired drawable feature to change, defined as a
1573 * constant by Window.
1574 * @param resId Resource identifier of the desired image.
1575 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001576 public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001577
1578 /**
1579 * Set the value for a drawable feature of this window, from a URI. You
1580 * must have called requestFeature(featureId) before calling this
1581 * function.
1582 *
1583 * <p>The only URI currently supported is "content:", specifying an image
1584 * in a content provider.
1585 *
1586 * @see android.widget.ImageView#setImageURI
1587 *
1588 * @param featureId The desired drawable feature to change. Features are
1589 * constants defined by Window.
1590 * @param uri The desired URI.
1591 */
1592 public abstract void setFeatureDrawableUri(int featureId, Uri uri);
1593
1594 /**
1595 * Set an explicit Drawable value for feature of this window. You must
1596 * have called requestFeature(featureId) before calling this function.
1597 *
Alan Viverette9678e342014-10-24 15:23:58 -07001598 * @param featureId The desired drawable feature to change. Features are
1599 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001600 * @param drawable A Drawable object to display.
1601 */
1602 public abstract void setFeatureDrawable(int featureId, Drawable drawable);
1603
1604 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001605 * Set a custom alpha value for the given drawable feature, controlling how
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001606 * much the background is visible through it.
1607 *
Alan Viverette9678e342014-10-24 15:23:58 -07001608 * @param featureId The desired drawable feature to change. Features are
1609 * constants defined by Window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001610 * @param alpha The alpha amount, 0 is completely transparent and 255 is
1611 * completely opaque.
1612 */
1613 public abstract void setFeatureDrawableAlpha(int featureId, int alpha);
1614
1615 /**
Alan Viverette9678e342014-10-24 15:23:58 -07001616 * Set the integer value for a feature. The range of the value depends on
1617 * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from
1618 * 0 to 10000. At 10000 the progress is complete and the indicator hidden.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001619 *
Alan Viverette9678e342014-10-24 15:23:58 -07001620 * @param featureId The desired feature to change. Features are constants
1621 * defined by Window.
1622 * @param value The value for the feature. The interpretation of this
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001623 * value is feature-specific.
1624 */
1625 public abstract void setFeatureInt(int featureId, int value);
1626
1627 /**
1628 * Request that key events come to this activity. Use this if your
1629 * activity has no views with focus, but the activity still wants
1630 * a chance to process key events.
1631 */
1632 public abstract void takeKeyEvents(boolean get);
1633
1634 /**
1635 * Used by custom windows, such as Dialog, to pass the key press event
1636 * further down the view hierarchy. Application developers should
1637 * not need to implement or call this.
1638 *
1639 */
1640 public abstract boolean superDispatchKeyEvent(KeyEvent event);
1641
1642 /**
Jeff Brown64da12a2011-01-04 19:57:47 -08001643 * Used by custom windows, such as Dialog, to pass the key shortcut press event
1644 * further down the view hierarchy. Application developers should
1645 * not need to implement or call this.
1646 *
1647 */
1648 public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event);
1649
1650 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001651 * Used by custom windows, such as Dialog, to pass the touch screen event
1652 * further down the view hierarchy. Application developers should
1653 * not need to implement or call this.
1654 *
1655 */
1656 public abstract boolean superDispatchTouchEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001657
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001658 /**
1659 * Used by custom windows, such as Dialog, to pass the trackball event
1660 * further down the view hierarchy. Application developers should
1661 * not need to implement or call this.
1662 *
1663 */
1664 public abstract boolean superDispatchTrackballEvent(MotionEvent event);
RoboErik55011652014-07-09 15:05:53 -07001665
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001666 /**
Jeff Browncb1404e2011-01-15 18:14:15 -08001667 * Used by custom windows, such as Dialog, to pass the generic motion event
1668 * further down the view hierarchy. Application developers should
1669 * not need to implement or call this.
1670 *
1671 */
1672 public abstract boolean superDispatchGenericMotionEvent(MotionEvent event);
1673
1674 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001675 * Retrieve the top-level window decor view (containing the standard
1676 * window frame/decorations and the client's content inside of that), which
1677 * can be added as a window to the window manager.
RoboErik55011652014-07-09 15:05:53 -07001678 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001679 * <p><em>Note that calling this function for the first time "locks in"
1680 * various window characteristics as described in
1681 * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p>
RoboErik55011652014-07-09 15:05:53 -07001682 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001683 * @return Returns the top-level window decor view.
1684 */
1685 public abstract View getDecorView();
1686
1687 /**
1688 * Retrieve the current decor view, but only if it has already been created;
1689 * otherwise returns null.
RoboErik55011652014-07-09 15:05:53 -07001690 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001691 * @return Returns the top-level window decor or null.
1692 * @see #getDecorView
1693 */
1694 public abstract View peekDecorView();
1695
1696 public abstract Bundle saveHierarchyState();
RoboErik55011652014-07-09 15:05:53 -07001697
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001698 public abstract void restoreHierarchyState(Bundle savedInstanceState);
RoboErik55011652014-07-09 15:05:53 -07001699
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001700 protected abstract void onActive();
1701
1702 /**
1703 * Return the feature bits that are enabled. This is the set of features
1704 * that were given to requestFeature(), and are being handled by this
1705 * Window itself or its container. That is, it is the set of
1706 * requested features that you can actually use.
1707 *
1708 * <p>To do: add a public version of this API that allows you to check for
1709 * features by their feature ID.
1710 *
1711 * @return int The feature bits.
1712 */
1713 protected final int getFeatures()
1714 {
1715 return mFeatures;
1716 }
RoboErik55011652014-07-09 15:05:53 -07001717
Adam Powell33b97432010-04-20 10:01:14 -07001718 /**
Bryce Leed6e6e722014-11-21 11:08:45 -08001719 * Return the feature bits set by default on a window.
1720 * @param context The context used to access resources
1721 */
1722 public static int getDefaultFeatures(Context context) {
1723 int features = 0;
1724
1725 final Resources res = context.getResources();
1726 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
1727 features |= 1 << FEATURE_OPTIONS_PANEL;
1728 }
1729
1730 if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
1731 features |= 1 << FEATURE_CONTEXT_MENU;
1732 }
1733
1734 return features;
1735 }
1736
1737 /**
Adam Powell33b97432010-04-20 10:01:14 -07001738 * Query for the availability of a certain feature.
RoboErik55011652014-07-09 15:05:53 -07001739 *
Adam Powell33b97432010-04-20 10:01:14 -07001740 * @param feature The feature ID to check
1741 * @return true if the feature is enabled, false otherwise.
1742 */
1743 public boolean hasFeature(int feature) {
1744 return (getFeatures() & (1 << feature)) != 0;
1745 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001746
1747 /**
1748 * Return the feature bits that are being implemented by this Window.
1749 * This is the set of features that were given to requestFeature(), and are
1750 * being handled by only this Window itself, not by its containers.
1751 *
1752 * @return int The feature bits.
1753 */
1754 protected final int getLocalFeatures()
1755 {
1756 return mLocalFeatures;
1757 }
1758
1759 /**
1760 * Set the default format of window, as per the PixelFormat types. This
1761 * is the format that will be used unless the client specifies in explicit
1762 * format with setFormat();
1763 *
1764 * @param format The new window format (see PixelFormat).
1765 *
1766 * @see #setFormat
1767 * @see PixelFormat
1768 */
1769 protected void setDefaultWindowFormat(int format) {
1770 mDefaultWindowFormat = format;
1771 if (!mHaveWindowFormat) {
1772 final WindowManager.LayoutParams attrs = getAttributes();
1773 attrs.format = format;
Adrian Roosea562512014-05-05 13:33:03 +02001774 dispatchWindowAttributesChanged(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001775 }
1776 }
1777
Dianne Hackborn661cd522011-08-22 00:26:20 -07001778 /** @hide */
1779 protected boolean haveDimAmount() {
1780 return mHaveDimAmount;
1781 }
1782
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001783 public abstract void setChildDrawable(int featureId, Drawable drawable);
1784
1785 public abstract void setChildInt(int featureId, int value);
1786
1787 /**
1788 * Is a keypress one of the defined shortcut keys for this window.
1789 * @param keyCode the key code from {@link android.view.KeyEvent} to check.
1790 * @param event the {@link android.view.KeyEvent} to use to help check.
1791 */
1792 public abstract boolean isShortcutKey(int keyCode, KeyEvent event);
RoboErik55011652014-07-09 15:05:53 -07001793
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001794 /**
RoboErik55011652014-07-09 15:05:53 -07001795 * @see android.app.Activity#setVolumeControlStream(int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001796 */
1797 public abstract void setVolumeControlStream(int streamType);
1798
1799 /**
1800 * @see android.app.Activity#getVolumeControlStream()
1801 */
1802 public abstract int getVolumeControlStream();
Adam Powell269248d2011-08-02 10:26:54 -07001803
1804 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001805 * Sets a {@link MediaController} to send media keys and volume changes to.
1806 * If set, this should be preferred for all media keys and volume requests
1807 * sent to this window.
1808 *
1809 * @param controller The controller for the session which should receive
1810 * media keys and volume changes.
RoboErik55011652014-07-09 15:05:53 -07001811 * @see android.app.Activity#setMediaController(android.media.session.MediaController)
1812 */
1813 public void setMediaController(MediaController controller) {
1814 }
1815
1816 /**
RoboErikfd63dd02014-08-28 15:22:55 -07001817 * Gets the {@link MediaController} that was previously set.
1818 *
1819 * @return The controller which should receive events.
1820 * @see #setMediaController(android.media.session.MediaController)
RoboErik55011652014-07-09 15:05:53 -07001821 * @see android.app.Activity#getMediaController()
1822 */
1823 public MediaController getMediaController() {
1824 return null;
1825 }
1826
1827 /**
Adam Powell269248d2011-08-02 10:26:54 -07001828 * Set extra options that will influence the UI for this window.
1829 * @param uiOptions Flags specifying extra options for this window.
1830 */
1831 public void setUiOptions(int uiOptions) { }
Adam Powelle43fca92011-08-16 12:57:01 -07001832
1833 /**
1834 * Set extra options that will influence the UI for this window.
1835 * Only the bits filtered by mask will be modified.
1836 * @param uiOptions Flags specifying extra options for this window.
1837 * @param mask Flags specifying which options should be modified. Others will remain unchanged.
1838 */
1839 public void setUiOptions(int uiOptions, int mask) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001840
1841 /**
1842 * Set the primary icon for this window.
1843 *
1844 * @param resId resource ID of a drawable to set
1845 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001846 public void setIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001847
1848 /**
1849 * Set the default icon for this window.
1850 * This will be overridden by any other icon set operation which could come from the
1851 * theme or another explicit set.
1852 *
1853 * @hide
1854 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001855 public void setDefaultIcon(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001856
1857 /**
1858 * Set the logo for this window. A logo is often shown in place of an
1859 * {@link #setIcon(int) icon} but is generally wider and communicates window title information
1860 * as well.
1861 *
1862 * @param resId resource ID of a drawable to set
1863 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001864 public void setLogo(@DrawableRes int resId) { }
Adam Powell04fe6eb2013-05-31 14:39:48 -07001865
1866 /**
1867 * Set the default logo for this window.
1868 * This will be overridden by any other logo set operation which could come from the
1869 * theme or another explicit set.
1870 *
1871 * @hide
1872 */
Tor Norbye7b9c9122013-05-30 16:48:33 -07001873 public void setDefaultLogo(@DrawableRes int resId) { }
keunyoung30f420f2013-08-02 14:23:10 -07001874
1875 /**
1876 * Set focus locally. The window should have the
1877 * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.
1878 * @param hasFocus Whether this window has focus or not.
1879 * @param inTouchMode Whether this window is in touch mode or not.
1880 */
1881 public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { }
1882
1883 /**
1884 * Inject an event to window locally.
1885 * @param event A key or touch event to inject to this window.
1886 */
1887 public void injectInputEvent(InputEvent event) { }
Adam Powellcfbe9be2013-11-06 14:58:58 -08001888
1889 /**
1890 * Retrieve the {@link TransitionManager} responsible for for default transitions
1891 * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1892 *
1893 * <p>This method will return non-null after content has been initialized (e.g. by using
1894 * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p>
1895 *
1896 * @return This window's content TransitionManager or null if none is set.
George Mountc3a043c2015-02-04 14:37:04 -08001897 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08001898 */
1899 public TransitionManager getTransitionManager() {
1900 return null;
1901 }
1902
1903 /**
1904 * Set the {@link TransitionManager} to use for default transitions in this window.
1905 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1906 *
1907 * @param tm The TransitionManager to use for scene changes.
George Mountc3a043c2015-02-04 14:37:04 -08001908 * @attr ref android.R.styleable#Window_windowContentTransitionManager
Adam Powellcfbe9be2013-11-06 14:58:58 -08001909 */
1910 public void setTransitionManager(TransitionManager tm) {
1911 throw new UnsupportedOperationException();
1912 }
1913
1914 /**
1915 * Retrieve the {@link Scene} representing this window's current content.
1916 * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
1917 *
1918 * <p>This method will return null if the current content is not represented by a Scene.</p>
1919 *
1920 * @return Current Scene being shown or null
1921 */
1922 public Scene getContentScene() {
1923 return null;
1924 }
1925
1926 /**
George Mount31a21722014-03-24 17:44:36 -07001927 * Sets the Transition that will be used to move Views into the initial scene. The entering
1928 * Views will be those that are regular Views or ViewGroups that have
1929 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1930 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1931 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
1932 * entering Views will remain unaffected.
George Mountc03da0e2014-08-22 17:04:02 -07001933 *
George Mount31a21722014-03-24 17:44:36 -07001934 * @param transition The Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001935 * @attr ref android.R.styleable#Window_windowEnterTransition
Adam Powellcfbe9be2013-11-06 14:58:58 -08001936 */
George Mount31a21722014-03-24 17:44:36 -07001937 public void setEnterTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08001938
1939 /**
George Mount68f96d82014-07-31 13:13:10 -07001940 * Sets the Transition that will be used to move Views out of the scene when the Window is
1941 * preparing to close, for example after a call to
1942 * {@link android.app.Activity#finishAfterTransition()}. The exiting
1943 * Views will be those that are regular Views or ViewGroups that have
1944 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1945 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1946 * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null,
1947 * entering Views will remain unaffected. If nothing is set, the default will be to
1948 * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
George Mountc03da0e2014-08-22 17:04:02 -07001949 *
George Mount68f96d82014-07-31 13:13:10 -07001950 * @param transition The Transition to use to move Views out of the Scene when the Window
1951 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07001952 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07001953 */
1954 public void setReturnTransition(Transition transition) {}
1955
1956 /**
George Mount31a21722014-03-24 17:44:36 -07001957 * Sets the Transition that will be used to move Views out of the scene when starting a
1958 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
1959 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1960 * {@link android.transition.Visibility} as exiting is governed by changing visibility
1961 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07001962 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001963 *
George Mount31a21722014-03-24 17:44:36 -07001964 * @param transition The Transition to use to move Views out of the scene when calling a
1965 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07001966 * @attr ref android.R.styleable#Window_windowExitTransition
George Mount0a778ed2013-12-13 13:35:36 -08001967 */
George Mount31a21722014-03-24 17:44:36 -07001968 public void setExitTransition(Transition transition) {}
George Mount0a778ed2013-12-13 13:35:36 -08001969
1970 /**
George Mount68f96d82014-07-31 13:13:10 -07001971 * Sets the Transition that will be used to move Views in to the scene when returning from
1972 * a previously-started Activity. The entering Views will be those that are regular Views
1973 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
1974 * will extend {@link android.transition.Visibility} as exiting is governed by changing
1975 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
1976 * the views will remain unaffected. If nothing is set, the default will be to use the same
1977 * transition as {@link #setExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07001978 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07001979 *
George Mount68f96d82014-07-31 13:13:10 -07001980 * @param transition The Transition to use to move Views into the scene when reentering from a
1981 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07001982 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07001983 */
1984 public void setReenterTransition(Transition transition) {}
1985
1986 /**
George Mount31a21722014-03-24 17:44:36 -07001987 * Returns the transition used to move Views into the initial scene. The entering
1988 * Views will be those that are regular Views or ViewGroups that have
1989 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
1990 * {@link android.transition.Visibility} as entering is governed by changing visibility from
1991 * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null,
George Mount9826f632014-09-11 08:50:09 -07001992 * entering Views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07001993 *
1994 * @return the Transition to use to move Views into the initial Scene.
George Mountc03da0e2014-08-22 17:04:02 -07001995 * @attr ref android.R.styleable#Window_windowEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08001996 */
George Mount31a21722014-03-24 17:44:36 -07001997 public Transition getEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08001998
1999 /**
Chet Haaseb64e777f2016-12-09 07:17:10 -08002000 * 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 -07002001 * preparing to close, for example after a call to
2002 * {@link android.app.Activity#finishAfterTransition()}. The exiting
2003 * Views will be those that are regular Views or ViewGroups that have
2004 * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2005 * {@link android.transition.Visibility} as entering is governed by changing visibility from
2006 * {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mountc03da0e2014-08-22 17:04:02 -07002007 *
George Mount68f96d82014-07-31 13:13:10 -07002008 * @return The Transition to use to move Views out of the Scene when the Window
2009 * is preparing to close.
George Mountc03da0e2014-08-22 17:04:02 -07002010 * @attr ref android.R.styleable#Window_windowReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002011 */
2012 public Transition getReturnTransition() { return null; }
2013
2014 /**
George Mount31a21722014-03-24 17:44:36 -07002015 * Returns the Transition that will be used to move Views out of the scene when starting a
2016 * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
2017 * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
2018 * {@link android.transition.Visibility} as exiting is governed by changing visibility
2019 * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
George Mount9826f632014-09-11 08:50:09 -07002020 * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002021 *
George Mount31a21722014-03-24 17:44:36 -07002022 * @return the Transition to use to move Views out of the scene when calling a
2023 * new Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002024 * @attr ref android.R.styleable#Window_windowExitTransition
George Mountcb4b7d92014-02-25 10:47:55 -08002025 */
George Mount31a21722014-03-24 17:44:36 -07002026 public Transition getExitTransition() { return null; }
George Mount0a778ed2013-12-13 13:35:36 -08002027
2028 /**
George Mount68f96d82014-07-31 13:13:10 -07002029 * Returns the Transition that will be used to move Views in to the scene when returning from
2030 * a previously-started Activity. The entering Views will be those that are regular Views
2031 * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
2032 * will extend {@link android.transition.Visibility} as exiting is governed by changing
2033 * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
George Mount9826f632014-09-11 08:50:09 -07002034 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002035 *
George Mount68f96d82014-07-31 13:13:10 -07002036 * @return The Transition to use to move Views into the scene when reentering from a
2037 * previously-started Activity.
George Mountc03da0e2014-08-22 17:04:02 -07002038 * @attr ref android.R.styleable#Window_windowReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002039 */
2040 public Transition getReenterTransition() { return null; }
2041
2042 /**
George Mount31a21722014-03-24 17:44:36 -07002043 * Sets the Transition that will be used for shared elements transferred into the content
2044 * Scene. Typical Transitions will affect size and location, such as
George Mount990205e2014-06-24 09:36:18 -07002045 * {@link android.transition.ChangeBounds}. A null
George Mount31a21722014-03-24 17:44:36 -07002046 * value will cause transferred shared elements to blink to the final position.
George Mount9826f632014-09-11 08:50:09 -07002047 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002048 *
George Mount31a21722014-03-24 17:44:36 -07002049 * @param transition The Transition to use for shared elements transferred into the content
2050 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002051 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mount0a778ed2013-12-13 13:35:36 -08002052 */
George Mount31a21722014-03-24 17:44:36 -07002053 public void setSharedElementEnterTransition(Transition transition) {}
George Mounte1803372014-02-26 19:00:52 +00002054
2055 /**
George Mount68f96d82014-07-31 13:13:10 -07002056 * Sets the Transition that will be used for shared elements transferred back to a
2057 * calling Activity. Typical Transitions will affect size and location, such as
2058 * {@link android.transition.ChangeBounds}. A null
2059 * value will cause transferred shared elements to blink to the final position.
2060 * If no value is set, the default will be to use the same value as
2061 * {@link #setSharedElementEnterTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07002062 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002063 *
George Mount68f96d82014-07-31 13:13:10 -07002064 * @param transition The Transition to use for shared elements transferred out of the content
2065 * Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002066 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002067 */
2068 public void setSharedElementReturnTransition(Transition transition) {}
2069
2070 /**
George Mount31a21722014-03-24 17:44:36 -07002071 * Returns the Transition that will be used for shared elements transferred into the content
George Mount9826f632014-09-11 08:50:09 -07002072 * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002073 *
George Mount31a21722014-03-24 17:44:36 -07002074 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002075 * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
George Mountcb4b7d92014-02-25 10:47:55 -08002076 */
George Mount31a21722014-03-24 17:44:36 -07002077 public Transition getSharedElementEnterTransition() { return null; }
George Mountcb4b7d92014-02-25 10:47:55 -08002078
2079 /**
George Mount68f96d82014-07-31 13:13:10 -07002080 * Returns the Transition that will be used for shared elements transferred back to a
George Mount9826f632014-09-11 08:50:09 -07002081 * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002082 *
George Mount68f96d82014-07-31 13:13:10 -07002083 * @return Transition to use for sharend elements transferred into the content Scene.
George Mountc03da0e2014-08-22 17:04:02 -07002084 * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
George Mount68f96d82014-07-31 13:13:10 -07002085 */
2086 public Transition getSharedElementReturnTransition() { return null; }
2087
2088 /**
George Mount31a21722014-03-24 17:44:36 -07002089 * Sets the Transition that will be used for shared elements after starting a new Activity
2090 * before the shared elements are transferred to the called Activity. If the shared elements
2091 * must animate during the exit transition, this Transition should be used. Upon completion,
2092 * the shared elements may be transferred to the started Activity.
George Mount9826f632014-09-11 08:50:09 -07002093 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002094 *
George Mount31a21722014-03-24 17:44:36 -07002095 * @param transition The Transition to use for shared elements in the launching Window
2096 * prior to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07002097 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mounte1803372014-02-26 19:00:52 +00002098 */
George Mount31a21722014-03-24 17:44:36 -07002099 public void setSharedElementExitTransition(Transition transition) {}
2100
2101 /**
George Mount68f96d82014-07-31 13:13:10 -07002102 * Sets the Transition that will be used for shared elements reentering from a started
2103 * Activity after it has returned the shared element to it start location. If no value
2104 * is set, this will default to
2105 * {@link #setSharedElementExitTransition(android.transition.Transition)}.
George Mount9826f632014-09-11 08:50:09 -07002106 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mountc03da0e2014-08-22 17:04:02 -07002107 *
George Mount68f96d82014-07-31 13:13:10 -07002108 * @param transition The Transition to use for shared elements in the launching Window
2109 * after the shared element has returned to the Window.
George Mountc03da0e2014-08-22 17:04:02 -07002110 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002111 */
2112 public void setSharedElementReenterTransition(Transition transition) {}
2113
2114 /**
George Mount31a21722014-03-24 17:44:36 -07002115 * Returns the Transition to use for shared elements in the launching Window prior
2116 * to transferring to the launched Activity's Window.
George Mount9826f632014-09-11 08:50:09 -07002117 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount31a21722014-03-24 17:44:36 -07002118 *
2119 * @return the Transition to use for shared elements in the launching Window prior
2120 * to transferring to the launched Activity's Window.
George Mountc03da0e2014-08-22 17:04:02 -07002121 * @attr ref android.R.styleable#Window_windowSharedElementExitTransition
George Mount31a21722014-03-24 17:44:36 -07002122 */
2123 public Transition getSharedElementExitTransition() { return null; }
2124
2125 /**
George Mount68f96d82014-07-31 13:13:10 -07002126 * Returns the Transition that will be used for shared elements reentering from a started
2127 * Activity after it has returned the shared element to it start location.
George Mount9826f632014-09-11 08:50:09 -07002128 * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
George Mount68f96d82014-07-31 13:13:10 -07002129 *
2130 * @return the Transition that will be used for shared elements reentering from a started
2131 * Activity after it has returned the shared element to it start location.
George Mountc03da0e2014-08-22 17:04:02 -07002132 * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
George Mount68f96d82014-07-31 13:13:10 -07002133 */
2134 public Transition getSharedElementReenterTransition() { return null; }
2135
2136 /**
George Mount31a21722014-03-24 17:44:36 -07002137 * Controls how the transition set in
2138 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
2139 * transition of the calling Activity. When true, the transition will start as soon as possible.
2140 * When false, the transition will wait until the remote exiting transition completes before
George Mount5d52d312016-06-10 14:16:45 -07002141 * starting. The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002142 *
George Mount31a21722014-03-24 17:44:36 -07002143 * @param allow true to start the enter transition when possible or false to
2144 * wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002145 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002146 */
2147 public void setAllowEnterTransitionOverlap(boolean allow) {}
2148
2149 /**
2150 * Returns how the transition set in
2151 * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
2152 * transition of the calling Activity. When true, the transition will start as soon as possible.
2153 * When false, the transition will wait until the remote exiting transition completes before
George Mount5d52d312016-06-10 14:16:45 -07002154 * starting. The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002155 *
George Mount31a21722014-03-24 17:44:36 -07002156 * @return true when the enter transition should start as soon as possible or false to
2157 * when it should wait until the exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002158 * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002159 */
2160 public boolean getAllowEnterTransitionOverlap() { return true; }
2161
2162 /**
2163 * Controls how the transition set in
2164 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2165 * transition of the called Activity when reentering after if finishes. When true,
2166 * the transition will start as soon as possible. When false, the transition will wait
2167 * until the called Activity's exiting transition completes before starting.
George Mount5d52d312016-06-10 14:16:45 -07002168 * The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002169 *
George Mount31a21722014-03-24 17:44:36 -07002170 * @param allow true to start the transition when possible or false to wait until the
2171 * called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002172 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002173 */
George Mountc03da0e2014-08-22 17:04:02 -07002174 public void setAllowReturnTransitionOverlap(boolean allow) {}
2175
2176 /**
George Mount31a21722014-03-24 17:44:36 -07002177 * Returns how the transition set in
2178 * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
2179 * transition of the called Activity when reentering after if finishes. When true,
2180 * the transition will start as soon as possible. When false, the transition will wait
2181 * until the called Activity's exiting transition completes before starting.
George Mount5d52d312016-06-10 14:16:45 -07002182 * The default value is true.
George Mountc03da0e2014-08-22 17:04:02 -07002183 *
George Mount31a21722014-03-24 17:44:36 -07002184 * @return true when the transition should start when possible or false when it should wait
2185 * until the called Activity's exiting transition completes.
George Mountc03da0e2014-08-22 17:04:02 -07002186 * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
George Mount31a21722014-03-24 17:44:36 -07002187 */
George Mountc03da0e2014-08-22 17:04:02 -07002188 public boolean getAllowReturnTransitionOverlap() { return true; }
2189
2190 /**
George Mounted1e01d2014-06-05 13:49:12 -07002191 * Returns the duration, in milliseconds, of the window background fade
2192 * when transitioning into or away from an Activity when called with an Activity Transition.
2193 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002194 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002195 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002196 *
George Mounted1e01d2014-06-05 13:49:12 -07002197 * @return The duration of the window background fade to opaque during enter transition.
2198 * @see #getEnterTransition()
George Mountc03da0e2014-08-22 17:04:02 -07002199 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002200 */
2201 public long getTransitionBackgroundFadeDuration() { return 0; }
2202
2203 /**
2204 * Sets the duration, in milliseconds, of the window background fade
2205 * when transitioning into or away from an Activity when called with an Activity Transition.
2206 * <p>When executing the enter transition, the background starts transparent
George Mount9826f632014-09-11 08:50:09 -07002207 * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
George Mounted1e01d2014-06-05 13:49:12 -07002208 * 300 milliseconds.</p>
George Mountc03da0e2014-08-22 17:04:02 -07002209 *
George Mounted1e01d2014-06-05 13:49:12 -07002210 * @param fadeDurationMillis The duration of the window background fade to or from opaque
2211 * during enter transition.
2212 * @see #setEnterTransition(android.transition.Transition)
George Mountc03da0e2014-08-22 17:04:02 -07002213 * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration
George Mounted1e01d2014-06-05 13:49:12 -07002214 */
2215 public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { }
2216
2217 /**
George Mountb89d5cc2014-08-18 16:50:50 -07002218 * Returns <code>true</code> when shared elements should use an Overlay during
2219 * shared element transitions or <code>false</code> when they should animate as
2220 * part of the normal View hierarchy. The default value is true.
2221 *
2222 * @return <code>true</code> when shared elements should use an Overlay during
2223 * shared element transitions or <code>false</code> when they should animate as
2224 * part of the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002225 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002226 */
2227 public boolean getSharedElementsUseOverlay() { return true; }
2228
2229 /**
2230 * Sets whether or not shared elements should use an Overlay during shared element transitions.
2231 * The default value is true.
2232 *
2233 * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should
2234 * be transitioned with an Overlay or <code>false</code>
2235 * to transition within the normal View hierarchy.
George Mountc03da0e2014-08-22 17:04:02 -07002236 * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
George Mountb89d5cc2014-08-18 16:50:50 -07002237 */
2238 public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { }
2239
2240 /**
Adrian Roos217ccd22014-05-09 14:29:04 +02002241 * @return the color of the status bar.
2242 */
Tor Norbye80756e32015-03-02 09:39:27 -08002243 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002244 public abstract int getStatusBarColor();
2245
2246 /**
John Spurlockbc4cf002015-03-24 21:51:20 -04002247 * Sets the color of the status bar to {@code color}.
Adrian Roos217ccd22014-05-09 14:29:04 +02002248 *
2249 * For this to take effect,
2250 * the window must be drawing the system bar backgrounds with
2251 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2252 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set.
2253 *
John Spurlockbc4cf002015-03-24 21:51:20 -04002254 * If {@code color} is not opaque, consider setting
Adrian Roos217ccd22014-05-09 14:29:04 +02002255 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2256 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
George Mount238010f2014-06-30 17:31:17 -07002257 * <p>
2258 * The transitionName for the view background will be "android:status:background".
2259 * </p>
Adrian Roos217ccd22014-05-09 14:29:04 +02002260 */
Tor Norbye80756e32015-03-02 09:39:27 -08002261 public abstract void setStatusBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002262
2263 /**
2264 * @return the color of the navigation bar.
2265 */
Tor Norbye80756e32015-03-02 09:39:27 -08002266 @ColorInt
Adrian Roos217ccd22014-05-09 14:29:04 +02002267 public abstract int getNavigationBarColor();
2268
2269 /**
2270 * Sets the color of the navigation bar to {@param color}.
2271 *
2272 * For this to take effect,
2273 * the window must be drawing the system bar backgrounds with
2274 * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
2275 * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
2276 *
2277 * If {@param color} is not opaque, consider setting
2278 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
2279 * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
George Mount238010f2014-06-30 17:31:17 -07002280 * <p>
2281 * The transitionName for the view background will be "android:navigation:background".
2282 * </p>
Jorim Jaggia0b78d52018-01-22 19:01:42 +01002283 * @attr ref android.R.styleable#Window_navigationBarColor
Adrian Roos217ccd22014-05-09 14:29:04 +02002284 */
Tor Norbye80756e32015-03-02 09:39:27 -08002285 public abstract void setNavigationBarColor(@ColorInt int color);
Adrian Roos217ccd22014-05-09 14:29:04 +02002286
Jorim Jaggia0b78d52018-01-22 19:01:42 +01002287 /**
2288 * Shows a thin line of the specified color between the navigation bar and the app
2289 * content.
2290 * <p>
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 * @param dividerColor The color of the thin line.
2297 * @attr ref android.R.styleable#Window_navigationBarDividerColor
2298 */
2299 public void setNavigationBarDividerColor(@ColorInt int dividerColor) {
2300 }
2301
2302 /**
2303 * Retrieves the color of the navigation bar divider.
2304 *
2305 * @return The color of the navigation bar divider color.
2306 * @see #setNavigationBarColor(int)
2307 * @attr ref android.R.styleable#Window_navigationBarDividerColor
2308 */
2309 public @ColorInt int getNavigationBarDividerColor() {
2310 return 0;
2311 }
2312
Filip Gruszczynski0daf2102015-09-29 08:39:07 -07002313 /** @hide */
2314 public void setTheme(int resId) {
2315 }
Filip Gruszczynski63250652015-11-18 14:43:01 -08002316
2317 /**
2318 * Whether the caption should be displayed directly on the content rather than push the content
2319 * down. This affects only freeform windows since they display the caption.
2320 * @hide
2321 */
Andrii Kulian933076d2016-03-29 17:04:42 -07002322 public void setOverlayWithDecorCaptionEnabled(boolean enabled) {
2323 mOverlayWithDecorCaptionEnabled = enabled;
Filip Gruszczynski63250652015-11-18 14:43:01 -08002324 }
2325
2326 /** @hide */
Andrii Kulian933076d2016-03-29 17:04:42 -07002327 public boolean isOverlayWithDecorCaptionEnabled() {
2328 return mOverlayWithDecorCaptionEnabled;
Filip Gruszczynski63250652015-11-18 14:43:01 -08002329 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002330
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002331 /** @hide */
2332 public void notifyRestrictedCaptionAreaCallback(int left, int top, int right, int bottom) {
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002333 if (mOnRestrictedCaptionAreaChangedListener != null) {
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002334 mRestrictedCaptionAreaRect.set(left, top, right, bottom);
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002335 mOnRestrictedCaptionAreaChangedListener.onRestrictedCaptionAreaChanged(
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002336 mRestrictedCaptionAreaRect);
2337 }
2338 }
Filip Gruszczynski9b81e402015-12-08 15:42:01 -08002339
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002340 /**
2341 * Set what color should the caption controls be. By default the system will try to determine
Wale Ogunwalea504ca32016-01-30 16:02:13 -08002342 * the color from the theme. You can overwrite this by using {@link #DECOR_CAPTION_SHADE_DARK},
2343 * {@link #DECOR_CAPTION_SHADE_LIGHT}, or {@link #DECOR_CAPTION_SHADE_AUTO}.
2344 * @see #DECOR_CAPTION_SHADE_DARK
2345 * @see #DECOR_CAPTION_SHADE_LIGHT
2346 * @see #DECOR_CAPTION_SHADE_AUTO
Filip Gruszczynski3dec0812015-12-09 08:42:41 -08002347 */
2348 public abstract void setDecorCaptionShade(int decorCaptionShade);
2349
2350 /**
2351 * Set the drawable that is drawn underneath the caption during the resizing.
2352 *
2353 * During the resizing the caption might not be drawn fast enough to match the new dimensions.
2354 * There is a second caption drawn underneath it that will be fast enough. By default the
2355 * caption is constructed from the theme. You can provide a drawable, that will be drawn instead
2356 * to better match your application.
2357 */
2358 public abstract void setResizingCaptionDrawable(Drawable drawable);
Wale Ogunwaleeb6722c2015-12-08 11:43:43 -08002359
2360 /**
2361 * Called when the activity changes from fullscreen mode to multi-window mode and visa-versa.
2362 * @hide
2363 */
Andrii Kulian933076d2016-03-29 17:04:42 -07002364 public abstract void onMultiWindowModeChanged();
Jorim Jaggi4846ee32016-01-07 17:39:12 +01002365
2366 /**
Winson Chung4d8681f2017-05-23 16:22:08 -07002367 * Called when the activity changes to/from picture-in-picture mode.
2368 * @hide
2369 */
2370 public abstract void onPictureInPictureModeChanged(boolean isInPictureInPictureMode);
2371
2372 /**
Jorim Jaggi4846ee32016-01-07 17:39:12 +01002373 * Called when the activity just relaunched.
2374 * @hide
2375 */
2376 public abstract void reportActivityRelaunched();
Michael Kwanf7964be2016-11-30 16:44:33 -08002377
2378 /**
2379 * Called to set flag to check if the close on swipe is enabled. This will only function if
2380 * FEATURE_SWIPE_TO_DISMISS has been set.
2381 * @hide
2382 */
2383 public void setCloseOnSwipeEnabled(boolean closeOnSwipeEnabled) {
2384 mCloseOnSwipeEnabled = closeOnSwipeEnabled;
2385 }
2386
2387 /**
2388 * @return {@code true} if the close on swipe is enabled.
2389 * @hide
2390 */
2391 public boolean isCloseOnSwipeEnabled() {
2392 return mCloseOnSwipeEnabled;
2393 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002394}