/* * Copyright (C) 2006 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view; import static android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS; import static android.Manifest.permission.HIDE_OVERLAY_WINDOWS; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; import android.annotation.ColorInt; import android.annotation.DrawableRes; import android.annotation.FlaggedApi; import android.annotation.FloatRange; import android.annotation.IdRes; import android.annotation.LayoutRes; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.StyleRes; import android.annotation.SystemApi; import android.annotation.TestApi; import android.annotation.UiContext; import android.app.WindowConfiguration; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Insets; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.media.session.MediaController; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.transition.Scene; import android.transition.Transition; import android.transition.TransitionManager; import android.util.Pair; import android.view.View.OnApplyWindowInsetsListener; import android.view.accessibility.AccessibilityEvent; import android.window.OnBackInvokedDispatcher; import java.util.Collections; import java.util.List; /** * Abstract base class for a top-level window look and behavior policy. An * instance of this class should be used as the top-level view added to the * window manager. It provides standard UI policies such as a background, title * area, default key processing, etc. * *
The framework will instantiate an implementation of this class on behalf of the application. */ public abstract class Window { /** Flag for the "options panel" feature. This is enabled by default. */ public static final int FEATURE_OPTIONS_PANEL = 0; /** Flag for the "no title" feature, turning off the title at the top * of the screen. */ public static final int FEATURE_NO_TITLE = 1; /** * Flag for the progress indicator feature. * * @deprecated No longer supported starting in API 21. */ @Deprecated public static final int FEATURE_PROGRESS = 2; /** Flag for having an icon on the left side of the title bar */ public static final int FEATURE_LEFT_ICON = 3; /** Flag for having an icon on the right side of the title bar */ public static final int FEATURE_RIGHT_ICON = 4; /** * Flag for indeterminate progress. * * @deprecated No longer supported starting in API 21. */ @Deprecated public static final int FEATURE_INDETERMINATE_PROGRESS = 5; /** Flag for the context menu. This is enabled by default. */ public static final int FEATURE_CONTEXT_MENU = 6; /** Flag for custom title. You cannot combine this feature with other title features. */ public static final int FEATURE_CUSTOM_TITLE = 7; /** * Flag for enabling the Action Bar. * This is enabled by default for some devices. The Action Bar * replaces the title bar and provides an alternate location * for an on-screen menu button on some devices. */ public static final int FEATURE_ACTION_BAR = 8; /** * Flag for requesting an Action Bar that overlays window content. * Normally an Action Bar will sit in the space above window content, but if this * feature is requested along with {@link #FEATURE_ACTION_BAR} it will be layered over * the window content itself. This is useful if you would like your app to have more control * over how the Action Bar is displayed, such as letting application content scroll beneath * an Action Bar with a transparent background or otherwise displaying a transparent/translucent * Action Bar over application content. * *
This mode is especially useful with {@link View#SYSTEM_UI_FLAG_FULLSCREEN * View.SYSTEM_UI_FLAG_FULLSCREEN}, which allows you to seamlessly hide the * action bar in conjunction with other screen decorations. * *
As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, when an * ActionBar is in this mode it will adjust the insets provided to * {@link View#fitSystemWindows(android.graphics.Rect) View.fitSystemWindows(Rect)} * to include the content covered by the action bar, so you can do layout within * that space. */ public static final int FEATURE_ACTION_BAR_OVERLAY = 9; /** * Flag for specifying the behavior of action modes when an Action Bar is not present. * If overlay is enabled, the action mode UI will be allowed to cover existing window content. */ public static final int FEATURE_ACTION_MODE_OVERLAY = 10; /** * Flag for requesting a decoration-free window that is dismissed by swiping from the left. * * @deprecated Swipe-to-dismiss isn't functional anymore. */ @Deprecated public static final int FEATURE_SWIPE_TO_DISMISS = 11; /** * Flag for requesting that window content changes should be animated using a * TransitionManager. * *
The TransitionManager is set using * {@link #setTransitionManager(android.transition.TransitionManager)}. If none is set, * a default TransitionManager will be used.
* * @see #setContentView */ public static final int FEATURE_CONTENT_TRANSITIONS = 12; /** * Enables Activities to run Activity Transitions either through sending or receiving * ActivityOptions bundle created with * {@link android.app.ActivityOptions#makeSceneTransitionAnimation(android.app.Activity, * android.util.Pair[])} or {@link android.app.ActivityOptions#makeSceneTransitionAnimation( * android.app.Activity, View, String)}. */ public static final int FEATURE_ACTIVITY_TRANSITIONS = 13; /** * Max value used as a feature ID * @hide */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) public static final int FEATURE_MAX = FEATURE_ACTIVITY_TRANSITIONS; /** * Flag for setting the progress bar's visibility to VISIBLE. * * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer * supported starting in API 21. */ @Deprecated public static final int PROGRESS_VISIBILITY_ON = -1; /** * Flag for setting the progress bar's visibility to GONE. * * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer * supported starting in API 21. */ @Deprecated public static final int PROGRESS_VISIBILITY_OFF = -2; /** * Flag for setting the progress bar's indeterminate mode on. * * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods * are no longer supported starting in API 21. */ @Deprecated public static final int PROGRESS_INDETERMINATE_ON = -3; /** * Flag for setting the progress bar's indeterminate mode off. * * @deprecated {@link #FEATURE_INDETERMINATE_PROGRESS} and related methods * are no longer supported starting in API 21. */ @Deprecated public static final int PROGRESS_INDETERMINATE_OFF = -4; /** * Starting value for the (primary) progress. * * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer * supported starting in API 21. */ @Deprecated public static final int PROGRESS_START = 0; /** * Ending value for the (primary) progress. * * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer * supported starting in API 21. */ @Deprecated public static final int PROGRESS_END = 10000; /** * Lowest possible value for the secondary progress. * * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer * supported starting in API 21. */ @Deprecated public static final int PROGRESS_SECONDARY_START = 20000; /** * Highest possible value for the secondary progress. * * @deprecated {@link #FEATURE_PROGRESS} and related methods are no longer * supported starting in API 21. */ @Deprecated public static final int PROGRESS_SECONDARY_END = 30000; /** * The transitionName for the status bar background View when a custom background is used. * @see android.view.Window#setStatusBarColor(int) */ public static final String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background"; /** * The transitionName for the navigation bar background View when a custom background is used. * @see android.view.Window#setNavigationBarColor(int) */ public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME = "android:navigation:background"; /** * The default features enabled. * @deprecated use {@link #getDefaultFeatures(android.content.Context)} instead. */ @Deprecated @SuppressWarnings({"PointlessBitwiseExpression"}) protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) | (1 << FEATURE_CONTEXT_MENU); /** * The ID that the main layout in the XML layout file should have. */ public static final int ID_ANDROID_CONTENT = com.android.internal.R.id.content; /** * Flag for letting the theme drive the color of the window caption controls. Use with * {@link #setDecorCaptionShade(int)}. This is the default value. */ public static final int DECOR_CAPTION_SHADE_AUTO = 0; /** * Flag for setting light-color controls on the window caption. Use with * {@link #setDecorCaptionShade(int)}. */ public static final int DECOR_CAPTION_SHADE_LIGHT = 1; /** * Flag for setting dark-color controls on the window caption. Use with * {@link #setDecorCaptionShade(int)}. */ public static final int DECOR_CAPTION_SHADE_DARK = 2; @UnsupportedAppUsage @UiContext private final Context mContext; @UnsupportedAppUsage private TypedArray mWindowStyle; @UnsupportedAppUsage private Callback mCallback; private OnWindowDismissedCallback mOnWindowDismissedCallback; private OnWindowSwipeDismissedCallback mOnWindowSwipeDismissedCallback; private WindowControllerCallback mWindowControllerCallback; @WindowInsetsController.Appearance private int mSystemBarAppearance; private DecorCallback mDecorCallback; private OnRestrictedCaptionAreaChangedListener mOnRestrictedCaptionAreaChangedListener; private Rect mRestrictedCaptionAreaRect; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private WindowManager mWindowManager; @UnsupportedAppUsage private IBinder mAppToken; @UnsupportedAppUsage private String mAppName; @UnsupportedAppUsage private boolean mHardwareAccelerated; private Window mContainer; private Window mActiveChild; private boolean mIsActive = false; private boolean mHasChildren = false; private boolean mCloseOnTouchOutside = false; private boolean mSetCloseOnTouchOutside = false; private int mForcedWindowFlags = 0; @UnsupportedAppUsage private int mFeatures; @UnsupportedAppUsage private int mLocalFeatures; private boolean mHaveWindowFormat = false; private boolean mHaveDimAmount = false; private int mDefaultWindowFormat = PixelFormat.OPAQUE; private boolean mHasSoftInputMode = false; @UnsupportedAppUsage private boolean mDestroyed; private boolean mOverlayWithDecorCaptionEnabled = true; private boolean mCloseOnSwipeEnabled = false; /** * To check if toolkitSetFrameRateReadOnly flag is enabled * * @hide */ protected static boolean sToolkitSetFrameRateReadOnlyFlagValue = android.view.flags.Flags.toolkitSetFrameRateReadOnly(); // The current window attributes. @UnsupportedAppUsage private final WindowManager.LayoutParams mWindowAttributes = new WindowManager.LayoutParams(); /** * API from a Window back to its caller. This allows the client to * intercept key dispatching, panels and menus, etc. */ public interface Callback { /** * Called to process key events. At the very least your * implementation must call * {@link android.view.Window#superDispatchKeyEvent} to do the * standard key processing. * * @param event The key event. * * @return boolean Return true if this event was consumed. */ public boolean dispatchKeyEvent(KeyEvent event); /** * Called to process a key shortcut event. * At the very least your implementation must call * {@link android.view.Window#superDispatchKeyShortcutEvent} to do the * standard key shortcut processing. * * @param event The key shortcut event. * @return True if this event was consumed. */ public boolean dispatchKeyShortcutEvent(KeyEvent event); /** * Called to process touch screen events. At the very least your * implementation must call * {@link android.view.Window#superDispatchTouchEvent} to do the * standard touch screen processing. * * @param event The touch screen event. * * @return boolean Return true if this event was consumed. */ public boolean dispatchTouchEvent(MotionEvent event); /** * Called to process trackball events. At the very least your * implementation must call * {@link android.view.Window#superDispatchTrackballEvent} to do the * standard trackball processing. * * @param event The trackball event. * * @return boolean Return true if this event was consumed. */ public boolean dispatchTrackballEvent(MotionEvent event); /** * Called to process generic motion events. At the very least your * implementation must call * {@link android.view.Window#superDispatchGenericMotionEvent} to do the * standard processing. * * @param event The generic motion event. * * @return boolean Return true if this event was consumed. */ public boolean dispatchGenericMotionEvent(MotionEvent event); /** * Called to process population of {@link AccessibilityEvent}s. * * @param event The event. * * @return boolean Return true if event population was completed. */ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event); /** * Instantiate the view to display in the panel for 'featureId'. * You can return null, in which case the default content (typically * a menu) will be created for you. * * @param featureId Which panel is being created. * * @return view The top-level view to place in the panel. * * @see #onPreparePanel */ @Nullable public View onCreatePanelView(int featureId); /** * Initialize the contents of the menu for panel 'featureId'. This is * called if onCreatePanelView() returns null, giving you a standard * menu in which you can place your items. It is only called once for * the panel, the first time it is shown. * *You can safely hold on to menu (and any items created
* from it), making modifications to it as desired, until the next
* time onCreatePanelMenu() is called for this feature.
*
* @param featureId The panel being created.
* @param menu The menu inside the panel.
*
* @return boolean You must return true for the panel to be displayed;
* if you return false it will not be shown.
*/
boolean onCreatePanelMenu(int featureId, @NonNull Menu menu);
/**
* Prepare a panel to be displayed. This is called right before the
* panel window is shown, every time it is shown.
*
* @param featureId The panel that is being displayed.
* @param view The View that was returned by onCreatePanelView().
* @param menu If onCreatePanelView() returned null, this is the Menu
* being displayed in the panel.
*
* @return boolean You must return true for the panel to be displayed;
* if you return false it will not be shown.
*
* @see #onCreatePanelView
*/
boolean onPreparePanel(int featureId, @Nullable View view, @NonNull Menu menu);
/**
* Called when a panel's menu is opened by the user. This may also be
* called when the menu is changing from one type to another (for
* example, from the icon menu to the expanded menu).
*
* @param featureId The panel that the menu is in.
* @param menu The menu that is opened.
* @return Return true to allow the menu to open, or false to prevent
* the menu from opening.
*/
boolean onMenuOpened(int featureId, @NonNull Menu menu);
/**
* Called when a panel's menu item has been selected by the user.
*
* @param featureId The panel that the menu is in.
* @param item The menu item that was selected.
*
* @return boolean Return true to finish processing of selection, or
* false to perform the normal menu handling (calling its
* Runnable or sending a Message to its target Handler).
*/
boolean onMenuItemSelected(int featureId, @NonNull MenuItem item);
/**
* This is called whenever the current window attributes change.
*
*/
public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
/**
* This hook is called whenever the content view of the screen changes
* (due to a call to
* {@link Window#setContentView(View, android.view.ViewGroup.LayoutParams)
* Window.setContentView} or
* {@link Window#addContentView(View, android.view.ViewGroup.LayoutParams)
* Window.addContentView}).
*/
public void onContentChanged();
/**
* This hook is called whenever the window focus changes. See
* {@link View#onWindowFocusChanged(boolean)
* View.onWindowFocusChangedNotLocked(boolean)} for more information.
*
* @param hasFocus Whether the window now has focus.
*/
public void onWindowFocusChanged(boolean hasFocus);
/**
* Called when the window has been attached to the window manager.
* See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
* for more information.
*/
public void onAttachedToWindow();
/**
* Called when the window has been detached from the window manager.
* See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
* for more information.
*/
public void onDetachedFromWindow();
/**
* Called when a panel is being closed. If another logical subsequent
* panel is being opened (and this panel is being closed to make room for the subsequent
* panel), this method will NOT be called.
*
* @param featureId The panel that is being displayed.
* @param menu If onCreatePanelView() returned null, this is the Menu
* being displayed in the panel.
*/
void onPanelClosed(int featureId, @NonNull Menu menu);
/**
* Called when the user signals the desire to start a search.
*
* @return true if search launched, false if activity refuses (blocks)
*
* @see android.app.Activity#onSearchRequested()
*/
public boolean onSearchRequested();
/**
* Called when the user signals the desire to start a search.
*
* @param searchEvent A {@link SearchEvent} describing the signal to
* start a search.
* @return true if search launched, false if activity refuses (blocks)
*/
public boolean onSearchRequested(SearchEvent searchEvent);
/**
* Called when an action mode is being started for this window. Gives the
* callback an opportunity to handle the action mode in its own unique and
* beautiful way. If this method returns null the system can choose a way
* to present the mode or choose not to start the mode at all. This is equivalent
* to {@link #onWindowStartingActionMode(android.view.ActionMode.Callback, int)}
* with type {@link ActionMode#TYPE_PRIMARY}.
*
* @param callback Callback to control the lifecycle of this action mode
* @return The ActionMode that was started, or null if the system should present it
*/
@Nullable
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback);
/**
* Called when an action mode is being started for this window. Gives the
* callback an opportunity to handle the action mode in its own unique and
* beautiful way. If this method returns null the system can choose a way
* to present the mode or choose not to start the mode at all.
*
* @param callback Callback to control the lifecycle of this action mode
* @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
* @return The ActionMode that was started, or null if the system should present it
*/
@Nullable
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type);
/**
* Called when an action mode has been started. The appropriate mode callback
* method will have already been invoked.
*
* @param mode The new mode that has just been started.
*/
public void onActionModeStarted(ActionMode mode);
/**
* Called when an action mode has been finished. The appropriate mode callback
* method will have already been invoked.
*
* @param mode The mode that was just finished.
*/
public void onActionModeFinished(ActionMode mode);
/**
* Called when Keyboard Shortcuts are requested for the current window.
*
* @param data The data list to populate with shortcuts.
* @param menu The current menu, which may be null.
* @param deviceId The id for the connected device the shortcuts should be provided for.
*/
default public void onProvideKeyboardShortcuts(
List Refer to the individual flags for the permissions needed.
*
* @param flags The flag bits to add.
*
* @hide
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void addPrivateFlags(int flags) {
setPrivateFlags(flags, flags);
}
/**
* Add system flag bits.
*
* Refer to the individual flags for the permissions needed.
*
* Note: Only for updateable system components (aka. mainline modules)
*
* @param flags The flag bits to add.
*
* @hide
*/
@SystemApi
public void addSystemFlags(@WindowManager.LayoutParams.SystemFlags int flags) {
addPrivateFlags(flags);
}
/**
* Convenience function to clear the flag bits as specified in flags, as
* per {@link #setFlags}.
* @param flags The flag bits to be cleared.
* @see #setFlags
* @see #addFlags
*/
public void clearFlags(int flags) {
setFlags(0, flags);
}
/**
* Set the flags of the window, as per the
* {@link WindowManager.LayoutParams WindowManager.LayoutParams}
* flags.
*
* Note that some flags must be set before the window decoration is
* created (by the first call to
* {@link #setContentView(View, android.view.ViewGroup.LayoutParams)} or
* {@link #getDecorView()}:
* {@link WindowManager.LayoutParams#FLAG_LAYOUT_IN_SCREEN} and
* {@link WindowManager.LayoutParams#FLAG_LAYOUT_INSET_DECOR}. These
* will be set for you based on the {@link android.R.attr#windowIsFloating}
* attribute.
*
* @param flags The new window flags (see WindowManager.LayoutParams).
* @param mask Which of the window flag bits to modify.
* @see #addFlags
* @see #clearFlags
*/
public void setFlags(int flags, int mask) {
final WindowManager.LayoutParams attrs = getAttributes();
attrs.flags = (attrs.flags&~mask) | (flags&mask);
mForcedWindowFlags |= mask;
dispatchWindowAttributesChanged(attrs);
}
private void setPrivateFlags(int flags, int mask) {
final WindowManager.LayoutParams attrs = getAttributes();
attrs.privateFlags = (attrs.privateFlags & ~mask) | (flags & mask);
dispatchWindowAttributesChanged(attrs);
}
/**
* {@hide}
*/
protected void dispatchWindowAttributesChanged(WindowManager.LayoutParams attrs) {
if (mCallback != null) {
mCallback.onWindowAttributesChanged(attrs);
}
}
/**
* Sets the requested color mode of the window. The requested the color mode might
* override the window's pixel {@link WindowManager.LayoutParams#format format}. The requested color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
* {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}. The requested color mode is not guaranteed to be honored. Please refer to
* {@link #getColorMode()} for more information. Sets the desired about of HDR headroom to be used when rendering as a ratio of
* targetHdrPeakBrightnessInNits / targetSdrWhitePointInNits. Only applies when
* {@link #setColorMode(int)} is {@link ActivityInfo#COLOR_MODE_HDR} By default the system will choose an amount of HDR headroom that is appropriate
* for the underlying device capabilities & bit-depth of the panel. However, for some types
* of content this can end up being more headroom than necessary or desired. An example
* would be a messaging app or gallery thumbnail view where some amount of HDR pop is desired
* without overly influencing the perceived brightness of the majority SDR content. This can
* also be used to animate in/out of an HDR range for smoother transitions. Note: The actual amount of HDR headroom that will be given is subject to a variety
* of factors such as ambient conditions, display capabilities, or bit-depth limitations.
* See {@link Display#getHdrSdrRatio()} for more information as well as how to query the
* current value. By default, the display does not do minimal post processing and if this is desired, this
* method should not be used. It should be used with {@code isPreferred=true} when low
* latency has a higher priority than image enhancement processing (e.g. for games or video
* conferencing). The display will automatically go back into standard image processing mode
* when no window requesting minimal posst processing is visible on screen anymore.
* {@code setPreferMinimalPostProcessing(false)} can be used if
* {@code setPreferMinimalPostProcessing(true)} was previously called for this window and
* minimal post processing is no longer required.
*
* If the Display sink is connected via HDMI, the device will begin to send infoframes with
* Auto Low Latency Mode enabled and Game Content Type. This will switch the connected display
* to a minimal image processing mode (if available), which reduces latency, improving the user
* experience for gaming or video conferencing applications. For more information, see HDMI 2.1
* specification.
*
* If the Display sink has an internal connection or uses some other protocol than HDMI,
* effects may be similar but implementation-defined.
*
* The ability to switch to a mode with minimal post proessing may be disabled by a user
* setting in the system settings menu. In that case, this method does nothing.
*
* @see android.content.pm.ActivityInfo#FLAG_PREFER_MINIMAL_POST_PROCESSING
* @see android.view.Display#isMinimalPostProcessingSupported
* @see android.view.WindowManager.LayoutParams#preferMinimalPostProcessing
*
* @param isPreferred Indicates whether minimal post processing is preferred for this window
* ({@code isPreferred=true}) or not ({@code isPreferred=false}).
*/
public void setPreferMinimalPostProcessing(boolean isPreferred) {
mWindowAttributes.preferMinimalPostProcessing = isPreferred;
dispatchWindowAttributesChanged(mWindowAttributes);
}
/**
* Returns the requested color mode of the window, one of
* {@link ActivityInfo#COLOR_MODE_DEFAULT}, {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
* or {@link ActivityInfo#COLOR_MODE_HDR}. If {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT}
* was requested it is possible the window will not be put in wide color gamut mode depending
* on device and display support for that mode. Use {@link #isWideColorGamut} to determine
* if the window is currently in wide color gamut mode.
*
* @see #setColorMode(int)
* @see Display#isWideColorGamut()
* @see Configuration#isScreenWideColorGamut()
*/
@ActivityInfo.ColorMode
public int getColorMode() {
return getAttributes().getColorMode();
}
/**
* Returns true if this window's color mode is {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT},
* the display has a wide color gamut and this device supports wide color gamut rendering.
*
* @see Display#isWideColorGamut()
* @see Configuration#isScreenWideColorGamut()
*/
public boolean isWideColorGamut() {
return getColorMode() == ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT
&& getContext().getResources().getConfiguration().isScreenWideColorGamut();
}
/**
* Set the amount of dim behind the window when using
* {@link WindowManager.LayoutParams#FLAG_DIM_BEHIND}. This overrides
* the default dim amount of that is selected by the Window based on
* its theme.
*
* @param amount The new dim amount, from 0 for no dim to 1 for full dim.
*/
public void setDimAmount(float amount) {
final WindowManager.LayoutParams attrs = getAttributes();
attrs.dimAmount = amount;
mHaveDimAmount = true;
dispatchWindowAttributesChanged(attrs);
}
/**
* Sets whether the decor view should fit root-level content views for {@link WindowInsets}.
*
* If set to {@code true}, the framework will inspect the now deprecated
* {@link View#SYSTEM_UI_LAYOUT_FLAGS} as well the
* {@link WindowManager.LayoutParams#SOFT_INPUT_ADJUST_RESIZE} flag and fits content according
* to these flags.
*
*
* If set to {@code false}, the framework will not fit the content view to the insets and will
* just pass through the {@link WindowInsets} to the content view.
*
*
* If the app targets
* {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
* the behavior will be like setting this to {@code false}, and cannot be changed.
*
* @param decorFitsSystemWindows Whether the decor view should fit root-level content views for
* insets.
* @deprecated Make space in the container views to prevent the critical elements from getting
* obscured by {@link WindowInsets.Type#systemBars()} or
* {@link WindowInsets.Type#displayCutout()} instead.
*/
public void setDecorFitsSystemWindows(boolean decorFitsSystemWindows) {
}
/** @hide */
public boolean decorFitsSystemWindows() {
return false;
}
/**
* Specify custom window attributes. PLEASE NOTE: the
* layout params you give here should generally be from values previously
* retrieved with {@link #getAttributes()}; you probably do not want to
* blindly create and apply your own, since this will blow away any values
* set by the framework that you are not interested in.
*
* @param a The new window attributes, which will completely override any
* current values.
*/
public void setAttributes(WindowManager.LayoutParams a) {
mWindowAttributes.copyFrom(a);
dispatchWindowAttributesChanged(mWindowAttributes);
}
/**
* Retrieve the current window attributes associated with this panel.
*
* @return WindowManager.LayoutParams Either the existing window
* attributes object, or a freshly created one if there is none.
*/
public final WindowManager.LayoutParams getAttributes() {
return mWindowAttributes;
}
/**
* Return the window flags that have been explicitly set by the client,
* so will not be modified by {@link #getDecorView}.
*/
protected final int getForcedWindowFlags() {
return mForcedWindowFlags;
}
/**
* Has the app specified their own soft input mode?
*/
protected final boolean hasSoftInputMode() {
return mHasSoftInputMode;
}
/** @hide */
@UnsupportedAppUsage
public void setCloseOnTouchOutside(boolean close) {
mCloseOnTouchOutside = close;
mSetCloseOnTouchOutside = true;
}
/** @hide */
@UnsupportedAppUsage
public void setCloseOnTouchOutsideIfNotSet(boolean close) {
if (!mSetCloseOnTouchOutside) {
mCloseOnTouchOutside = close;
mSetCloseOnTouchOutside = true;
}
}
/** @hide */
public boolean shouldCloseOnTouchOutside() {
return mCloseOnTouchOutside;
}
/** @hide */
@SuppressWarnings("HiddenAbstractMethod")
@UnsupportedAppUsage
public abstract void alwaysReadCloseOnTouchAttr();
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public boolean shouldCloseOnTouch(Context context, MotionEvent event) {
final boolean isOutside =
event.getAction() == MotionEvent.ACTION_UP && isOutOfBounds(context, event)
|| event.getAction() == MotionEvent.ACTION_OUTSIDE;
if (mCloseOnTouchOutside && peekDecorView() != null && isOutside) {
return true;
}
return false;
}
/* Sets the Sustained Performance requirement for the calling window.
* @param enable disables or enables the mode.
*/
public void setSustainedPerformanceMode(boolean enable) {
setPrivateFlags(enable
? WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE : 0,
WindowManager.LayoutParams.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE);
}
private boolean isOutOfBounds(Context context, MotionEvent event) {
final int x = (int) event.getX();
final int y = (int) event.getY();
final int slop = ViewConfiguration.get(context).getScaledWindowTouchSlop();
final View decorView = getDecorView();
return (x < -slop) || (y < -slop)
|| (x > (decorView.getWidth()+slop))
|| (y > (decorView.getHeight()+slop));
}
/**
* Enable extended screen features. This must be called before
* setContentView(). May be called as many times as desired as long as it
* is before setContentView(). If not called, no extended features
* will be available. You can not turn off a feature once it is requested.
* You canot use other title features with {@link #FEATURE_CUSTOM_TITLE}.
*
* @param featureId The desired features, defined as constants by Window.
* @return The features that are now set.
*/
public boolean requestFeature(int featureId) {
final int flag = 1<
* Note: In most cases -- depending on compiler support --
* the resulting view is automatically cast to the target class type. If
* the target class type is unconstrained, an explicit cast may be
* necessary.
*
* @param id the ID to search for
* @return a view with given ID if found, or {@code null} otherwise
* @see View#findViewById(int)
* @see Window#requireViewById(int)
*/
@Nullable
public
* Note: In most cases -- depending on compiler support --
* the resulting view is automatically cast to the target class type. If
* the target class type is unconstrained, an explicit cast may be
* necessary.
*
* @param id the ID to search for
* @return a view with given ID
* @see View#requireViewById(int)
* @see Window#findViewById(int)
*/
@NonNull
public final Note that calling this function "locks in" various characteristics
* of the window that can not, from this point forward, be changed: the
* features that have been requested with {@link #requestFeature(int)},
* and certain window flags as described in {@link #setFlags(int, int)}. If {@link #FEATURE_CONTENT_TRANSITIONS} is set, the window's
* TransitionManager will be used to animate content from the current
* content View to view.
* Changes to this property take effect immediately and will cause the
* window surface to be recreated. This is an expensive operation and as a
* result, this property should not be animated.
*
* @param elevation The window elevation.
* @see View#setElevation(float)
* @see android.R.styleable#Window_windowElevation
*/
public void setElevation(float elevation) {}
/**
* Gets the window elevation.
*
* @hide
*/
public float getElevation() {
return 0.0f;
}
/**
* Sets whether window content should be clipped to the outline of the
* window background.
*
* @param clipToOutline Whether window content should be clipped to the
* outline of the window background.
* @see View#setClipToOutline(boolean)
* @see android.R.styleable#Window_windowClipToOutline
*/
public void setClipToOutline(boolean clipToOutline) {}
/**
* Change the background of this window to a Drawable resource. Setting the
* background to null will make the window be opaque. To make the window
* transparent, you can use an empty drawable (for instance a ColorDrawable
* with the color 0 or the system drawable android:drawable/empty.)
*
* @param resId The resource identifier of a drawable resource which will
* be installed as the new background.
*/
public void setBackgroundDrawableResource(@DrawableRes int resId) {
setBackgroundDrawable(mContext.getDrawable(resId));
}
/**
* Change the background of this window to a custom Drawable. Setting the
* background to null will make the window be opaque. To make the window
* transparent, you can use an empty drawable (for instance a ColorDrawable
* with the color 0 or the system drawable android:drawable/empty.)
*
* @param drawable The new Drawable to use for this window's background.
*/
public abstract void setBackgroundDrawable(Drawable drawable);
/**
*
* Blurs the screen behind the window within the bounds of the window.
*
* The density of the blur is set by the blur radius. The radius defines the size
* of the neighbouring area, from which pixels will be averaged to form the final
* color for each pixel. The operation approximates a Gaussian blur.
* A radius of 0 means no blur. The higher the radius, the denser the blur.
*
* The window background drawable is drawn on top of the blurred region. The blur
* region bounds and rounded corners will mimic those of the background drawable.
*
* For the blur region to be visible, the window has to be translucent
* (see {@link android.R.attr#windowIsTranslucent}) and floating
* (see {@link android.R.attr#windowIsFloating}).
*
* Note the difference with {@link WindowManager.LayoutParams#setBlurBehindRadius},
* which blurs the whole screen behind the window. Background blur blurs the screen behind
* only within the bounds of the window.
*
* Some devices might not support cross-window blur due to GPU limitations. It can also be
* disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or
* when minimal post processing is requested. In such situations, no blur will be computed or
* drawn, resulting in a transparent window background. To avoid this, the app might want to
* change its theme to one that does not use blurs. To listen for cross-window blur
* enabled/disabled events, use {@link WindowManager#addCrossWindowBlurEnabledListener}.
* The only URI currently supported is "content:", specifying an image
* in a content provider.
*
* @see android.widget.ImageView#setImageURI
*
* @param featureId The desired drawable feature to change. Features are
* constants defined by Window.
* @param uri The desired URI.
*/
public abstract void setFeatureDrawableUri(int featureId, Uri uri);
/**
* Set an explicit Drawable value for feature of this window. You must
* have called requestFeature(featureId) before calling this function.
*
* @param featureId The desired drawable feature to change. Features are
* constants defined by Window.
* @param drawable A Drawable object to display.
*/
public abstract void setFeatureDrawable(int featureId, Drawable drawable);
/**
* Set a custom alpha value for the given drawable feature, controlling how
* much the background is visible through it.
*
* @param featureId The desired drawable feature to change. Features are
* constants defined by Window.
* @param alpha The alpha amount, 0 is completely transparent and 255 is
* completely opaque.
*/
public abstract void setFeatureDrawableAlpha(int featureId, int alpha);
/**
* Set the integer value for a feature. The range of the value depends on
* the feature being set. For {@link #FEATURE_PROGRESS}, it should go from
* 0 to 10000. At 10000 the progress is complete and the indicator hidden.
*
* @param featureId The desired feature to change. Features are constants
* defined by Window.
* @param value The value for the feature. The interpretation of this
* value is feature-specific.
*/
public abstract void setFeatureInt(int featureId, int value);
/**
* Request that key events come to this activity. Use this if your
* activity has no views with focus, but the activity still wants
* a chance to process key events.
*/
public abstract void takeKeyEvents(boolean get);
/**
* Used by custom windows, such as Dialog, to pass the key press event
* further down the view hierarchy. Application developers should
* not need to implement or call this.
*
*/
public abstract boolean superDispatchKeyEvent(KeyEvent event);
/**
* Used by custom windows, such as Dialog, to pass the key shortcut press event
* further down the view hierarchy. Application developers should
* not need to implement or call this.
*
*/
public abstract boolean superDispatchKeyShortcutEvent(KeyEvent event);
/**
* Used by custom windows, such as Dialog, to pass the touch screen event
* further down the view hierarchy. Application developers should
* not need to implement or call this.
*
*/
public abstract boolean superDispatchTouchEvent(MotionEvent event);
/**
* Used by custom windows, such as Dialog, to pass the trackball event
* further down the view hierarchy. Application developers should
* not need to implement or call this.
*
*/
public abstract boolean superDispatchTrackballEvent(MotionEvent event);
/**
* Used by custom windows, such as Dialog, to pass the generic motion event
* further down the view hierarchy. Application developers should
* not need to implement or call this.
*
*/
public abstract boolean superDispatchGenericMotionEvent(MotionEvent event);
/**
* Retrieve the top-level window decor view (containing the standard
* window frame/decorations and the client's content inside of that), which
* can be added as a window to the window manager.
*
* Note that calling this function for the first time "locks in"
* various window characteristics as described in
* {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}. To do: add a public version of this API that allows you to check for
* features by their feature ID.
*
* @return int The feature bits.
*/
protected final int getFeatures()
{
return mFeatures;
}
/**
* Return the feature bits set by default on a window.
* @param context The context used to access resources
*/
public static int getDefaultFeatures(Context context) {
int features = 0;
final Resources res = context.getResources();
if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureOptionsPanel)) {
features |= 1 << FEATURE_OPTIONS_PANEL;
}
if (res.getBoolean(com.android.internal.R.bool.config_defaultWindowFeatureContextMenu)) {
features |= 1 << FEATURE_CONTEXT_MENU;
}
return features;
}
/**
* Query for the availability of a certain feature.
*
* @param feature The feature ID to check
* @return true if the feature is enabled, false otherwise.
*/
public boolean hasFeature(int feature) {
return (getFeatures() & (1 << feature)) != 0;
}
/**
* Return the feature bits that are being implemented by this Window.
* This is the set of features that were given to requestFeature(), and are
* being handled by only this Window itself, not by its containers.
*
* @return int The feature bits.
*/
protected final int getLocalFeatures()
{
return mLocalFeatures;
}
/**
* Set the default format of window, as per the PixelFormat types. This
* is the format that will be used unless the client specifies in explicit
* format with setFormat();
*
* @param format The new window format (see PixelFormat).
*
* @see #setFormat
* @see PixelFormat
*/
protected void setDefaultWindowFormat(int format) {
mDefaultWindowFormat = format;
if (!mHaveWindowFormat) {
final WindowManager.LayoutParams attrs = getAttributes();
attrs.format = format;
dispatchWindowAttributesChanged(attrs);
}
}
/** @hide */
protected boolean haveDimAmount() {
return mHaveDimAmount;
}
public abstract void setChildDrawable(int featureId, Drawable drawable);
public abstract void setChildInt(int featureId, int value);
/**
* Is a keypress one of the defined shortcut keys for this window.
* @param keyCode the key code from {@link android.view.KeyEvent} to check.
* @param event the {@link android.view.KeyEvent} to use to help check.
*/
public abstract boolean isShortcutKey(int keyCode, KeyEvent event);
/**
* @see android.app.Activity#setVolumeControlStream(int)
*/
public abstract void setVolumeControlStream(int streamType);
/**
* @see android.app.Activity#getVolumeControlStream()
*/
public abstract int getVolumeControlStream();
/**
* Sets a {@link MediaController} to send media keys and volume changes to.
* If set, this should be preferred for all media keys and volume requests
* sent to this window.
*
* @param controller The controller for the session which should receive
* media keys and volume changes.
* @see android.app.Activity#setMediaController(android.media.session.MediaController)
*/
public void setMediaController(MediaController controller) {
}
/**
* Gets the {@link MediaController} that was previously set.
*
* @return The controller which should receive events.
* @see #setMediaController(android.media.session.MediaController)
* @see android.app.Activity#getMediaController()
*/
public MediaController getMediaController() {
return null;
}
/**
* Set extra options that will influence the UI for this window.
* @param uiOptions Flags specifying extra options for this window.
*/
public void setUiOptions(int uiOptions) { }
/**
* Set extra options that will influence the UI for this window.
* Only the bits filtered by mask will be modified.
* @param uiOptions Flags specifying extra options for this window.
* @param mask Flags specifying which options should be modified. Others will remain unchanged.
*/
public void setUiOptions(int uiOptions, int mask) { }
/**
* Set the primary icon for this window.
*
* @param resId resource ID of a drawable to set
*/
public void setIcon(@DrawableRes int resId) { }
/**
* Set the default icon for this window.
* This will be overridden by any other icon set operation which could come from the
* theme or another explicit set.
*
* @hide
*/
public void setDefaultIcon(@DrawableRes int resId) { }
/**
* Set the logo for this window. A logo is often shown in place of an
* {@link #setIcon(int) icon} but is generally wider and communicates window title information
* as well.
*
* @param resId resource ID of a drawable to set
*/
public void setLogo(@DrawableRes int resId) { }
/**
* Set the default logo for this window.
* This will be overridden by any other logo set operation which could come from the
* theme or another explicit set.
*
* @hide
*/
public void setDefaultLogo(@DrawableRes int resId) { }
/**
* Set focus locally. The window should have the
* {@link WindowManager.LayoutParams#FLAG_LOCAL_FOCUS_MODE} flag set already.
* @param hasFocus Whether this window has focus or not.
* @param inTouchMode Whether this window is in touch mode or not.
*/
public void setLocalFocus(boolean hasFocus, boolean inTouchMode) { }
/**
* Inject an event to window locally.
* @param event A key or touch event to inject to this window.
*/
public void injectInputEvent(InputEvent event) { }
/**
* Retrieve the {@link TransitionManager} responsible for for default transitions
* in this window. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
*
* This method will return non-null after content has been initialized (e.g. by using
* {@link #setContentView}) if {@link #FEATURE_CONTENT_TRANSITIONS} has been granted. This method will return null if the current content is not represented by a Scene. When executing the enter transition, the background starts transparent
* and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
* 300 milliseconds. When executing the enter transition, the background starts transparent
* and fades in. This requires {@link #FEATURE_ACTIVITY_TRANSITIONS}. The default is
* 300 milliseconds.
* The transitionName for the view background will be "android:status:background".
*
*
* If the color is transparent and the window enforces the status bar contrast, the system
* will determine whether a scrim is necessary and draw one on behalf of the app to ensure
* that the status bar has enough contrast with the contents of this app, and set an appropriate
* effective bar background accordingly.
*
*
* If the app targets
* {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
* the color will be transparent and cannot be changed.
*
* @see #setNavigationBarContrastEnforced
* @deprecated Draw proper background behind {@link WindowInsets.Type#statusBars()}} instead.
*/
@Deprecated
public abstract void setStatusBarColor(@ColorInt int color);
/**
* @return the color of the navigation bar.
* @deprecated This is no longer needed since the setter is deprecated.
*/
@Deprecated
@ColorInt
public abstract int getNavigationBarColor();
/**
* Sets the color of the navigation bar to {@param color}.
*
* For this to take effect,
* the window must be drawing the system bar backgrounds with
* {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
* {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
*
* If {@param color} is not opaque, consider setting
* {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
* {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
*
* The transitionName for the view background will be "android:navigation:background".
*
*
* If the color is transparent and the window enforces the navigation bar contrast, the system
* will determine whether a scrim is necessary and draw one on behalf of the app to ensure that
* the navigation bar has enough contrast with the contents of this app, and set an appropriate
* effective bar background accordingly.
*
*
* If the app targets
* {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
* the color will be transparent and cannot be changed.
*
* @attr ref android.R.styleable#Window_navigationBarColor
* @see #setNavigationBarContrastEnforced
* @deprecated Draw proper background behind {@link WindowInsets.Type#navigationBars()} or
* {@link WindowInsets.Type#tappableElement()} instead.
*/
@Deprecated
public abstract void setNavigationBarColor(@ColorInt int color);
/**
* Shows a thin line of the specified color between the navigation bar and the app
* content.
*
* For this to take effect,
* the window must be drawing the system bar backgrounds with
* {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
* {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION} must not be set.
*
*
* If the app targets
* {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM VANILLA_ICE_CREAM} or above,
* the color will be transparent and cannot be changed.
*
* @param dividerColor The color of the thin line.
* @attr ref android.R.styleable#Window_navigationBarDividerColor
* @deprecated Draw proper background behind {@link WindowInsets.Type#navigationBars()} or
* {@link WindowInsets.Type#tappableElement()} instead.
*/
@Deprecated
public void setNavigationBarDividerColor(@ColorInt int dividerColor) {
}
/**
* Retrieves the color of the navigation bar divider.
*
* @return The color of the navigation bar divider color.
* @see #setNavigationBarColor(int)
* @attr ref android.R.styleable#Window_navigationBarDividerColor
* @deprecated This is no longer needed since the setter is deprecated.
*/
@Deprecated
public @ColorInt int getNavigationBarDividerColor() {
return 0;
}
/**
* Sets whether the system should ensure that the status bar has enough
* contrast when a fully transparent background is requested.
*
* If set to this value, the system will determine whether a scrim is necessary
* to ensure that the status bar has enough contrast with the contents of
* this app, and set an appropriate effective bar background color accordingly.
*
* When the status bar color has a non-zero alpha value, the value of this
* property has no effect.
*
* @see android.R.attr#enforceStatusBarContrast
* @see #isStatusBarContrastEnforced
* @see #setStatusBarColor
* @deprecated Draw proper background behind {@link WindowInsets.Type#statusBars()}} instead.
*/
@Deprecated
public void setStatusBarContrastEnforced(boolean ensureContrast) {
}
/**
* Returns whether the system is ensuring that the status bar has enough contrast when a
* fully transparent background is requested.
*
* When the status bar color has a non-zero alpha value, the value of this
* property has no effect.
*
* @return true, if the system is ensuring contrast, false otherwise.
* @see android.R.attr#enforceStatusBarContrast
* @see #setStatusBarContrastEnforced
* @see #setStatusBarColor
* @deprecated This is not needed since the setter is deprecated.
*/
@Deprecated
public boolean isStatusBarContrastEnforced() {
return false;
}
/**
* Sets whether the system should ensure that the navigation bar has enough
* contrast when a fully transparent background is requested.
*
* If set to this value, the system will determine whether a scrim is necessary
* to ensure that the navigation bar has enough contrast with the contents of
* this app, and set an appropriate effective bar background color accordingly.
*
* When the navigation bar color has a non-zero alpha value, the value of this
* property has no effect.
*
* @see android.R.attr#enforceNavigationBarContrast
* @see #isNavigationBarContrastEnforced
* @see #setNavigationBarColor
*/
public void setNavigationBarContrastEnforced(boolean enforceContrast) {
}
/**
* Returns whether the system is ensuring that the navigation bar has enough contrast when a
* fully transparent background is requested.
*
* When the navigation bar color has a non-zero alpha value, the value of this
* property has no effect.
*
* @return true, if the system is ensuring contrast, false otherwise.
* @see android.R.attr#enforceNavigationBarContrast
* @see #setNavigationBarContrastEnforced
* @see #setNavigationBarColor
*/
public boolean isNavigationBarContrastEnforced() {
return false;
}
/**
* Sets a list of areas within this window's coordinate space where the system should not
* intercept touch or other pointing device gestures.
*
* This method should be used by apps that make use of
* {@link #takeSurface(SurfaceHolder.Callback2)} and do not have a view hierarchy available.
* Apps that do have a view hierarchy should use
* {@link View#setSystemGestureExclusionRects(List)} instead. This method does not modify or
* replace the gesture exclusion rects populated by individual views in this window's view
* hierarchy using {@link View#setSystemGestureExclusionRects(List)}. Use this to tell the system which specific sub-areas of a view need to receive gesture
* input in order to function correctly in the presence of global system gestures that may
* conflict. For example, if the system wishes to capture swipe-in-from-screen-edge gestures
* to provide system-level navigation functionality, a view such as a navigation drawer
* container can mark the left (or starting) edge of itself as requiring gesture capture
* priority using this API. The system may then choose to relax its own gesture recognition
* to allow the app to consume the user's gesture. It is not necessary for an app to register
* exclusion rects for broadly spanning regions such as the entirety of a
* Do not modify the provided list after this method is called.transition
is null,
* entering Views will remain unaffected.
*
* @param transition The Transition to use to move Views into the initial Scene.
* @attr ref android.R.styleable#Window_windowEnterTransition
*/
public void setEnterTransition(Transition transition) {}
/**
* Sets the Transition that will be used to move Views out of the scene when the Window is
* preparing to close, for example after a call to
* {@link android.app.Activity#finishAfterTransition()}. The exiting
* Views will be those that are regular Views or ViewGroups that have
* {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
* {@link android.transition.Visibility} as entering is governed by changing visibility from
* {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition
is null,
* entering Views will remain unaffected. If nothing is set, the default will be to
* use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
*
* @param transition The Transition to use to move Views out of the Scene when the Window
* is preparing to close.
* @attr ref android.R.styleable#Window_windowReturnTransition
*/
public void setReturnTransition(Transition transition) {}
/**
* Sets the Transition that will be used to move Views out of the scene when starting a
* new Activity. The exiting Views will be those that are regular Views or ViewGroups that
* have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
* {@link android.transition.Visibility} as exiting is governed by changing visibility
* from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
* remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @param transition The Transition to use to move Views out of the scene when calling a
* new Activity.
* @attr ref android.R.styleable#Window_windowExitTransition
*/
public void setExitTransition(Transition transition) {}
/**
* Sets the Transition that will be used to move Views in to the scene when returning from
* a previously-started Activity. The entering Views will be those that are regular Views
* or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
* will extend {@link android.transition.Visibility} as exiting is governed by changing
* visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
* the views will remain unaffected. If nothing is set, the default will be to use the same
* transition as {@link #setExitTransition(android.transition.Transition)}.
* Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @param transition The Transition to use to move Views into the scene when reentering from a
* previously-started Activity.
* @attr ref android.R.styleable#Window_windowReenterTransition
*/
public void setReenterTransition(Transition transition) {}
/**
* Returns the transition used to move Views into the initial scene. The entering
* Views will be those that are regular Views or ViewGroups that have
* {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
* {@link android.transition.Visibility} as entering is governed by changing visibility from
* {@link View#INVISIBLE} to {@link View#VISIBLE}. If transition
is null,
* entering Views will remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @return the Transition to use to move Views into the initial Scene.
* @attr ref android.R.styleable#Window_windowEnterTransition
*/
public Transition getEnterTransition() { return null; }
/**
* Returns the Transition that will be used to move Views out of the scene when the Window is
* preparing to close, for example after a call to
* {@link android.app.Activity#finishAfterTransition()}. The exiting
* Views will be those that are regular Views or ViewGroups that have
* {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
* {@link android.transition.Visibility} as entering is governed by changing visibility from
* {@link View#VISIBLE} to {@link View#INVISIBLE}.
*
* @return The Transition to use to move Views out of the Scene when the Window
* is preparing to close.
* @attr ref android.R.styleable#Window_windowReturnTransition
*/
public Transition getReturnTransition() { return null; }
/**
* Returns the Transition that will be used to move Views out of the scene when starting a
* new Activity. The exiting Views will be those that are regular Views or ViewGroups that
* have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
* {@link android.transition.Visibility} as exiting is governed by changing visibility
* from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null, the views will
* remain unaffected. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @return the Transition to use to move Views out of the scene when calling a
* new Activity.
* @attr ref android.R.styleable#Window_windowExitTransition
*/
public Transition getExitTransition() { return null; }
/**
* Returns the Transition that will be used to move Views in to the scene when returning from
* a previously-started Activity. The entering Views will be those that are regular Views
* or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
* will extend {@link android.transition.Visibility} as exiting is governed by changing
* visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
* Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @return The Transition to use to move Views into the scene when reentering from a
* previously-started Activity.
* @attr ref android.R.styleable#Window_windowReenterTransition
*/
public Transition getReenterTransition() { return null; }
/**
* Sets the Transition that will be used for shared elements transferred into the content
* Scene. Typical Transitions will affect size and location, such as
* {@link android.transition.ChangeBounds}. A null
* value will cause transferred shared elements to blink to the final position.
* Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @param transition The Transition to use for shared elements transferred into the content
* Scene.
* @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
*/
public void setSharedElementEnterTransition(Transition transition) {}
/**
* Sets the Transition that will be used for shared elements transferred back to a
* calling Activity. Typical Transitions will affect size and location, such as
* {@link android.transition.ChangeBounds}. A null
* value will cause transferred shared elements to blink to the final position.
* If no value is set, the default will be to use the same value as
* {@link #setSharedElementEnterTransition(android.transition.Transition)}.
* Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @param transition The Transition to use for shared elements transferred out of the content
* Scene.
* @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
*/
public void setSharedElementReturnTransition(Transition transition) {}
/**
* Returns the Transition that will be used for shared elements transferred into the content
* Scene. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @return Transition to use for sharend elements transferred into the content Scene.
* @attr ref android.R.styleable#Window_windowSharedElementEnterTransition
*/
public Transition getSharedElementEnterTransition() { return null; }
/**
* Returns the Transition that will be used for shared elements transferred back to a
* calling Activity. Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @return Transition to use for sharend elements transferred into the content Scene.
* @attr ref android.R.styleable#Window_windowSharedElementReturnTransition
*/
public Transition getSharedElementReturnTransition() { return null; }
/**
* Sets the Transition that will be used for shared elements after starting a new Activity
* before the shared elements are transferred to the called Activity. If the shared elements
* must animate during the exit transition, this Transition should be used. Upon completion,
* the shared elements may be transferred to the started Activity.
* Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @param transition The Transition to use for shared elements in the launching Window
* prior to transferring to the launched Activity's Window.
* @attr ref android.R.styleable#Window_windowSharedElementExitTransition
*/
public void setSharedElementExitTransition(Transition transition) {}
/**
* Sets the Transition that will be used for shared elements reentering from a started
* Activity after it has returned the shared element to it start location. If no value
* is set, this will default to
* {@link #setSharedElementExitTransition(android.transition.Transition)}.
* Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @param transition The Transition to use for shared elements in the launching Window
* after the shared element has returned to the Window.
* @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
*/
public void setSharedElementReenterTransition(Transition transition) {}
/**
* Returns the Transition to use for shared elements in the launching Window prior
* to transferring to the launched Activity's Window.
* Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @return the Transition to use for shared elements in the launching Window prior
* to transferring to the launched Activity's Window.
* @attr ref android.R.styleable#Window_windowSharedElementExitTransition
*/
public Transition getSharedElementExitTransition() { return null; }
/**
* Returns the Transition that will be used for shared elements reentering from a started
* Activity after it has returned the shared element to it start location.
* Requires {@link #FEATURE_ACTIVITY_TRANSITIONS}.
*
* @return the Transition that will be used for shared elements reentering from a started
* Activity after it has returned the shared element to it start location.
* @attr ref android.R.styleable#Window_windowSharedElementReenterTransition
*/
public Transition getSharedElementReenterTransition() { return null; }
/**
* Controls how the transition set in
* {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
* transition of the calling Activity. When true, the transition will start as soon as possible.
* When false, the transition will wait until the remote exiting transition completes before
* starting. The default value is true.
*
* @param allow true to start the enter transition when possible or false to
* wait until the exiting transition completes.
* @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
*/
public void setAllowEnterTransitionOverlap(boolean allow) {}
/**
* Returns how the transition set in
* {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
* transition of the calling Activity. When true, the transition will start as soon as possible.
* When false, the transition will wait until the remote exiting transition completes before
* starting. The default value is true.
*
* @return true when the enter transition should start as soon as possible or false to
* when it should wait until the exiting transition completes.
* @attr ref android.R.styleable#Window_windowAllowEnterTransitionOverlap
*/
public boolean getAllowEnterTransitionOverlap() { return true; }
/**
* Controls how the transition set in
* {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
* transition of the called Activity when reentering after if finishes. When true,
* the transition will start as soon as possible. When false, the transition will wait
* until the called Activity's exiting transition completes before starting.
* The default value is true.
*
* @param allow true to start the transition when possible or false to wait until the
* called Activity's exiting transition completes.
* @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
*/
public void setAllowReturnTransitionOverlap(boolean allow) {}
/**
* Returns how the transition set in
* {@link #setExitTransition(android.transition.Transition)} overlaps with the exit
* transition of the called Activity when reentering after if finishes. When true,
* the transition will start as soon as possible. When false, the transition will wait
* until the called Activity's exiting transition completes before starting.
* The default value is true.
*
* @return true when the transition should start when possible or false when it should wait
* until the called Activity's exiting transition completes.
* @attr ref android.R.styleable#Window_windowAllowReturnTransitionOverlap
*/
public boolean getAllowReturnTransitionOverlap() { return true; }
/**
* Returns the duration, in milliseconds, of the window background fade
* when transitioning into or away from an Activity when called with an Activity Transition.
* true
when shared elements should use an Overlay during
* shared element transitions or false
when they should animate as
* part of the normal View hierarchy. The default value is true.
*
* @return true
when shared elements should use an Overlay during
* shared element transitions or false
when they should animate as
* part of the normal View hierarchy.
* @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
*/
public boolean getSharedElementsUseOverlay() { return true; }
/**
* Sets whether or not shared elements should use an Overlay during shared element transitions.
* The default value is true.
*
* @param sharedElementsUseOverlay true
indicates that shared elements should
* be transitioned with an Overlay or false
* to transition within the normal View hierarchy.
* @attr ref android.R.styleable#Window_windowSharedElementsUseOverlay
*/
public void setSharedElementsUseOverlay(boolean sharedElementsUseOverlay) { }
/**
* @return the color of the status bar.
* @deprecated This is no longer needed since the setter is deprecated.
*/
@Deprecated
@ColorInt
public abstract int getStatusBarColor();
/**
* Sets the color of the status bar to {@code color}.
*
* For this to take effect,
* the window must be drawing the system bar backgrounds with
* {@link android.view.WindowManager.LayoutParams#FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS} and
* {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_STATUS} must not be set.
*
* If {@code color} is not opaque, consider setting
* {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
* {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
* ScrollView
or for simple press and release click targets such as
* Button
. Mark an exclusion rect when interacting with a view requires
* a precision touch gesture in a small area in either the X or Y dimension, such as
* an edge swipe or dragging a SeekBar
thumb.