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. |
| 568 | */ |
| 569 | public void onProvideKeyboardShortcuts( |
| 570 | List<KeyboardShortcutGroup> data, @Nullable Menu menu); |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 571 | } |
Will Haldean Brown | ca6234e | 2014-02-12 10:23:41 -0800 | [diff] [blame] | 572 | |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 573 | /** @hide */ |
| 574 | public interface OnWindowDismissedCallback { |
Will Haldean Brown | ca6234e | 2014-02-12 10:23:41 -0800 | [diff] [blame] | 575 | /** |
| 576 | * Called when a window is dismissed. This informs the callback that the |
| 577 | * window is gone, and it should finish itself. |
Wale Ogunwale | ba7881c | 2015-08-01 19:28:29 -0700 | [diff] [blame] | 578 | * @param finishTask True if the task should also be finished. |
Will Haldean Brown | ca6234e | 2014-02-12 10:23:41 -0800 | [diff] [blame] | 579 | */ |
Wale Ogunwale | ba7881c | 2015-08-01 19:28:29 -0700 | [diff] [blame] | 580 | void onWindowDismissed(boolean finishTask); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 581 | } |
| 582 | |
Wale Ogunwale | 868a5e1 | 2015-08-02 16:19:20 -0700 | [diff] [blame] | 583 | /** @hide */ |
Skuhne | ce2faa5 | 2015-08-11 10:36:38 -0700 | [diff] [blame] | 584 | public interface WindowControllerCallback { |
| 585 | /** |
Filip Gruszczynski | 411c06f | 2016-01-07 09:44:44 -0800 | [diff] [blame] | 586 | * Moves the activity from |
| 587 | * {@link android.app.ActivityManager.StackId#FREEFORM_WORKSPACE_STACK_ID} to |
| 588 | * {@link android.app.ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} stack. |
Wale Ogunwale | 868a5e1 | 2015-08-02 16:19:20 -0700 | [diff] [blame] | 589 | */ |
Filip Gruszczynski | 411c06f | 2016-01-07 09:44:44 -0800 | [diff] [blame] | 590 | void exitFreeformMode() throws RemoteException; |
Wale Ogunwale | 868a5e1 | 2015-08-02 16:19:20 -0700 | [diff] [blame] | 591 | |
| 592 | /** Returns the current stack Id for the window. */ |
| 593 | int getWindowStackId() throws RemoteException; |
| 594 | } |
| 595 | |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 596 | /** |
| 597 | * Callback for clients that want to be aware of where caption draws content. |
| 598 | */ |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 599 | public interface OnRestrictedCaptionAreaChangedListener { |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 600 | /** |
| 601 | * Called when the area where caption draws content changes. |
| 602 | * |
| 603 | * @param rect The area where caption content is positioned, relative to the top view. |
| 604 | */ |
| 605 | void onRestrictedCaptionAreaChanged(Rect rect); |
| 606 | } |
| 607 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 608 | /** |
| 609 | * Callback for clients that want frame timing information for each |
| 610 | * frame rendered by the Window. |
| 611 | */ |
| 612 | public interface FrameMetricsListener { |
| 613 | /** |
| 614 | * Called when information is available for the previously rendered frame. |
| 615 | * |
| 616 | * Reports can be dropped if this callback takes too |
| 617 | * long to execute, as the report producer cannot wait for the consumer to |
| 618 | * complete. |
| 619 | * |
| 620 | * It is highly recommended that clients copy the passed in FrameMetrics |
| 621 | * via {@link FrameMetrics#FrameMetrics(FrameMetrics)} within this method and defer |
| 622 | * additional computation or storage to another thread to avoid unnecessarily |
| 623 | * dropping reports. |
| 624 | * |
| 625 | * @param window The {@link Window} on which the frame was displayed. |
| 626 | * @param frameMetrics the available metrics. This object is reused on every call |
| 627 | * and thus <strong>this reference is not valid outside the scope of this method</strong>. |
| 628 | * @param dropCountSinceLastInvocation the number of reports dropped since the last time |
| 629 | * this callback was invoked. |
| 630 | */ |
| 631 | void onMetricsAvailable(Window window, FrameMetrics frameMetrics, |
| 632 | int dropCountSinceLastInvocation); |
| 633 | } |
| 634 | |
| 635 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 636 | public Window(Context context) { |
| 637 | mContext = context; |
Bryce Lee | d6e6e72 | 2014-11-21 11:08:45 -0800 | [diff] [blame] | 638 | mFeatures = mLocalFeatures = getDefaultFeatures(context); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | /** |
| 642 | * Return the Context this window policy is running in, for retrieving |
| 643 | * resources and other information. |
| 644 | * |
| 645 | * @return Context The Context that was supplied to the constructor. |
| 646 | */ |
| 647 | public final Context getContext() { |
| 648 | return mContext; |
| 649 | } |
| 650 | |
| 651 | /** |
| 652 | * Return the {@link android.R.styleable#Window} attributes from this |
| 653 | * window's theme. |
| 654 | */ |
| 655 | public final TypedArray getWindowStyle() { |
| 656 | synchronized (this) { |
| 657 | if (mWindowStyle == null) { |
| 658 | mWindowStyle = mContext.obtainStyledAttributes( |
| 659 | com.android.internal.R.styleable.Window); |
| 660 | } |
| 661 | return mWindowStyle; |
| 662 | } |
| 663 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 664 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 665 | /** |
| 666 | * Set the container for this window. If not set, the DecorWindow |
| 667 | * operates as a top-level window; otherwise, it negotiates with the |
| 668 | * container to display itself appropriately. |
| 669 | * |
| 670 | * @param container The desired containing Window. |
| 671 | */ |
| 672 | public void setContainer(Window container) { |
| 673 | mContainer = container; |
| 674 | if (container != null) { |
| 675 | // Embedded screens never have a title. |
| 676 | mFeatures |= 1<<FEATURE_NO_TITLE; |
| 677 | mLocalFeatures |= 1<<FEATURE_NO_TITLE; |
| 678 | container.mHasChildren = true; |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | /** |
| 683 | * Return the container for this Window. |
| 684 | * |
| 685 | * @return Window The containing window, or null if this is a |
| 686 | * top-level window. |
| 687 | */ |
| 688 | public final Window getContainer() { |
| 689 | return mContainer; |
| 690 | } |
| 691 | |
| 692 | public final boolean hasChildren() { |
| 693 | return mHasChildren; |
| 694 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 695 | |
Dianne Hackborn | 291905e | 2010-08-17 15:17:15 -0700 | [diff] [blame] | 696 | /** @hide */ |
| 697 | public final void destroy() { |
| 698 | mDestroyed = true; |
| 699 | } |
| 700 | |
| 701 | /** @hide */ |
| 702 | public final boolean isDestroyed() { |
| 703 | return mDestroyed; |
| 704 | } |
| 705 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 706 | /** |
| 707 | * Set the window manager for use by this Window to, for example, |
| 708 | * display panels. This is <em>not</em> used for displaying the |
| 709 | * Window itself -- that must be done by the client. |
| 710 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 711 | * @param wm The window manager for adding new windows. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 712 | */ |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 713 | public void setWindowManager(WindowManager wm, IBinder appToken, String appName) { |
| 714 | setWindowManager(wm, appToken, appName, false); |
| 715 | } |
| 716 | |
| 717 | /** |
| 718 | * Set the window manager for use by this Window to, for example, |
| 719 | * display panels. This is <em>not</em> used for displaying the |
| 720 | * Window itself -- that must be done by the client. |
| 721 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 722 | * @param wm The window manager for adding new windows. |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 723 | */ |
| 724 | public void setWindowManager(WindowManager wm, IBinder appToken, String appName, |
| 725 | boolean hardwareAccelerated) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 726 | mAppToken = appToken; |
| 727 | mAppName = appName; |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 728 | mHardwareAccelerated = hardwareAccelerated |
| 729 | || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 730 | if (wm == null) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 731 | wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 732 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 733 | mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 734 | } |
| 735 | |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 736 | void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) { |
| 737 | CharSequence curTitle = wp.getTitle(); |
| 738 | if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW && |
tiger_huang | ff58e30 | 2015-10-13 21:38:19 +0800 | [diff] [blame] | 739 | wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 740 | if (wp.token == null) { |
| 741 | View decor = peekDecorView(); |
| 742 | if (decor != null) { |
| 743 | wp.token = decor.getWindowToken(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 744 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 745 | } |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 746 | if (curTitle == null || curTitle.length() == 0) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 747 | final StringBuilder title = new StringBuilder(32); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 748 | if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 749 | title.append("Media"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 750 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 751 | title.append("MediaOvr"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 752 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 753 | title.append("Panel"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 754 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 755 | title.append("SubPanel"); |
Wale Ogunwale | 0a4dc22 | 2015-04-14 12:58:42 -0700 | [diff] [blame] | 756 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 757 | title.append("AboveSubPanel"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 758 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 759 | title.append("AtchDlg"); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 760 | } else { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 761 | title.append(wp.type); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 762 | } |
| 763 | if (mAppName != null) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 764 | title.append(":").append(mAppName); |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 765 | } |
| 766 | wp.setTitle(title); |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 767 | } |
tiger_huang | ff58e30 | 2015-10-13 21:38:19 +0800 | [diff] [blame] | 768 | } else if (wp.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW && |
| 769 | wp.type <= WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) { |
| 770 | // We don't set the app token to this system window because the life cycles should be |
| 771 | // independent. If an app creates a system window and then the app goes to the stopped |
| 772 | // state, the system window should not be affected (can still show and receive input |
| 773 | // events). |
| 774 | if (curTitle == null || curTitle.length() == 0) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 775 | final StringBuilder title = new StringBuilder(32); |
| 776 | title.append("Sys").append(wp.type); |
tiger_huang | ff58e30 | 2015-10-13 21:38:19 +0800 | [diff] [blame] | 777 | if (mAppName != null) { |
Wale Ogunwale | 9b34442 | 2015-10-16 09:07:45 -0700 | [diff] [blame] | 778 | title.append(":").append(mAppName); |
tiger_huang | ff58e30 | 2015-10-13 21:38:19 +0800 | [diff] [blame] | 779 | } |
| 780 | wp.setTitle(title); |
| 781 | } |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 782 | } else { |
| 783 | if (wp.token == null) { |
| 784 | wp.token = mContainer == null ? mAppToken : mContainer.mAppToken; |
| 785 | } |
| 786 | if ((curTitle == null || curTitle.length() == 0) |
| 787 | && mAppName != null) { |
| 788 | wp.setTitle(mAppName); |
| 789 | } |
| 790 | } |
| 791 | if (wp.packageName == null) { |
| 792 | wp.packageName = mContext.getPackageName(); |
| 793 | } |
| 794 | if (mHardwareAccelerated) { |
| 795 | wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 796 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | /** |
| 800 | * Return the window manager allowing this Window to display its own |
| 801 | * windows. |
| 802 | * |
| 803 | * @return WindowManager The ViewManager. |
| 804 | */ |
| 805 | public WindowManager getWindowManager() { |
| 806 | return mWindowManager; |
| 807 | } |
| 808 | |
| 809 | /** |
| 810 | * Set the Callback interface for this window, used to intercept key |
| 811 | * events and other dynamic operations in the window. |
| 812 | * |
| 813 | * @param callback The desired Callback interface. |
| 814 | */ |
| 815 | public void setCallback(Callback callback) { |
| 816 | mCallback = callback; |
| 817 | } |
| 818 | |
| 819 | /** |
| 820 | * Return the current Callback interface for this window. |
| 821 | */ |
| 822 | public final Callback getCallback() { |
| 823 | return mCallback; |
| 824 | } |
| 825 | |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 826 | /** |
| 827 | * Set an observer to collect frame stats for each frame rendererd in this window. |
| 828 | * |
| 829 | * Must be in hardware rendering mode. |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 830 | */ |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 831 | public final void addFrameMetricsListener(@NonNull FrameMetricsListener listener, |
| 832 | Handler handler) { |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 833 | final View decorView = getDecorView(); |
| 834 | if (decorView == null) { |
| 835 | throw new IllegalStateException("can't observe a Window without an attached view"); |
| 836 | } |
| 837 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 838 | if (listener == null) { |
| 839 | throw new NullPointerException("listener cannot be null"); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 840 | } |
| 841 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 842 | decorView.addFrameMetricsListener(this, listener, handler); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | /** |
| 846 | * Remove observer and stop listening to frame stats for this window. |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 847 | */ |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 848 | public final void removeFrameMetricsListener(FrameMetricsListener listener) { |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 849 | final View decorView = getDecorView(); |
| 850 | if (decorView != null) { |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 851 | getDecorView().removeFrameMetricsListener(listener); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 852 | } |
| 853 | } |
| 854 | |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 855 | /** @hide */ |
| 856 | public final void setOnWindowDismissedCallback(OnWindowDismissedCallback dcb) { |
| 857 | mOnWindowDismissedCallback = dcb; |
| 858 | } |
| 859 | |
| 860 | /** @hide */ |
Stefan Kuhne | 1b42057 | 2015-08-07 10:50:19 -0700 | [diff] [blame] | 861 | public final void dispatchOnWindowDismissed(boolean finishTask) { |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 862 | if (mOnWindowDismissedCallback != null) { |
Stefan Kuhne | 1b42057 | 2015-08-07 10:50:19 -0700 | [diff] [blame] | 863 | mOnWindowDismissedCallback.onWindowDismissed(finishTask); |
Adam Powell | 117b695 | 2014-05-05 18:14:56 -0700 | [diff] [blame] | 864 | } |
| 865 | } |
| 866 | |
Stefan Kuhne | 9bad741 | 2015-08-07 10:35:52 -0700 | [diff] [blame] | 867 | /** @hide */ |
Skuhne | ce2faa5 | 2015-08-11 10:36:38 -0700 | [diff] [blame] | 868 | public final void setWindowControllerCallback(WindowControllerCallback wccb) { |
| 869 | mWindowControllerCallback = wccb; |
Stefan Kuhne | 9bad741 | 2015-08-07 10:35:52 -0700 | [diff] [blame] | 870 | } |
| 871 | |
| 872 | /** @hide */ |
Skuhne | ce2faa5 | 2015-08-11 10:36:38 -0700 | [diff] [blame] | 873 | public final WindowControllerCallback getWindowControllerCallback() { |
| 874 | return mWindowControllerCallback; |
Stefan Kuhne | 9bad741 | 2015-08-07 10:35:52 -0700 | [diff] [blame] | 875 | } |
| 876 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 877 | /** |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 878 | * Set a callback for changes of area where caption will draw its content. |
| 879 | * |
| 880 | * @param listener Callback that will be called when the area changes. |
| 881 | */ |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 882 | public final void setRestrictedCaptionAreaListener(OnRestrictedCaptionAreaChangedListener listener) { |
| 883 | mOnRestrictedCaptionAreaChangedListener = listener; |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 884 | mRestrictedCaptionAreaRect = listener != null ? new Rect() : null; |
| 885 | } |
| 886 | |
| 887 | /** |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 888 | * Take ownership of this window's surface. The window's view hierarchy |
| 889 | * will no longer draw into the surface, though it will otherwise continue |
| 890 | * to operate (such as for receiving input events). The given SurfaceHolder |
| 891 | * callback will be used to tell you about state changes to the surface. |
| 892 | */ |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 893 | public abstract void takeSurface(SurfaceHolder.Callback2 callback); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 894 | |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 895 | /** |
Dianne Hackborn | 1e4b9f3 | 2010-06-23 14:10:57 -0700 | [diff] [blame] | 896 | * Take ownership of this window's InputQueue. The window will no |
| 897 | * longer read and dispatch input events from the queue; it is your |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 898 | * responsibility to do so. |
| 899 | */ |
Dianne Hackborn | 1e4b9f3 | 2010-06-23 14:10:57 -0700 | [diff] [blame] | 900 | public abstract void takeInputQueue(InputQueue.Callback callback); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 901 | |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 902 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 903 | * Return whether this window is being displayed with a floating style |
| 904 | * (based on the {@link android.R.attr#windowIsFloating} attribute in |
| 905 | * the style/theme). |
| 906 | * |
| 907 | * @return Returns true if the window is configured to be displayed floating |
| 908 | * on top of whatever is behind it. |
| 909 | */ |
| 910 | public abstract boolean isFloating(); |
| 911 | |
| 912 | /** |
| 913 | * Set the width and height layout parameters of the window. The default |
Dianne Hackborn | c918935 | 2010-12-15 14:57:25 -0800 | [diff] [blame] | 914 | * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT |
| 915 | * 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] | 916 | * |
| 917 | * @param width The desired layout width of the window. |
| 918 | * @param height The desired layout height of the window. |
Dianne Hackborn | c918935 | 2010-12-15 14:57:25 -0800 | [diff] [blame] | 919 | * |
| 920 | * @see ViewGroup.LayoutParams#height |
| 921 | * @see ViewGroup.LayoutParams#width |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 922 | */ |
Dianne Hackborn | c918935 | 2010-12-15 14:57:25 -0800 | [diff] [blame] | 923 | public void setLayout(int width, int height) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 924 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 925 | attrs.width = width; |
| 926 | attrs.height = height; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 927 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | /** |
| 931 | * Set the gravity of the window, as per the Gravity constants. This |
| 932 | * controls how the window manager is positioned in the overall window; it |
| 933 | * is only useful when using WRAP_CONTENT for the layout width or height. |
| 934 | * |
| 935 | * @param gravity The desired gravity constant. |
| 936 | * |
| 937 | * @see Gravity |
| 938 | * @see #setLayout |
| 939 | */ |
| 940 | public void setGravity(int gravity) |
| 941 | { |
| 942 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 943 | attrs.gravity = gravity; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 944 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | /** |
| 948 | * Set the type of the window, as per the WindowManager.LayoutParams |
| 949 | * types. |
| 950 | * |
| 951 | * @param type The new window type (see WindowManager.LayoutParams). |
| 952 | */ |
| 953 | public void setType(int type) { |
| 954 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 955 | attrs.type = type; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 956 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | /** |
| 960 | * Set the format of window, as per the PixelFormat types. This overrides |
| 961 | * the default format that is selected by the Window based on its |
| 962 | * window decorations. |
| 963 | * |
| 964 | * @param format The new window format (see PixelFormat). Use |
| 965 | * PixelFormat.UNKNOWN to allow the Window to select |
| 966 | * the format. |
| 967 | * |
| 968 | * @see PixelFormat |
| 969 | */ |
| 970 | public void setFormat(int format) { |
| 971 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 972 | if (format != PixelFormat.UNKNOWN) { |
| 973 | attrs.format = format; |
| 974 | mHaveWindowFormat = true; |
| 975 | } else { |
| 976 | attrs.format = mDefaultWindowFormat; |
| 977 | mHaveWindowFormat = false; |
| 978 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 979 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | /** |
| 983 | * Specify custom animations to use for the window, as per |
| 984 | * {@link WindowManager.LayoutParams#windowAnimations |
| 985 | * WindowManager.LayoutParams.windowAnimations}. Providing anything besides |
| 986 | * 0 here will override the animations the window would |
| 987 | * normally retrieve from its theme. |
| 988 | */ |
Tor Norbye | 417ee5b | 2015-03-10 20:57:37 -0700 | [diff] [blame] | 989 | public void setWindowAnimations(@StyleRes int resId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 990 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 991 | attrs.windowAnimations = resId; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 992 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | /** |
| 996 | * Specify an explicit soft input mode to use for the window, as per |
| 997 | * {@link WindowManager.LayoutParams#softInputMode |
| 998 | * WindowManager.LayoutParams.softInputMode}. Providing anything besides |
| 999 | * "unspecified" here will override the input mode the window would |
| 1000 | * normally retrieve from its theme. |
| 1001 | */ |
| 1002 | public void setSoftInputMode(int mode) { |
| 1003 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1004 | if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) { |
| 1005 | attrs.softInputMode = mode; |
| 1006 | mHasSoftInputMode = true; |
| 1007 | } else { |
| 1008 | mHasSoftInputMode = false; |
| 1009 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1010 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1011 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1012 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1013 | /** |
| 1014 | * Convenience function to set the flag bits as specified in flags, as |
| 1015 | * per {@link #setFlags}. |
| 1016 | * @param flags The flag bits to be set. |
| 1017 | * @see #setFlags |
Christopher Tate | 193fc07 | 2012-06-04 11:27:40 -0700 | [diff] [blame] | 1018 | * @see #clearFlags |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1019 | */ |
| 1020 | public void addFlags(int flags) { |
| 1021 | setFlags(flags, flags); |
| 1022 | } |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1023 | |
| 1024 | /** @hide */ |
| 1025 | public void addPrivateFlags(int flags) { |
| 1026 | setPrivateFlags(flags, flags); |
| 1027 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1028 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1029 | /** |
| 1030 | * Convenience function to clear the flag bits as specified in flags, as |
| 1031 | * per {@link #setFlags}. |
| 1032 | * @param flags The flag bits to be cleared. |
| 1033 | * @see #setFlags |
Christopher Tate | 193fc07 | 2012-06-04 11:27:40 -0700 | [diff] [blame] | 1034 | * @see #addFlags |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1035 | */ |
| 1036 | public void clearFlags(int flags) { |
| 1037 | setFlags(0, flags); |
| 1038 | } |
| 1039 | |
| 1040 | /** |
| 1041 | * Set the flags of the window, as per the |
| 1042 | * {@link WindowManager.LayoutParams WindowManager.LayoutParams} |
| 1043 | * flags. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1044 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1045 | * <p>Note that some flags must be set before the window decoration is |
| 1046 | * created (by the first call to |
| 1047 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or |
| 1048 | * {@link #getDecorView()}: |
| 1049 | * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and |
| 1050 | * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These |
| 1051 | * will be set for you based on the {@link android.R.attr#windowIsFloating} |
| 1052 | * attribute. |
| 1053 | * |
| 1054 | * @param flags The new window flags (see WindowManager.LayoutParams). |
| 1055 | * @param mask Which of the window flag bits to modify. |
Christopher Tate | 193fc07 | 2012-06-04 11:27:40 -0700 | [diff] [blame] | 1056 | * @see #addFlags |
| 1057 | * @see #clearFlags |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1058 | */ |
| 1059 | public void setFlags(int flags, int mask) { |
| 1060 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1061 | attrs.flags = (attrs.flags&~mask) | (flags&mask); |
| 1062 | mForcedWindowFlags |= mask; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1063 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1064 | } |
| 1065 | |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1066 | private void setPrivateFlags(int flags, int mask) { |
| 1067 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1068 | attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask); |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1069 | dispatchWindowAttributesChanged(attrs); |
| 1070 | } |
| 1071 | |
| 1072 | /** |
| 1073 | * {@hide} |
| 1074 | */ |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 1075 | protected void setNeedsMenuKey(int value) { |
| 1076 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1077 | attrs.needsMenuKey = value; |
| 1078 | dispatchWindowAttributesChanged(attrs); |
| 1079 | } |
| 1080 | |
| 1081 | /** |
| 1082 | * {@hide} |
| 1083 | */ |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1084 | protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) { |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1085 | if (mCallback != null) { |
| 1086 | mCallback.onWindowAttributesChanged(attrs); |
| 1087 | } |
| 1088 | } |
| 1089 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1090 | /** |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1091 | * Set the amount of dim behind the window when using |
| 1092 | * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides |
| 1093 | * the default dim amount of that is selected by the Window based on |
| 1094 | * its theme. |
| 1095 | * |
| 1096 | * @param amount The new dim amount, from 0 for no dim to 1 for full dim. |
| 1097 | */ |
| 1098 | public void setDimAmount(float amount) { |
| 1099 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1100 | attrs.dimAmount = amount; |
| 1101 | mHaveDimAmount = true; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1102 | dispatchWindowAttributesChanged(attrs); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1103 | } |
| 1104 | |
| 1105 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1106 | * Specify custom window attributes. <strong>PLEASE NOTE:</strong> the |
| 1107 | * layout params you give here should generally be from values previously |
| 1108 | * retrieved with {@link #getAttributes()}; you probably do not want to |
| 1109 | * blindly create and apply your own, since this will blow away any values |
| 1110 | * set by the framework that you are not interested in. |
| 1111 | * |
| 1112 | * @param a The new window attributes, which will completely override any |
| 1113 | * current values. |
| 1114 | */ |
| 1115 | public void setAttributes(WindowManager.LayoutParams a) { |
| 1116 | mWindowAttributes.copyFrom(a); |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1117 | dispatchWindowAttributesChanged(mWindowAttributes); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1118 | } |
| 1119 | |
| 1120 | /** |
| 1121 | * Retrieve the current window attributes associated with this panel. |
| 1122 | * |
| 1123 | * @return WindowManager.LayoutParams Either the existing window |
| 1124 | * attributes object, or a freshly created one if there is none. |
| 1125 | */ |
| 1126 | public final WindowManager.LayoutParams getAttributes() { |
| 1127 | return mWindowAttributes; |
| 1128 | } |
| 1129 | |
| 1130 | /** |
| 1131 | * Return the window flags that have been explicitly set by the client, |
| 1132 | * so will not be modified by {@link #getDecorView}. |
| 1133 | */ |
| 1134 | protected final int getForcedWindowFlags() { |
| 1135 | return mForcedWindowFlags; |
| 1136 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1137 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1138 | /** |
| 1139 | * Has the app specified their own soft input mode? |
| 1140 | */ |
| 1141 | protected final boolean hasSoftInputMode() { |
| 1142 | return mHasSoftInputMode; |
| 1143 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1144 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1145 | /** @hide */ |
| 1146 | public void setCloseOnTouchOutside(boolean close) { |
| 1147 | mCloseOnTouchOutside = close; |
| 1148 | mSetCloseOnTouchOutside = true; |
| 1149 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1150 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1151 | /** @hide */ |
Dianne Hackborn | ef57575 | 2011-01-18 17:35:17 -0800 | [diff] [blame] | 1152 | public void setCloseOnTouchOutsideIfNotSet(boolean close) { |
| 1153 | if (!mSetCloseOnTouchOutside) { |
| 1154 | mCloseOnTouchOutside = close; |
| 1155 | mSetCloseOnTouchOutside = true; |
| 1156 | } |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1157 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1158 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1159 | /** @hide */ |
Filip Gruszczynski | fe56835 | 2015-01-05 10:41:29 -0800 | [diff] [blame] | 1160 | @SystemApi |
| 1161 | public void setDisableWallpaperTouchEvents(boolean disable) { |
| 1162 | setPrivateFlags(disable |
| 1163 | ? WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS : 0, |
| 1164 | WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS); |
| 1165 | } |
| 1166 | |
| 1167 | /** @hide */ |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1168 | public abstract void alwaysReadCloseOnTouchAttr(); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1169 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1170 | /** @hide */ |
| 1171 | public boolean shouldCloseOnTouch(Context context, MotionEvent event) { |
| 1172 | if (mCloseOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN |
| 1173 | && isOutOfBounds(context, event) && peekDecorView() != null) { |
| 1174 | return true; |
| 1175 | } |
| 1176 | return false; |
| 1177 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1178 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 1179 | private boolean isOutOfBounds(Context context, MotionEvent event) { |
| 1180 | final int x = (int) event.getX(); |
| 1181 | final int y = (int) event.getY(); |
| 1182 | final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop(); |
| 1183 | final View decorView = getDecorView(); |
| 1184 | return (x < -slop) || (y < -slop) |
| 1185 | || (x > (decorView.getWidth()+slop)) |
| 1186 | || (y > (decorView.getHeight()+slop)); |
| 1187 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1188 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1189 | /** |
| 1190 | * Enable extended screen features. This must be called before |
| 1191 | * setContentView(). May be called as many times as desired as long as it |
| 1192 | * is before setContentView(). If not called, no extended features |
| 1193 | * will be available. You can not turn off a feature once it is requested. |
| 1194 | * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}. |
| 1195 | * |
| 1196 | * @param featureId The desired features, defined as constants by Window. |
| 1197 | * @return The features that are now set. |
| 1198 | */ |
| 1199 | public boolean requestFeature(int featureId) { |
| 1200 | final int flag = 1<<featureId; |
| 1201 | mFeatures |= flag; |
| 1202 | mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag; |
| 1203 | return (mFeatures&flag) != 0; |
| 1204 | } |
| 1205 | |
Adam Powell | f4a6ec4 | 2010-08-24 14:18:10 -0700 | [diff] [blame] | 1206 | /** |
| 1207 | * @hide Used internally to help resolve conflicting features. |
| 1208 | */ |
| 1209 | protected void removeFeature(int featureId) { |
| 1210 | final int flag = 1<<featureId; |
| 1211 | mFeatures &= ~flag; |
| 1212 | mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag); |
| 1213 | } |
| 1214 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1215 | public final void makeActive() { |
| 1216 | if (mContainer != null) { |
| 1217 | if (mContainer.mActiveChild != null) { |
| 1218 | mContainer.mActiveChild.mIsActive = false; |
| 1219 | } |
| 1220 | mContainer.mActiveChild = this; |
| 1221 | } |
| 1222 | mIsActive = true; |
| 1223 | onActive(); |
| 1224 | } |
| 1225 | |
| 1226 | public final boolean isActive() |
| 1227 | { |
| 1228 | return mIsActive; |
| 1229 | } |
| 1230 | |
| 1231 | /** |
| 1232 | * Finds a view that was identified by the id attribute from the XML that |
| 1233 | * was processed in {@link android.app.Activity#onCreate}. This will |
| 1234 | * implicitly call {@link #getDecorView} for you, with all of the |
| 1235 | * associated side-effects. |
| 1236 | * |
| 1237 | * @return The view if found or null otherwise. |
| 1238 | */ |
Scott Kennedy | c051955 | 2015-02-11 15:33:10 -0800 | [diff] [blame] | 1239 | @Nullable |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1240 | public View findViewById(@IdRes int id) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1241 | return getDecorView().findViewById(id); |
| 1242 | } |
| 1243 | |
| 1244 | /** |
| 1245 | * Convenience for |
| 1246 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} |
| 1247 | * to set the screen content from a layout resource. The resource will be |
| 1248 | * inflated, adding all top-level views to the screen. |
| 1249 | * |
| 1250 | * @param layoutResID Resource ID to be inflated. |
| 1251 | * @see #setContentView(View, android.view.ViewGroup.LayoutParams) |
| 1252 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1253 | public abstract void setContentView(@LayoutRes int layoutResID); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1254 | |
| 1255 | /** |
| 1256 | * Convenience for |
| 1257 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} |
| 1258 | * set the screen content to an explicit view. This view is placed |
| 1259 | * directly into the screen's view hierarchy. It can itself be a complex |
| 1260 | * view hierarhcy. |
| 1261 | * |
| 1262 | * @param view The desired content to display. |
| 1263 | * @see #setContentView(View, android.view.ViewGroup.LayoutParams) |
| 1264 | */ |
| 1265 | public abstract void setContentView(View view); |
| 1266 | |
| 1267 | /** |
| 1268 | * Set the screen content to an explicit view. This view is placed |
| 1269 | * directly into the screen's view hierarchy. It can itself be a complex |
| 1270 | * view hierarchy. |
| 1271 | * |
| 1272 | * <p>Note that calling this function "locks in" various characteristics |
| 1273 | * of the window that can not, from this point forward, be changed: the |
| 1274 | * features that have been requested with {@link #requestFeature(int)}, |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 1275 | * and certain window flags as described in {@link #setFlags(int, int)}.</p> |
| 1276 | * |
| 1277 | * <p>If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's |
| 1278 | * TransitionManager will be used to animate content from the current |
| 1279 | * content View to view.</p> |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1280 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1281 | * @param view The desired content to display. |
| 1282 | * @param params Layout parameters for the view. |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 1283 | * @see #getTransitionManager() |
| 1284 | * @see #setTransitionManager(android.transition.TransitionManager) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1285 | */ |
| 1286 | public abstract void setContentView(View view, ViewGroup.LayoutParams params); |
| 1287 | |
| 1288 | /** |
| 1289 | * Variation on |
| 1290 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} |
| 1291 | * to add an additional content view to the screen. Added after any existing |
| 1292 | * ones in the screen -- existing views are NOT removed. |
| 1293 | * |
| 1294 | * @param view The desired content to display. |
| 1295 | * @param params Layout parameters for the view. |
| 1296 | */ |
| 1297 | public abstract void addContentView(View view, ViewGroup.LayoutParams params); |
| 1298 | |
| 1299 | /** |
Filip Gruszczynski | a59ac9c | 2015-09-10 18:28:48 -0700 | [diff] [blame] | 1300 | * Remove the view that was used as the screen content. |
| 1301 | * |
| 1302 | * @hide |
| 1303 | */ |
| 1304 | public abstract void clearContentView(); |
| 1305 | |
| 1306 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1307 | * Return the view in this Window that currently has focus, or null if |
| 1308 | * there are none. Note that this does not look in any containing |
| 1309 | * Window. |
| 1310 | * |
| 1311 | * @return View The current View with focus or null. |
| 1312 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1313 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1314 | public abstract View getCurrentFocus(); |
| 1315 | |
| 1316 | /** |
| 1317 | * Quick access to the {@link LayoutInflater} instance that this Window |
| 1318 | * retrieved from its Context. |
| 1319 | * |
| 1320 | * @return LayoutInflater The shared LayoutInflater. |
| 1321 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1322 | @NonNull |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1323 | public abstract LayoutInflater getLayoutInflater(); |
| 1324 | |
| 1325 | public abstract void setTitle(CharSequence title); |
| 1326 | |
Alan Viverette | 2525d9c | 2013-11-15 14:42:19 -0800 | [diff] [blame] | 1327 | @Deprecated |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 1328 | public abstract void setTitleColor(@ColorInt int textColor); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1329 | |
| 1330 | public abstract void openPanel(int featureId, KeyEvent event); |
| 1331 | |
| 1332 | public abstract void closePanel(int featureId); |
| 1333 | |
| 1334 | public abstract void togglePanel(int featureId, KeyEvent event); |
| 1335 | |
Dianne Hackborn | b31e84bc | 2010-06-08 18:04:35 -0700 | [diff] [blame] | 1336 | public abstract void invalidatePanelMenu(int featureId); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1337 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1338 | public abstract boolean performPanelShortcut(int featureId, |
| 1339 | int keyCode, |
| 1340 | KeyEvent event, |
| 1341 | int flags); |
| 1342 | public abstract boolean performPanelIdentifierAction(int featureId, |
| 1343 | int id, |
| 1344 | int flags); |
| 1345 | |
| 1346 | public abstract void closeAllPanels(); |
| 1347 | |
| 1348 | public abstract boolean performContextMenuIdentifierAction(int id, int flags); |
| 1349 | |
| 1350 | /** |
| 1351 | * Should be called when the configuration is changed. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1352 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1353 | * @param newConfig The new configuration. |
| 1354 | */ |
| 1355 | public abstract void onConfigurationChanged(Configuration newConfig); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1356 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1357 | /** |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1358 | * Sets the window elevation. |
Alan Viverette | 71922de | 2015-01-12 16:14:02 -0800 | [diff] [blame] | 1359 | * <p> |
| 1360 | * Changes to this property take effect immediately and will cause the |
| 1361 | * window surface to be recreated. This is an expensive operation and as a |
| 1362 | * result, this property should not be animated. |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1363 | * |
| 1364 | * @param elevation The window elevation. |
| 1365 | * @see View#setElevation(float) |
| 1366 | * @see android.R.styleable#Window_windowElevation |
| 1367 | */ |
| 1368 | public void setElevation(float elevation) {} |
| 1369 | |
| 1370 | /** |
Filip Gruszczynski | a59ac9c | 2015-09-10 18:28:48 -0700 | [diff] [blame] | 1371 | * Gets the window elevation. |
| 1372 | * |
| 1373 | * @hide |
| 1374 | */ |
| 1375 | public float getElevation() { |
| 1376 | return 0.0f; |
| 1377 | } |
| 1378 | |
| 1379 | /** |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1380 | * Sets whether window content should be clipped to the outline of the |
| 1381 | * window background. |
| 1382 | * |
| 1383 | * @param clipToOutline Whether window content should be clipped to the |
| 1384 | * outline of the window background. |
| 1385 | * @see View#setClipToOutline(boolean) |
| 1386 | * @see android.R.styleable#Window_windowClipToOutline |
| 1387 | */ |
| 1388 | public void setClipToOutline(boolean clipToOutline) {} |
| 1389 | |
| 1390 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1391 | * Change the background of this window to a Drawable resource. Setting the |
| 1392 | * background to null will make the window be opaque. To make the window |
| 1393 | * transparent, you can use an empty drawable (for instance a ColorDrawable |
| 1394 | * with the color 0 or the system drawable android:drawable/empty.) |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1395 | * |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1396 | * @param resId The resource identifier of a drawable resource which will |
| 1397 | * be installed as the new background. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1398 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1399 | public void setBackgroundDrawableResource(@DrawableRes int resId) { |
Alan Viverette | 79c067c5 | 2014-10-29 14:27:47 -0700 | [diff] [blame] | 1400 | setBackgroundDrawable(mContext.getDrawable(resId)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | /** |
| 1404 | * Change the background of this window to a custom Drawable. Setting the |
| 1405 | * background to null will make the window be opaque. To make the window |
| 1406 | * transparent, you can use an empty drawable (for instance a ColorDrawable |
| 1407 | * with the color 0 or the system drawable android:drawable/empty.) |
| 1408 | * |
| 1409 | * @param drawable The new Drawable to use for this window's background. |
| 1410 | */ |
| 1411 | public abstract void setBackgroundDrawable(Drawable drawable); |
| 1412 | |
| 1413 | /** |
| 1414 | * 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] | 1415 | * identifier. You must have called requestFeature(featureId) before |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1416 | * calling this function. |
| 1417 | * |
| 1418 | * @see android.content.res.Resources#getDrawable(int) |
| 1419 | * |
| 1420 | * @param featureId The desired drawable feature to change, defined as a |
| 1421 | * constant by Window. |
| 1422 | * @param resId Resource identifier of the desired image. |
| 1423 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1424 | public abstract void setFeatureDrawableResource(int featureId, @DrawableRes int resId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1425 | |
| 1426 | /** |
| 1427 | * Set the value for a drawable feature of this window, from a URI. You |
| 1428 | * must have called requestFeature(featureId) before calling this |
| 1429 | * function. |
| 1430 | * |
| 1431 | * <p>The only URI currently supported is "content:", specifying an image |
| 1432 | * in a content provider. |
| 1433 | * |
| 1434 | * @see android.widget.ImageView#setImageURI |
| 1435 | * |
| 1436 | * @param featureId The desired drawable feature to change. Features are |
| 1437 | * constants defined by Window. |
| 1438 | * @param uri The desired URI. |
| 1439 | */ |
| 1440 | public abstract void setFeatureDrawableUri(int featureId, Uri uri); |
| 1441 | |
| 1442 | /** |
| 1443 | * Set an explicit Drawable value for feature of this window. You must |
| 1444 | * have called requestFeature(featureId) before calling this function. |
| 1445 | * |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1446 | * @param featureId The desired drawable feature to change. Features are |
| 1447 | * constants defined by Window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1448 | * @param drawable A Drawable object to display. |
| 1449 | */ |
| 1450 | public abstract void setFeatureDrawable(int featureId, Drawable drawable); |
| 1451 | |
| 1452 | /** |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1453 | * 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] | 1454 | * much the background is visible through it. |
| 1455 | * |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1456 | * @param featureId The desired drawable feature to change. Features are |
| 1457 | * constants defined by Window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1458 | * @param alpha The alpha amount, 0 is completely transparent and 255 is |
| 1459 | * completely opaque. |
| 1460 | */ |
| 1461 | public abstract void setFeatureDrawableAlpha(int featureId, int alpha); |
| 1462 | |
| 1463 | /** |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1464 | * Set the integer value for a feature. The range of the value depends on |
| 1465 | * the feature being set. For {@link #FEATURE_PROGRESS}, it should go from |
| 1466 | * 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] | 1467 | * |
Alan Viverette | 9678e34 | 2014-10-24 15:23:58 -0700 | [diff] [blame] | 1468 | * @param featureId The desired feature to change. Features are constants |
| 1469 | * defined by Window. |
| 1470 | * @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] | 1471 | * value is feature-specific. |
| 1472 | */ |
| 1473 | public abstract void setFeatureInt(int featureId, int value); |
| 1474 | |
| 1475 | /** |
| 1476 | * Request that key events come to this activity. Use this if your |
| 1477 | * activity has no views with focus, but the activity still wants |
| 1478 | * a chance to process key events. |
| 1479 | */ |
| 1480 | public abstract void takeKeyEvents(boolean get); |
| 1481 | |
| 1482 | /** |
| 1483 | * Used by custom windows, such as Dialog, to pass the key press event |
| 1484 | * further down the view hierarchy. Application developers should |
| 1485 | * not need to implement or call this. |
| 1486 | * |
| 1487 | */ |
| 1488 | public abstract boolean superDispatchKeyEvent(KeyEvent event); |
| 1489 | |
| 1490 | /** |
Jeff Brown | 64da12a | 2011-01-04 19:57:47 -0800 | [diff] [blame] | 1491 | * Used by custom windows, such as Dialog, to pass the key shortcut press event |
| 1492 | * further down the view hierarchy. Application developers should |
| 1493 | * not need to implement or call this. |
| 1494 | * |
| 1495 | */ |
| 1496 | public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event); |
| 1497 | |
| 1498 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1499 | * Used by custom windows, such as Dialog, to pass the touch screen event |
| 1500 | * further down the view hierarchy. Application developers should |
| 1501 | * not need to implement or call this. |
| 1502 | * |
| 1503 | */ |
| 1504 | public abstract boolean superDispatchTouchEvent(MotionEvent event); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1505 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1506 | /** |
| 1507 | * Used by custom windows, such as Dialog, to pass the trackball event |
| 1508 | * further down the view hierarchy. Application developers should |
| 1509 | * not need to implement or call this. |
| 1510 | * |
| 1511 | */ |
| 1512 | public abstract boolean superDispatchTrackballEvent(MotionEvent event); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1513 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1514 | /** |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1515 | * Used by custom windows, such as Dialog, to pass the generic motion event |
| 1516 | * further down the view hierarchy. Application developers should |
| 1517 | * not need to implement or call this. |
| 1518 | * |
| 1519 | */ |
| 1520 | public abstract boolean superDispatchGenericMotionEvent(MotionEvent event); |
| 1521 | |
| 1522 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1523 | * Retrieve the top-level window decor view (containing the standard |
| 1524 | * window frame/decorations and the client's content inside of that), which |
| 1525 | * can be added as a window to the window manager. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1526 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1527 | * <p><em>Note that calling this function for the first time "locks in" |
| 1528 | * various window characteristics as described in |
| 1529 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p> |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1530 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1531 | * @return Returns the top-level window decor view. |
| 1532 | */ |
| 1533 | public abstract View getDecorView(); |
| 1534 | |
| 1535 | /** |
| 1536 | * Retrieve the current decor view, but only if it has already been created; |
| 1537 | * otherwise returns null. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1538 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1539 | * @return Returns the top-level window decor or null. |
| 1540 | * @see #getDecorView |
| 1541 | */ |
| 1542 | public abstract View peekDecorView(); |
| 1543 | |
| 1544 | public abstract Bundle saveHierarchyState(); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1545 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1546 | public abstract void restoreHierarchyState(Bundle savedInstanceState); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1547 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1548 | protected abstract void onActive(); |
| 1549 | |
| 1550 | /** |
| 1551 | * Return the feature bits that are enabled. This is the set of features |
| 1552 | * that were given to requestFeature(), and are being handled by this |
| 1553 | * Window itself or its container. That is, it is the set of |
| 1554 | * requested features that you can actually use. |
| 1555 | * |
| 1556 | * <p>To do: add a public version of this API that allows you to check for |
| 1557 | * features by their feature ID. |
| 1558 | * |
| 1559 | * @return int The feature bits. |
| 1560 | */ |
| 1561 | protected final int getFeatures() |
| 1562 | { |
| 1563 | return mFeatures; |
| 1564 | } |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1565 | |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1566 | /** |
Bryce Lee | d6e6e72 | 2014-11-21 11:08:45 -0800 | [diff] [blame] | 1567 | * Return the feature bits set by default on a window. |
| 1568 | * @param context The context used to access resources |
| 1569 | */ |
| 1570 | public static int getDefaultFeatures(Context context) { |
| 1571 | int features = 0; |
| 1572 | |
| 1573 | final Resources res = context.getResources(); |
| 1574 | if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) { |
| 1575 | features |= 1 << FEATURE_OPTIONS_PANEL; |
| 1576 | } |
| 1577 | |
| 1578 | if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) { |
| 1579 | features |= 1 << FEATURE_CONTEXT_MENU; |
| 1580 | } |
| 1581 | |
| 1582 | return features; |
| 1583 | } |
| 1584 | |
| 1585 | /** |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1586 | * Query for the availability of a certain feature. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1587 | * |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1588 | * @param feature The feature ID to check |
| 1589 | * @return true if the feature is enabled, false otherwise. |
| 1590 | */ |
| 1591 | public boolean hasFeature(int feature) { |
| 1592 | return (getFeatures() & (1 << feature)) != 0; |
| 1593 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1594 | |
| 1595 | /** |
| 1596 | * Return the feature bits that are being implemented by this Window. |
| 1597 | * This is the set of features that were given to requestFeature(), and are |
| 1598 | * being handled by only this Window itself, not by its containers. |
| 1599 | * |
| 1600 | * @return int The feature bits. |
| 1601 | */ |
| 1602 | protected final int getLocalFeatures() |
| 1603 | { |
| 1604 | return mLocalFeatures; |
| 1605 | } |
| 1606 | |
| 1607 | /** |
| 1608 | * Set the default format of window, as per the PixelFormat types. This |
| 1609 | * is the format that will be used unless the client specifies in explicit |
| 1610 | * format with setFormat(); |
| 1611 | * |
| 1612 | * @param format The new window format (see PixelFormat). |
| 1613 | * |
| 1614 | * @see #setFormat |
| 1615 | * @see PixelFormat |
| 1616 | */ |
| 1617 | protected void setDefaultWindowFormat(int format) { |
| 1618 | mDefaultWindowFormat = format; |
| 1619 | if (!mHaveWindowFormat) { |
| 1620 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1621 | attrs.format = format; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1622 | dispatchWindowAttributesChanged(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1623 | } |
| 1624 | } |
| 1625 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1626 | /** @hide */ |
| 1627 | protected boolean haveDimAmount() { |
| 1628 | return mHaveDimAmount; |
| 1629 | } |
| 1630 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1631 | public abstract void setChildDrawable(int featureId, Drawable drawable); |
| 1632 | |
| 1633 | public abstract void setChildInt(int featureId, int value); |
| 1634 | |
| 1635 | /** |
| 1636 | * Is a keypress one of the defined shortcut keys for this window. |
| 1637 | * @param keyCode the key code from {@link android.view.KeyEvent} to check. |
| 1638 | * @param event the {@link android.view.KeyEvent} to use to help check. |
| 1639 | */ |
| 1640 | public abstract boolean isShortcutKey(int keyCode, KeyEvent event); |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1641 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1642 | /** |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1643 | * @see android.app.Activity#setVolumeControlStream(int) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1644 | */ |
| 1645 | public abstract void setVolumeControlStream(int streamType); |
| 1646 | |
| 1647 | /** |
| 1648 | * @see android.app.Activity#getVolumeControlStream() |
| 1649 | */ |
| 1650 | public abstract int getVolumeControlStream(); |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 1651 | |
| 1652 | /** |
RoboErik | fd63dd0 | 2014-08-28 15:22:55 -0700 | [diff] [blame] | 1653 | * Sets a {@link MediaController} to send media keys and volume changes to. |
| 1654 | * If set, this should be preferred for all media keys and volume requests |
| 1655 | * sent to this window. |
| 1656 | * |
| 1657 | * @param controller The controller for the session which should receive |
| 1658 | * media keys and volume changes. |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1659 | * @see android.app.Activity#setMediaController(android.media.session.MediaController) |
| 1660 | */ |
| 1661 | public void setMediaController(MediaController controller) { |
| 1662 | } |
| 1663 | |
| 1664 | /** |
RoboErik | fd63dd0 | 2014-08-28 15:22:55 -0700 | [diff] [blame] | 1665 | * Gets the {@link MediaController} that was previously set. |
| 1666 | * |
| 1667 | * @return The controller which should receive events. |
| 1668 | * @see #setMediaController(android.media.session.MediaController) |
RoboErik | 5501165 | 2014-07-09 15:05:53 -0700 | [diff] [blame] | 1669 | * @see android.app.Activity#getMediaController() |
| 1670 | */ |
| 1671 | public MediaController getMediaController() { |
| 1672 | return null; |
| 1673 | } |
| 1674 | |
| 1675 | /** |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 1676 | * Set extra options that will influence the UI for this window. |
| 1677 | * @param uiOptions Flags specifying extra options for this window. |
| 1678 | */ |
| 1679 | public void setUiOptions(int uiOptions) { } |
Adam Powell | e43fca9 | 2011-08-16 12:57:01 -0700 | [diff] [blame] | 1680 | |
| 1681 | /** |
| 1682 | * Set extra options that will influence the UI for this window. |
| 1683 | * Only the bits filtered by mask will be modified. |
| 1684 | * @param uiOptions Flags specifying extra options for this window. |
| 1685 | * @param mask Flags specifying which options should be modified. Others will remain unchanged. |
| 1686 | */ |
| 1687 | public void setUiOptions(int uiOptions, int mask) { } |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1688 | |
| 1689 | /** |
| 1690 | * Set the primary icon for this window. |
| 1691 | * |
| 1692 | * @param resId resource ID of a drawable to set |
| 1693 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1694 | public void setIcon(@DrawableRes int resId) { } |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1695 | |
| 1696 | /** |
| 1697 | * Set the default icon for this window. |
| 1698 | * This will be overridden by any other icon set operation which could come from the |
| 1699 | * theme or another explicit set. |
| 1700 | * |
| 1701 | * @hide |
| 1702 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1703 | public void setDefaultIcon(@DrawableRes int resId) { } |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1704 | |
| 1705 | /** |
| 1706 | * Set the logo for this window. A logo is often shown in place of an |
| 1707 | * {@link #setIcon(int) icon} but is generally wider and communicates window title information |
| 1708 | * as well. |
| 1709 | * |
| 1710 | * @param resId resource ID of a drawable to set |
| 1711 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1712 | public void setLogo(@DrawableRes int resId) { } |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1713 | |
| 1714 | /** |
| 1715 | * Set the default logo for this window. |
| 1716 | * This will be overridden by any other logo set operation which could come from the |
| 1717 | * theme or another explicit set. |
| 1718 | * |
| 1719 | * @hide |
| 1720 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 1721 | public void setDefaultLogo(@DrawableRes int resId) { } |
keunyoung | 30f420f | 2013-08-02 14:23:10 -0700 | [diff] [blame] | 1722 | |
| 1723 | /** |
| 1724 | * Set focus locally. The window should have the |
| 1725 | * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already. |
| 1726 | * @param hasFocus Whether this window has focus or not. |
| 1727 | * @param inTouchMode Whether this window is in touch mode or not. |
| 1728 | */ |
| 1729 | public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { } |
| 1730 | |
| 1731 | /** |
| 1732 | * Inject an event to window locally. |
| 1733 | * @param event A key or touch event to inject to this window. |
| 1734 | */ |
| 1735 | public void injectInputEvent(InputEvent event) { } |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1736 | |
| 1737 | /** |
| 1738 | * Retrieve the {@link TransitionManager} responsible for for default transitions |
| 1739 | * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}. |
| 1740 | * |
| 1741 | * <p>This method will return non-null after content has been initialized (e.g. by using |
| 1742 | * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p> |
| 1743 | * |
| 1744 | * @return This window's content TransitionManager or null if none is set. |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 1745 | * @attr ref android.R.styleable#Window_windowContentTransitionManager |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1746 | */ |
| 1747 | public TransitionManager getTransitionManager() { |
| 1748 | return null; |
| 1749 | } |
| 1750 | |
| 1751 | /** |
| 1752 | * Set the {@link TransitionManager} to use for default transitions in this window. |
| 1753 | * Requires {@link #FEATURE_CONTENT_TRANSITIONS}. |
| 1754 | * |
| 1755 | * @param tm The TransitionManager to use for scene changes. |
George Mount | c3a043c | 2015-02-04 14:37:04 -0800 | [diff] [blame] | 1756 | * @attr ref android.R.styleable#Window_windowContentTransitionManager |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1757 | */ |
| 1758 | public void setTransitionManager(TransitionManager tm) { |
| 1759 | throw new UnsupportedOperationException(); |
| 1760 | } |
| 1761 | |
| 1762 | /** |
| 1763 | * Retrieve the {@link Scene} representing this window's current content. |
| 1764 | * Requires {@link #FEATURE_CONTENT_TRANSITIONS}. |
| 1765 | * |
| 1766 | * <p>This method will return null if the current content is not represented by a Scene.</p> |
| 1767 | * |
| 1768 | * @return Current Scene being shown or null |
| 1769 | */ |
| 1770 | public Scene getContentScene() { |
| 1771 | return null; |
| 1772 | } |
| 1773 | |
| 1774 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1775 | * Sets the Transition that will be used to move Views into the initial scene. The entering |
| 1776 | * Views will be those that are regular Views or ViewGroups that have |
| 1777 | * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1778 | * {@link android.transition.Visibility} as entering is governed by changing visibility from |
| 1779 | * {@link View#INVISIBLE} to {@link View#VISIBLE}. If <code>transition</code> is null, |
| 1780 | * entering Views will remain unaffected. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1781 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1782 | * @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] | 1783 | * @attr ref android.R.styleable#Window_windowEnterTransition |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1784 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1785 | public void setEnterTransition(Transition transition) {} |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1786 | |
| 1787 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1788 | * Sets the Transition that will be used to move Views out of the scene when the Window is |
| 1789 | * preparing to close, for example after a call to |
| 1790 | * {@link android.app.Activity#finishAfterTransition()}. The exiting |
| 1791 | * Views will be those that are regular Views or ViewGroups that have |
| 1792 | * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1793 | * {@link android.transition.Visibility} as entering is governed by changing visibility from |
| 1794 | * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null, |
| 1795 | * entering Views will remain unaffected. If nothing is set, the default will be to |
| 1796 | * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1797 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1798 | * @param transition The Transition to use to move Views out of the Scene when the Window |
| 1799 | * is preparing to close. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1800 | * @attr ref android.R.styleable#Window_windowReturnTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1801 | */ |
| 1802 | public void setReturnTransition(Transition transition) {} |
| 1803 | |
| 1804 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1805 | * Sets the Transition that will be used to move Views out of the scene when starting a |
| 1806 | * new Activity. The exiting Views will be those that are regular Views or ViewGroups that |
| 1807 | * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1808 | * {@link android.transition.Visibility} as exiting is governed by changing visibility |
| 1809 | * 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] | 1810 | * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1811 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1812 | * @param transition The Transition to use to move Views out of the scene when calling a |
| 1813 | * new Activity. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1814 | * @attr ref android.R.styleable#Window_windowExitTransition |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1815 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1816 | public void setExitTransition(Transition transition) {} |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1817 | |
| 1818 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1819 | * Sets the Transition that will be used to move Views in to the scene when returning from |
| 1820 | * a previously-started Activity. The entering Views will be those that are regular Views |
| 1821 | * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions |
| 1822 | * will extend {@link android.transition.Visibility} as exiting is governed by changing |
| 1823 | * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, |
| 1824 | * the views will remain unaffected. If nothing is set, the default will be to use the same |
| 1825 | * transition as {@link #setExitTransition(android.transition.Transition)}. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1826 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1827 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1828 | * @param transition The Transition to use to move Views into the scene when reentering from a |
| 1829 | * previously-started Activity. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1830 | * @attr ref android.R.styleable#Window_windowReenterTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1831 | */ |
| 1832 | public void setReenterTransition(Transition transition) {} |
| 1833 | |
| 1834 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1835 | * Returns the transition used to move Views into the initial scene. The entering |
| 1836 | * Views will be those that are regular Views or ViewGroups that have |
| 1837 | * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1838 | * {@link android.transition.Visibility} as entering is governed by changing visibility from |
| 1839 | * {@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] | 1840 | * entering Views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1841 | * |
| 1842 | * @return the Transition to use to move Views into the initial Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1843 | * @attr ref android.R.styleable#Window_windowEnterTransition |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1844 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1845 | public Transition getEnterTransition() { return null; } |
George Mount | cb4b7d9 | 2014-02-25 10:47:55 -0800 | [diff] [blame] | 1846 | |
| 1847 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1848 | * Returns he Transition that will be used to move Views out of the scene when the Window is |
| 1849 | * preparing to close, for example after a call to |
| 1850 | * {@link android.app.Activity#finishAfterTransition()}. The exiting |
| 1851 | * Views will be those that are regular Views or ViewGroups that have |
| 1852 | * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1853 | * {@link android.transition.Visibility} as entering is governed by changing visibility from |
| 1854 | * {@link View#VISIBLE} to {@link View#INVISIBLE}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1855 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1856 | * @return The Transition to use to move Views out of the Scene when the Window |
| 1857 | * is preparing to close. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1858 | * @attr ref android.R.styleable#Window_windowReturnTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1859 | */ |
| 1860 | public Transition getReturnTransition() { return null; } |
| 1861 | |
| 1862 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1863 | * Returns the Transition that will be used to move Views out of the scene when starting a |
| 1864 | * new Activity. The exiting Views will be those that are regular Views or ViewGroups that |
| 1865 | * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend |
| 1866 | * {@link android.transition.Visibility} as exiting is governed by changing visibility |
| 1867 | * 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] | 1868 | * remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1869 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1870 | * @return the Transition to use to move Views out of the scene when calling a |
| 1871 | * new Activity. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1872 | * @attr ref android.R.styleable#Window_windowExitTransition |
George Mount | cb4b7d9 | 2014-02-25 10:47:55 -0800 | [diff] [blame] | 1873 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1874 | public Transition getExitTransition() { return null; } |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1875 | |
| 1876 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1877 | * Returns the Transition that will be used to move Views in to the scene when returning from |
| 1878 | * a previously-started Activity. The entering Views will be those that are regular Views |
| 1879 | * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions |
| 1880 | * will extend {@link android.transition.Visibility} as exiting is governed by changing |
| 1881 | * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1882 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1883 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1884 | * @return The Transition to use to move Views into the scene when reentering from a |
| 1885 | * previously-started Activity. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1886 | * @attr ref android.R.styleable#Window_windowReenterTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1887 | */ |
| 1888 | public Transition getReenterTransition() { return null; } |
| 1889 | |
| 1890 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1891 | * Sets the Transition that will be used for shared elements transferred into the content |
| 1892 | * Scene. Typical Transitions will affect size and location, such as |
George Mount | 990205e | 2014-06-24 09:36:18 -0700 | [diff] [blame] | 1893 | * {@link android.transition.ChangeBounds}. A null |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1894 | * value will cause transferred shared elements to blink to the final position. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1895 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1896 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1897 | * @param transition The Transition to use for shared elements transferred into the content |
| 1898 | * Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1899 | * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1900 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1901 | public void setSharedElementEnterTransition(Transition transition) {} |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 1902 | |
| 1903 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1904 | * Sets the Transition that will be used for shared elements transferred back to a |
| 1905 | * calling Activity. Typical Transitions will affect size and location, such as |
| 1906 | * {@link android.transition.ChangeBounds}. A null |
| 1907 | * value will cause transferred shared elements to blink to the final position. |
| 1908 | * If no value is set, the default will be to use the same value as |
| 1909 | * {@link #setSharedElementEnterTransition(android.transition.Transition)}. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1910 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1911 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1912 | * @param transition The Transition to use for shared elements transferred out of the content |
| 1913 | * Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1914 | * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1915 | */ |
| 1916 | public void setSharedElementReturnTransition(Transition transition) {} |
| 1917 | |
| 1918 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1919 | * 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] | 1920 | * Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1921 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1922 | * @return Transition to use for sharend elements transferred into the content Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1923 | * @attr ref android.R.styleable#Window_windowSharedElementEnterTransition |
George Mount | cb4b7d9 | 2014-02-25 10:47:55 -0800 | [diff] [blame] | 1924 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1925 | public Transition getSharedElementEnterTransition() { return null; } |
George Mount | cb4b7d9 | 2014-02-25 10:47:55 -0800 | [diff] [blame] | 1926 | |
| 1927 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1928 | * 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] | 1929 | * calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1930 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1931 | * @return Transition to use for sharend elements transferred into the content Scene. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1932 | * @attr ref android.R.styleable#Window_windowSharedElementReturnTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1933 | */ |
| 1934 | public Transition getSharedElementReturnTransition() { return null; } |
| 1935 | |
| 1936 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1937 | * Sets the Transition that will be used for shared elements after starting a new Activity |
| 1938 | * before the shared elements are transferred to the called Activity. If the shared elements |
| 1939 | * must animate during the exit transition, this Transition should be used. Upon completion, |
| 1940 | * the shared elements may be transferred to the started Activity. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1941 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1942 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1943 | * @param transition The Transition to use for shared elements in the launching Window |
| 1944 | * prior to transferring to the launched Activity's Window. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1945 | * @attr ref android.R.styleable#Window_windowSharedElementExitTransition |
George Mount | e180337 | 2014-02-26 19:00:52 +0000 | [diff] [blame] | 1946 | */ |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1947 | public void setSharedElementExitTransition(Transition transition) {} |
| 1948 | |
| 1949 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1950 | * Sets the Transition that will be used for shared elements reentering from a started |
| 1951 | * Activity after it has returned the shared element to it start location. If no value |
| 1952 | * is set, this will default to |
| 1953 | * {@link #setSharedElementExitTransition(android.transition.Transition)}. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1954 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1955 | * |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1956 | * @param transition The Transition to use for shared elements in the launching Window |
| 1957 | * after the shared element has returned to the Window. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1958 | * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1959 | */ |
| 1960 | public void setSharedElementReenterTransition(Transition transition) {} |
| 1961 | |
| 1962 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1963 | * Returns the Transition to use for shared elements in the launching Window prior |
| 1964 | * to transferring to the launched Activity's Window. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1965 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1966 | * |
| 1967 | * @return the Transition to use for shared elements in the launching Window prior |
| 1968 | * to transferring to the launched Activity's Window. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1969 | * @attr ref android.R.styleable#Window_windowSharedElementExitTransition |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1970 | */ |
| 1971 | public Transition getSharedElementExitTransition() { return null; } |
| 1972 | |
| 1973 | /** |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1974 | * Returns the Transition that will be used for shared elements reentering from a started |
| 1975 | * Activity after it has returned the shared element to it start location. |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 1976 | * Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1977 | * |
| 1978 | * @return the Transition that will be used for shared elements reentering from a started |
| 1979 | * Activity after it has returned the shared element to it start location. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1980 | * @attr ref android.R.styleable#Window_windowSharedElementReenterTransition |
George Mount | 68f96d8 | 2014-07-31 13:13:10 -0700 | [diff] [blame] | 1981 | */ |
| 1982 | public Transition getSharedElementReenterTransition() { return null; } |
| 1983 | |
| 1984 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1985 | * Controls how the transition set in |
| 1986 | * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit |
| 1987 | * transition of the calling Activity. When true, the transition will start as soon as possible. |
| 1988 | * When false, the transition will wait until the remote exiting transition completes before |
| 1989 | * starting. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1990 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1991 | * @param allow true to start the enter transition when possible or false to |
| 1992 | * wait until the exiting transition completes. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 1993 | * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 1994 | */ |
| 1995 | public void setAllowEnterTransitionOverlap(boolean allow) {} |
| 1996 | |
| 1997 | /** |
| 1998 | * Returns how the transition set in |
| 1999 | * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit |
| 2000 | * transition of the calling Activity. When true, the transition will start as soon as possible. |
| 2001 | * When false, the transition will wait until the remote exiting transition completes before |
| 2002 | * starting. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2003 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2004 | * @return true when the enter transition should start as soon as possible or false to |
| 2005 | * when it should wait until the exiting transition completes. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2006 | * @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2007 | */ |
| 2008 | public boolean getAllowEnterTransitionOverlap() { return true; } |
| 2009 | |
| 2010 | /** |
| 2011 | * Controls how the transition set in |
| 2012 | * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit |
| 2013 | * transition of the called Activity when reentering after if finishes. When true, |
| 2014 | * the transition will start as soon as possible. When false, the transition will wait |
| 2015 | * until the called Activity's exiting transition completes before starting. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2016 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2017 | * @param allow true to start the transition when possible or false to wait until the |
| 2018 | * called Activity's exiting transition completes. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2019 | * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2020 | */ |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2021 | public void setAllowReturnTransitionOverlap(boolean allow) {} |
| 2022 | |
| 2023 | /** |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2024 | * Returns how the transition set in |
| 2025 | * {@link #setExitTransition(android.transition.Transition)} overlaps with the exit |
| 2026 | * transition of the called Activity when reentering after if finishes. When true, |
| 2027 | * the transition will start as soon as possible. When false, the transition will wait |
| 2028 | * until the called Activity's exiting transition completes before starting. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2029 | * |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2030 | * @return true when the transition should start when possible or false when it should wait |
| 2031 | * until the called Activity's exiting transition completes. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2032 | * @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap |
George Mount | 31a2172 | 2014-03-24 17:44:36 -0700 | [diff] [blame] | 2033 | */ |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2034 | public boolean getAllowReturnTransitionOverlap() { return true; } |
| 2035 | |
| 2036 | /** |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2037 | * Returns the duration, in milliseconds, of the window background fade |
| 2038 | * when transitioning into or away from an Activity when called with an Activity Transition. |
| 2039 | * <p>When executing the enter transition, the background starts transparent |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2040 | * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2041 | * 300 milliseconds.</p> |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2042 | * |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2043 | * @return The duration of the window background fade to opaque during enter transition. |
| 2044 | * @see #getEnterTransition() |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2045 | * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2046 | */ |
| 2047 | public long getTransitionBackgroundFadeDuration() { return 0; } |
| 2048 | |
| 2049 | /** |
| 2050 | * Sets the duration, in milliseconds, of the window background fade |
| 2051 | * when transitioning into or away from an Activity when called with an Activity Transition. |
| 2052 | * <p>When executing the enter transition, the background starts transparent |
George Mount | 9826f63 | 2014-09-11 08:50:09 -0700 | [diff] [blame] | 2053 | * and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2054 | * 300 milliseconds.</p> |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2055 | * |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2056 | * @param fadeDurationMillis The duration of the window background fade to or from opaque |
| 2057 | * during enter transition. |
| 2058 | * @see #setEnterTransition(android.transition.Transition) |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2059 | * @attr ref android.R.styleable#Window_windowTransitionBackgroundFadeDuration |
George Mount | ed1e01d | 2014-06-05 13:49:12 -0700 | [diff] [blame] | 2060 | */ |
| 2061 | public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { } |
| 2062 | |
| 2063 | /** |
George Mount | b89d5cc | 2014-08-18 16:50:50 -0700 | [diff] [blame] | 2064 | * Returns <code>true</code> when shared elements should use an Overlay during |
| 2065 | * shared element transitions or <code>false</code> when they should animate as |
| 2066 | * part of the normal View hierarchy. The default value is true. |
| 2067 | * |
| 2068 | * @return <code>true</code> when shared elements should use an Overlay during |
| 2069 | * shared element transitions or <code>false</code> when they should animate as |
| 2070 | * part of the normal View hierarchy. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2071 | * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay |
George Mount | b89d5cc | 2014-08-18 16:50:50 -0700 | [diff] [blame] | 2072 | */ |
| 2073 | public boolean getSharedElementsUseOverlay() { return true; } |
| 2074 | |
| 2075 | /** |
| 2076 | * Sets whether or not shared elements should use an Overlay during shared element transitions. |
| 2077 | * The default value is true. |
| 2078 | * |
| 2079 | * @param sharedElementsUseOverlay <code>true</code> indicates that shared elements should |
| 2080 | * be transitioned with an Overlay or <code>false</code> |
| 2081 | * to transition within the normal View hierarchy. |
George Mount | c03da0e | 2014-08-22 17:04:02 -0700 | [diff] [blame] | 2082 | * @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay |
George Mount | b89d5cc | 2014-08-18 16:50:50 -0700 | [diff] [blame] | 2083 | */ |
| 2084 | public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { } |
| 2085 | |
| 2086 | /** |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2087 | * @return the color of the status bar. |
| 2088 | */ |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 2089 | @ColorInt |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2090 | public abstract int getStatusBarColor(); |
| 2091 | |
| 2092 | /** |
John Spurlock | bc4cf00 | 2015-03-24 21:51:20 -0400 | [diff] [blame] | 2093 | * Sets the color of the status bar to {@code color}. |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2094 | * |
| 2095 | * For this to take effect, |
| 2096 | * the window must be drawing the system bar backgrounds with |
| 2097 | * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and |
| 2098 | * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set. |
| 2099 | * |
John Spurlock | bc4cf00 | 2015-03-24 21:51:20 -0400 | [diff] [blame] | 2100 | * If {@code color} is not opaque, consider setting |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2101 | * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and |
| 2102 | * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}. |
George Mount | 238010f | 2014-06-30 17:31:17 -0700 | [diff] [blame] | 2103 | * <p> |
| 2104 | * The transitionName for the view background will be "android:status:background". |
| 2105 | * </p> |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2106 | */ |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 2107 | public abstract void setStatusBarColor(@ColorInt int color); |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2108 | |
| 2109 | /** |
| 2110 | * @return the color of the navigation bar. |
| 2111 | */ |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 2112 | @ColorInt |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2113 | public abstract int getNavigationBarColor(); |
| 2114 | |
| 2115 | /** |
| 2116 | * Sets the color of the navigation bar to {@param color}. |
| 2117 | * |
| 2118 | * For this to take effect, |
| 2119 | * the window must be drawing the system bar backgrounds with |
| 2120 | * {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and |
| 2121 | * {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set. |
| 2122 | * |
| 2123 | * If {@param color} is not opaque, consider setting |
| 2124 | * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and |
| 2125 | * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}. |
George Mount | 238010f | 2014-06-30 17:31:17 -0700 | [diff] [blame] | 2126 | * <p> |
| 2127 | * The transitionName for the view background will be "android:navigation:background". |
| 2128 | * </p> |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2129 | */ |
Tor Norbye | 80756e3 | 2015-03-02 09:39:27 -0800 | [diff] [blame] | 2130 | public abstract void setNavigationBarColor(@ColorInt int color); |
Adrian Roos | 217ccd2 | 2014-05-09 14:29:04 +0200 | [diff] [blame] | 2131 | |
Filip Gruszczynski | 0daf210 | 2015-09-29 08:39:07 -0700 | [diff] [blame] | 2132 | /** @hide */ |
| 2133 | public void setTheme(int resId) { |
| 2134 | } |
Filip Gruszczynski | 6325065 | 2015-11-18 14:43:01 -0800 | [diff] [blame] | 2135 | |
| 2136 | /** |
| 2137 | * Whether the caption should be displayed directly on the content rather than push the content |
| 2138 | * down. This affects only freeform windows since they display the caption. |
| 2139 | * @hide |
| 2140 | */ |
| 2141 | public void setOverlayDecorCaption(boolean overlayCaption) { |
| 2142 | mOverlayWithDecorCaption = overlayCaption; |
| 2143 | } |
| 2144 | |
| 2145 | /** @hide */ |
| 2146 | public boolean getOverlayDecorCaption() { |
| 2147 | return mOverlayWithDecorCaption; |
| 2148 | } |
Filip Gruszczynski | 9b81e40 | 2015-12-08 15:42:01 -0800 | [diff] [blame] | 2149 | |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2150 | /** @hide */ |
| 2151 | public void notifyRestrictedCaptionAreaCallback(int left, int top, int right, int bottom) { |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 2152 | if (mOnRestrictedCaptionAreaChangedListener != null) { |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2153 | mRestrictedCaptionAreaRect.set(left, top, right, bottom); |
Wale Ogunwale | a504ca3 | 2016-01-30 16:02:13 -0800 | [diff] [blame] | 2154 | mOnRestrictedCaptionAreaChangedListener.onRestrictedCaptionAreaChanged( |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2155 | mRestrictedCaptionAreaRect); |
| 2156 | } |
| 2157 | } |
Filip Gruszczynski | 9b81e40 | 2015-12-08 15:42:01 -0800 | [diff] [blame] | 2158 | |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2159 | /** |
| 2160 | * 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] | 2161 | * the color from the theme. You can overwrite this by using {@link #DECOR_CAPTION_SHADE_DARK}, |
| 2162 | * {@link #DECOR_CAPTION_SHADE_LIGHT}, or {@link #DECOR_CAPTION_SHADE_AUTO}. |
| 2163 | * @see #DECOR_CAPTION_SHADE_DARK |
| 2164 | * @see #DECOR_CAPTION_SHADE_LIGHT |
| 2165 | * @see #DECOR_CAPTION_SHADE_AUTO |
Filip Gruszczynski | 3dec081 | 2015-12-09 08:42:41 -0800 | [diff] [blame] | 2166 | */ |
| 2167 | public abstract void setDecorCaptionShade(int decorCaptionShade); |
| 2168 | |
| 2169 | /** |
| 2170 | * Set the drawable that is drawn underneath the caption during the resizing. |
| 2171 | * |
| 2172 | * During the resizing the caption might not be drawn fast enough to match the new dimensions. |
| 2173 | * There is a second caption drawn underneath it that will be fast enough. By default the |
| 2174 | * caption is constructed from the theme. You can provide a drawable, that will be drawn instead |
| 2175 | * to better match your application. |
| 2176 | */ |
| 2177 | public abstract void setResizingCaptionDrawable(Drawable drawable); |
Wale Ogunwale | eb6722c | 2015-12-08 11:43:43 -0800 | [diff] [blame] | 2178 | |
| 2179 | /** |
| 2180 | * Called when the activity changes from fullscreen mode to multi-window mode and visa-versa. |
| 2181 | * @hide |
| 2182 | */ |
Wale Ogunwale | 3b93a4d | 2016-01-29 17:46:53 -0800 | [diff] [blame] | 2183 | public abstract void onMultiWindowChanged(); |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 2184 | |
| 2185 | /** |
| 2186 | * Called when the activity just relaunched. |
| 2187 | * @hide |
| 2188 | */ |
| 2189 | public abstract void reportActivityRelaunched(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2190 | } |