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 | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.Nullable; |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 21 | import android.app.ActivityOptions; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.content.Context; |
| 23 | import android.content.res.Configuration; |
| 24 | import android.content.res.TypedArray; |
| 25 | import android.graphics.PixelFormat; |
| 26 | import android.graphics.drawable.Drawable; |
| 27 | import android.net.Uri; |
| 28 | import android.os.Bundle; |
| 29 | import android.os.IBinder; |
Romain Guy | 9622e20 | 2011-09-29 16:37:27 -0700 | [diff] [blame] | 30 | import android.os.SystemProperties; |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 31 | import android.transition.Scene; |
| 32 | import android.transition.TransitionManager; |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 33 | import android.view.accessibility.AccessibilityEvent; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Abstract base class for a top-level window look and behavior policy. An |
| 37 | * instance of this class should be used as the top-level view added to the |
| 38 | * window manager. It provides standard UI policies such as a background, title |
| 39 | * area, default key processing, etc. |
| 40 | * |
| 41 | * <p>The only existing implementation of this abstract class is |
| 42 | * android.policy.PhoneWindow, which you should instantiate when needing a |
| 43 | * Window. Eventually that class will be refactored and a factory method |
| 44 | * added for creating Window instances without knowing about a particular |
| 45 | * implementation. |
| 46 | */ |
| 47 | public abstract class Window { |
| 48 | /** Flag for the "options panel" feature. This is enabled by default. */ |
| 49 | public static final int FEATURE_OPTIONS_PANEL = 0; |
| 50 | /** Flag for the "no title" feature, turning off the title at the top |
| 51 | * of the screen. */ |
| 52 | public static final int FEATURE_NO_TITLE = 1; |
| 53 | /** Flag for the progress indicator feature */ |
| 54 | public static final int FEATURE_PROGRESS = 2; |
| 55 | /** Flag for having an icon on the left side of the title bar */ |
| 56 | public static final int FEATURE_LEFT_ICON = 3; |
| 57 | /** Flag for having an icon on the right side of the title bar */ |
| 58 | public static final int FEATURE_RIGHT_ICON = 4; |
| 59 | /** Flag for indeterminate progress */ |
| 60 | public static final int FEATURE_INDETERMINATE_PROGRESS = 5; |
| 61 | /** Flag for the context menu. This is enabled by default. */ |
| 62 | public static final int FEATURE_CONTEXT_MENU = 6; |
| 63 | /** Flag for custom title. You cannot combine this feature with other title features. */ |
| 64 | public static final int FEATURE_CUSTOM_TITLE = 7; |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 65 | /** |
| 66 | * Flag for enabling the Action Bar. |
| 67 | * This is enabled by default for some devices. The Action Bar |
| 68 | * replaces the title bar and provides an alternate location |
| 69 | * for an on-screen menu button on some devices. |
| 70 | */ |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 71 | public static final int FEATURE_ACTION_BAR = 8; |
| 72 | /** |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 73 | * Flag for requesting an Action Bar that overlays window content. |
| 74 | * Normally an Action Bar will sit in the space above window content, but if this |
| 75 | * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over |
| 76 | * the window content itself. This is useful if you would like your app to have more control |
| 77 | * over how the Action Bar is displayed, such as letting application content scroll beneath |
| 78 | * an Action Bar with a transparent background or otherwise displaying a transparent/translucent |
| 79 | * Action Bar over application content. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 80 | * |
| 81 | * <p>This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN |
| 82 | * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the |
| 83 | * action bar in conjunction with other screen decorations. |
| 84 | * |
| 85 | * <p>As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an |
| 86 | * ActionBar is in this mode it will adjust the insets provided to |
| 87 | * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)} |
| 88 | * to include the content covered by the action bar, so you can do layout within |
| 89 | * that space. |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 90 | */ |
| 91 | public static final int FEATURE_ACTION_BAR_OVERLAY = 9; |
| 92 | /** |
Adam Powell | 5d27977 | 2010-07-27 16:34:07 -0700 | [diff] [blame] | 93 | * Flag for specifying the behavior of action modes when an Action Bar is not present. |
| 94 | * If overlay is enabled, the action mode UI will be allowed to cover existing window content. |
| 95 | */ |
Adam Powell | 6b336f8 | 2010-08-10 20:13:01 -0700 | [diff] [blame] | 96 | public static final int FEATURE_ACTION_MODE_OVERLAY = 10; |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 97 | /** |
| 98 | * Flag for requesting that window content changes should be represented |
| 99 | * with scenes and transitions. |
| 100 | * |
| 101 | * TODO Add docs |
| 102 | * |
| 103 | * @see #setContentView |
| 104 | */ |
| 105 | public static final int FEATURE_CONTENT_TRANSITIONS = 11; |
Adam Powell | 4b6d93f | 2012-09-18 18:34:08 -0700 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * Max value used as a feature ID |
| 109 | * @hide |
| 110 | */ |
Adam Powell | 18e905f | 2013-10-24 14:27:48 -0700 | [diff] [blame] | 111 | public static final int FEATURE_MAX = FEATURE_CONTENT_TRANSITIONS; |
Adam Powell | 4b6d93f | 2012-09-18 18:34:08 -0700 | [diff] [blame] | 112 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | /** Flag for setting the progress bar's visibility to VISIBLE */ |
| 114 | public static final int PROGRESS_VISIBILITY_ON = -1; |
| 115 | /** Flag for setting the progress bar's visibility to GONE */ |
| 116 | public static final int PROGRESS_VISIBILITY_OFF = -2; |
| 117 | /** Flag for setting the progress bar's indeterminate mode on */ |
| 118 | public static final int PROGRESS_INDETERMINATE_ON = -3; |
| 119 | /** Flag for setting the progress bar's indeterminate mode off */ |
| 120 | public static final int PROGRESS_INDETERMINATE_OFF = -4; |
| 121 | /** Starting value for the (primary) progress */ |
| 122 | public static final int PROGRESS_START = 0; |
| 123 | /** Ending value for the (primary) progress */ |
| 124 | public static final int PROGRESS_END = 10000; |
| 125 | /** Lowest possible value for the secondary progress */ |
| 126 | public static final int PROGRESS_SECONDARY_START = 20000; |
| 127 | /** Highest possible value for the secondary progress */ |
| 128 | public static final int PROGRESS_SECONDARY_END = 30000; |
| 129 | |
| 130 | /** The default features enabled */ |
| 131 | @SuppressWarnings({"PointlessBitwiseExpression"}) |
| 132 | protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) | |
| 133 | (1 << FEATURE_CONTEXT_MENU); |
| 134 | |
| 135 | /** |
| 136 | * The ID that the main layout in the XML layout file should have. |
| 137 | */ |
| 138 | public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content; |
| 139 | |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 140 | private static final String PROPERTY_HARDWARE_UI = "persist.sys.ui.hw"; |
| 141 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 142 | private final Context mContext; |
| 143 | |
| 144 | private TypedArray mWindowStyle; |
| 145 | private Callback mCallback; |
| 146 | private WindowManager mWindowManager; |
| 147 | private IBinder mAppToken; |
| 148 | private String mAppName; |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 149 | private boolean mHardwareAccelerated; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 150 | private Window mContainer; |
| 151 | private Window mActiveChild; |
| 152 | private boolean mIsActive = false; |
| 153 | private boolean mHasChildren = false; |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 154 | private boolean mCloseOnTouchOutside = false; |
| 155 | private boolean mSetCloseOnTouchOutside = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 156 | private int mForcedWindowFlags = 0; |
| 157 | |
| 158 | private int mFeatures = DEFAULT_FEATURES; |
| 159 | private int mLocalFeatures = DEFAULT_FEATURES; |
| 160 | |
| 161 | private boolean mHaveWindowFormat = false; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 162 | private boolean mHaveDimAmount = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 163 | private int mDefaultWindowFormat = PixelFormat.OPAQUE; |
| 164 | |
| 165 | private boolean mHasSoftInputMode = false; |
| 166 | |
Dianne Hackborn | 291905e | 2010-08-17 15:17:15 -0700 | [diff] [blame] | 167 | private boolean mDestroyed; |
| 168 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | // The current window attributes. |
| 170 | private final WindowManager.LayoutParams mWindowAttributes = |
| 171 | new WindowManager.LayoutParams(); |
| 172 | |
| 173 | /** |
| 174 | * API from a Window back to its caller. This allows the client to |
| 175 | * intercept key dispatching, panels and menus, etc. |
| 176 | */ |
| 177 | public interface Callback { |
| 178 | /** |
| 179 | * Called to process key events. At the very least your |
| 180 | * implementation must call |
| 181 | * {@link android.view.Window#superDispatchKeyEvent} to do the |
| 182 | * standard key processing. |
| 183 | * |
| 184 | * @param event The key event. |
| 185 | * |
| 186 | * @return boolean Return true if this event was consumed. |
| 187 | */ |
| 188 | public boolean dispatchKeyEvent(KeyEvent event); |
| 189 | |
| 190 | /** |
Jeff Brown | 64da12a | 2011-01-04 19:57:47 -0800 | [diff] [blame] | 191 | * Called to process a key shortcut event. |
| 192 | * At the very least your implementation must call |
| 193 | * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the |
| 194 | * standard key shortcut processing. |
| 195 | * |
| 196 | * @param event The key shortcut event. |
| 197 | * @return True if this event was consumed. |
| 198 | */ |
| 199 | public boolean dispatchKeyShortcutEvent(KeyEvent event); |
| 200 | |
| 201 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 202 | * Called to process touch screen events. At the very least your |
| 203 | * implementation must call |
| 204 | * {@link android.view.Window#superDispatchTouchEvent} to do the |
| 205 | * standard touch screen processing. |
| 206 | * |
| 207 | * @param event The touch screen event. |
| 208 | * |
| 209 | * @return boolean Return true if this event was consumed. |
| 210 | */ |
| 211 | public boolean dispatchTouchEvent(MotionEvent event); |
| 212 | |
| 213 | /** |
| 214 | * Called to process trackball events. At the very least your |
| 215 | * implementation must call |
| 216 | * {@link android.view.Window#superDispatchTrackballEvent} to do the |
| 217 | * standard trackball processing. |
| 218 | * |
| 219 | * @param event The trackball event. |
| 220 | * |
| 221 | * @return boolean Return true if this event was consumed. |
| 222 | */ |
| 223 | public boolean dispatchTrackballEvent(MotionEvent event); |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 224 | |
| 225 | /** |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 226 | * Called to process generic motion events. At the very least your |
| 227 | * implementation must call |
| 228 | * {@link android.view.Window#superDispatchGenericMotionEvent} to do the |
| 229 | * standard processing. |
| 230 | * |
| 231 | * @param event The generic motion event. |
| 232 | * |
| 233 | * @return boolean Return true if this event was consumed. |
| 234 | */ |
| 235 | public boolean dispatchGenericMotionEvent(MotionEvent event); |
| 236 | |
| 237 | /** |
svetoslavganov | 75986cf | 2009-05-14 22:28:01 -0700 | [diff] [blame] | 238 | * Called to process population of {@link AccessibilityEvent}s. |
| 239 | * |
| 240 | * @param event The event. |
| 241 | * |
| 242 | * @return boolean Return true if event population was completed. |
| 243 | */ |
| 244 | public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event); |
| 245 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | /** |
| 247 | * Instantiate the view to display in the panel for 'featureId'. |
| 248 | * You can return null, in which case the default content (typically |
| 249 | * a menu) will be created for you. |
| 250 | * |
| 251 | * @param featureId Which panel is being created. |
| 252 | * |
| 253 | * @return view The top-level view to place in the panel. |
| 254 | * |
| 255 | * @see #onPreparePanel |
| 256 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 257 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 258 | public View onCreatePanelView(int featureId); |
| 259 | |
| 260 | /** |
| 261 | * Initialize the contents of the menu for panel 'featureId'. This is |
| 262 | * called if onCreatePanelView() returns null, giving you a standard |
| 263 | * menu in which you can place your items. It is only called once for |
| 264 | * the panel, the first time it is shown. |
| 265 | * |
| 266 | * <p>You can safely hold on to <var>menu</var> (and any items created |
| 267 | * from it), making modifications to it as desired, until the next |
| 268 | * time onCreatePanelMenu() is called for this feature. |
| 269 | * |
| 270 | * @param featureId The panel being created. |
| 271 | * @param menu The menu inside the panel. |
| 272 | * |
| 273 | * @return boolean You must return true for the panel to be displayed; |
| 274 | * if you return false it will not be shown. |
| 275 | */ |
| 276 | public boolean onCreatePanelMenu(int featureId, Menu menu); |
| 277 | |
| 278 | /** |
| 279 | * Prepare a panel to be displayed. This is called right before the |
| 280 | * panel window is shown, every time it is shown. |
| 281 | * |
| 282 | * @param featureId The panel that is being displayed. |
| 283 | * @param view The View that was returned by onCreatePanelView(). |
| 284 | * @param menu If onCreatePanelView() returned null, this is the Menu |
| 285 | * being displayed in the panel. |
| 286 | * |
| 287 | * @return boolean You must return true for the panel to be displayed; |
| 288 | * if you return false it will not be shown. |
| 289 | * |
| 290 | * @see #onCreatePanelView |
| 291 | */ |
| 292 | public boolean onPreparePanel(int featureId, View view, Menu menu); |
| 293 | |
| 294 | /** |
| 295 | * Called when a panel's menu is opened by the user. This may also be |
| 296 | * called when the menu is changing from one type to another (for |
| 297 | * example, from the icon menu to the expanded menu). |
| 298 | * |
| 299 | * @param featureId The panel that the menu is in. |
| 300 | * @param menu The menu that is opened. |
| 301 | * @return Return true to allow the menu to open, or false to prevent |
| 302 | * the menu from opening. |
| 303 | */ |
| 304 | public boolean onMenuOpened(int featureId, Menu menu); |
| 305 | |
| 306 | /** |
| 307 | * Called when a panel's menu item has been selected by the user. |
| 308 | * |
| 309 | * @param featureId The panel that the menu is in. |
| 310 | * @param item The menu item that was selected. |
| 311 | * |
| 312 | * @return boolean Return true to finish processing of selection, or |
| 313 | * false to perform the normal menu handling (calling its |
| 314 | * Runnable or sending a Message to its target Handler). |
| 315 | */ |
| 316 | public boolean onMenuItemSelected(int featureId, MenuItem item); |
| 317 | |
| 318 | /** |
| 319 | * This is called whenever the current window attributes change. |
| 320 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 321 | */ |
| 322 | public void onWindowAttributesChanged(WindowManager.LayoutParams attrs); |
| 323 | |
| 324 | /** |
| 325 | * This hook is called whenever the content view of the screen changes |
| 326 | * (due to a call to |
| 327 | * {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams) |
| 328 | * Window.setContentView} or |
| 329 | * {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams) |
| 330 | * Window.addContentView}). |
| 331 | */ |
| 332 | public void onContentChanged(); |
| 333 | |
| 334 | /** |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 335 | * This hook is called whenever the window focus changes. See |
| 336 | * {@link View#onWindowFocusChanged(boolean) |
| 337 | * View.onWindowFocusChanged(boolean)} for more information. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 338 | * |
| 339 | * @param hasFocus Whether the window now has focus. |
| 340 | */ |
| 341 | public void onWindowFocusChanged(boolean hasFocus); |
| 342 | |
| 343 | /** |
Dianne Hackborn | 3be63c0 | 2009-08-20 19:31:38 -0700 | [diff] [blame] | 344 | * Called when the window has been attached to the window manager. |
| 345 | * See {@link View#onAttachedToWindow() View.onAttachedToWindow()} |
| 346 | * for more information. |
| 347 | */ |
| 348 | public void onAttachedToWindow(); |
| 349 | |
| 350 | /** |
| 351 | * Called when the window has been attached to the window manager. |
| 352 | * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()} |
| 353 | * for more information. |
| 354 | */ |
| 355 | public void onDetachedFromWindow(); |
| 356 | |
| 357 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 358 | * Called when a panel is being closed. If another logical subsequent |
| 359 | * panel is being opened (and this panel is being closed to make room for the subsequent |
| 360 | * panel), this method will NOT be called. |
| 361 | * |
| 362 | * @param featureId The panel that is being displayed. |
| 363 | * @param menu If onCreatePanelView() returned null, this is the Menu |
| 364 | * being displayed in the panel. |
| 365 | */ |
| 366 | public void onPanelClosed(int featureId, Menu menu); |
| 367 | |
| 368 | /** |
| 369 | * Called when the user signals the desire to start a search. |
| 370 | * |
| 371 | * @return true if search launched, false if activity refuses (blocks) |
| 372 | * |
| 373 | * @see android.app.Activity#onSearchRequested() |
| 374 | */ |
| 375 | public boolean onSearchRequested(); |
Adam Powell | 6e34636 | 2010-07-23 10:18:23 -0700 | [diff] [blame] | 376 | |
| 377 | /** |
Adam Powell | debf3be | 2010-11-15 18:58:48 -0800 | [diff] [blame] | 378 | * Called when an action mode is being started for this window. Gives the |
| 379 | * callback an opportunity to handle the action mode in its own unique and |
| 380 | * beautiful way. If this method returns null the system can choose a way |
| 381 | * to present the mode or choose not to start the mode at all. |
Adam Powell | 6e34636 | 2010-07-23 10:18:23 -0700 | [diff] [blame] | 382 | * |
| 383 | * @param callback Callback to control the lifecycle of this action mode |
Adam Powell | debf3be | 2010-11-15 18:58:48 -0800 | [diff] [blame] | 384 | * @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] | 385 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 386 | @Nullable |
Adam Powell | debf3be | 2010-11-15 18:58:48 -0800 | [diff] [blame] | 387 | public ActionMode onWindowStartingActionMode(ActionMode.Callback callback); |
| 388 | |
| 389 | /** |
| 390 | * Called when an action mode has been started. The appropriate mode callback |
| 391 | * method will have already been invoked. |
| 392 | * |
| 393 | * @param mode The new mode that has just been started. |
| 394 | */ |
| 395 | public void onActionModeStarted(ActionMode mode); |
| 396 | |
| 397 | /** |
| 398 | * Called when an action mode has been finished. The appropriate mode callback |
| 399 | * method will have already been invoked. |
| 400 | * |
| 401 | * @param mode The mode that was just finished. |
| 402 | */ |
| 403 | public void onActionModeFinished(ActionMode mode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | public Window(Context context) { |
| 407 | mContext = context; |
| 408 | } |
| 409 | |
| 410 | /** |
| 411 | * Return the Context this window policy is running in, for retrieving |
| 412 | * resources and other information. |
| 413 | * |
| 414 | * @return Context The Context that was supplied to the constructor. |
| 415 | */ |
| 416 | public final Context getContext() { |
| 417 | return mContext; |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Return the {@link android.R.styleable#Window} attributes from this |
| 422 | * window's theme. |
| 423 | */ |
| 424 | public final TypedArray getWindowStyle() { |
| 425 | synchronized (this) { |
| 426 | if (mWindowStyle == null) { |
| 427 | mWindowStyle = mContext.obtainStyledAttributes( |
| 428 | com.android.internal.R.styleable.Window); |
| 429 | } |
| 430 | return mWindowStyle; |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Set the container for this window. If not set, the DecorWindow |
| 436 | * operates as a top-level window; otherwise, it negotiates with the |
| 437 | * container to display itself appropriately. |
| 438 | * |
| 439 | * @param container The desired containing Window. |
| 440 | */ |
| 441 | public void setContainer(Window container) { |
| 442 | mContainer = container; |
| 443 | if (container != null) { |
| 444 | // Embedded screens never have a title. |
| 445 | mFeatures |= 1<<FEATURE_NO_TITLE; |
| 446 | mLocalFeatures |= 1<<FEATURE_NO_TITLE; |
| 447 | container.mHasChildren = true; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Return the container for this Window. |
| 453 | * |
| 454 | * @return Window The containing window, or null if this is a |
| 455 | * top-level window. |
| 456 | */ |
| 457 | public final Window getContainer() { |
| 458 | return mContainer; |
| 459 | } |
| 460 | |
| 461 | public final boolean hasChildren() { |
| 462 | return mHasChildren; |
| 463 | } |
| 464 | |
Dianne Hackborn | 291905e | 2010-08-17 15:17:15 -0700 | [diff] [blame] | 465 | /** @hide */ |
| 466 | public final void destroy() { |
| 467 | mDestroyed = true; |
| 468 | } |
| 469 | |
| 470 | /** @hide */ |
| 471 | public final boolean isDestroyed() { |
| 472 | return mDestroyed; |
| 473 | } |
| 474 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 475 | /** |
| 476 | * Set the window manager for use by this Window to, for example, |
| 477 | * display panels. This is <em>not</em> used for displaying the |
| 478 | * Window itself -- that must be done by the client. |
| 479 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 480 | * @param wm The window manager for adding new windows. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 481 | */ |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 482 | public void setWindowManager(WindowManager wm, IBinder appToken, String appName) { |
| 483 | setWindowManager(wm, appToken, appName, false); |
| 484 | } |
| 485 | |
| 486 | /** |
| 487 | * Set the window manager for use by this Window to, for example, |
| 488 | * display panels. This is <em>not</em> used for displaying the |
| 489 | * Window itself -- that must be done by the client. |
| 490 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 491 | * @param wm The window manager for adding new windows. |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 492 | */ |
| 493 | public void setWindowManager(WindowManager wm, IBinder appToken, String appName, |
| 494 | boolean hardwareAccelerated) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 495 | mAppToken = appToken; |
| 496 | mAppName = appName; |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 497 | mHardwareAccelerated = hardwareAccelerated |
| 498 | || SystemProperties.getBoolean(PROPERTY_HARDWARE_UI, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 499 | if (wm == null) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 500 | wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 501 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 502 | mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 503 | } |
| 504 | |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 505 | void adjustLayoutParamsForSubWindow(WindowManager.LayoutParams wp) { |
| 506 | CharSequence curTitle = wp.getTitle(); |
| 507 | if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW && |
| 508 | wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 509 | if (wp.token == null) { |
| 510 | View decor = peekDecorView(); |
| 511 | if (decor != null) { |
| 512 | wp.token = decor.getWindowToken(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 513 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 514 | } |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 515 | if (curTitle == null || curTitle.length() == 0) { |
| 516 | String title; |
| 517 | if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) { |
| 518 | title="Media"; |
| 519 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) { |
| 520 | title="MediaOvr"; |
| 521 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) { |
| 522 | title="Panel"; |
| 523 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) { |
| 524 | title="SubPanel"; |
| 525 | } else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) { |
| 526 | title="AtchDlg"; |
| 527 | } else { |
| 528 | title=Integer.toString(wp.type); |
| 529 | } |
| 530 | if (mAppName != null) { |
| 531 | title += ":" + mAppName; |
| 532 | } |
| 533 | wp.setTitle(title); |
Romain Guy | 529b60a | 2010-08-03 18:05:47 -0700 | [diff] [blame] | 534 | } |
Jeff Brown | d32460c | 2012-07-20 16:15:36 -0700 | [diff] [blame] | 535 | } else { |
| 536 | if (wp.token == null) { |
| 537 | wp.token = mContainer == null ? mAppToken : mContainer.mAppToken; |
| 538 | } |
| 539 | if ((curTitle == null || curTitle.length() == 0) |
| 540 | && mAppName != null) { |
| 541 | wp.setTitle(mAppName); |
| 542 | } |
| 543 | } |
| 544 | if (wp.packageName == null) { |
| 545 | wp.packageName = mContext.getPackageName(); |
| 546 | } |
| 547 | if (mHardwareAccelerated) { |
| 548 | wp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 549 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | /** |
| 553 | * Return the window manager allowing this Window to display its own |
| 554 | * windows. |
| 555 | * |
| 556 | * @return WindowManager The ViewManager. |
| 557 | */ |
| 558 | public WindowManager getWindowManager() { |
| 559 | return mWindowManager; |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * Set the Callback interface for this window, used to intercept key |
| 564 | * events and other dynamic operations in the window. |
| 565 | * |
| 566 | * @param callback The desired Callback interface. |
| 567 | */ |
| 568 | public void setCallback(Callback callback) { |
| 569 | mCallback = callback; |
| 570 | } |
| 571 | |
| 572 | /** |
| 573 | * Return the current Callback interface for this window. |
| 574 | */ |
| 575 | public final Callback getCallback() { |
| 576 | return mCallback; |
| 577 | } |
| 578 | |
| 579 | /** |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 580 | * Take ownership of this window's surface. The window's view hierarchy |
| 581 | * will no longer draw into the surface, though it will otherwise continue |
| 582 | * to operate (such as for receiving input events). The given SurfaceHolder |
| 583 | * callback will be used to tell you about state changes to the surface. |
| 584 | */ |
Dianne Hackborn | d76b67c | 2010-07-13 17:48:30 -0700 | [diff] [blame] | 585 | public abstract void takeSurface(SurfaceHolder.Callback2 callback); |
Dianne Hackborn | dc8a7f6 | 2010-05-10 11:29:34 -0700 | [diff] [blame] | 586 | |
| 587 | /** |
Dianne Hackborn | 1e4b9f3 | 2010-06-23 14:10:57 -0700 | [diff] [blame] | 588 | * Take ownership of this window's InputQueue. The window will no |
| 589 | * longer read and dispatch input events from the queue; it is your |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 590 | * responsibility to do so. |
| 591 | */ |
Dianne Hackborn | 1e4b9f3 | 2010-06-23 14:10:57 -0700 | [diff] [blame] | 592 | public abstract void takeInputQueue(InputQueue.Callback callback); |
Dianne Hackborn | a95e4cb | 2010-06-18 18:09:33 -0700 | [diff] [blame] | 593 | |
| 594 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 595 | * Return whether this window is being displayed with a floating style |
| 596 | * (based on the {@link android.R.attr#windowIsFloating} attribute in |
| 597 | * the style/theme). |
| 598 | * |
| 599 | * @return Returns true if the window is configured to be displayed floating |
| 600 | * on top of whatever is behind it. |
| 601 | */ |
| 602 | public abstract boolean isFloating(); |
| 603 | |
| 604 | /** |
| 605 | * Set the width and height layout parameters of the window. The default |
Dianne Hackborn | c918935 | 2010-12-15 14:57:25 -0800 | [diff] [blame] | 606 | * for both of these is MATCH_PARENT; you can change them to WRAP_CONTENT |
| 607 | * 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] | 608 | * |
| 609 | * @param width The desired layout width of the window. |
| 610 | * @param height The desired layout height of the window. |
Dianne Hackborn | c918935 | 2010-12-15 14:57:25 -0800 | [diff] [blame] | 611 | * |
| 612 | * @see ViewGroup.LayoutParams#height |
| 613 | * @see ViewGroup.LayoutParams#width |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 614 | */ |
Dianne Hackborn | c918935 | 2010-12-15 14:57:25 -0800 | [diff] [blame] | 615 | public void setLayout(int width, int height) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 616 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 617 | attrs.width = width; |
| 618 | attrs.height = height; |
| 619 | if (mCallback != null) { |
| 620 | mCallback.onWindowAttributesChanged(attrs); |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | /** |
| 625 | * Set the gravity of the window, as per the Gravity constants. This |
| 626 | * controls how the window manager is positioned in the overall window; it |
| 627 | * is only useful when using WRAP_CONTENT for the layout width or height. |
| 628 | * |
| 629 | * @param gravity The desired gravity constant. |
| 630 | * |
| 631 | * @see Gravity |
| 632 | * @see #setLayout |
| 633 | */ |
| 634 | public void setGravity(int gravity) |
| 635 | { |
| 636 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 637 | attrs.gravity = gravity; |
| 638 | if (mCallback != null) { |
| 639 | mCallback.onWindowAttributesChanged(attrs); |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | /** |
| 644 | * Set the type of the window, as per the WindowManager.LayoutParams |
| 645 | * types. |
| 646 | * |
| 647 | * @param type The new window type (see WindowManager.LayoutParams). |
| 648 | */ |
| 649 | public void setType(int type) { |
| 650 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 651 | attrs.type = type; |
| 652 | if (mCallback != null) { |
| 653 | mCallback.onWindowAttributesChanged(attrs); |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | /** |
| 658 | * Set the format of window, as per the PixelFormat types. This overrides |
| 659 | * the default format that is selected by the Window based on its |
| 660 | * window decorations. |
| 661 | * |
| 662 | * @param format The new window format (see PixelFormat). Use |
| 663 | * PixelFormat.UNKNOWN to allow the Window to select |
| 664 | * the format. |
| 665 | * |
| 666 | * @see PixelFormat |
| 667 | */ |
| 668 | public void setFormat(int format) { |
| 669 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 670 | if (format != PixelFormat.UNKNOWN) { |
| 671 | attrs.format = format; |
| 672 | mHaveWindowFormat = true; |
| 673 | } else { |
| 674 | attrs.format = mDefaultWindowFormat; |
| 675 | mHaveWindowFormat = false; |
| 676 | } |
| 677 | if (mCallback != null) { |
| 678 | mCallback.onWindowAttributesChanged(attrs); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | /** |
| 683 | * Specify custom animations to use for the window, as per |
| 684 | * {@link WindowManager.LayoutParams#windowAnimations |
| 685 | * WindowManager.LayoutParams.windowAnimations}. Providing anything besides |
| 686 | * 0 here will override the animations the window would |
| 687 | * normally retrieve from its theme. |
| 688 | */ |
| 689 | public void setWindowAnimations(int resId) { |
| 690 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 691 | attrs.windowAnimations = resId; |
| 692 | if (mCallback != null) { |
| 693 | mCallback.onWindowAttributesChanged(attrs); |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | /** |
| 698 | * Specify an explicit soft input mode to use for the window, as per |
| 699 | * {@link WindowManager.LayoutParams#softInputMode |
| 700 | * WindowManager.LayoutParams.softInputMode}. Providing anything besides |
| 701 | * "unspecified" here will override the input mode the window would |
| 702 | * normally retrieve from its theme. |
| 703 | */ |
| 704 | public void setSoftInputMode(int mode) { |
| 705 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 706 | if (mode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) { |
| 707 | attrs.softInputMode = mode; |
| 708 | mHasSoftInputMode = true; |
| 709 | } else { |
| 710 | mHasSoftInputMode = false; |
| 711 | } |
| 712 | if (mCallback != null) { |
| 713 | mCallback.onWindowAttributesChanged(attrs); |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | /** |
| 718 | * Convenience function to set the flag bits as specified in flags, as |
| 719 | * per {@link #setFlags}. |
| 720 | * @param flags The flag bits to be set. |
| 721 | * @see #setFlags |
Christopher Tate | 193fc07 | 2012-06-04 11:27:40 -0700 | [diff] [blame] | 722 | * @see #clearFlags |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 723 | */ |
| 724 | public void addFlags(int flags) { |
| 725 | setFlags(flags, flags); |
| 726 | } |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 727 | |
| 728 | /** @hide */ |
| 729 | public void addPrivateFlags(int flags) { |
| 730 | setPrivateFlags(flags, flags); |
| 731 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 732 | |
| 733 | /** |
| 734 | * Convenience function to clear the flag bits as specified in flags, as |
| 735 | * per {@link #setFlags}. |
| 736 | * @param flags The flag bits to be cleared. |
| 737 | * @see #setFlags |
Christopher Tate | 193fc07 | 2012-06-04 11:27:40 -0700 | [diff] [blame] | 738 | * @see #addFlags |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 739 | */ |
| 740 | public void clearFlags(int flags) { |
| 741 | setFlags(0, flags); |
| 742 | } |
| 743 | |
| 744 | /** |
| 745 | * Set the flags of the window, as per the |
| 746 | * {@link WindowManager.LayoutParams WindowManager.LayoutParams} |
| 747 | * flags. |
| 748 | * |
| 749 | * <p>Note that some flags must be set before the window decoration is |
| 750 | * created (by the first call to |
| 751 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or |
| 752 | * {@link #getDecorView()}: |
| 753 | * {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and |
| 754 | * {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These |
| 755 | * will be set for you based on the {@link android.R.attr#windowIsFloating} |
| 756 | * attribute. |
| 757 | * |
| 758 | * @param flags The new window flags (see WindowManager.LayoutParams). |
| 759 | * @param mask Which of the window flag bits to modify. |
Christopher Tate | 193fc07 | 2012-06-04 11:27:40 -0700 | [diff] [blame] | 760 | * @see #addFlags |
| 761 | * @see #clearFlags |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 762 | */ |
| 763 | public void setFlags(int flags, int mask) { |
| 764 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 765 | attrs.flags = (attrs.flags&~mask) | (flags&mask); |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 766 | if ((mask&WindowManager.LayoutParams.FLAG_NEEDS_MENU_KEY) != 0) { |
| 767 | attrs.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY; |
| 768 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 769 | mForcedWindowFlags |= mask; |
| 770 | if (mCallback != null) { |
| 771 | mCallback.onWindowAttributesChanged(attrs); |
| 772 | } |
| 773 | } |
| 774 | |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 775 | private void setPrivateFlags(int flags, int mask) { |
| 776 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 777 | attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask); |
| 778 | if (mCallback != null) { |
| 779 | mCallback.onWindowAttributesChanged(attrs); |
| 780 | } |
| 781 | } |
| 782 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 783 | /** |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 784 | * Set the amount of dim behind the window when using |
| 785 | * {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides |
| 786 | * the default dim amount of that is selected by the Window based on |
| 787 | * its theme. |
| 788 | * |
| 789 | * @param amount The new dim amount, from 0 for no dim to 1 for full dim. |
| 790 | */ |
| 791 | public void setDimAmount(float amount) { |
| 792 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 793 | attrs.dimAmount = amount; |
| 794 | mHaveDimAmount = true; |
| 795 | if (mCallback != null) { |
| 796 | mCallback.onWindowAttributesChanged(attrs); |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 801 | * Specify custom window attributes. <strong>PLEASE NOTE:</strong> the |
| 802 | * layout params you give here should generally be from values previously |
| 803 | * retrieved with {@link #getAttributes()}; you probably do not want to |
| 804 | * blindly create and apply your own, since this will blow away any values |
| 805 | * set by the framework that you are not interested in. |
| 806 | * |
| 807 | * @param a The new window attributes, which will completely override any |
| 808 | * current values. |
| 809 | */ |
| 810 | public void setAttributes(WindowManager.LayoutParams a) { |
| 811 | mWindowAttributes.copyFrom(a); |
| 812 | if (mCallback != null) { |
| 813 | mCallback.onWindowAttributesChanged(mWindowAttributes); |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | /** |
| 818 | * Retrieve the current window attributes associated with this panel. |
| 819 | * |
| 820 | * @return WindowManager.LayoutParams Either the existing window |
| 821 | * attributes object, or a freshly created one if there is none. |
| 822 | */ |
| 823 | public final WindowManager.LayoutParams getAttributes() { |
| 824 | return mWindowAttributes; |
| 825 | } |
| 826 | |
| 827 | /** |
| 828 | * Return the window flags that have been explicitly set by the client, |
| 829 | * so will not be modified by {@link #getDecorView}. |
| 830 | */ |
| 831 | protected final int getForcedWindowFlags() { |
| 832 | return mForcedWindowFlags; |
| 833 | } |
| 834 | |
| 835 | /** |
| 836 | * Has the app specified their own soft input mode? |
| 837 | */ |
| 838 | protected final boolean hasSoftInputMode() { |
| 839 | return mHasSoftInputMode; |
| 840 | } |
| 841 | |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 842 | /** @hide */ |
| 843 | public void setCloseOnTouchOutside(boolean close) { |
| 844 | mCloseOnTouchOutside = close; |
| 845 | mSetCloseOnTouchOutside = true; |
| 846 | } |
| 847 | |
| 848 | /** @hide */ |
Dianne Hackborn | ef57575 | 2011-01-18 17:35:17 -0800 | [diff] [blame] | 849 | public void setCloseOnTouchOutsideIfNotSet(boolean close) { |
| 850 | if (!mSetCloseOnTouchOutside) { |
| 851 | mCloseOnTouchOutside = close; |
| 852 | mSetCloseOnTouchOutside = true; |
| 853 | } |
Dianne Hackborn | cfaf887 | 2011-01-18 13:57:54 -0800 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | /** @hide */ |
| 857 | public abstract void alwaysReadCloseOnTouchAttr(); |
| 858 | |
| 859 | /** @hide */ |
| 860 | public boolean shouldCloseOnTouch(Context context, MotionEvent event) { |
| 861 | if (mCloseOnTouchOutside && event.getAction() == MotionEvent.ACTION_DOWN |
| 862 | && isOutOfBounds(context, event) && peekDecorView() != null) { |
| 863 | return true; |
| 864 | } |
| 865 | return false; |
| 866 | } |
| 867 | |
| 868 | private boolean isOutOfBounds(Context context, MotionEvent event) { |
| 869 | final int x = (int) event.getX(); |
| 870 | final int y = (int) event.getY(); |
| 871 | final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop(); |
| 872 | final View decorView = getDecorView(); |
| 873 | return (x < -slop) || (y < -slop) |
| 874 | || (x > (decorView.getWidth()+slop)) |
| 875 | || (y > (decorView.getHeight()+slop)); |
| 876 | } |
| 877 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 878 | /** |
| 879 | * Enable extended screen features. This must be called before |
| 880 | * setContentView(). May be called as many times as desired as long as it |
| 881 | * is before setContentView(). If not called, no extended features |
| 882 | * will be available. You can not turn off a feature once it is requested. |
| 883 | * You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}. |
| 884 | * |
| 885 | * @param featureId The desired features, defined as constants by Window. |
| 886 | * @return The features that are now set. |
| 887 | */ |
| 888 | public boolean requestFeature(int featureId) { |
| 889 | final int flag = 1<<featureId; |
| 890 | mFeatures |= flag; |
| 891 | mLocalFeatures |= mContainer != null ? (flag&~mContainer.mFeatures) : flag; |
| 892 | return (mFeatures&flag) != 0; |
| 893 | } |
| 894 | |
Adam Powell | f4a6ec4 | 2010-08-24 14:18:10 -0700 | [diff] [blame] | 895 | /** |
| 896 | * @hide Used internally to help resolve conflicting features. |
| 897 | */ |
| 898 | protected void removeFeature(int featureId) { |
| 899 | final int flag = 1<<featureId; |
| 900 | mFeatures &= ~flag; |
| 901 | mLocalFeatures &= ~(mContainer != null ? (flag&~mContainer.mFeatures) : flag); |
| 902 | } |
| 903 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 904 | public final void makeActive() { |
| 905 | if (mContainer != null) { |
| 906 | if (mContainer.mActiveChild != null) { |
| 907 | mContainer.mActiveChild.mIsActive = false; |
| 908 | } |
| 909 | mContainer.mActiveChild = this; |
| 910 | } |
| 911 | mIsActive = true; |
| 912 | onActive(); |
| 913 | } |
| 914 | |
| 915 | public final boolean isActive() |
| 916 | { |
| 917 | return mIsActive; |
| 918 | } |
| 919 | |
| 920 | /** |
| 921 | * Finds a view that was identified by the id attribute from the XML that |
| 922 | * was processed in {@link android.app.Activity#onCreate}. This will |
| 923 | * implicitly call {@link #getDecorView} for you, with all of the |
| 924 | * associated side-effects. |
| 925 | * |
| 926 | * @return The view if found or null otherwise. |
| 927 | */ |
| 928 | public View findViewById(int id) { |
| 929 | return getDecorView().findViewById(id); |
| 930 | } |
| 931 | |
| 932 | /** |
| 933 | * Convenience for |
| 934 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} |
| 935 | * to set the screen content from a layout resource. The resource will be |
| 936 | * inflated, adding all top-level views to the screen. |
| 937 | * |
| 938 | * @param layoutResID Resource ID to be inflated. |
| 939 | * @see #setContentView(View, android.view.ViewGroup.LayoutParams) |
| 940 | */ |
| 941 | public abstract void setContentView(int layoutResID); |
| 942 | |
| 943 | /** |
| 944 | * Convenience for |
| 945 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} |
| 946 | * set the screen content to an explicit view. This view is placed |
| 947 | * directly into the screen's view hierarchy. It can itself be a complex |
| 948 | * view hierarhcy. |
| 949 | * |
| 950 | * @param view The desired content to display. |
| 951 | * @see #setContentView(View, android.view.ViewGroup.LayoutParams) |
| 952 | */ |
| 953 | public abstract void setContentView(View view); |
| 954 | |
| 955 | /** |
| 956 | * Set the screen content to an explicit view. This view is placed |
| 957 | * directly into the screen's view hierarchy. It can itself be a complex |
| 958 | * view hierarchy. |
| 959 | * |
| 960 | * <p>Note that calling this function "locks in" various characteristics |
| 961 | * of the window that can not, from this point forward, be changed: the |
| 962 | * features that have been requested with {@link #requestFeature(int)}, |
| 963 | * and certain window flags as described in {@link #setFlags(int, int)}. |
| 964 | * |
| 965 | * @param view The desired content to display. |
| 966 | * @param params Layout parameters for the view. |
| 967 | */ |
| 968 | public abstract void setContentView(View view, ViewGroup.LayoutParams params); |
| 969 | |
| 970 | /** |
| 971 | * Variation on |
| 972 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} |
| 973 | * to add an additional content view to the screen. Added after any existing |
| 974 | * ones in the screen -- existing views are NOT removed. |
| 975 | * |
| 976 | * @param view The desired content to display. |
| 977 | * @param params Layout parameters for the view. |
| 978 | */ |
| 979 | public abstract void addContentView(View view, ViewGroup.LayoutParams params); |
| 980 | |
| 981 | /** |
| 982 | * Return the view in this Window that currently has focus, or null if |
| 983 | * there are none. Note that this does not look in any containing |
| 984 | * Window. |
| 985 | * |
| 986 | * @return View The current View with focus or null. |
| 987 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 988 | @Nullable |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 989 | public abstract View getCurrentFocus(); |
| 990 | |
| 991 | /** |
| 992 | * Quick access to the {@link LayoutInflater} instance that this Window |
| 993 | * retrieved from its Context. |
| 994 | * |
| 995 | * @return LayoutInflater The shared LayoutInflater. |
| 996 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 997 | @NonNull |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 998 | public abstract LayoutInflater getLayoutInflater(); |
| 999 | |
| 1000 | public abstract void setTitle(CharSequence title); |
| 1001 | |
Alan Viverette | 2525d9c | 2013-11-15 14:42:19 -0800 | [diff] [blame] | 1002 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1003 | public abstract void setTitleColor(int textColor); |
| 1004 | |
| 1005 | public abstract void openPanel(int featureId, KeyEvent event); |
| 1006 | |
| 1007 | public abstract void closePanel(int featureId); |
| 1008 | |
| 1009 | public abstract void togglePanel(int featureId, KeyEvent event); |
| 1010 | |
Dianne Hackborn | b31e84bc | 2010-06-08 18:04:35 -0700 | [diff] [blame] | 1011 | public abstract void invalidatePanelMenu(int featureId); |
| 1012 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1013 | public abstract boolean performPanelShortcut(int featureId, |
| 1014 | int keyCode, |
| 1015 | KeyEvent event, |
| 1016 | int flags); |
| 1017 | public abstract boolean performPanelIdentifierAction(int featureId, |
| 1018 | int id, |
| 1019 | int flags); |
| 1020 | |
| 1021 | public abstract void closeAllPanels(); |
| 1022 | |
| 1023 | public abstract boolean performContextMenuIdentifierAction(int id, int flags); |
| 1024 | |
| 1025 | /** |
| 1026 | * Should be called when the configuration is changed. |
| 1027 | * |
| 1028 | * @param newConfig The new configuration. |
| 1029 | */ |
| 1030 | public abstract void onConfigurationChanged(Configuration newConfig); |
| 1031 | |
| 1032 | /** |
| 1033 | * Change the background of this window to a Drawable resource. Setting the |
| 1034 | * background to null will make the window be opaque. To make the window |
| 1035 | * transparent, you can use an empty drawable (for instance a ColorDrawable |
| 1036 | * with the color 0 or the system drawable android:drawable/empty.) |
| 1037 | * |
| 1038 | * @param resid The resource identifier of a drawable resource which will be |
| 1039 | * installed as the new background. |
| 1040 | */ |
| 1041 | public void setBackgroundDrawableResource(int resid) |
| 1042 | { |
Alan Viverette | 8eea3ea | 2014-02-03 18:40:20 -0800 | [diff] [blame] | 1043 | setBackgroundDrawable(mContext.getDrawable(resid)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1044 | } |
| 1045 | |
| 1046 | /** |
| 1047 | * Change the background of this window to a custom Drawable. Setting the |
| 1048 | * background to null will make the window be opaque. To make the window |
| 1049 | * transparent, you can use an empty drawable (for instance a ColorDrawable |
| 1050 | * with the color 0 or the system drawable android:drawable/empty.) |
| 1051 | * |
| 1052 | * @param drawable The new Drawable to use for this window's background. |
| 1053 | */ |
| 1054 | public abstract void setBackgroundDrawable(Drawable drawable); |
| 1055 | |
| 1056 | /** |
| 1057 | * Set the value for a drawable feature of this window, from a resource |
| 1058 | * identifier. You must have called requestFeauture(featureId) before |
| 1059 | * calling this function. |
| 1060 | * |
| 1061 | * @see android.content.res.Resources#getDrawable(int) |
| 1062 | * |
| 1063 | * @param featureId The desired drawable feature to change, defined as a |
| 1064 | * constant by Window. |
| 1065 | * @param resId Resource identifier of the desired image. |
| 1066 | */ |
| 1067 | public abstract void setFeatureDrawableResource(int featureId, int resId); |
| 1068 | |
| 1069 | /** |
| 1070 | * Set the value for a drawable feature of this window, from a URI. You |
| 1071 | * must have called requestFeature(featureId) before calling this |
| 1072 | * function. |
| 1073 | * |
| 1074 | * <p>The only URI currently supported is "content:", specifying an image |
| 1075 | * in a content provider. |
| 1076 | * |
| 1077 | * @see android.widget.ImageView#setImageURI |
| 1078 | * |
| 1079 | * @param featureId The desired drawable feature to change. Features are |
| 1080 | * constants defined by Window. |
| 1081 | * @param uri The desired URI. |
| 1082 | */ |
| 1083 | public abstract void setFeatureDrawableUri(int featureId, Uri uri); |
| 1084 | |
| 1085 | /** |
| 1086 | * Set an explicit Drawable value for feature of this window. You must |
| 1087 | * have called requestFeature(featureId) before calling this function. |
| 1088 | * |
| 1089 | * @param featureId The desired drawable feature to change. |
| 1090 | * Features are constants defined by Window. |
| 1091 | * @param drawable A Drawable object to display. |
| 1092 | */ |
| 1093 | public abstract void setFeatureDrawable(int featureId, Drawable drawable); |
| 1094 | |
| 1095 | /** |
| 1096 | * Set a custom alpha value for the given drawale feature, controlling how |
| 1097 | * much the background is visible through it. |
| 1098 | * |
| 1099 | * @param featureId The desired drawable feature to change. |
| 1100 | * Features are constants defined by Window. |
| 1101 | * @param alpha The alpha amount, 0 is completely transparent and 255 is |
| 1102 | * completely opaque. |
| 1103 | */ |
| 1104 | public abstract void setFeatureDrawableAlpha(int featureId, int alpha); |
| 1105 | |
| 1106 | /** |
| 1107 | * Set the integer value for a feature. The range of the value depends on |
| 1108 | * the feature being set. For FEATURE_PROGRESSS, it should go from 0 to |
| 1109 | * 10000. At 10000 the progress is complete and the indicator hidden. |
| 1110 | * |
| 1111 | * @param featureId The desired feature to change. |
| 1112 | * Features are constants defined by Window. |
| 1113 | * @param value The value for the feature. The interpretation of this |
| 1114 | * value is feature-specific. |
| 1115 | */ |
| 1116 | public abstract void setFeatureInt(int featureId, int value); |
| 1117 | |
| 1118 | /** |
| 1119 | * Request that key events come to this activity. Use this if your |
| 1120 | * activity has no views with focus, but the activity still wants |
| 1121 | * a chance to process key events. |
| 1122 | */ |
| 1123 | public abstract void takeKeyEvents(boolean get); |
| 1124 | |
| 1125 | /** |
| 1126 | * Used by custom windows, such as Dialog, to pass the key press event |
| 1127 | * further down the view hierarchy. Application developers should |
| 1128 | * not need to implement or call this. |
| 1129 | * |
| 1130 | */ |
| 1131 | public abstract boolean superDispatchKeyEvent(KeyEvent event); |
| 1132 | |
| 1133 | /** |
Jeff Brown | 64da12a | 2011-01-04 19:57:47 -0800 | [diff] [blame] | 1134 | * Used by custom windows, such as Dialog, to pass the key shortcut press event |
| 1135 | * further down the view hierarchy. Application developers should |
| 1136 | * not need to implement or call this. |
| 1137 | * |
| 1138 | */ |
| 1139 | public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event); |
| 1140 | |
| 1141 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1142 | * Used by custom windows, such as Dialog, to pass the touch screen event |
| 1143 | * further down the view hierarchy. Application developers should |
| 1144 | * not need to implement or call this. |
| 1145 | * |
| 1146 | */ |
| 1147 | public abstract boolean superDispatchTouchEvent(MotionEvent event); |
| 1148 | |
| 1149 | /** |
| 1150 | * Used by custom windows, such as Dialog, to pass the trackball event |
| 1151 | * further down the view hierarchy. Application developers should |
| 1152 | * not need to implement or call this. |
| 1153 | * |
| 1154 | */ |
| 1155 | public abstract boolean superDispatchTrackballEvent(MotionEvent event); |
| 1156 | |
| 1157 | /** |
Jeff Brown | cb1404e | 2011-01-15 18:14:15 -0800 | [diff] [blame] | 1158 | * Used by custom windows, such as Dialog, to pass the generic motion event |
| 1159 | * further down the view hierarchy. Application developers should |
| 1160 | * not need to implement or call this. |
| 1161 | * |
| 1162 | */ |
| 1163 | public abstract boolean superDispatchGenericMotionEvent(MotionEvent event); |
| 1164 | |
| 1165 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1166 | * Retrieve the top-level window decor view (containing the standard |
| 1167 | * window frame/decorations and the client's content inside of that), which |
| 1168 | * can be added as a window to the window manager. |
| 1169 | * |
| 1170 | * <p><em>Note that calling this function for the first time "locks in" |
| 1171 | * various window characteristics as described in |
| 1172 | * {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p> |
| 1173 | * |
| 1174 | * @return Returns the top-level window decor view. |
| 1175 | */ |
| 1176 | public abstract View getDecorView(); |
| 1177 | |
| 1178 | /** |
| 1179 | * Retrieve the current decor view, but only if it has already been created; |
| 1180 | * otherwise returns null. |
| 1181 | * |
| 1182 | * @return Returns the top-level window decor or null. |
| 1183 | * @see #getDecorView |
| 1184 | */ |
| 1185 | public abstract View peekDecorView(); |
| 1186 | |
| 1187 | public abstract Bundle saveHierarchyState(); |
| 1188 | |
| 1189 | public abstract void restoreHierarchyState(Bundle savedInstanceState); |
| 1190 | |
| 1191 | protected abstract void onActive(); |
| 1192 | |
| 1193 | /** |
| 1194 | * Return the feature bits that are enabled. This is the set of features |
| 1195 | * that were given to requestFeature(), and are being handled by this |
| 1196 | * Window itself or its container. That is, it is the set of |
| 1197 | * requested features that you can actually use. |
| 1198 | * |
| 1199 | * <p>To do: add a public version of this API that allows you to check for |
| 1200 | * features by their feature ID. |
| 1201 | * |
| 1202 | * @return int The feature bits. |
| 1203 | */ |
| 1204 | protected final int getFeatures() |
| 1205 | { |
| 1206 | return mFeatures; |
| 1207 | } |
Adam Powell | 33b9743 | 2010-04-20 10:01:14 -0700 | [diff] [blame] | 1208 | |
| 1209 | /** |
| 1210 | * Query for the availability of a certain feature. |
| 1211 | * |
| 1212 | * @param feature The feature ID to check |
| 1213 | * @return true if the feature is enabled, false otherwise. |
| 1214 | */ |
| 1215 | public boolean hasFeature(int feature) { |
| 1216 | return (getFeatures() & (1 << feature)) != 0; |
| 1217 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1218 | |
| 1219 | /** |
| 1220 | * Return the feature bits that are being implemented by this Window. |
| 1221 | * This is the set of features that were given to requestFeature(), and are |
| 1222 | * being handled by only this Window itself, not by its containers. |
| 1223 | * |
| 1224 | * @return int The feature bits. |
| 1225 | */ |
| 1226 | protected final int getLocalFeatures() |
| 1227 | { |
| 1228 | return mLocalFeatures; |
| 1229 | } |
| 1230 | |
| 1231 | /** |
| 1232 | * Set the default format of window, as per the PixelFormat types. This |
| 1233 | * is the format that will be used unless the client specifies in explicit |
| 1234 | * format with setFormat(); |
| 1235 | * |
| 1236 | * @param format The new window format (see PixelFormat). |
| 1237 | * |
| 1238 | * @see #setFormat |
| 1239 | * @see PixelFormat |
| 1240 | */ |
| 1241 | protected void setDefaultWindowFormat(int format) { |
| 1242 | mDefaultWindowFormat = format; |
| 1243 | if (!mHaveWindowFormat) { |
| 1244 | final WindowManager.LayoutParams attrs = getAttributes(); |
| 1245 | attrs.format = format; |
| 1246 | if (mCallback != null) { |
| 1247 | mCallback.onWindowAttributesChanged(attrs); |
| 1248 | } |
| 1249 | } |
| 1250 | } |
| 1251 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1252 | /** @hide */ |
| 1253 | protected boolean haveDimAmount() { |
| 1254 | return mHaveDimAmount; |
| 1255 | } |
| 1256 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1257 | public abstract void setChildDrawable(int featureId, Drawable drawable); |
| 1258 | |
| 1259 | public abstract void setChildInt(int featureId, int value); |
| 1260 | |
| 1261 | /** |
| 1262 | * Is a keypress one of the defined shortcut keys for this window. |
| 1263 | * @param keyCode the key code from {@link android.view.KeyEvent} to check. |
| 1264 | * @param event the {@link android.view.KeyEvent} to use to help check. |
| 1265 | */ |
| 1266 | public abstract boolean isShortcutKey(int keyCode, KeyEvent event); |
| 1267 | |
| 1268 | /** |
| 1269 | * @see android.app.Activity#setVolumeControlStream(int) |
| 1270 | */ |
| 1271 | public abstract void setVolumeControlStream(int streamType); |
| 1272 | |
| 1273 | /** |
| 1274 | * @see android.app.Activity#getVolumeControlStream() |
| 1275 | */ |
| 1276 | public abstract int getVolumeControlStream(); |
Adam Powell | 269248d | 2011-08-02 10:26:54 -0700 | [diff] [blame] | 1277 | |
| 1278 | /** |
| 1279 | * Set extra options that will influence the UI for this window. |
| 1280 | * @param uiOptions Flags specifying extra options for this window. |
| 1281 | */ |
| 1282 | public void setUiOptions(int uiOptions) { } |
Adam Powell | e43fca9 | 2011-08-16 12:57:01 -0700 | [diff] [blame] | 1283 | |
| 1284 | /** |
| 1285 | * Set extra options that will influence the UI for this window. |
| 1286 | * Only the bits filtered by mask will be modified. |
| 1287 | * @param uiOptions Flags specifying extra options for this window. |
| 1288 | * @param mask Flags specifying which options should be modified. Others will remain unchanged. |
| 1289 | */ |
| 1290 | public void setUiOptions(int uiOptions, int mask) { } |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1291 | |
| 1292 | /** |
| 1293 | * Set the primary icon for this window. |
| 1294 | * |
| 1295 | * @param resId resource ID of a drawable to set |
| 1296 | */ |
| 1297 | public void setIcon(int resId) { } |
| 1298 | |
| 1299 | /** |
| 1300 | * Set the default icon for this window. |
| 1301 | * This will be overridden by any other icon set operation which could come from the |
| 1302 | * theme or another explicit set. |
| 1303 | * |
| 1304 | * @hide |
| 1305 | */ |
| 1306 | public void setDefaultIcon(int resId) { } |
| 1307 | |
| 1308 | /** |
| 1309 | * Set the logo for this window. A logo is often shown in place of an |
| 1310 | * {@link #setIcon(int) icon} but is generally wider and communicates window title information |
| 1311 | * as well. |
| 1312 | * |
| 1313 | * @param resId resource ID of a drawable to set |
| 1314 | */ |
| 1315 | public void setLogo(int resId) { } |
| 1316 | |
| 1317 | /** |
| 1318 | * Set the default logo for this window. |
| 1319 | * This will be overridden by any other logo set operation which could come from the |
| 1320 | * theme or another explicit set. |
| 1321 | * |
| 1322 | * @hide |
| 1323 | */ |
| 1324 | public void setDefaultLogo(int resId) { } |
keunyoung | 30f420f | 2013-08-02 14:23:10 -0700 | [diff] [blame] | 1325 | |
| 1326 | /** |
| 1327 | * Set focus locally. The window should have the |
| 1328 | * {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already. |
| 1329 | * @param hasFocus Whether this window has focus or not. |
| 1330 | * @param inTouchMode Whether this window is in touch mode or not. |
| 1331 | */ |
| 1332 | public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { } |
| 1333 | |
| 1334 | /** |
| 1335 | * Inject an event to window locally. |
| 1336 | * @param event A key or touch event to inject to this window. |
| 1337 | */ |
| 1338 | public void injectInputEvent(InputEvent event) { } |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1339 | |
| 1340 | /** |
| 1341 | * Retrieve the {@link TransitionManager} responsible for for default transitions |
| 1342 | * in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}. |
| 1343 | * |
| 1344 | * <p>This method will return non-null after content has been initialized (e.g. by using |
| 1345 | * {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted.</p> |
| 1346 | * |
| 1347 | * @return This window's content TransitionManager or null if none is set. |
| 1348 | */ |
| 1349 | public TransitionManager getTransitionManager() { |
| 1350 | return null; |
| 1351 | } |
| 1352 | |
| 1353 | /** |
| 1354 | * Set the {@link TransitionManager} to use for default transitions in this window. |
| 1355 | * Requires {@link #FEATURE_CONTENT_TRANSITIONS}. |
| 1356 | * |
| 1357 | * @param tm The TransitionManager to use for scene changes. |
| 1358 | */ |
| 1359 | public void setTransitionManager(TransitionManager tm) { |
| 1360 | throw new UnsupportedOperationException(); |
| 1361 | } |
| 1362 | |
| 1363 | /** |
| 1364 | * Retrieve the {@link Scene} representing this window's current content. |
| 1365 | * Requires {@link #FEATURE_CONTENT_TRANSITIONS}. |
| 1366 | * |
| 1367 | * <p>This method will return null if the current content is not represented by a Scene.</p> |
| 1368 | * |
| 1369 | * @return Current Scene being shown or null |
| 1370 | */ |
| 1371 | public Scene getContentScene() { |
| 1372 | return null; |
| 1373 | } |
| 1374 | |
| 1375 | /** |
| 1376 | * Set options that can affect the transition behavior within this window. |
| 1377 | * @param options Options to set or null for none |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1378 | * @hide |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1379 | */ |
George Mount | 0a778ed | 2013-12-13 13:35:36 -0800 | [diff] [blame] | 1380 | public void setTransitionOptions(ActivityOptions options, SceneTransitionListener listener) { |
| 1381 | } |
| 1382 | |
| 1383 | /** |
| 1384 | * A callback for Activity transitions to be told when the shared element is ready to be shown |
| 1385 | * and start the transition to its target location. |
| 1386 | * @hide |
| 1387 | */ |
| 1388 | public interface SceneTransitionListener { |
| 1389 | void enterSharedElement(Bundle transitionArgs); |
| 1390 | void nullPendingTransition(); |
| 1391 | void convertFromTranslucent(); |
| 1392 | void convertToTranslucent(); |
| 1393 | } |
| 1394 | |
| 1395 | /** |
| 1396 | * Controls how the background fade is triggered. If fadeEarly is true, the Window background |
| 1397 | * will fade in as soon as the shared elements are ready to switch. If fadeEarly is false, |
| 1398 | * the background will fade only after the calling Activity's exit transition completes. |
| 1399 | * By default, the Window will fade in when the calling Activity's exit transition completes. |
| 1400 | * |
| 1401 | * @param fadeEarly Set to true to fade out the exiting Activity as soon as the shared elements |
| 1402 | * are transferred. Set to false to fade out the exiting Activity as soon as |
| 1403 | * the shared element is transferred. |
| 1404 | * @hide |
| 1405 | */ |
| 1406 | public void setEarlyBackgroundTransition(boolean fadeEarly) { |
| 1407 | } |
| 1408 | |
| 1409 | /** |
| 1410 | * Start the exit transition. |
| 1411 | * @hide |
| 1412 | */ |
| 1413 | public void startExitTransition(ActivityOptions activityOptions) { |
Adam Powell | cfbe9be | 2013-11-06 14:58:58 -0800 | [diff] [blame] | 1414 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1415 | } |