The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.view; |
| 18 | |
Aurimas Liutikas | 67e2ae8 | 2016-10-11 18:17:42 -0700 | [diff] [blame] | 19 | import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 20 | |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 21 | import android.annotation.ColorInt; |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 22 | import android.annotation.DrawableRes; |
| 23 | import android.annotation.IdRes; |
| 24 | import android.annotation.LayoutRes; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 25 | import android.annotation.NonNull; |
| 26 | import android.annotation.Nullable; |
Tor Norbye | 417ee5b | 2015-03-10 20:57:37 -0700 | [diff] [blame] | 27 | import android.annotation.StyleRes; |
Filip Gruszczynski | fe56835 | 2015-01-05 10:41:29 -0800 | [diff] [blame] | 28 | import android.annotation.SystemApi; |
Wale Ogunwale | 3382ab1 | 2017-07-27 08:55:03 -0700 | [diff] [blame] | 29 | import android.app.WindowConfiguration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.content.Context; |
Romain Guy | 4832745 | 2017-01-23 17:03:35 -0800 | [diff] [blame] | 31 | import android.content.pm.ActivityInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.content.res.Configuration; |
Bryce Lee | d6e6e72 | 2014-11-21 11:08:45 -0800 | [diff] [blame] | 33 | import android.content.res.Resources; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import android.content.res.TypedArray; |
Skuhne | ce2faa5 | 2015-08-11 10:36:38 -0700 | [diff] [blame] | 35 | import android.graphics.PixelFormat; |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 36 | import android.graphics.Rect; |
Filip Gruszczynski | 14418da | 2015-10-04 16:43:48 -0700 | [diff] [blame] | 37 | import android.graphics.drawable.Drawable; |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 38 | import android.media.session.MediaController; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | import android.net.Uri; |
| 40 | import android.os.Bundle; |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 41 | import android.os.Handler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 42 | import android.os.IBinder; |
Wale Ogunwale | 868a5e1 | 2015-08-02 16:19:20 -0700 | [diff] [blame] | 43 | import android.os.RemoteException; |
Romain Guy | 9622e20 | 2011-09-29 16:37:27 -0700 | [diff] [blame] | 44 | import android.os.SystemProperties; |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 45 | import android.transition.Scene; |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 46 | import android.transition.Transition; |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 47 | import android.transition.TransitionManager; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 48 | import android.view.accessibility.AccessibilityEvent; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | |
Clara Bayarri | 75e0979 | 2015-07-29 16:20:40 +0100 | [diff] [blame] | 50 | import java.util.List; |
| 51 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | /** |
| 53 | * Abstract base class for a top-level window look and behavior policy. An |
| 54 | * instance of this class should be used as the top-level view added to the |
| 55 | * window manager. It provides standard UI policies such as a background, title |
| 56 | * area, default key processing, etc. |
| 57 | * |
| 58 | * <p>The only existing implementation of this abstract class is |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 59 | * android.view.PhoneWindow, which you should instantiate when needing a |
| 60 | * Window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | */ |
| 62 | public abstract class Window { |
| 63 | /** Flag for the "options panel" feature. This is enabled by default. */ |
| 64 | public static final int FEATURE_OPTIONS_PANEL = 0; |
| 65 | /** Flag for the "no title" feature, turning off the title at the top |
| 66 | * of the screen. */ |
| 67 | public static final int FEATURE_NO_TITLE = 1; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Flag for the progress indicator feature. |
| 71 | * |
| 72 | * @deprecated No longer supported starting in API 21. |
| 73 | */ |
| 74 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | public static final int FEATURE_PROGRESS = 2; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 76 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | /** Flag for having an icon on the left side of the title bar */ |
| 78 | public static final int FEATURE_LEFT_ICON = 3; |
| 79 | /** Flag for having an icon on the right side of the title bar */ |
| 80 | public static final int FEATURE_RIGHT_ICON = 4; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 81 | |
| 82 | /** |
| 83 | * Flag for indeterminate progress. |
| 84 | * |
| 85 | * @deprecated No longer supported starting in API 21. |
| 86 | */ |
| 87 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | public static final int FEATURE_INDETERMINATE_PROGRESS = 5; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 89 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | /** Flag for the context menu. This is enabled by default. */ |
| 91 | public static final int FEATURE_CONTEXT_MENU = 6; |
| 92 | /** Flag for custom title. You cannot combine this feature with other title features. */ |
| 93 | public static final int FEATURE_CUSTOM_TITLE = 7; |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 94 | /** |
| 95 | * Flag for enabling the Action Bar. |
| 96 | * This is enabled by default for some devices. The Action Bar |
| 97 | * replaces the title bar and provides an alternate location |
| 98 | * for an on-screen menu button on some devices. |
| 99 | */ |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 100 | public static final int FEATURE_ACTION_BAR = 8; |
| 101 | /** |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 102 | * Flag for requesting an Action Bar that overlays window content. |
| 103 | * Normally an Action Bar will sit in the space above window content, but if this |
| 104 | * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over |
| 105 | * the window content itself. This is useful if you would like your app to have more control |
| 106 | * over how the Action Bar is displayed, such as letting application content scroll beneath |
| 107 | * an Action Bar with a transparent background or otherwise displaying a transparent/translucent |
| 108 | * Action Bar over application content. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 109 | * |
| 110 | * <p>This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN |
| 111 | * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the |
| 112 | * action bar in conjunction with other screen decorations. |
| 113 | * |
| 114 | * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an |
| 115 | * ActionBar is in this mode it will adjust the insets provided to |
| 116 | * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)} |
| 117 | * to include the content covered by the action bar, so you can do layout within |
| 118 | * that space. |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 119 | */ |
| 120 | public static final int FEATURE_ACTION_BAR_OVERLAY = 9; |
| 121 | /** |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 122 | * Flag for specifying the behavior of action modes when an Action Bar is not present. |
| 123 | * If overlay is enabled, the action mode UI will be allowed to cover existing window content. |
| 124 | */ |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 125 | public static final int FEATURE_ACTION_MODE_OVERLAY = 10; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 126 | /** |
Will Haldean Brown | ca6234e | 2014-02-12 10:23:41 -0800 | [diff] [blame] | 127 | * Flag for requesting a decoration-free window that is dismissed by swiping from the left. |
| 128 | */ |
| 129 | public static final int FEATURE_SWIPE_TO_DISMISS = 11; |
Will Haldean Brown | 568628d | 2014-03-04 15:25:43 -0800 | [diff] [blame] | 130 | /** |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 131 | * Flag for requesting that window content changes should be animated using a |
| 132 | * TransitionManager. |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 133 | * |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 134 | * <p>The TransitionManager is set using |
| 135 | * {@link #setTransitionManager(android.transition.TransitionManager)}. If none is set, |
| 136 | * a default TransitionManager will be used.</p> |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 137 | * |
| 138 | * @see #setContentView |
| 139 | */ |
Will Haldean Brown | 568628d | 2014-03-04 15:25:43 -0800 | [diff] [blame] | 140 | public static final int FEATURE_CONTENT_TRANSITIONS = 12; |
Adam Powell | 4b6d93f | 2012-09-18 18:34:08 -0700 | [diff] [blame] | 141 | |
| 142 | /** |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 143 | * Enables Activities to run Activity Transitions either through sending or receiving |
| 144 | * ActivityOptions bundle created with |
| 145 | * {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity, |
| 146 | * android.util.Pair[])} or {@link android.app.ActivityOptions#makeSceneTransitionAnimation( |
| 147 | * android.app.Activity, View, String)}. |
| 148 | */ |
| 149 | public static final int FEATURE_ACTIVITY_TRANSITIONS = 13; |
| 150 | |
| 151 | /** |
Adam Powell | 4b6d93f | 2012-09-18 18:34:08 -0700 | [diff] [blame] | 152 | * Max value used as a feature ID |
| 153 | * @hide |
| 154 | */ |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 155 | public static final int FEATURE_MAX = FEATURE_ACTIVITY_TRANSITIONS; |
Adam Powell | 4b6d93f | 2012-09-18 18:34:08 -0700 | [diff] [blame] | 156 | |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 157 | /** |
| 158 | * Flag for setting the progress bar's visibility to VISIBLE. |
| 159 | * |
| 160 | * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer |
| 161 | * supported starting in API 21. |
| 162 | */ |
| 163 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | public static final int PROGRESS_VISIBILITY_ON = -1; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 165 | |
| 166 | /** |
| 167 | * Flag for setting the progress bar's visibility to GONE. |
| 168 | * |
| 169 | * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer |
| 170 | * supported starting in API 21. |
| 171 | */ |
| 172 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 173 | public static final int PROGRESS_VISIBILITY_OFF = -2; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 174 | |
| 175 | /** |
| 176 | * Flag for setting the progress bar's indeterminate mode on. |
| 177 | * |
| 178 | * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods |
| 179 | * are no longer supported starting in API 21. |
| 180 | */ |
| 181 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 182 | public static final int PROGRESS_INDETERMINATE_ON = -3; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 183 | |
| 184 | /** |
| 185 | * Flag for setting the progress bar's indeterminate mode off. |
| 186 | * |
| 187 | * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods |
| 188 | * are no longer supported starting in API 21. |
| 189 | */ |
| 190 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 191 | public static final int PROGRESS_INDETERMINATE_OFF = -4; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 192 | |
| 193 | /** |
| 194 | * Starting value for the (primary) progress. |
| 195 | * |
| 196 | * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer |
| 197 | * supported starting in API 21. |
| 198 | */ |
| 199 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 200 | public static final int PROGRESS_START = 0; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 201 | |
| 202 | /** |
| 203 | * Ending value for the (primary) progress. |
| 204 | * |
| 205 | * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer |
| 206 | * supported starting in API 21. |
| 207 | */ |
| 208 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 209 | public static final int PROGRESS_END = 10000; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 210 | |
| 211 | /** |
| 212 | * Lowest possible value for the secondary progress. |
| 213 | * |
| 214 | * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer |
| 215 | * supported starting in API 21. |
| 216 | */ |
| 217 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | public static final int PROGRESS_SECONDARY_START = 20000; |
Alan Viverette | 4aef7c8 | 2015-09-04 14:14:50 -0400 | [diff] [blame] | 219 | |
| 220 | /** |
| 221 | * Highest possible value for the secondary progress. |
| 222 | * |
| 223 | * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer |
| 224 | * supported starting in API 21. |
| 225 | */ |
| 226 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 227 | public static final int PROGRESS_SECONDARY_END = 30000; |
George Mount | 238010f | 2014-06-30 17:31:17 -0700 | [diff] [blame] | 228 | |
| 229 | /** |
| 230 | * The transitionName for the status bar background View when a custom background is used. |
| 231 | * @see android.view.Window#setStatusBarColor(int) |
| 232 | */ |
| 233 | public static final String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background"; |
| 234 | |
| 235 | /** |
| 236 | * The transitionName for the navigation bar background View when a custom background is used. |
| 237 | * @see android.view.Window#setNavigationBarColor(int) |
| 238 | */ |
| 239 | public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME = |
| 240 | "android:navigation:background"; |
| 241 | |
Bryce Lee | aa1008c | 2015-01-13 09:26:46 -0800 | [diff] [blame] | 242 | /** |
| 243 | * The default features enabled. |
| 244 | * @deprecated use {@link #getDefaultFeatures(android.content.Context)} instead. |
| 245 | */ |
Bryce Lee | d6e6e72 | 2014-11-21 11:08:45 -0800 | [diff] [blame] | 246 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 247 | @SuppressWarnings({"PointlessBitwiseExpression"}) |
| 248 | protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) | |
| 249 | (1 << FEATURE_CONTEXT_MENU); |
| 250 | |
| 251 | /** |
| 252 | * The ID that the main layout in the XML layout file should have. |
| 253 | */ |
| 254 | public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content; |
| 255 | |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 256 | private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw"; |
| 257 | |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 258 | /** |
| 259 | * Flag for letting the theme drive the color of the window caption controls. Use with |
| 260 | * {@link #setDecorCaptionShade(int)}. This is the default value. |
| 261 | */ |
| 262 | public static final int DECOR_CAPTION_SHADE_AUTO = 0; |
| 263 | /** |
| 264 | * Flag for setting light-color controls on the window caption. Use with |
| 265 | * {@link #setDecorCaptionShade(int)}. |
| 266 | */ |
| 267 | public static final int DECOR_CAPTION_SHADE_LIGHT = 1; |
| 268 | /** |
| 269 | * Flag for setting dark-color controls on the window caption. Use with |
| 270 | * {@link #setDecorCaptionShade(int)}. |
| 271 | */ |
| 272 | public static final int DECOR_CAPTION_SHADE_DARK = 2; |
| 273 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 274 | private final Context mContext; |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 275 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 276 | private TypedArray mWindowStyle; |
| 277 | private Callback mCallback; |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 278 | private OnWindowDismissedCallback mOnWindowDismissedCallback; |
Michael Kwan | 67639a5 | 2016-12-16 12:38:10 -0800 | [diff] [blame] | 279 | private OnWindowSwipeDismissedCallback mOnWindowSwipeDismissedCallback; |
Skuhne | ce2faa5 | 2015-08-11 10:36:38 -0700 | [diff] [blame] | 280 | private WindowControllerCallback mWindowControllerCallback; |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 281 | private OnRestrictedCaptionAreaChangedListener mOnRestrictedCaptionAreaChangedListener; |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 282 | private Rect mRestrictedCaptionAreaRect; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 283 | private WindowManager mWindowManager; |
| 284 | private IBinder mAppToken; |
| 285 | private String mAppName; |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 286 | private boolean mHardwareAccelerated; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 287 | private Window mContainer; |
| 288 | private Window mActiveChild; |
| 289 | private boolean mIsActive = false; |
| 290 | private boolean mHasChildren = false; |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 291 | private boolean mCloseOnTouchOutside = false; |
| 292 | private boolean mSetCloseOnTouchOutside = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 293 | private int mForcedWindowFlags = 0; |
| 294 | |
Bryce Lee | d6e6e72 | 2014-11-21 11:08:45 -0800 | [diff] [blame] | 295 | private int mFeatures; |
| 296 | private int mLocalFeatures; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 297 | |
| 298 | private boolean mHaveWindowFormat = false; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 299 | private boolean mHaveDimAmount = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 300 | private int mDefaultWindowFormat = PixelFormat.OPAQUE; |
| 301 | |
| 302 | private boolean mHasSoftInputMode = false; |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 303 | |
Dianne Hackborn | 291905e | 2010-08-17 15:17:15 -0700 | [diff] [blame] | 304 | private boolean mDestroyed; |
| 305 | |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 306 | private boolean mOverlayWithDecorCaptionEnabled = false; |
Michael Kwan | f7964be | 2016-11-30 16:44:33 -0800 | [diff] [blame] | 307 | private boolean mCloseOnSwipeEnabled = false; |
Filip Gruszczynski | 6325065 | 2015-11-18 14:43:01 -0800 | [diff] [blame] | 308 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 309 | // The current window attributes. |
| 310 | private final WindowManager.LayoutParams mWindowAttributes = |
| 311 | new WindowManager.LayoutParams(); |
| 312 | |
| 313 | /** |
| 314 | * API from a Window back to its caller. This allows the client to |
| 315 | * intercept key dispatching, panels and menus, etc. |
| 316 | */ |
| 317 | public interface Callback { |
| 318 | /** |
| 319 | * Called to process key events. At the very least your |
| 320 | * implementation must call |
| 321 | * {@link android.view.Window#superDispatchKeyEvent} to do the |
| 322 | * standard key processing. |
| 323 | * |
| 324 | * @param event The key event. |
| 325 | * |
| 326 | * @return boolean Return true if this event was consumed. |
| 327 | */ |
| 328 | public boolean dispatchKeyEvent(KeyEvent event); |
| 329 | |
| 330 | /** |
Jeff Brown | 64da12a | 2011-01-04 19:57:47 -0800 | [diff] [blame] | 331 | * Called to process a key shortcut event. |
| 332 | * At the very least your implementation must call |
| 333 | * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the |
| 334 | * standard key shortcut processing. |
| 335 | * |
| 336 | * @param event The key shortcut event. |
| 337 | * @return True if this event was consumed. |
| 338 | */ |
| 339 | public boolean dispatchKeyShortcutEvent(KeyEvent event); |
| 340 | |
| 341 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 342 | * Called to process touch screen events. At the very least your |
| 343 | * implementation must call |
| 344 | * {@link android.view.Window#superDispatchTouchEvent} to do the |
| 345 | * standard touch screen processing. |
| 346 | * |
| 347 | * @param event The touch screen event. |
| 348 | * |
| 349 | * @return boolean Return true if this event was consumed. |
| 350 | */ |
| 351 | public boolean dispatchTouchEvent(MotionEvent event); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 352 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 353 | /** |
| 354 | * Called to process trackball events. At the very least your |
| 355 | * implementation must call |
| 356 | * {@link android.view.Window#superDispatchTrackballEvent} to do the |
| 357 | * standard trackball processing. |
| 358 | * |
| 359 | * @param event The trackball event. |
| 360 | * |
| 361 | * @return boolean Return true if this event was consumed. |
| 362 | */ |
| 363 | public boolean dispatchTrackballEvent(MotionEvent event); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 364 | |
| 365 | /** |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 366 | * Called to process generic motion events. At the very least your |
| 367 | * implementation must call |
| 368 | * {@link android.view.Window#superDispatchGenericMotionEvent} to do the |
| 369 | * standard processing. |
| 370 | * |
| 371 | * @param event The generic motion event. |
| 372 | * |
| 373 | * @return boolean Return true if this event was consumed. |
| 374 | */ |
| 375 | public boolean dispatchGenericMotionEvent(MotionEvent event); |
| 376 | |
| 377 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 378 | * Called to process population of {@link AccessibilityEvent}s. |
| 379 | * |
| 380 | * @param event The event. |
| 381 | * |
| 382 | * @return boolean Return true if event population was completed. |
| 383 | */ |
| 384 | public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event); |
| 385 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 386 | /** |
| 387 | * Instantiate the view to display in the panel for 'featureId'. |
| 388 | * You can return null, in which case the default content (typically |
| 389 | * a menu) will be created for you. |
| 390 | * |
| 391 | * @param featureId Which panel is being created. |
| 392 | * |
| 393 | * @return view The top-level view to place in the panel. |
| 394 | * |
| 395 | * @see #onPreparePanel |
| 396 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 397 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 398 | public View onCreatePanelView(int featureId); |
| 399 | |
| 400 | /** |
| 401 | * Initialize the contents of the menu for panel 'featureId'. This is |
| 402 | * called if onCreatePanelView() returns null, giving you a standard |
| 403 | * menu in which you can place your items. It is only called once for |
| 404 | * the panel, the first time it is shown. |
| 405 | * |
| 406 | * <p>You can safely hold on to <var>menu</var> (and any items created |
| 407 | * from it), making modifications to it as desired, until the next |
| 408 | * time onCreatePanelMenu() is called for this feature. |
| 409 | * |
| 410 | * @param featureId The panel being created. |
| 411 | * @param menu The menu inside the panel. |
| 412 | * |
| 413 | * @return boolean You must return true for the panel to be displayed; |
| 414 | * if you return false it will not be shown. |
| 415 | */ |
| 416 | public boolean onCreatePanelMenu(int featureId, Menu menu); |
| 417 | |
| 418 | /** |
| 419 | * Prepare a panel to be displayed. This is called right before the |
| 420 | * panel window is shown, every time it is shown. |
| 421 | * |
| 422 | * @param featureId The panel that is being displayed. |
| 423 | * @param view The View that was returned by onCreatePanelView(). |
| 424 | * @param menu If onCreatePanelView() returned null, this is the Menu |
| 425 | * being displayed in the panel. |
| 426 | * |
| 427 | * @return boolean You must return true for the panel to be displayed; |
| 428 | * if you return false it will not be shown. |
| 429 | * |
| 430 | * @see #onCreatePanelView |
| 431 | */ |
| 432 | public boolean onPreparePanel(int featureId, View view, Menu menu); |
| 433 | |
| 434 | /** |
| 435 | * Called when a panel's menu is opened by the user. This may also be |
| 436 | * called when the menu is changing from one type to another (for |
| 437 | * example, from the icon menu to the expanded menu). |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 438 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 439 | * @param featureId The panel that the menu is in. |
| 440 | * @param menu The menu that is opened. |
| 441 | * @return Return true to allow the menu to open, or false to prevent |
| 442 | * the menu from opening. |
| 443 | */ |
| 444 | public boolean onMenuOpened(int featureId, Menu menu); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 445 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 446 | /** |
| 447 | * Called when a panel's menu item has been selected by the user. |
| 448 | * |
| 449 | * @param featureId The panel that the menu is in. |
| 450 | * @param item The menu item that was selected. |
| 451 | * |
| 452 | * @return boolean Return true to finish processing of selection, or |
| 453 | * false to perform the normal menu handling (calling its |
| 454 | * Runnable or sending a Message to its target Handler). |
| 455 | */ |
| 456 | public boolean onMenuItemSelected(int featureId, MenuItem item); |
| 457 | |
| 458 | /** |
| 459 | * This is called whenever the current window attributes change. |
| 460 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 461 | */ |
| 462 | public void onWindowAttributesChanged(WindowManager.LayoutParams attrs); |
| 463 | |
| 464 | /** |
| 465 | * This hook is called whenever the content view of the screen changes |
| 466 | * (due to a call to |
| 467 | * {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams) |
| 468 | * Window.setContentView} or |
| 469 | * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams) |
| 470 | * Window.addContentView}). |
| 471 | */ |
| 472 | public void onContentChanged(); |
| 473 | |
| 474 | /** |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 475 | * This hook is called whenever the window focus changes. See |
| 476 | * {@link View#onWindowFocusChanged(boolean) |
Svetoslav | 3a0d878 | 2014-12-04 12:50:11 -0800 | [diff] [blame] | 477 | * View.onWindowFocusChangedNotLocked(boolean)} for more information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 478 | * |
| 479 | * @param hasFocus Whether the window now has focus. |
| 480 | */ |
| 481 | public void onWindowFocusChanged(boolean hasFocus); |
| 482 | |
| 483 | /** |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 484 | * Called when the window has been attached to the window manager. |
| 485 | * See {@link View#onAttachedToWindow() View.onAttachedToWindow()} |
| 486 | * for more information. |
| 487 | */ |
| 488 | public void onAttachedToWindow(); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 489 | |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 490 | /** |
Chet Haase | e7bf219 | 2017-08-18 15:24:56 -0700 | [diff] [blame] | 491 | * Called when the window has been detached from the window manager. |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 492 | * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()} |
| 493 | * for more information. |
| 494 | */ |
| 495 | public void onDetachedFromWindow(); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 496 | |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 497 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 498 | * Called when a panel is being closed. If another logical subsequent |
| 499 | * panel is being opened (and this panel is being closed to make room for the subsequent |
| 500 | * panel), this method will NOT be called. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 501 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 502 | * @param featureId The panel that is being displayed. |
| 503 | * @param menu If onCreatePanelView() returned null, this is the Menu |
| 504 | * being displayed in the panel. |
| 505 | */ |
| 506 | public void onPanelClosed(int featureId, Menu menu); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 507 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 508 | /** |
| 509 | * Called when the user signals the desire to start a search. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 510 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 511 | * @return true if search launched, false if activity refuses (blocks) |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 512 | * |
| 513 | * @see android.app.Activity#onSearchRequested() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 514 | */ |
| 515 | public boolean onSearchRequested(); |
Adam Powell | 6e34636 | 2010-07-23 10:18:23 -0700 | [diff] [blame] | 516 | |
| 517 | /** |
Tim Kilbourn | 6a975b3 | 2015-04-09 17:14:34 -0700 | [diff] [blame] | 518 | * Called when the user signals the desire to start a search. |
| 519 | * |
| 520 | * @param searchEvent A {@link SearchEvent} describing the signal to |
| 521 | * start a search. |
| 522 | * @return true if search launched, false if activity refuses (blocks) |
| 523 | */ |
| 524 | public boolean onSearchRequested(SearchEvent searchEvent); |
| 525 | |
| 526 | /** |
Adam Powell | debf3be | 2010-11-15 18:58:48 -0800 | [diff] [blame] | 527 | * Called when an action mode is being started for this window. Gives the |
| 528 | * callback an opportunity to handle the action mode in its own unique and |
| 529 | * beautiful way. If this method returns null the system can choose a way |
Clara Bayarri | 4423d91 | 2015-03-02 19:42:48 +0000 | [diff] [blame] | 530 | * to present the mode or choose not to start the mode at all. This is equivalent |
| 531 | * to {@link #onWindowStartingActionMode(android.view.ActionMode.Callback, int)} |
| 532 | * with type {@link ActionMode#TYPE_PRIMARY}. |
Adam Powell | 6e34636 | 2010-07-23 10:18:23 -0700 | [diff] [blame] | 533 | * |
| 534 | * @param callback Callback to control the lifecycle of this action mode |
Adam Powell | debf3be | 2010-11-15 18:58:48 -0800 | [diff] [blame] | 535 | * @return The ActionMode that was started, or null if the system should present it |
Adam Powell | 6e34636 | 2010-07-23 10:18:23 -0700 | [diff] [blame] | 536 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 537 | @Nullable |
Adam Powell | debf3be | 2010-11-15 18:58:48 -0800 | [diff] [blame] | 538 | public ActionMode onWindowStartingActionMode(ActionMode.Callback callback); |
| 539 | |
| 540 | /** |
Clara Bayarri | 4423d91 | 2015-03-02 19:42:48 +0000 | [diff] [blame] | 541 | * Called when an action mode is being started for this window. Gives the |
| 542 | * callback an opportunity to handle the action mode in its own unique and |
| 543 | * beautiful way. If this method returns null the system can choose a way |
| 544 | * to present the mode or choose not to start the mode at all. |
| 545 | * |
| 546 | * @param callback Callback to control the lifecycle of this action mode |
| 547 | * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}. |
| 548 | * @return The ActionMode that was started, or null if the system should present it |
| 549 | */ |
| 550 | @Nullable |
| 551 | public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type); |
| 552 | |
| 553 | /** |
Adam Powell | debf3be | 2010-11-15 18:58:48 -0800 | [diff] [blame] | 554 | * Called when an action mode has been started. The appropriate mode callback |
| 555 | * method will have already been invoked. |
| 556 | * |
| 557 | * @param mode The new mode that has just been started. |
| 558 | */ |
| 559 | public void onActionModeStarted(ActionMode mode); |
| 560 | |
| 561 | /** |
| 562 | * Called when an action mode has been finished. The appropriate mode callback |
| 563 | * method will have already been invoked. |
| 564 | * |
| 565 | * @param mode The mode that was just finished. |
| 566 | */ |
| 567 | public void onActionModeFinished(ActionMode mode); |
Clara Bayarri | 75e0979 | 2015-07-29 16:20:40 +0100 | [diff] [blame] | 568 | |
| 569 | /** |
| 570 | * Called when Keyboard Shortcuts are requested for the current window. |
| 571 | * |
| 572 | * @param data The data list to populate with shortcuts. |
| 573 | * @param menu The current menu, which may be null. |
Clara Bayarri | fcd7e80 | 2016-03-10 12:58:18 +0000 | [diff] [blame] | 574 | * @param deviceId The id for the connected device the shortcuts should be provided for. |
Clara Bayarri | 75e0979 | 2015-07-29 16:20:40 +0100 | [diff] [blame] | 575 | */ |
Sunny Goyal | 2a6d9aa | 2016-03-16 17:12:46 -0700 | [diff] [blame] | 576 | default public void onProvideKeyboardShortcuts( |
Clara Bayarri | fcd7e80 | 2016-03-10 12:58:18 +0000 | [diff] [blame] | 577 | List<KeyboardShortcutGroup> data, @Nullable Menu menu, int deviceId) { }; |
Vladislav Kaznacheev | 3787de1 | 2016-12-21 10:36:35 -0800 | [diff] [blame] | 578 | |
| 579 | /** |
| 580 | * Called when pointer capture is enabled or disabled for the current window. |
| 581 | * |
| 582 | * @param hasCapture True if the window has pointer capture. |
| 583 | */ |
| 584 | default public void onPointerCaptureChanged(boolean hasCapture) { }; |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 585 | } |
Will Haldean Brown | ca6234e | 2014-02-12 10:23:41 -0800 | [diff] [blame] | 586 | |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 587 | /** @hide */ |
| 588 | public interface OnWindowDismissedCallback { |
Will Haldean Brown | ca6234e | 2014-02-12 10:23:41 -0800 | [diff] [blame] | 589 | /** |
| 590 | * Called when a window is dismissed. This informs the callback that the |
| 591 | * window is gone, and it should finish itself. |
Wale Ogunwale | ba7881c | 2015-08-01 19:28:29 -0700 | [diff] [blame] | 592 | * @param finishTask True if the task should also be finished. |
Ned Burns | 7d6cb91 | 2016-12-02 17:25:33 -0500 | [diff] [blame] | 593 | * @param suppressWindowTransition True if the resulting exit and enter window transition |
| 594 | * animations should be suppressed. |
Will Haldean Brown | ca6234e | 2014-02-12 10:23:41 -0800 | [diff] [blame] | 595 | */ |
Ned Burns | 7d6cb91 | 2016-12-02 17:25:33 -0500 | [diff] [blame] | 596 | void onWindowDismissed(boolean finishTask, boolean suppressWindowTransition); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 597 | } |
| 598 | |
Wale Ogunwale | 868a5e1 | 2015-08-02 16:19:20 -0700 | [diff] [blame] | 599 | /** @hide */ |
Michael Kwan | 67639a5 | 2016-12-16 12:38:10 -0800 | [diff] [blame] | 600 | public interface OnWindowSwipeDismissedCallback { |
| 601 | /** |
| 602 | * Called when a window is swipe dismissed. This informs the callback that the |
| 603 | * window is gone, and it should finish itself. |
| 604 | * @param finishTask True if the task should also be finished. |
| 605 | * @param suppressWindowTransition True if the resulting exit and enter window transition |
| 606 | * animations should be suppressed. |
| 607 | */ |
| 608 | void onWindowSwipeDismissed(); |
| 609 | } |
| 610 | |
| 611 | /** @hide */ |
Skuhne | ce2faa5 | 2015-08-11 10:36:38 -0700 | [diff] [blame] | 612 | public interface WindowControllerCallback { |
| 613 | /** |
Filip Gruszczynski | 411c06f | 2016-01-07 09:44:44 -0800 | [diff] [blame] | 614 | * Moves the activity from |
Wale Ogunwale | 3382ab1 | 2017-07-27 08:55:03 -0700 | [diff] [blame] | 615 | * Moves the activity from {@link WindowConfiguration#WINDOWING_MODE_FREEFORM} windowing |
| 616 | * mode to {@link WindowConfiguration#WINDOWING_MODE_FULLSCREEN}. |
Wale Ogunwale | 868a5e1 | 2015-08-02 16:19:20 -0700 | [diff] [blame] | 617 | */ |
Filip Gruszczynski | 411c06f | 2016-01-07 09:44:44 -0800 | [diff] [blame] | 618 | void exitFreeformMode() throws RemoteException; |
Wale Ogunwale | 868a5e1 | 2015-08-02 16:19:20 -0700 | [diff] [blame] | 619 | |
Jaewan Kim | d98dcab | 2016-05-03 02:52:18 +0900 | [diff] [blame] | 620 | /** |
| 621 | * Puts the activity in picture-in-picture mode if the activity supports. |
| 622 | * @see android.R.attr#supportsPictureInPicture |
| 623 | */ |
| 624 | void enterPictureInPictureModeIfPossible(); |
| 625 | |
Winson Chung | 4d8681f | 2017-05-23 16:22:08 -0700 | [diff] [blame] | 626 | /** Returns whether the window belongs to the task root. */ |
| 627 | boolean isTaskRoot(); |
Wale Ogunwale | 868a5e1 | 2015-08-02 16:19:20 -0700 | [diff] [blame] | 628 | } |
| 629 | |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 630 | /** |
| 631 | * Callback for clients that want to be aware of where caption draws content. |
| 632 | */ |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 633 | public interface OnRestrictedCaptionAreaChangedListener { |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 634 | /** |
| 635 | * Called when the area where caption draws content changes. |
| 636 | * |
| 637 | * @param rect The area where caption content is positioned, relative to the top view. |
| 638 | */ |
| 639 | void onRestrictedCaptionAreaChanged(Rect rect); |
| 640 | } |
| 641 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 642 | /** |
| 643 | * Callback for clients that want frame timing information for each |
| 644 | * frame rendered by the Window. |
| 645 | */ |
Andres Morales | d908c62 | 2016-04-20 13:13:34 -0700 | [diff] [blame] | 646 | public interface OnFrameMetricsAvailableListener { |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 647 | /** |
| 648 | * Called when information is available for the previously rendered frame. |
| 649 | * |
| 650 | * Reports can be dropped if this callback takes too |
| 651 | * long to execute, as the report producer cannot wait for the consumer to |
| 652 | * complete. |
| 653 | * |
| 654 | * It is highly recommended that clients copy the passed in FrameMetrics |
| 655 | * via {@link FrameMetrics#FrameMetrics(FrameMetrics)} within this method and defer |
| 656 | * additional computation or storage to another thread to avoid unnecessarily |
| 657 | * dropping reports. |
| 658 | * |
| 659 | * @param window The {@link Window} on which the frame was displayed. |
| 660 | * @param frameMetrics the available metrics. This object is reused on every call |
| 661 | * and thus <strong>this reference is not valid outside the scope of this method</strong>. |
| 662 | * @param dropCountSinceLastInvocation the number of reports dropped since the last time |
| 663 | * this callback was invoked. |
| 664 | */ |
Andres Morales | d908c62 | 2016-04-20 13:13:34 -0700 | [diff] [blame] | 665 | void onFrameMetricsAvailable(Window window, FrameMetrics frameMetrics, |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 666 | int dropCountSinceLastInvocation); |
| 667 | } |
| 668 | |
| 669 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 670 | public Window(Context context) { |
| 671 | mContext = context; |
Bryce Lee | d6e6e72 | 2014-11-21 11:08:45 -0800 | [diff] [blame] | 672 | mFeatures = mLocalFeatures = getDefaultFeatures(context); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | /** |
| 676 | * Return the Context this window policy is running in, for retrieving |
| 677 | * resources and other information. |
| 678 | * |
| 679 | * @return Context The Context that was supplied to the constructor. |
| 680 | */ |
| 681 | public final Context getContext() { |
| 682 | return mContext; |
| 683 | } |
| 684 | |
| 685 | /** |
| 686 | * Return the {@link android.R.styleable#Window} attributes from this |
| 687 | * window's theme. |
| 688 | */ |
| 689 | public final TypedArray getWindowStyle() { |
| 690 | synchronized (this) { |
| 691 | if (mWindowStyle == null) { |
| 692 | mWindowStyle = mContext.obtainStyledAttributes( |
| 693 | com.android.internal.R.styleable.Window); |
| 694 | } |
| 695 | return mWindowStyle; |
| 696 | } |
| 697 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 698 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 699 | /** |
| 700 | * Set the container for this window. If not set, the DecorWindow |
| 701 | * operates as a top-level window; otherwise, it negotiates with the |
| 702 | * container to display itself appropriately. |
| 703 | * |
| 704 | * @param container The desired containing Window. |
| 705 | */ |
| 706 | public void setContainer(Window container) { |
| 707 | mContainer = container; |
| 708 | if (container != null) { |
| 709 | // Embedded screens never have a title. |
| 710 | mFeatures |= 1<<FEATURE_NO_TITLE; |
| 711 | mLocalFeatures |= 1<<FEATURE_NO_TITLE; |
| 712 | container.mHasChildren = true; |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | /** |
| 717 | * Return the container for this Window. |
| 718 | * |
| 719 | * @return Window The containing window, or null if this is a |
| 720 | * top-level window. |
| 721 | */ |
| 722 | public final Window getContainer() { |
| 723 | return mContainer; |
| 724 | } |
| 725 | |
| 726 | public final boolean hasChildren() { |
| 727 | return mHasChildren; |
| 728 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 729 | |
Dianne Hackborn | 291905e | 2010-08-17 15:17:15 -0700 | [diff] [blame] | 730 | /** @hide */ |
| 731 | public final void destroy() { |
| 732 | mDestroyed = true; |
| 733 | } |
| 734 | |
| 735 | /** @hide */ |
| 736 | public final boolean isDestroyed() { |
| 737 | return mDestroyed; |
| 738 | } |
| 739 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 740 | /** |
| 741 | * Set the window manager for use by this Window to, for example, |
| 742 | * display panels. This is <em>not</em> used for displaying the |
| 743 | * Window itself -- that must be done by the client. |
| 744 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 745 | * @param wm The window manager for adding new windows. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 746 | */ |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 747 | public void setWindowManager(WindowManager wm, IBinder appToken, String appName) { |
| 748 | setWindowManager(wm, appToken, appName, false); |
| 749 | } |
| 750 | |
| 751 | /** |
| 752 | * Set the window manager for use by this Window to, for example, |
| 753 | * display panels. This is <em>not</em> used for displaying the |
| 754 | * Window itself -- that must be done by the client. |
| 755 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 756 | * @param wm The window manager for adding new windows. |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 757 | */ |
| 758 | public void setWindowManager(WindowManager wm, IBinder appToken, String appName, |
| 759 | boolean hardwareAccelerated) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 760 | mAppToken = appToken; |
| 761 | mAppName = appName; |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 762 | mHardwareAccelerated = hardwareAccelerated |
| 763 | || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 764 | if (wm == null) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 765 | wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 766 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 767 | mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 768 | } |
| 769 | |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 770 | void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) { |
| 771 | CharSequence curTitle = wp.getTitle(); |
| 772 | if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW && |
tiger_huang | ff58e30 | 2015-10-13 21:38:19 +0800 | [diff] [blame] | 773 | wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 774 | if (wp.token == null) { |
| 775 | View decor = peekDecorView(); |
| 776 | if (decor != null) { |
| 777 | wp.token = decor.getWindowToken(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 778 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 779 | } |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 780 | if (curTitle == null || curTitle.length() == 0) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 781 | final StringBuilder title = new StringBuilder(32); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 782 | if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 783 | title.append("Media"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 784 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 785 | title.append("MediaOvr"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 786 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 787 | title.append("Panel"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 788 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 789 | title.append("SubPanel"); |
Wale Ogunwale | 0a4dc22 | 2015-04-14 12:58:42 -0700 | [diff] [blame] | 790 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 791 | title.append("AboveSubPanel"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 792 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 793 | title.append("AtchDlg"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 794 | } else { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 795 | title.append(wp.type); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 796 | } |
| 797 | if (mAppName != null) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 798 | title.append(":").append(mAppName); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 799 | } |
| 800 | wp.setTitle(title); |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 801 | } |
tiger_huang | ff58e30 | 2015-10-13 21:38:19 +0800 | [diff] [blame] | 802 | } else if (wp.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW && |
| 803 | wp.type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) { |
| 804 | // We don't set the app token to this system window because the life cycles should be |
| 805 | // independent. If an app creates a system window and then the app goes to the stopped |
| 806 | // state, the system window should not be affected (can still show and receive input |
| 807 | // events). |
| 808 | if (curTitle == null || curTitle.length() == 0) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 809 | final StringBuilder title = new StringBuilder(32); |
| 810 | title.append("Sys").append(wp.type); |
tiger_huang | ff58e30 | 2015-10-13 21:38:19 +0800 | [diff] [blame] | 811 | if (mAppName != null) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 812 | title.append(":").append(mAppName); |
tiger_huang | ff58e30 | 2015-10-13 21:38:19 +0800 | [diff] [blame] | 813 | } |
| 814 | wp.setTitle(title); |
| 815 | } |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 816 | } else { |
| 817 | if (wp.token == null) { |
| 818 | wp.token = mContainer == null ? mAppToken : mContainer.mAppToken; |
| 819 | } |
| 820 | if ((curTitle == null || curTitle.length() == 0) |
| 821 | && mAppName != null) { |
| 822 | wp.setTitle(mAppName); |
| 823 | } |
| 824 | } |
| 825 | if (wp.packageName == null) { |
| 826 | wp.packageName = mContext.getPackageName(); |
| 827 | } |
Robert Carr | 13678ee | 2016-04-20 14:04:15 -0700 | [diff] [blame] | 828 | if (mHardwareAccelerated || |
| 829 | (mWindowAttributes.flags & FLAG_HARDWARE_ACCELERATED) != 0) { |
| 830 | wp.flags |= FLAG_HARDWARE_ACCELERATED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 831 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | /** |
| 835 | * Return the window manager allowing this Window to display its own |
| 836 | * windows. |
| 837 | * |
| 838 | * @return WindowManager The ViewManager. |
| 839 | */ |
| 840 | public WindowManager getWindowManager() { |
| 841 | return mWindowManager; |
| 842 | } |
| 843 | |
| 844 | /** |
| 845 | * Set the Callback interface for this window, used to intercept key |
| 846 | * events and other dynamic operations in the window. |
| 847 | * |
| 848 | * @param callback The desired Callback interface. |
| 849 | */ |
| 850 | public void setCallback(Callback callback) { |
| 851 | mCallback = callback; |
| 852 | } |
| 853 | |
| 854 | /** |
| 855 | * Return the current Callback interface for this window. |
| 856 | */ |
| 857 | public final Callback getCallback() { |
| 858 | return mCallback; |
| 859 | } |
| 860 | |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 861 | /** |
| 862 | * Set an observer to collect frame stats for each frame rendererd in this window. |
| 863 | * |
| 864 | * Must be in hardware rendering mode. |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 865 | */ |
Andres Morales | d908c62 | 2016-04-20 13:13:34 -0700 | [diff] [blame] | 866 | public final void addOnFrameMetricsAvailableListener( |
| 867 | @NonNull OnFrameMetricsAvailableListener listener, |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 868 | Handler handler) { |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 869 | final View decorView = getDecorView(); |
| 870 | if (decorView == null) { |
| 871 | throw new IllegalStateException("can't observe a Window without an attached view"); |
| 872 | } |
| 873 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 874 | if (listener == null) { |
| 875 | throw new NullPointerException("listener cannot be null"); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 876 | } |
| 877 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 878 | decorView.addFrameMetricsListener(this, listener, handler); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 879 | } |
| 880 | |
| 881 | /** |
| 882 | * Remove observer and stop listening to frame stats for this window. |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 883 | */ |
Andres Morales | d908c62 | 2016-04-20 13:13:34 -0700 | [diff] [blame] | 884 | public final void removeOnFrameMetricsAvailableListener(OnFrameMetricsAvailableListener listener) { |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 885 | final View decorView = getDecorView(); |
| 886 | if (decorView != null) { |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 887 | getDecorView().removeFrameMetricsListener(listener); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 888 | } |
| 889 | } |
| 890 | |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 891 | /** @hide */ |
| 892 | public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) { |
| 893 | mOnWindowDismissedCallback = dcb; |
| 894 | } |
| 895 | |
| 896 | /** @hide */ |
Ned Burns | 7d6cb91 | 2016-12-02 17:25:33 -0500 | [diff] [blame] | 897 | public final void dispatchOnWindowDismissed( |
| 898 | boolean finishTask, boolean suppressWindowTransition) { |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 899 | if (mOnWindowDismissedCallback != null) { |
Ned Burns | 7d6cb91 | 2016-12-02 17:25:33 -0500 | [diff] [blame] | 900 | mOnWindowDismissedCallback.onWindowDismissed(finishTask, suppressWindowTransition); |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 901 | } |
| 902 | } |
| 903 | |
Stefan Kuhne | 9bad741 | 2015-08-07 10:35:52 -0700 | [diff] [blame] | 904 | /** @hide */ |
Michael Kwan | 67639a5 | 2016-12-16 12:38:10 -0800 | [diff] [blame] | 905 | public final void setOnWindowSwipeDismissedCallback(OnWindowSwipeDismissedCallback sdcb) { |
| 906 | mOnWindowSwipeDismissedCallback = sdcb; |
| 907 | } |
| 908 | |
| 909 | /** @hide */ |
| 910 | public final void dispatchOnWindowSwipeDismissed() { |
| 911 | if (mOnWindowSwipeDismissedCallback != null) { |
| 912 | mOnWindowSwipeDismissedCallback.onWindowSwipeDismissed(); |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | /** @hide */ |
Skuhne | ce2faa5 | 2015-08-11 10:36:38 -0700 | [diff] [blame] | 917 | public final void setWindowControllerCallback(WindowControllerCallback wccb) { |
| 918 | mWindowControllerCallback = wccb; |
Stefan Kuhne | 9bad741 | 2015-08-07 10:35:52 -0700 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | /** @hide */ |
Skuhne | ce2faa5 | 2015-08-11 10:36:38 -0700 | [diff] [blame] | 922 | public final WindowControllerCallback getWindowControllerCallback() { |
| 923 | return mWindowControllerCallback; |
Stefan Kuhne | 9bad741 | 2015-08-07 10:35:52 -0700 | [diff] [blame] | 924 | } |
| 925 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 926 | /** |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 927 | * Set a callback for changes of area where caption will draw its content. |
| 928 | * |
| 929 | * @param listener Callback that will be called when the area changes. |
| 930 | */ |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 931 | public final void setRestrictedCaptionAreaListener(OnRestrictedCaptionAreaChangedListener listener) { |
| 932 | mOnRestrictedCaptionAreaChangedListener = listener; |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 933 | mRestrictedCaptionAreaRect = listener != null ? new Rect() : null; |
| 934 | } |
| 935 | |
| 936 | /** |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 937 | * Take ownership of this window's surface. The window's view hierarchy |
| 938 | * will no longer draw into the surface, though it will otherwise continue |
| 939 | * to operate (such as for receiving input events). The given SurfaceHolder |
| 940 | * callback will be used to tell you about state changes to the surface. |
| 941 | */ |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 942 | public abstract void takeSurface(SurfaceHolder.Callback2 callback); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 943 | |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 944 | /** |
Dianne Hackborn | 1e4b9f3 | 2010-06-23 14:10:57 -0700 | [diff] [blame] | 945 | * Take ownership of this window's InputQueue. The window will no |
| 946 | * longer read and dispatch input events from the queue; it is your |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 947 | * responsibility to do so. |
| 948 | */ |
Dianne Hackborn | 1e4b9f3 | 2010-06-23 14:10:57 -0700 | [diff] [blame] | 949 | public abstract void takeInputQueue(InputQueue.Callback callback); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 950 | |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 951 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 952 | * Return whether this window is being displayed with a floating style |
| 953 | * (based on the {@link android.R.attr#windowIsFloating} attribute in |
| 954 | * the style/theme). |
| 955 | * |
| 956 | * @return Returns true if the window is configured to be displayed floating |
| 957 | * on top of whatever is behind it. |
| 958 | */ |
| 959 | public abstract boolean isFloating(); |
| 960 | |
| 961 | /** |
| 962 | * Set the width and height layout parameters of the window. The default |
Dianne Hackborn | c918935 | 2010-12-15 14:57:25 -0800 | [diff] [blame] | 963 | * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT |
| 964 | * or an absolute value to make a window that is not full-screen. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 965 | * |
| 966 | * @param width The desired layout width of the window. |
| 967 | * @param height The desired layout height of the window. |
Dianne Hackborn | c918935 | 2010-12-15 14:57:25 -0800 | [diff] [blame] | 968 | * |
| 969 | * @see ViewGroup.LayoutParams#height |
| 970 | * @see ViewGroup.LayoutParams#width |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 971 | */ |
Dianne Hackborn | c918935 | 2010-12-15 14:57:25 -0800 | [diff] [blame] | 972 | public void setLayout(int width, int height) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 973 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 974 | attrs.width = width; |
| 975 | attrs.height = height; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 976 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | /** |
| 980 | * Set the gravity of the window, as per the Gravity constants. This |
| 981 | * controls how the window manager is positioned in the overall window; it |
| 982 | * is only useful when using WRAP_CONTENT for the layout width or height. |
| 983 | * |
| 984 | * @param gravity The desired gravity constant. |
| 985 | * |
| 986 | * @see Gravity |
| 987 | * @see #setLayout |
| 988 | */ |
| 989 | public void setGravity(int gravity) |
| 990 | { |
| 991 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 992 | attrs.gravity = gravity; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 993 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 994 | } |
| 995 | |
| 996 | /** |
| 997 | * Set the type of the window, as per the WindowManager.LayoutParams |
| 998 | * types. |
| 999 | * |
| 1000 | * @param type The new window type (see WindowManager.LayoutParams). |
| 1001 | */ |
| 1002 | public void setType(int type) { |
| 1003 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1004 | attrs.type = type; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1005 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | /** |
| 1009 | * Set the format of window, as per the PixelFormat types. This overrides |
| 1010 | * the default format that is selected by the Window based on its |
| 1011 | * window decorations. |
| 1012 | * |
| 1013 | * @param format The new window format (see PixelFormat). Use |
| 1014 | * PixelFormat.UNKNOWN to allow the Window to select |
| 1015 | * the format. |
| 1016 | * |
| 1017 | * @see PixelFormat |
| 1018 | */ |
| 1019 | public void setFormat(int format) { |
| 1020 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1021 | if (format != PixelFormat.UNKNOWN) { |
| 1022 | attrs.format = format; |
| 1023 | mHaveWindowFormat = true; |
| 1024 | } else { |
| 1025 | attrs.format = mDefaultWindowFormat; |
| 1026 | mHaveWindowFormat = false; |
| 1027 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1028 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1029 | } |
| 1030 | |
| 1031 | /** |
| 1032 | * Specify custom animations to use for the window, as per |
| 1033 | * {@link WindowManager.LayoutParams#windowAnimations |
| 1034 | * WindowManager.LayoutParams.windowAnimations}. Providing anything besides |
| 1035 | * 0 here will override the animations the window would |
| 1036 | * normally retrieve from its theme. |
| 1037 | */ |
Tor Norbye | 417ee5b | 2015-03-10 20:57:37 -0700 | [diff] [blame] | 1038 | public void setWindowAnimations(@StyleRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1039 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1040 | attrs.windowAnimations = resId; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1041 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1042 | } |
| 1043 | |
| 1044 | /** |
| 1045 | * Specify an explicit soft input mode to use for the window, as per |
| 1046 | * {@link WindowManager.LayoutParams#softInputMode |
| 1047 | * WindowManager.LayoutParams.softInputMode}. Providing anything besides |
| 1048 | * "unspecified" here will override the input mode the window would |
| 1049 | * normally retrieve from its theme. |
| 1050 | */ |
| 1051 | public void setSoftInputMode(int mode) { |
| 1052 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1053 | if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) { |
| 1054 | attrs.softInputMode = mode; |
| 1055 | mHasSoftInputMode = true; |
| 1056 | } else { |
| 1057 | mHasSoftInputMode = false; |
| 1058 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1059 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1060 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1061 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1062 | /** |
| 1063 | * Convenience function to set the flag bits as specified in flags, as |
| 1064 | * per {@link #setFlags}. |
| 1065 | * @param flags The flag bits to be set. |
| 1066 | * @see #setFlags |
Christopher Tate | 193fc07 | 2012-06-04 11:27:40 -0700 | [diff] [blame] | 1067 | * @see #clearFlags |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1068 | */ |
| 1069 | public void addFlags(int flags) { |
| 1070 | setFlags(flags, flags); |
| 1071 | } |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1072 | |
| 1073 | /** @hide */ |
| 1074 | public void addPrivateFlags(int flags) { |
| 1075 | setPrivateFlags(flags, flags); |
| 1076 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1077 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1078 | /** |
| 1079 | * Convenience function to clear the flag bits as specified in flags, as |
| 1080 | * per {@link #setFlags}. |
| 1081 | * @param flags The flag bits to be cleared. |
| 1082 | * @see #setFlags |
Christopher Tate | 193fc07 | 2012-06-04 11:27:40 -0700 | [diff] [blame] | 1083 | * @see #addFlags |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1084 | */ |
| 1085 | public void clearFlags(int flags) { |
| 1086 | setFlags(0, flags); |
| 1087 | } |
| 1088 | |
| 1089 | /** |
| 1090 | * Set the flags of the window, as per the |
| 1091 | * {@link WindowManager.LayoutParams WindowManager.LayoutParams} |
| 1092 | * flags. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1093 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1094 | * <p>Note that some flags must be set before the window decoration is |
| 1095 | * created (by the first call to |
| 1096 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or |
| 1097 | * {@link #getDecorView()}: |
| 1098 | * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and |
| 1099 | * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These |
| 1100 | * will be set for you based on the {@link android.R.attr#windowIsFloating} |
| 1101 | * attribute. |
| 1102 | * |
| 1103 | * @param flags The new window flags (see WindowManager.LayoutParams). |
| 1104 | * @param mask Which of the window flag bits to modify. |
Christopher Tate | 193fc07 | 2012-06-04 11:27:40 -0700 | [diff] [blame] | 1105 | * @see #addFlags |
| 1106 | * @see #clearFlags |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1107 | */ |
| 1108 | public void setFlags(int flags, int mask) { |
| 1109 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1110 | attrs.flags = (attrs.flags&~mask) | (flags&mask); |
| 1111 | mForcedWindowFlags |= mask; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1112 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1113 | } |
| 1114 | |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1115 | private void setPrivateFlags(int flags, int mask) { |
| 1116 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1117 | attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask); |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1118 | dispatchWindowAttributesChanged(attrs); |
| 1119 | } |
| 1120 | |
| 1121 | /** |
| 1122 | * {@hide} |
| 1123 | */ |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 1124 | protected void setNeedsMenuKey(int value) { |
| 1125 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1126 | attrs.needsMenuKey = value; |
| 1127 | dispatchWindowAttributesChanged(attrs); |
| 1128 | } |
| 1129 | |
| 1130 | /** |
| 1131 | * {@hide} |
| 1132 | */ |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1133 | protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) { |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1134 | if (mCallback != null) { |
| 1135 | mCallback.onWindowAttributesChanged(attrs); |
| 1136 | } |
| 1137 | } |
| 1138 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1139 | /** |
Romain Guy | adae59b | 2017-06-20 14:45:53 -0700 | [diff] [blame] | 1140 | * <p>Sets the requested color mode of the window. The requested the color mode might |
Romain Guy | 4832745 | 2017-01-23 17:03:35 -0800 | [diff] [blame] | 1141 | * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p> |
| 1142 | * |
Romain Guy | adae59b | 2017-06-20 14:45:53 -0700 | [diff] [blame] | 1143 | * <p>The requested color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT}, |
Romain Guy | 4832745 | 2017-01-23 17:03:35 -0800 | [diff] [blame] | 1144 | * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}.</p> |
Romain Guy | adae59b | 2017-06-20 14:45:53 -0700 | [diff] [blame] | 1145 | * |
| 1146 | * <p>The requested color mode is not guaranteed to be honored. Please refer to |
| 1147 | * {@link #getColorMode()} for more information.</p> |
| 1148 | * |
| 1149 | * @see #getColorMode() |
| 1150 | * @see Display#isWideColorGamut() |
| 1151 | * @see Configuration#isScreenWideColorGamut() |
Romain Guy | 4832745 | 2017-01-23 17:03:35 -0800 | [diff] [blame] | 1152 | */ |
| 1153 | public void setColorMode(@ActivityInfo.ColorMode int colorMode) { |
| 1154 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1155 | attrs.setColorMode(colorMode); |
| 1156 | dispatchWindowAttributesChanged(attrs); |
| 1157 | } |
| 1158 | |
| 1159 | /** |
Romain Guy | adae59b | 2017-06-20 14:45:53 -0700 | [diff] [blame] | 1160 | * Returns the requested color mode of the window, one of |
| 1161 | * {@link ActivityInfo#COLOR_MODE_DEFAULT}, {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} |
| 1162 | * or {@link ActivityInfo#COLOR_MODE_HDR}. If {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} |
| 1163 | * was requested it is possible the window will not be put in wide color gamut mode depending |
| 1164 | * on device and display support for that mode. Use {@link #isWideColorGamut} to determine |
| 1165 | * if the window is currently in wide color gamut mode. |
| 1166 | * |
| 1167 | * @see #setColorMode(int) |
| 1168 | * @see Display#isWideColorGamut() |
| 1169 | * @see Configuration#isScreenWideColorGamut() |
Romain Guy | 4832745 | 2017-01-23 17:03:35 -0800 | [diff] [blame] | 1170 | */ |
| 1171 | @ActivityInfo.ColorMode |
| 1172 | public int getColorMode() { |
| 1173 | return getAttributes().getColorMode(); |
| 1174 | } |
| 1175 | |
| 1176 | /** |
Romain Guy | adae59b | 2017-06-20 14:45:53 -0700 | [diff] [blame] | 1177 | * Returns true if this window's color mode is {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}, |
| 1178 | * the display has a wide color gamut and this device supports wide color gamut rendering. |
| 1179 | * |
| 1180 | * @see Display#isWideColorGamut() |
| 1181 | * @see Configuration#isScreenWideColorGamut() |
| 1182 | */ |
| 1183 | public boolean isWideColorGamut() { |
| 1184 | return getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT |
| 1185 | && getContext().getResources().getConfiguration().isScreenWideColorGamut(); |
| 1186 | } |
| 1187 | |
| 1188 | /** |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1189 | * Set the amount of dim behind the window when using |
| 1190 | * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides |
| 1191 | * the default dim amount of that is selected by the Window based on |
| 1192 | * its theme. |
| 1193 | * |
| 1194 | * @param amount The new dim amount, from 0 for no dim to 1 for full dim. |
| 1195 | */ |
| 1196 | public void setDimAmount(float amount) { |
| 1197 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1198 | attrs.dimAmount = amount; |
| 1199 | mHaveDimAmount = true; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1200 | dispatchWindowAttributesChanged(attrs); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1204 | * Specify custom window attributes. <strong>PLEASE NOTE:</strong> the |
| 1205 | * layout params you give here should generally be from values previously |
| 1206 | * retrieved with {@link #getAttributes()}; you probably do not want to |
| 1207 | * blindly create and apply your own, since this will blow away any values |
| 1208 | * set by the framework that you are not interested in. |
| 1209 | * |
| 1210 | * @param a The new window attributes, which will completely override any |
| 1211 | * current values. |
| 1212 | */ |
| 1213 | public void setAttributes(WindowManager.LayoutParams a) { |
| 1214 | mWindowAttributes.copyFrom(a); |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1215 | dispatchWindowAttributesChanged(mWindowAttributes); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1216 | } |
| 1217 | |
| 1218 | /** |
| 1219 | * Retrieve the current window attributes associated with this panel. |
| 1220 | * |
| 1221 | * @return WindowManager.LayoutParams Either the existing window |
| 1222 | * attributes object, or a freshly created one if there is none. |
| 1223 | */ |
| 1224 | public final WindowManager.LayoutParams getAttributes() { |
| 1225 | return mWindowAttributes; |
| 1226 | } |
| 1227 | |
| 1228 | /** |
| 1229 | * Return the window flags that have been explicitly set by the client, |
| 1230 | * so will not be modified by {@link #getDecorView}. |
| 1231 | */ |
| 1232 | protected final int getForcedWindowFlags() { |
| 1233 | return mForcedWindowFlags; |
| 1234 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1235 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1236 | /** |
| 1237 | * Has the app specified their own soft input mode? |
| 1238 | */ |
| 1239 | protected final boolean hasSoftInputMode() { |
| 1240 | return mHasSoftInputMode; |
| 1241 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1242 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1243 | /** @hide */ |
| 1244 | public void setCloseOnTouchOutside(boolean close) { |
| 1245 | mCloseOnTouchOutside = close; |
| 1246 | mSetCloseOnTouchOutside = true; |
| 1247 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1248 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1249 | /** @hide */ |
Dianne Hackborn | ef57575 | 2011-01-18 17:35:17 -0800 | [diff] [blame] | 1250 | public void setCloseOnTouchOutsideIfNotSet(boolean close) { |
| 1251 | if (!mSetCloseOnTouchOutside) { |
| 1252 | mCloseOnTouchOutside = close; |
| 1253 | mSetCloseOnTouchOutside = true; |
| 1254 | } |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1255 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1256 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1257 | /** @hide */ |
Filip Gruszczynski | fe56835 | 2015-01-05 10:41:29 -0800 | [diff] [blame] | 1258 | @SystemApi |
| 1259 | public void setDisableWallpaperTouchEvents(boolean disable) { |
| 1260 | setPrivateFlags(disable |
| 1261 | ? WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS : 0, |
| 1262 | WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS); |
| 1263 | } |
| 1264 | |
| 1265 | /** @hide */ |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1266 | public abstract void alwaysReadCloseOnTouchAttr(); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1267 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1268 | /** @hide */ |
| 1269 | public boolean shouldCloseOnTouch(Context context, MotionEvent event) { |
Michael Wright | ddec8fb | 2017-06-16 18:36:26 +0100 | [diff] [blame] | 1270 | final boolean isOutside = |
| 1271 | event.getAction() == MotionEvent.ACTION_DOWN && isOutOfBounds(context, event) |
| 1272 | || event.getAction() == MotionEvent.ACTION_OUTSIDE; |
| 1273 | if (mCloseOnTouchOutside && peekDecorView() != null && isOutside) { |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1274 | return true; |
| 1275 | } |
| 1276 | return false; |
| 1277 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1278 | |
Ruchi Kandoi | 43e38de | 2016-04-14 19:34:53 -0700 | [diff] [blame] | 1279 | /* Sets the Sustained Performance requirement for the calling window. |
| 1280 | * @param enable disables or enables the mode. |
| 1281 | */ |
| 1282 | public void setSustainedPerformanceMode(boolean enable) { |
| 1283 | setPrivateFlags(enable |
| 1284 | ? WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE : 0, |
| 1285 | WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE); |
| 1286 | } |
| 1287 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1288 | private boolean isOutOfBounds(Context context, MotionEvent event) { |
| 1289 | final int x = (int) event.getX(); |
| 1290 | final int y = (int) event.getY(); |
| 1291 | final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop(); |
| 1292 | final View decorView = getDecorView(); |
| 1293 | return (x < -slop) || (y < -slop) |
| 1294 | || (x > (decorView.getWidth()+slop)) |
| 1295 | || (y > (decorView.getHeight()+slop)); |
| 1296 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1297 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1298 | /** |
| 1299 | * Enable extended screen features. This must be called before |
| 1300 | * setContentView(). May be called as many times as desired as long as it |
| 1301 | * is before setContentView(). If not called, no extended features |
| 1302 | * will be available. You can not turn off a feature once it is requested. |
| 1303 | * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}. |
| 1304 | * |
| 1305 | * @param featureId The desired features, defined as constants by Window. |
| 1306 | * @return The features that are now set. |
| 1307 | */ |
| 1308 | public boolean requestFeature(int featureId) { |
| 1309 | final int flag = 1<<featureId; |
| 1310 | mFeatures |= flag; |
| 1311 | mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag; |
| 1312 | return (mFeatures&flag) != 0; |
| 1313 | } |
| 1314 | |
Adam Powell | f4a6ec4 | 2010-08-24 14:18:10 -0700 | [diff] [blame] | 1315 | /** |
| 1316 | * @hide Used internally to help resolve conflicting features. |
| 1317 | */ |
| 1318 | protected void removeFeature(int featureId) { |
| 1319 | final int flag = 1<<featureId; |
| 1320 | mFeatures &= ~flag; |
| 1321 | mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag); |
| 1322 | } |
| 1323 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1324 | public final void makeActive() { |
| 1325 | if (mContainer != null) { |
| 1326 | if (mContainer.mActiveChild != null) { |
| 1327 | mContainer.mActiveChild.mIsActive = false; |
| 1328 | } |
| 1329 | mContainer.mActiveChild = this; |
| 1330 | } |
| 1331 | mIsActive = true; |
| 1332 | onActive(); |
| 1333 | } |
| 1334 | |
| 1335 | public final boolean isActive() |
| 1336 | { |
| 1337 | return mIsActive; |
| 1338 | } |
| 1339 | |
| 1340 | /** |
Alan Viverette | db7423c | 2017-03-31 13:13:58 -0400 | [diff] [blame] | 1341 | * Finds a view that was identified by the {@code android:id} XML attribute |
Chris Craik | 6faa9e5 | 2018-01-11 10:46:10 -0800 | [diff] [blame] | 1342 | * that was processed in {@link android.app.Activity#onCreate}. |
| 1343 | * <p> |
| 1344 | * This will implicitly call {@link #getDecorView} with all of the associated side-effects. |
Alan Viverette | db7423c | 2017-03-31 13:13:58 -0400 | [diff] [blame] | 1345 | * <p> |
| 1346 | * <strong>Note:</strong> In most cases -- depending on compiler support -- |
| 1347 | * the resulting view is automatically cast to the target class type. If |
| 1348 | * the target class type is unconstrained, an explicit cast may be |
| 1349 | * necessary. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1350 | * |
Alan Viverette | db7423c | 2017-03-31 13:13:58 -0400 | [diff] [blame] | 1351 | * @param id the ID to search for |
| 1352 | * @return a view with given ID if found, or {@code null} otherwise |
| 1353 | * @see View#findViewById(int) |
Chris Craik | 6faa9e5 | 2018-01-11 10:46:10 -0800 | [diff] [blame] | 1354 | * @see Window#requireViewById(int) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1355 | */ |
Scott Kennedy | c051955 | 2015-02-11 15:33:10 -0800 | [diff] [blame] | 1356 | @Nullable |
Alan Viverette | db7423c | 2017-03-31 13:13:58 -0400 | [diff] [blame] | 1357 | public <T extends View> T findViewById(@IdRes int id) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1358 | return getDecorView().findViewById(id); |
| 1359 | } |
Chris Craik | 6faa9e5 | 2018-01-11 10:46:10 -0800 | [diff] [blame] | 1360 | /** |
| 1361 | * Finds a view that was identified by the {@code android:id} XML attribute |
| 1362 | * that was processed in {@link android.app.Activity#onCreate}, or throws an |
| 1363 | * IllegalArgumentException if the ID is invalid, or there is no matching view in the hierarchy. |
| 1364 | * <p> |
| 1365 | * <strong>Note:</strong> In most cases -- depending on compiler support -- |
| 1366 | * the resulting view is automatically cast to the target class type. If |
| 1367 | * the target class type is unconstrained, an explicit cast may be |
| 1368 | * necessary. |
| 1369 | * |
| 1370 | * @param id the ID to search for |
| 1371 | * @return a view with given ID |
| 1372 | * @see View#requireViewById(int) |
| 1373 | * @see Window#findViewById(int) |
| 1374 | */ |
| 1375 | @NonNull |
| 1376 | public final <T extends View> T requireViewById(@IdRes int id) { |
| 1377 | T view = findViewById(id); |
| 1378 | if (view == null) { |
| 1379 | throw new IllegalArgumentException("ID does not reference a View inside this Window"); |
| 1380 | } |
| 1381 | return view; |
| 1382 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1383 | |
| 1384 | /** |
| 1385 | * Convenience for |
| 1386 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} |
| 1387 | * to set the screen content from a layout resource. The resource will be |
| 1388 | * inflated, adding all top-level views to the screen. |
| 1389 | * |
| 1390 | * @param layoutResID Resource ID to be inflated. |
| 1391 | * @see #setContentView(View, android.view.ViewGroup.LayoutParams) |
| 1392 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1393 | public abstract void setContentView(@LayoutRes int layoutResID); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1394 | |
| 1395 | /** |
| 1396 | * Convenience for |
| 1397 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} |
| 1398 | * set the screen content to an explicit view. This view is placed |
| 1399 | * directly into the screen's view hierarchy. It can itself be a complex |
| 1400 | * view hierarhcy. |
| 1401 | * |
| 1402 | * @param view The desired content to display. |
| 1403 | * @see #setContentView(View, android.view.ViewGroup.LayoutParams) |
| 1404 | */ |
| 1405 | public abstract void setContentView(View view); |
| 1406 | |
| 1407 | /** |
| 1408 | * Set the screen content to an explicit view. This view is placed |
| 1409 | * directly into the screen's view hierarchy. It can itself be a complex |
| 1410 | * view hierarchy. |
| 1411 | * |
| 1412 | * <p>Note that calling this function "locks in" various characteristics |
| 1413 | * of the window that can not, from this point forward, be changed: the |
| 1414 | * features that have been requested with {@link #requestFeature(int)}, |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 1415 | * and certain window flags as described in {@link #setFlags(int, int)}.</p> |
| 1416 | * |
| 1417 | * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's |
| 1418 | * TransitionManager will be used to animate content from the current |
| 1419 | * content View to view.</p> |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1420 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1421 | * @param view The desired content to display. |
| 1422 | * @param params Layout parameters for the view. |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 1423 | * @see #getTransitionManager() |
| 1424 | * @see #setTransitionManager(android.transition.TransitionManager) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1425 | */ |
| 1426 | public abstract void setContentView(View view, ViewGroup.LayoutParams params); |
| 1427 | |
| 1428 | /** |
| 1429 | * Variation on |
| 1430 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} |
| 1431 | * to add an additional content view to the screen. Added after any existing |
| 1432 | * ones in the screen -- existing views are NOT removed. |
| 1433 | * |
| 1434 | * @param view The desired content to display. |
| 1435 | * @param params Layout parameters for the view. |
| 1436 | */ |
| 1437 | public abstract void addContentView(View view, ViewGroup.LayoutParams params); |
| 1438 | |
| 1439 | /** |
Filip Gruszczynski | a59ac9c | 2015-09-10 18:28:48 -0700 | [diff] [blame] | 1440 | * Remove the view that was used as the screen content. |
| 1441 | * |
| 1442 | * @hide |
| 1443 | */ |
| 1444 | public abstract void clearContentView(); |
| 1445 | |
| 1446 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1447 | * Return the view in this Window that currently has focus, or null if |
| 1448 | * there are none. Note that this does not look in any containing |
| 1449 | * Window. |
| 1450 | * |
| 1451 | * @return View The current View with focus or null. |
| 1452 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1453 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1454 | public abstract View getCurrentFocus(); |
| 1455 | |
| 1456 | /** |
| 1457 | * Quick access to the {@link LayoutInflater} instance that this Window |
| 1458 | * retrieved from its Context. |
| 1459 | * |
| 1460 | * @return LayoutInflater The shared LayoutInflater. |
| 1461 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1462 | @NonNull |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1463 | public abstract LayoutInflater getLayoutInflater(); |
| 1464 | |
| 1465 | public abstract void setTitle(CharSequence title); |
| 1466 | |
Alan Viverette | 2525d9c | 2013-11-15 14:42:19 -0800 | [diff] [blame] | 1467 | @Deprecated |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 1468 | public abstract void setTitleColor(@ColorInt int textColor); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1469 | |
| 1470 | public abstract void openPanel(int featureId, KeyEvent event); |
| 1471 | |
| 1472 | public abstract void closePanel(int featureId); |
| 1473 | |
| 1474 | public abstract void togglePanel(int featureId, KeyEvent event); |
| 1475 | |
Dianne Hackborn | b31e84bc | 2010-06-08 18:04:35 -0700 | [diff] [blame] | 1476 | public abstract void invalidatePanelMenu(int featureId); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1477 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1478 | public abstract boolean performPanelShortcut(int featureId, |
| 1479 | int keyCode, |
| 1480 | KeyEvent event, |
| 1481 | int flags); |
| 1482 | public abstract boolean performPanelIdentifierAction(int featureId, |
| 1483 | int id, |
| 1484 | int flags); |
| 1485 | |
| 1486 | public abstract void closeAllPanels(); |
| 1487 | |
| 1488 | public abstract boolean performContextMenuIdentifierAction(int id, int flags); |
| 1489 | |
| 1490 | /** |
| 1491 | * Should be called when the configuration is changed. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1492 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1493 | * @param newConfig The new configuration. |
| 1494 | */ |
| 1495 | public abstract void onConfigurationChanged(Configuration newConfig); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1496 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1497 | /** |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1498 | * Sets the window elevation. |
Alan Viverette | 71922de | 2015-01-12 16:14:02 -0800 | [diff] [blame] | 1499 | * <p> |
| 1500 | * Changes to this property take effect immediately and will cause the |
| 1501 | * window surface to be recreated. This is an expensive operation and as a |
| 1502 | * result, this property should not be animated. |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1503 | * |
| 1504 | * @param elevation The window elevation. |
| 1505 | * @see View#setElevation(float) |
| 1506 | * @see android.R.styleable#Window_windowElevation |
| 1507 | */ |
| 1508 | public void setElevation(float elevation) {} |
| 1509 | |
| 1510 | /** |
Filip Gruszczynski | a59ac9c | 2015-09-10 18:28:48 -0700 | [diff] [blame] | 1511 | * Gets the window elevation. |
| 1512 | * |
| 1513 | * @hide |
| 1514 | */ |
| 1515 | public float getElevation() { |
| 1516 | return 0.0f; |
| 1517 | } |
| 1518 | |
| 1519 | /** |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1520 | * Sets whether window content should be clipped to the outline of the |
| 1521 | * window background. |
| 1522 | * |
| 1523 | * @param clipToOutline Whether window content should be clipped to the |
| 1524 | * outline of the window background. |
| 1525 | * @see View#setClipToOutline(boolean) |
| 1526 | * @see android.R.styleable#Window_windowClipToOutline |
| 1527 | */ |
| 1528 | public void setClipToOutline(boolean clipToOutline) {} |
| 1529 | |
| 1530 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1531 | * Change the background of this window to a Drawable resource. Setting the |
| 1532 | * background to null will make the window be opaque. To make the window |
| 1533 | * transparent, you can use an empty drawable (for instance a ColorDrawable |
| 1534 | * with the color 0 or the system drawable android:drawable/empty.) |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1535 | * |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1536 | * @param resId The resource identifier of a drawable resource which will |
| 1537 | * be installed as the new background. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1538 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1539 | public void setBackgroundDrawableResource(@DrawableRes int resId) { |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1540 | setBackgroundDrawable(mContext.getDrawable(resId)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1541 | } |
| 1542 | |
| 1543 | /** |
| 1544 | * Change the background of this window to a custom Drawable. Setting the |
| 1545 | * background to null will make the window be opaque. To make the window |
| 1546 | * transparent, you can use an empty drawable (for instance a ColorDrawable |
| 1547 | * with the color 0 or the system drawable android:drawable/empty.) |
| 1548 | * |
| 1549 | * @param drawable The new Drawable to use for this window's background. |
| 1550 | */ |
| 1551 | public abstract void setBackgroundDrawable(Drawable drawable); |
| 1552 | |
| 1553 | /** |
| 1554 | * Set the value for a drawable feature of this window, from a resource |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1555 | * identifier. You must have called requestFeature(featureId) before |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1556 | * calling this function. |
| 1557 | * |
| 1558 | * @see android.content.res.Resources#getDrawable(int) |
| 1559 | * |
| 1560 | * @param featureId The desired drawable feature to change, defined as a |
| 1561 | * constant by Window. |
| 1562 | * @param resId Resource identifier of the desired image. |
| 1563 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1564 | public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1565 | |
| 1566 | /** |
| 1567 | * Set the value for a drawable feature of this window, from a URI. You |
| 1568 | * must have called requestFeature(featureId) before calling this |
| 1569 | * function. |
| 1570 | * |
| 1571 | * <p>The only URI currently supported is "content:", specifying an image |
| 1572 | * in a content provider. |
| 1573 | * |
| 1574 | * @see android.widget.ImageView#setImageURI |
| 1575 | * |
| 1576 | * @param featureId The desired drawable feature to change. Features are |
| 1577 | * constants defined by Window. |
| 1578 | * @param uri The desired URI. |
| 1579 | */ |
| 1580 | public abstract void setFeatureDrawableUri(int featureId, Uri uri); |
| 1581 | |
| 1582 | /** |
| 1583 | * Set an explicit Drawable value for feature of this window. You must |
| 1584 | * have called requestFeature(featureId) before calling this function. |
| 1585 | * |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1586 | * @param featureId The desired drawable feature to change. Features are |
| 1587 | * constants defined by Window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1588 | * @param drawable A Drawable object to display. |
| 1589 | */ |
| 1590 | public abstract void setFeatureDrawable(int featureId, Drawable drawable); |
| 1591 | |
| 1592 | /** |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1593 | * Set a custom alpha value for the given drawable feature, controlling how |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1594 | * much the background is visible through it. |
| 1595 | * |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1596 | * @param featureId The desired drawable feature to change. Features are |
| 1597 | * constants defined by Window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1598 | * @param alpha The alpha amount, 0 is completely transparent and 255 is |
| 1599 | * completely opaque. |
| 1600 | */ |
| 1601 | public abstract void setFeatureDrawableAlpha(int featureId, int alpha); |
| 1602 | |
| 1603 | /** |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1604 | * Set the integer value for a feature. The range of the value depends on |
| 1605 | * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from |
| 1606 | * 0 to 10000. At 10000 the progress is complete and the indicator hidden. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1607 | * |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1608 | * @param featureId The desired feature to change. Features are constants |
| 1609 | * defined by Window. |
| 1610 | * @param value The value for the feature. The interpretation of this |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1611 | * value is feature-specific. |
| 1612 | */ |
| 1613 | public abstract void setFeatureInt(int featureId, int value); |
| 1614 | |
| 1615 | /** |
| 1616 | * Request that key events come to this activity. Use this if your |
| 1617 | * activity has no views with focus, but the activity still wants |
| 1618 | * a chance to process key events. |
| 1619 | */ |
| 1620 | public abstract void takeKeyEvents(boolean get); |
| 1621 | |
| 1622 | /** |
| 1623 | * Used by custom windows, such as Dialog, to pass the key press event |
| 1624 | * further down the view hierarchy. Application developers should |
| 1625 | * not need to implement or call this. |
| 1626 | * |
| 1627 | */ |
| 1628 | public abstract boolean superDispatchKeyEvent(KeyEvent event); |
| 1629 | |
| 1630 | /** |
Jeff Brown | 64da12a | 2011-01-04 19:57:47 -0800 | [diff] [blame] | 1631 | * Used by custom windows, such as Dialog, to pass the key shortcut press event |
| 1632 | * further down the view hierarchy. Application developers should |
| 1633 | * not need to implement or call this. |
| 1634 | * |
| 1635 | */ |
| 1636 | public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event); |
| 1637 | |
| 1638 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1639 | * Used by custom windows, such as Dialog, to pass the touch screen event |
| 1640 | * further down the view hierarchy. Application developers should |
| 1641 | * not need to implement or call this. |
| 1642 | * |
| 1643 | */ |
| 1644 | public abstract boolean superDispatchTouchEvent(MotionEvent event); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1645 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1646 | /** |
| 1647 | * Used by custom windows, such as Dialog, to pass the trackball event |
| 1648 | * further down the view hierarchy. Application developers should |
| 1649 | * not need to implement or call this. |
| 1650 | * |
| 1651 | */ |
| 1652 | public abstract boolean superDispatchTrackballEvent(MotionEvent event); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1653 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1654 | /** |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1655 | * Used by custom windows, such as Dialog, to pass the generic motion event |
| 1656 | * further down the view hierarchy. Application developers should |
| 1657 | * not need to implement or call this. |
| 1658 | * |
| 1659 | */ |
| 1660 | public abstract boolean superDispatchGenericMotionEvent(MotionEvent event); |
| 1661 | |
| 1662 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1663 | * Retrieve the top-level window decor view (containing the standard |
| 1664 | * window frame/decorations and the client's content inside of that), which |
| 1665 | * can be added as a window to the window manager. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1666 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1667 | * <p><em>Note that calling this function for the first time "locks in" |
| 1668 | * various window characteristics as described in |
| 1669 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p> |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1670 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1671 | * @return Returns the top-level window decor view. |
| 1672 | */ |
| 1673 | public abstract View getDecorView(); |
| 1674 | |
| 1675 | /** |
| 1676 | * Retrieve the current decor view, but only if it has already been created; |
| 1677 | * otherwise returns null. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1678 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1679 | * @return Returns the top-level window decor or null. |
| 1680 | * @see #getDecorView |
| 1681 | */ |
| 1682 | public abstract View peekDecorView(); |
| 1683 | |
| 1684 | public abstract Bundle saveHierarchyState(); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1685 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1686 | public abstract void restoreHierarchyState(Bundle savedInstanceState); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1687 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1688 | protected abstract void onActive(); |
| 1689 | |
| 1690 | /** |
| 1691 | * Return the feature bits that are enabled. This is the set of features |
| 1692 | * that were given to requestFeature(), and are being handled by this |
| 1693 | * Window itself or its container. That is, it is the set of |
| 1694 | * requested features that you can actually use. |
| 1695 | * |
| 1696 | * <p>To do: add a public version of this API that allows you to check for |
| 1697 | * features by their feature ID. |
| 1698 | * |
| 1699 | * @return int The feature bits. |
| 1700 | */ |
| 1701 | protected final int getFeatures() |
| 1702 | { |
| 1703 | return mFeatures; |
| 1704 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1705 | |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1706 | /** |
Bryce Lee | d6e6e72 | 2014-11-21 11:08:45 -0800 | [diff] [blame] | 1707 | * Return the feature bits set by default on a window. |
| 1708 | * @param context The context used to access resources |
| 1709 | */ |
| 1710 | public static int getDefaultFeatures(Context context) { |
| 1711 | int features = 0; |
| 1712 | |
| 1713 | final Resources res = context.getResources(); |
| 1714 | if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) { |
| 1715 | features |= 1 << FEATURE_OPTIONS_PANEL; |
| 1716 | } |
| 1717 | |
| 1718 | if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) { |
| 1719 | features |= 1 << FEATURE_CONTEXT_MENU; |
| 1720 | } |
| 1721 | |
| 1722 | return features; |
| 1723 | } |
| 1724 | |
| 1725 | /** |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1726 | * Query for the availability of a certain feature. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1727 | * |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1728 | * @param feature The feature ID to check |
| 1729 | * @return true if the feature is enabled, false otherwise. |
| 1730 | */ |
| 1731 | public boolean hasFeature(int feature) { |
| 1732 | return (getFeatures() & (1 << feature)) != 0; |
| 1733 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1734 | |
| 1735 | /** |
| 1736 | * Return the feature bits that are being implemented by this Window. |
| 1737 | * This is the set of features that were given to requestFeature(), and are |
| 1738 | * being handled by only this Window itself, not by its containers. |
| 1739 | * |
| 1740 | * @return int The feature bits. |
| 1741 | */ |
| 1742 | protected final int getLocalFeatures() |
| 1743 | { |
| 1744 | return mLocalFeatures; |
| 1745 | } |
| 1746 | |
| 1747 | /** |
| 1748 | * Set the default format of window, as per the PixelFormat types. This |
| 1749 | * is the format that will be used unless the client specifies in explicit |
| 1750 | * format with setFormat(); |
| 1751 | * |
| 1752 | * @param format The new window format (see PixelFormat). |
| 1753 | * |
| 1754 | * @see #setFormat |
| 1755 | * @see PixelFormat |
| 1756 | */ |
| 1757 | protected void setDefaultWindowFormat(int format) { |
| 1758 | mDefaultWindowFormat = format; |
| 1759 | if (!mHaveWindowFormat) { |
| 1760 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1761 | attrs.format = format; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1762 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1763 | } |
| 1764 | } |
| 1765 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1766 | /** @hide */ |
| 1767 | protected boolean haveDimAmount() { |
| 1768 | return mHaveDimAmount; |
| 1769 | } |
| 1770 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1771 | public abstract void setChildDrawable(int featureId, Drawable drawable); |
| 1772 | |
| 1773 | public abstract void setChildInt(int featureId, int value); |
| 1774 | |
| 1775 | /** |
| 1776 | * Is a keypress one of the defined shortcut keys for this window. |
| 1777 | * @param keyCode the key code from {@link android.view.KeyEvent} to check. |
| 1778 | * @param event the {@link android.view.KeyEvent} to use to help check. |
| 1779 | */ |
| 1780 | public abstract boolean isShortcutKey(int keyCode, KeyEvent event); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1781 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1782 | /** |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1783 | * @see android.app.Activity#setVolumeControlStream(int) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1784 | */ |
| 1785 | public abstract void setVolumeControlStream(int streamType); |
| 1786 | |
| 1787 | /** |
| 1788 | * @see android.app.Activity#getVolumeControlStream() |
| 1789 | */ |
| 1790 | public abstract int getVolumeControlStream(); |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 1791 | |
| 1792 | /** |
RoboErik | fd63dd0 | 2014-08-28 15:22:55 -0700 | [diff] [blame] | 1793 | * Sets a {@link MediaController} to send media keys and volume changes to. |
| 1794 | * If set, this should be preferred for all media keys and volume requests |
| 1795 | * sent to this window. |
| 1796 | * |
| 1797 | * @param controller The controller for the session which should receive |
| 1798 | * media keys and volume changes. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1799 | * @see android.app.Activity#setMediaController(android.media.session.MediaController) |
| 1800 | */ |
| 1801 | public void setMediaController(MediaController controller) { |
| 1802 | } |
| 1803 | |
| 1804 | /** |
RoboErik | fd63dd0 | 2014-08-28 15:22:55 -0700 | [diff] [blame] | 1805 | * Gets the {@link MediaController} that was previously set. |
| 1806 | * |
| 1807 | * @return The controller which should receive events. |
| 1808 | * @see #setMediaController(android.media.session.MediaController) |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1809 | * @see android.app.Activity#getMediaController() |
| 1810 | */ |
| 1811 | public MediaController getMediaController() { |
| 1812 | return null; |
| 1813 | } |
| 1814 | |
| 1815 | /** |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 1816 | * Set extra options that will influence the UI for this window. |
| 1817 | * @param uiOptions Flags specifying extra options for this window. |
| 1818 | */ |
| 1819 | public void setUiOptions(int uiOptions) { } |
Adam Powell | e43fca9 | 2011-08-16 12:57:01 -0700 | [diff] [blame] | 1820 | |
| 1821 | /** |
| 1822 | * Set extra options that will influence the UI for this window. |
| 1823 | * Only the bits filtered by mask will be modified. |
| 1824 | * @param uiOptions Flags specifying extra options for this window. |
| 1825 | * @param mask Flags specifying which options should be modified. Others will remain unchanged. |
| 1826 | */ |
| 1827 | public void setUiOptions(int uiOptions, int mask) { } |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1828 | |
| 1829 | /** |
| 1830 | * Set the primary icon for this window. |
| 1831 | * |
| 1832 | * @param resId resource ID of a drawable to set |
| 1833 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1834 | public void setIcon(@DrawableRes int resId) { } |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1835 | |
| 1836 | /** |
| 1837 | * Set the default icon for this window. |
| 1838 | * This will be overridden by any other icon set operation which could come from the |
| 1839 | * theme or another explicit set. |
| 1840 | * |
| 1841 | * @hide |
| 1842 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1843 | public void setDefaultIcon(@DrawableRes int resId) { } |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1844 | |
| 1845 | /** |
| 1846 | * Set the logo for this window. A logo is often shown in place of an |
| 1847 | * {@link #setIcon(int) icon} but is generally wider and communicates window title information |
| 1848 | * as well. |
| 1849 | * |
| 1850 | * @param resId resource ID of a drawable to set |
| 1851 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1852 | public void setLogo(@DrawableRes int resId) { } |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1853 | |
| 1854 | /** |
| 1855 | * Set the default logo for this window. |
| 1856 | * This will be overridden by any other logo set operation which could come from the |
| 1857 | * theme or another explicit set. |
| 1858 | * |
| 1859 | * @hide |
| 1860 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1861 | public void setDefaultLogo(@DrawableRes int resId) { } |
keunyoung | 30f420f | 2013-08-02 14:23:10 -0700 | [diff] [blame] | 1862 | |
| 1863 | /** |
| 1864 | * Set focus locally. The window should have the |
| 1865 | * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already. |
| 1866 | * @param hasFocus Whether this window has focus or not. |
| 1867 | * @param inTouchMode Whether this window is in touch mode or not. |
| 1868 | */ |
| 1869 | public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { } |
| 1870 | |
| 1871 | /** |
| 1872 | * Inject an event to window locally. |
| 1873 | * @param event A key or touch event to inject to this window. |
| 1874 | */ |
| 1875 | public void injectInputEvent(InputEvent event) { } |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1876 | |
| 1877 | /** |
| 1878 | * Retrieve the {@link TransitionManager} responsible for for default transitions |
| 1879 | * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}. |
| 1880 | * |
| 1881 | * <p>This method will return non-null after content has been initialized (e.g. by using |
| 1882 | * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p> |
| 1883 | * |
| 1884 | * @return This window's content TransitionManager or null if none is set. |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 1885 | * @attr ref android.R.styleable#Window_windowContentTransitionManager |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1886 | */ |
| 1887 | public TransitionManager getTransitionManager() { |
| 1888 | return null; |
| 1889 | } |
| 1890 | |
| 1891 | /** |
| 1892 | * Set the {@link TransitionManager} to use for default transitions in this window. |
| 1893 | * Requires {@link #FEATURE_CONTENT_TRANSITIONS}. |
| 1894 | * |
| 1895 | * @param tm The TransitionManager to use for scene changes. |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 1896 | * @attr ref android.R.styleable#Window_windowContentTransitionManager |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1897 | */ |
| 1898 | public void setTransitionManager(TransitionManager tm) { |
| 1899 | throw new UnsupportedOperationException(); |
| 1900 | } |
| 1901 | |
| 1902 | /** |
| 1903 | * Retrieve the {@link Scene} representing this window's current content. |
| 1904 | * Requires {@link #FEATURE_CONTENT_TRANSITIONS}. |
| 1905 | * |
| 1906 | * <p>This method will return null if the current content is not represented by a Scene.</p> |
| 1907 | * |
| 1908 | * @return Current Scene being shown or null |
| 1909 | */ |
| 1910 | public Scene getContentScene() { |
| 1911 | return null; |
| 1912 | } |
| 1913 | |
| 1914 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1915 | * Sets the Transition that will be used to move Views into the initial scene. The entering |
| 1916 | * Views will be those that are regular Views or ViewGroups that have |
| 1917 | * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1918 | * {@link android.transition.Visibility} as entering is governed by changing visibility from |
| 1919 | * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null, |
| 1920 | * entering Views will remain unaffected. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1921 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1922 | * @param transition The Transition to use to move Views into the initial Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1923 | * @attr ref android.R.styleable#Window_windowEnterTransition |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1924 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1925 | public void setEnterTransition(Transition transition) {} |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1926 | |
| 1927 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1928 | * Sets the Transition that will be used to move Views out of the scene when the Window is |
| 1929 | * preparing to close, for example after a call to |
| 1930 | * {@link android.app.Activity#finishAfterTransition()}. The exiting |
| 1931 | * Views will be those that are regular Views or ViewGroups that have |
| 1932 | * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1933 | * {@link android.transition.Visibility} as entering is governed by changing visibility from |
| 1934 | * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null, |
| 1935 | * entering Views will remain unaffected. If nothing is set, the default will be to |
| 1936 | * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1937 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1938 | * @param transition The Transition to use to move Views out of the Scene when the Window |
| 1939 | * is preparing to close. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1940 | * @attr ref android.R.styleable#Window_windowReturnTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1941 | */ |
| 1942 | public void setReturnTransition(Transition transition) {} |
| 1943 | |
| 1944 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1945 | * Sets the Transition that will be used to move Views out of the scene when starting a |
| 1946 | * new Activity. The exiting Views will be those that are regular Views or ViewGroups that |
| 1947 | * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1948 | * {@link android.transition.Visibility} as exiting is governed by changing visibility |
| 1949 | * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1950 | * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1951 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1952 | * @param transition The Transition to use to move Views out of the scene when calling a |
| 1953 | * new Activity. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1954 | * @attr ref android.R.styleable#Window_windowExitTransition |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1955 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1956 | public void setExitTransition(Transition transition) {} |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1957 | |
| 1958 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1959 | * Sets the Transition that will be used to move Views in to the scene when returning from |
| 1960 | * a previously-started Activity. The entering Views will be those that are regular Views |
| 1961 | * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions |
| 1962 | * will extend {@link android.transition.Visibility} as exiting is governed by changing |
| 1963 | * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, |
| 1964 | * the views will remain unaffected. If nothing is set, the default will be to use the same |
| 1965 | * transition as {@link #setExitTransition(android.transition.Transition)}. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1966 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1967 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1968 | * @param transition The Transition to use to move Views into the scene when reentering from a |
| 1969 | * previously-started Activity. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1970 | * @attr ref android.R.styleable#Window_windowReenterTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1971 | */ |
| 1972 | public void setReenterTransition(Transition transition) {} |
| 1973 | |
| 1974 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1975 | * Returns the transition used to move Views into the initial scene. The entering |
| 1976 | * Views will be those that are regular Views or ViewGroups that have |
| 1977 | * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1978 | * {@link android.transition.Visibility} as entering is governed by changing visibility from |
| 1979 | * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null, |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1980 | * entering Views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1981 | * |
| 1982 | * @return the Transition to use to move Views into the initial Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1983 | * @attr ref android.R.styleable#Window_windowEnterTransition |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1984 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1985 | public Transition getEnterTransition() { return null; } |
George Mount | cb4b7d9 | 2014-02-25 10:47:55 -0800 | [diff] [blame] | 1986 | |
| 1987 | /** |
Chet Haase | b64e777f | 2016-12-09 07:17:10 -0800 | [diff] [blame] | 1988 | * Returns the Transition that will be used to move Views out of the scene when the Window is |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1989 | * preparing to close, for example after a call to |
| 1990 | * {@link android.app.Activity#finishAfterTransition()}. The exiting |
| 1991 | * Views will be those that are regular Views or ViewGroups that have |
| 1992 | * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1993 | * {@link android.transition.Visibility} as entering is governed by changing visibility from |
| 1994 | * {@link View#VISIBLE} to {@link View#INVISIBLE}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1995 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1996 | * @return The Transition to use to move Views out of the Scene when the Window |
| 1997 | * is preparing to close. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1998 | * @attr ref android.R.styleable#Window_windowReturnTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1999 | */ |
| 2000 | public Transition getReturnTransition() { return null; } |
| 2001 | |
| 2002 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2003 | * Returns the Transition that will be used to move Views out of the scene when starting a |
| 2004 | * new Activity. The exiting Views will be those that are regular Views or ViewGroups that |
| 2005 | * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 2006 | * {@link android.transition.Visibility} as exiting is governed by changing visibility |
| 2007 | * from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2008 | * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2009 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2010 | * @return the Transition to use to move Views out of the scene when calling a |
| 2011 | * new Activity. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2012 | * @attr ref android.R.styleable#Window_windowExitTransition |
George Mount | cb4b7d9 | 2014-02-25 10:47:55 -0800 | [diff] [blame] | 2013 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2014 | public Transition getExitTransition() { return null; } |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 2015 | |
| 2016 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2017 | * Returns the Transition that will be used to move Views in to the scene when returning from |
| 2018 | * a previously-started Activity. The entering Views will be those that are regular Views |
| 2019 | * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions |
| 2020 | * will extend {@link android.transition.Visibility} as exiting is governed by changing |
| 2021 | * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2022 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2023 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2024 | * @return The Transition to use to move Views into the scene when reentering from a |
| 2025 | * previously-started Activity. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2026 | * @attr ref android.R.styleable#Window_windowReenterTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2027 | */ |
| 2028 | public Transition getReenterTransition() { return null; } |
| 2029 | |
| 2030 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2031 | * Sets the Transition that will be used for shared elements transferred into the content |
| 2032 | * Scene. Typical Transitions will affect size and location, such as |
George Mount | 990205e | 2014-06-24 09:36:18 -0700 | [diff] [blame] | 2033 | * {@link android.transition.ChangeBounds}. A null |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2034 | * value will cause transferred shared elements to blink to the final position. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2035 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2036 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2037 | * @param transition The Transition to use for shared elements transferred into the content |
| 2038 | * Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2039 | * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 2040 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2041 | public void setSharedElementEnterTransition(Transition transition) {} |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 2042 | |
| 2043 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2044 | * Sets the Transition that will be used for shared elements transferred back to a |
| 2045 | * calling Activity. Typical Transitions will affect size and location, such as |
| 2046 | * {@link android.transition.ChangeBounds}. A null |
| 2047 | * value will cause transferred shared elements to blink to the final position. |
| 2048 | * If no value is set, the default will be to use the same value as |
| 2049 | * {@link #setSharedElementEnterTransition(android.transition.Transition)}. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2050 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2051 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2052 | * @param transition The Transition to use for shared elements transferred out of the content |
| 2053 | * Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2054 | * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2055 | */ |
| 2056 | public void setSharedElementReturnTransition(Transition transition) {} |
| 2057 | |
| 2058 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2059 | * Returns the Transition that will be used for shared elements transferred into the content |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2060 | * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2061 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2062 | * @return Transition to use for sharend elements transferred into the content Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2063 | * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition |
George Mount | cb4b7d9 | 2014-02-25 10:47:55 -0800 | [diff] [blame] | 2064 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2065 | public Transition getSharedElementEnterTransition() { return null; } |
George Mount | cb4b7d9 | 2014-02-25 10:47:55 -0800 | [diff] [blame] | 2066 | |
| 2067 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2068 | * Returns the Transition that will be used for shared elements transferred back to a |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2069 | * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2070 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2071 | * @return Transition to use for sharend elements transferred into the content Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2072 | * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2073 | */ |
| 2074 | public Transition getSharedElementReturnTransition() { return null; } |
| 2075 | |
| 2076 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2077 | * Sets the Transition that will be used for shared elements after starting a new Activity |
| 2078 | * before the shared elements are transferred to the called Activity. If the shared elements |
| 2079 | * must animate during the exit transition, this Transition should be used. Upon completion, |
| 2080 | * the shared elements may be transferred to the started Activity. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2081 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2082 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2083 | * @param transition The Transition to use for shared elements in the launching Window |
| 2084 | * prior to transferring to the launched Activity's Window. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2085 | * @attr ref android.R.styleable#Window_windowSharedElementExitTransition |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 2086 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2087 | public void setSharedElementExitTransition(Transition transition) {} |
| 2088 | |
| 2089 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2090 | * Sets the Transition that will be used for shared elements reentering from a started |
| 2091 | * Activity after it has returned the shared element to it start location. If no value |
| 2092 | * is set, this will default to |
| 2093 | * {@link #setSharedElementExitTransition(android.transition.Transition)}. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2094 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2095 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2096 | * @param transition The Transition to use for shared elements in the launching Window |
| 2097 | * after the shared element has returned to the Window. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2098 | * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2099 | */ |
| 2100 | public void setSharedElementReenterTransition(Transition transition) {} |
| 2101 | |
| 2102 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2103 | * Returns the Transition to use for shared elements in the launching Window prior |
| 2104 | * to transferring to the launched Activity's Window. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2105 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2106 | * |
| 2107 | * @return the Transition to use for shared elements in the launching Window prior |
| 2108 | * to transferring to the launched Activity's Window. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2109 | * @attr ref android.R.styleable#Window_windowSharedElementExitTransition |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2110 | */ |
| 2111 | public Transition getSharedElementExitTransition() { return null; } |
| 2112 | |
| 2113 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2114 | * Returns the Transition that will be used for shared elements reentering from a started |
| 2115 | * Activity after it has returned the shared element to it start location. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2116 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2117 | * |
| 2118 | * @return the Transition that will be used for shared elements reentering from a started |
| 2119 | * Activity after it has returned the shared element to it start location. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2120 | * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 2121 | */ |
| 2122 | public Transition getSharedElementReenterTransition() { return null; } |
| 2123 | |
| 2124 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2125 | * Controls how the transition set in |
| 2126 | * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit |
| 2127 | * transition of the calling Activity. When true, the transition will start as soon as possible. |
| 2128 | * When false, the transition will wait until the remote exiting transition completes before |
George Mount | 5d52d31 | 2016-06-10 14:16:45 -0700 | [diff] [blame] | 2129 | * starting. The default value is true. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2130 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2131 | * @param allow true to start the enter transition when possible or false to |
| 2132 | * wait until the exiting transition completes. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2133 | * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2134 | */ |
| 2135 | public void setAllowEnterTransitionOverlap(boolean allow) {} |
| 2136 | |
| 2137 | /** |
| 2138 | * Returns how the transition set in |
| 2139 | * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit |
| 2140 | * transition of the calling Activity. When true, the transition will start as soon as possible. |
| 2141 | * When false, the transition will wait until the remote exiting transition completes before |
George Mount | 5d52d31 | 2016-06-10 14:16:45 -0700 | [diff] [blame] | 2142 | * starting. The default value is true. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2143 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2144 | * @return true when the enter transition should start as soon as possible or false to |
| 2145 | * when it should wait until the exiting transition completes. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2146 | * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2147 | */ |
| 2148 | public boolean getAllowEnterTransitionOverlap() { return true; } |
| 2149 | |
| 2150 | /** |
| 2151 | * Controls how the transition set in |
| 2152 | * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit |
| 2153 | * transition of the called Activity when reentering after if finishes. When true, |
| 2154 | * the transition will start as soon as possible. When false, the transition will wait |
| 2155 | * until the called Activity's exiting transition completes before starting. |
George Mount | 5d52d31 | 2016-06-10 14:16:45 -0700 | [diff] [blame] | 2156 | * The default value is true. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2157 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2158 | * @param allow true to start the transition when possible or false to wait until the |
| 2159 | * called Activity's exiting transition completes. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2160 | * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2161 | */ |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2162 | public void setAllowReturnTransitionOverlap(boolean allow) {} |
| 2163 | |
| 2164 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2165 | * Returns how the transition set in |
| 2166 | * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit |
| 2167 | * transition of the called Activity when reentering after if finishes. When true, |
| 2168 | * the transition will start as soon as possible. When false, the transition will wait |
| 2169 | * until the called Activity's exiting transition completes before starting. |
George Mount | 5d52d31 | 2016-06-10 14:16:45 -0700 | [diff] [blame] | 2170 | * The default value is true. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2171 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2172 | * @return true when the transition should start when possible or false when it should wait |
| 2173 | * until the called Activity's exiting transition completes. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2174 | * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2175 | */ |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2176 | public boolean getAllowReturnTransitionOverlap() { return true; } |
| 2177 | |
| 2178 | /** |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2179 | * Returns the duration, in milliseconds, of the window background fade |
| 2180 | * when transitioning into or away from an Activity when called with an Activity Transition. |
| 2181 | * <p>When executing the enter transition, the background starts transparent |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2182 | * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2183 | * 300 milliseconds.</p> |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2184 | * |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2185 | * @return The duration of the window background fade to opaque during enter transition. |
| 2186 | * @see #getEnterTransition() |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2187 | * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2188 | */ |
| 2189 | public long getTransitionBackgroundFadeDuration() { return 0; } |
| 2190 | |
| 2191 | /** |
| 2192 | * Sets the duration, in milliseconds, of the window background fade |
| 2193 | * when transitioning into or away from an Activity when called with an Activity Transition. |
| 2194 | * <p>When executing the enter transition, the background starts transparent |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2195 | * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2196 | * 300 milliseconds.</p> |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2197 | * |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2198 | * @param fadeDurationMillis The duration of the window background fade to or from opaque |
| 2199 | * during enter transition. |
| 2200 | * @see #setEnterTransition(android.transition.Transition) |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2201 | * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2202 | */ |
| 2203 | public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { } |
| 2204 | |
| 2205 | /** |
George Mount | b89d5cc | 2014-08-18 16:50:50 -0700 | [diff] [blame] | 2206 | * Returns <code>true</code> when shared elements should use an Overlay during |
| 2207 | * shared element transitions or <code>false</code> when they should animate as |
| 2208 | * part of the normal View hierarchy. The default value is true. |
| 2209 | * |
| 2210 | * @return <code>true</code> when shared elements should use an Overlay during |
| 2211 | * shared element transitions or <code>false</code> when they should animate as |
| 2212 | * part of the normal View hierarchy. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2213 | * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay |
George Mount | b89d5cc | 2014-08-18 16:50:50 -0700 | [diff] [blame] | 2214 | */ |
| 2215 | public boolean getSharedElementsUseOverlay() { return true; } |
| 2216 | |
| 2217 | /** |
| 2218 | * Sets whether or not shared elements should use an Overlay during shared element transitions. |
| 2219 | * The default value is true. |
| 2220 | * |
| 2221 | * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should |
| 2222 | * be transitioned with an Overlay or <code>false</code> |
| 2223 | * to transition within the normal View hierarchy. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2224 | * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay |
George Mount | b89d5cc | 2014-08-18 16:50:50 -0700 | [diff] [blame] | 2225 | */ |
| 2226 | public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { } |
| 2227 | |
| 2228 | /** |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2229 | * @return the color of the status bar. |
| 2230 | */ |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 2231 | @ColorInt |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2232 | public abstract int getStatusBarColor(); |
| 2233 | |
| 2234 | /** |
John Spurlock | bc4cf00 | 2015-03-24 21:51:20 -0400 | [diff] [blame] | 2235 | * Sets the color of the status bar to {@code color}. |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2236 | * |
| 2237 | * For this to take effect, |
| 2238 | * the window must be drawing the system bar backgrounds with |
| 2239 | * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and |
| 2240 | * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set. |
| 2241 | * |
John Spurlock | bc4cf00 | 2015-03-24 21:51:20 -0400 | [diff] [blame] | 2242 | * If {@code color} is not opaque, consider setting |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2243 | * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and |
| 2244 | * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}. |
George Mount | 238010f | 2014-06-30 17:31:17 -0700 | [diff] [blame] | 2245 | * <p> |
| 2246 | * The transitionName for the view background will be "android:status:background". |
| 2247 | * </p> |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2248 | */ |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 2249 | public abstract void setStatusBarColor(@ColorInt int color); |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2250 | |
| 2251 | /** |
| 2252 | * @return the color of the navigation bar. |
| 2253 | */ |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 2254 | @ColorInt |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2255 | public abstract int getNavigationBarColor(); |
| 2256 | |
| 2257 | /** |
| 2258 | * Sets the color of the navigation bar to {@param color}. |
| 2259 | * |
| 2260 | * For this to take effect, |
| 2261 | * the window must be drawing the system bar backgrounds with |
| 2262 | * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and |
| 2263 | * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set. |
| 2264 | * |
| 2265 | * If {@param color} is not opaque, consider setting |
| 2266 | * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and |
| 2267 | * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}. |
George Mount | 238010f | 2014-06-30 17:31:17 -0700 | [diff] [blame] | 2268 | * <p> |
| 2269 | * The transitionName for the view background will be "android:navigation:background". |
| 2270 | * </p> |
Jorim Jaggi | a0b78d5 | 2018-01-22 19:01:42 +0100 | [diff] [blame] | 2271 | * @attr ref android.R.styleable#Window_navigationBarColor |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2272 | */ |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 2273 | public abstract void setNavigationBarColor(@ColorInt int color); |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2274 | |
Jorim Jaggi | a0b78d5 | 2018-01-22 19:01:42 +0100 | [diff] [blame] | 2275 | /** |
| 2276 | * Shows a thin line of the specified color between the navigation bar and the app |
| 2277 | * content. |
| 2278 | * <p> |
| 2279 | * For this to take effect, |
| 2280 | * the window must be drawing the system bar backgrounds with |
| 2281 | * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and |
| 2282 | * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set. |
| 2283 | * |
| 2284 | * @param dividerColor The color of the thin line. |
| 2285 | * @attr ref android.R.styleable#Window_navigationBarDividerColor |
| 2286 | */ |
| 2287 | public void setNavigationBarDividerColor(@ColorInt int dividerColor) { |
| 2288 | } |
| 2289 | |
| 2290 | /** |
| 2291 | * Retrieves the color of the navigation bar divider. |
| 2292 | * |
| 2293 | * @return The color of the navigation bar divider color. |
| 2294 | * @see #setNavigationBarColor(int) |
| 2295 | * @attr ref android.R.styleable#Window_navigationBarDividerColor |
| 2296 | */ |
| 2297 | public @ColorInt int getNavigationBarDividerColor() { |
| 2298 | return 0; |
| 2299 | } |
| 2300 | |
Filip Gruszczynski | 0daf210 | 2015-09-29 08:39:07 -0700 | [diff] [blame] | 2301 | /** @hide */ |
| 2302 | public void setTheme(int resId) { |
| 2303 | } |
Filip Gruszczynski | 6325065 | 2015-11-18 14:43:01 -0800 | [diff] [blame] | 2304 | |
| 2305 | /** |
| 2306 | * Whether the caption should be displayed directly on the content rather than push the content |
| 2307 | * down. This affects only freeform windows since they display the caption. |
| 2308 | * @hide |
| 2309 | */ |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 2310 | public void setOverlayWithDecorCaptionEnabled(boolean enabled) { |
| 2311 | mOverlayWithDecorCaptionEnabled = enabled; |
Filip Gruszczynski | 6325065 | 2015-11-18 14:43:01 -0800 | [diff] [blame] | 2312 | } |
| 2313 | |
| 2314 | /** @hide */ |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 2315 | public boolean isOverlayWithDecorCaptionEnabled() { |
| 2316 | return mOverlayWithDecorCaptionEnabled; |
Filip Gruszczynski | 6325065 | 2015-11-18 14:43:01 -0800 | [diff] [blame] | 2317 | } |
Filip Gruszczynski | 9b81e40 | 2015-12-08 15:42:01 -0800 | [diff] [blame] | 2318 | |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2319 | /** @hide */ |
| 2320 | public void notifyRestrictedCaptionAreaCallback(int left, int top, int right, int bottom) { |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 2321 | if (mOnRestrictedCaptionAreaChangedListener != null) { |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2322 | mRestrictedCaptionAreaRect.set(left, top, right, bottom); |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 2323 | mOnRestrictedCaptionAreaChangedListener.onRestrictedCaptionAreaChanged( |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2324 | mRestrictedCaptionAreaRect); |
| 2325 | } |
| 2326 | } |
Filip Gruszczynski | 9b81e40 | 2015-12-08 15:42:01 -0800 | [diff] [blame] | 2327 | |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2328 | /** |
| 2329 | * Set what color should the caption controls be. By default the system will try to determine |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 2330 | * the color from the theme. You can overwrite this by using {@link #DECOR_CAPTION_SHADE_DARK}, |
| 2331 | * {@link #DECOR_CAPTION_SHADE_LIGHT}, or {@link #DECOR_CAPTION_SHADE_AUTO}. |
| 2332 | * @see #DECOR_CAPTION_SHADE_DARK |
| 2333 | * @see #DECOR_CAPTION_SHADE_LIGHT |
| 2334 | * @see #DECOR_CAPTION_SHADE_AUTO |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2335 | */ |
| 2336 | public abstract void setDecorCaptionShade(int decorCaptionShade); |
| 2337 | |
| 2338 | /** |
| 2339 | * Set the drawable that is drawn underneath the caption during the resizing. |
| 2340 | * |
| 2341 | * During the resizing the caption might not be drawn fast enough to match the new dimensions. |
| 2342 | * There is a second caption drawn underneath it that will be fast enough. By default the |
| 2343 | * caption is constructed from the theme. You can provide a drawable, that will be drawn instead |
| 2344 | * to better match your application. |
| 2345 | */ |
| 2346 | public abstract void setResizingCaptionDrawable(Drawable drawable); |
Wale Ogunwale | eb6722c | 2015-12-08 11:43:43 -0800 | [diff] [blame] | 2347 | |
| 2348 | /** |
| 2349 | * Called when the activity changes from fullscreen mode to multi-window mode and visa-versa. |
| 2350 | * @hide |
| 2351 | */ |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 2352 | public abstract void onMultiWindowModeChanged(); |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 2353 | |
| 2354 | /** |
Winson Chung | 4d8681f | 2017-05-23 16:22:08 -0700 | [diff] [blame] | 2355 | * Called when the activity changes to/from picture-in-picture mode. |
| 2356 | * @hide |
| 2357 | */ |
| 2358 | public abstract void onPictureInPictureModeChanged(boolean isInPictureInPictureMode); |
| 2359 | |
| 2360 | /** |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 2361 | * Called when the activity just relaunched. |
| 2362 | * @hide |
| 2363 | */ |
| 2364 | public abstract void reportActivityRelaunched(); |
Michael Kwan | f7964be | 2016-11-30 16:44:33 -0800 | [diff] [blame] | 2365 | |
| 2366 | /** |
| 2367 | * Called to set flag to check if the close on swipe is enabled. This will only function if |
| 2368 | * FEATURE_SWIPE_TO_DISMISS has been set. |
| 2369 | * @hide |
| 2370 | */ |
| 2371 | public void setCloseOnSwipeEnabled(boolean closeOnSwipeEnabled) { |
| 2372 | mCloseOnSwipeEnabled = closeOnSwipeEnabled; |
| 2373 | } |
| 2374 | |
| 2375 | /** |
| 2376 | * @return {@code true} if the close on swipe is enabled. |
| 2377 | * @hide |
| 2378 | */ |
| 2379 | public boolean isCloseOnSwipeEnabled() { |
| 2380 | return mCloseOnSwipeEnabled; |
| 2381 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2382 | } |