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