public class MockWindow extends Window
Window.Callback, Window.OnFrameMetricsAvailableListener, Window.OnRestrictedCaptionAreaChangedListener, Window.OnWindowDismissedCallback, Window.WindowControllerCallback
DECOR_CAPTION_SHADE_AUTO, DECOR_CAPTION_SHADE_DARK, DECOR_CAPTION_SHADE_LIGHT, DEFAULT_FEATURES, FEATURE_ACTION_BAR, FEATURE_ACTION_BAR_OVERLAY, FEATURE_ACTION_MODE_OVERLAY, FEATURE_ACTIVITY_TRANSITIONS, FEATURE_CONTENT_TRANSITIONS, FEATURE_CONTEXT_MENU, FEATURE_CUSTOM_TITLE, FEATURE_INDETERMINATE_PROGRESS, FEATURE_LEFT_ICON, FEATURE_MAX, FEATURE_NO_TITLE, FEATURE_OPTIONS_PANEL, FEATURE_PROGRESS, FEATURE_RIGHT_ICON, FEATURE_SWIPE_TO_DISMISS, ID_ANDROID_CONTENT, NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME, PROGRESS_END, PROGRESS_INDETERMINATE_OFF, PROGRESS_INDETERMINATE_ON, PROGRESS_SECONDARY_END, PROGRESS_SECONDARY_START, PROGRESS_START, PROGRESS_VISIBILITY_OFF, PROGRESS_VISIBILITY_ON, STATUS_BAR_BACKGROUND_TRANSITION_NAME
Constructor and Description |
---|
MockWindow(Context context) |
Modifier and Type | Method and Description |
---|---|
void |
addContentView(View view,
ViewGroup.LayoutParams layoutParams)
Variation on
Window.setContentView(View, android.view.ViewGroup.LayoutParams)
to add an additional content view to the screen. |
void |
closeAllPanels() |
void |
closePanel(int i) |
View |
getCurrentFocus()
Return the view in this Window that currently has focus, or null if
there are none.
|
View |
getDecorView()
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.
|
LayoutInflater |
getLayoutInflater()
Quick access to the
LayoutInflater instance that this Window
retrieved from its Context. |
int |
getNavigationBarColor() |
int |
getStatusBarColor() |
int |
getVolumeControlStream() |
void |
invalidatePanelMenu(int i) |
boolean |
isFloating()
Return whether this window is being displayed with a floating style
(based on the
android.R.attr#windowIsFloating attribute in
the style/theme). |
boolean |
isShortcutKey(int i,
KeyEvent keyEvent)
Is a keypress one of the defined shortcut keys for this window.
|
protected void |
onActive() |
void |
onConfigurationChanged(Configuration configuration)
Should be called when the configuration is changed.
|
void |
openPanel(int i,
KeyEvent keyEvent) |
View |
peekDecorView()
Retrieve the current decor view, but only if it has already been created;
otherwise returns null.
|
boolean |
performContextMenuIdentifierAction(int i,
int i1) |
boolean |
performPanelIdentifierAction(int i,
int i1,
int i2) |
boolean |
performPanelShortcut(int i,
int i1,
KeyEvent keyEvent,
int i2) |
void |
restoreHierarchyState(Bundle bundle) |
Bundle |
saveHierarchyState() |
void |
setBackgroundDrawable(Drawable drawable)
Change the background of this window to a custom Drawable.
|
void |
setChildDrawable(int i,
Drawable drawable) |
void |
setChildInt(int i,
int i1) |
void |
setContentView(int i)
Convenience for
Window.setContentView(View, android.view.ViewGroup.LayoutParams)
to set the screen content from a layout resource. |
void |
setContentView(View view)
Convenience for
Window.setContentView(View, android.view.ViewGroup.LayoutParams)
set the screen content to an explicit view. |
void |
setContentView(View view,
ViewGroup.LayoutParams layoutParams)
Set the screen content to an explicit view.
|
void |
setFeatureDrawable(int i,
Drawable drawable)
Set an explicit Drawable value for feature of this window.
|
void |
setFeatureDrawableAlpha(int i,
int i1)
Set a custom alpha value for the given drawable feature, controlling how
much the background is visible through it.
|
void |
setFeatureDrawableResource(int i,
int i1)
Set the value for a drawable feature of this window, from a resource
identifier.
|
void |
setFeatureDrawableUri(int i,
Uri uri)
Set the value for a drawable feature of this window, from a URI.
|
void |
setFeatureInt(int i,
int i1)
Set the integer value for a feature.
|
void |
setNavigationBarColor(int i)
Sets the color of the navigation bar to .
|
void |
setStatusBarColor(int i)
Sets the color of the status bar to
color . |
void |
setTitle(CharSequence charSequence) |
void |
setTitleColor(int i) |
void |
setVolumeControlStream(int i) |
boolean |
superDispatchGenericMotionEvent(MotionEvent motionEvent)
Used by custom windows, such as Dialog, to pass the generic motion event
further down the view hierarchy.
|
boolean |
superDispatchKeyEvent(KeyEvent keyEvent)
Used by custom windows, such as Dialog, to pass the key press event
further down the view hierarchy.
|
boolean |
superDispatchKeyShortcutEvent(KeyEvent keyEvent)
Used by custom windows, such as Dialog, to pass the key shortcut press event
further down the view hierarchy.
|
boolean |
superDispatchTouchEvent(MotionEvent motionEvent)
Used by custom windows, such as Dialog, to pass the touch screen event
further down the view hierarchy.
|
boolean |
superDispatchTrackballEvent(MotionEvent motionEvent)
Used by custom windows, such as Dialog, to pass the trackball event
further down the view hierarchy.
|
void |
takeInputQueue(InputQueue.Callback callback)
Take ownership of this window's InputQueue.
|
void |
takeKeyEvents(boolean b)
Request that key events come to this activity.
|
void |
takeSurface(SurfaceHolder.Callback2 callback2)
Take ownership of this window's surface.
|
void |
togglePanel(int i,
KeyEvent keyEvent) |
addFlags, addOnFrameMetricsAvailableListener, addPrivateFlags, alwaysReadCloseOnTouchAttr, clearContentView, clearFlags, destroy, dispatchOnWindowDismissed, dispatchWindowAttributesChanged, findViewById, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getAttributes, getCallback, getContainer, getContentScene, getContext, getDefaultFeatures, getElevation, getEnterTransition, getExitTransition, getFeatures, getForcedWindowFlags, getLocalFeatures, getMediaController, getReenterTransition, getReturnTransition, getSharedElementEnterTransition, getSharedElementExitTransition, getSharedElementReenterTransition, getSharedElementReturnTransition, getSharedElementsUseOverlay, getTransitionBackgroundFadeDuration, getTransitionManager, getWindowControllerCallback, getWindowManager, getWindowStyle, hasChildren, hasFeature, hasSoftInputMode, haveDimAmount, injectInputEvent, isActive, isDestroyed, isOverlayWithDecorCaptionEnabled, makeActive, notifyRestrictedCaptionAreaCallback, onMultiWindowModeChanged, removeFeature, removeOnFrameMetricsAvailableListener, reportActivityRelaunched, requestFeature, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setAttributes, setBackgroundDrawableResource, setCallback, setClipToOutline, setCloseOnTouchOutside, setCloseOnTouchOutsideIfNotSet, setContainer, setDecorCaptionShade, setDefaultIcon, setDefaultLogo, setDefaultWindowFormat, setDimAmount, setDisableWallpaperTouchEvents, setElevation, setEnterTransition, setExitTransition, setFlags, setFormat, setGravity, setIcon, setLayout, setLocalFocus, setLogo, setMediaController, setNeedsMenuKey, setOnWindowDismissedCallback, setOverlayWithDecorCaptionEnabled, setReenterTransition, setResizingCaptionDrawable, setRestrictedCaptionAreaListener, setReturnTransition, setSharedElementEnterTransition, setSharedElementExitTransition, setSharedElementReenterTransition, setSharedElementReturnTransition, setSharedElementsUseOverlay, setSoftInputMode, setSustainedPerformanceMode, setTheme, setTransitionBackgroundFadeDuration, setTransitionManager, setType, setUiOptions, setUiOptions, setWindowAnimations, setWindowControllerCallback, setWindowManager, setWindowManager, shouldCloseOnTouch
public MockWindow(Context context)
public void takeSurface(SurfaceHolder.Callback2 callback2)
Window
takeSurface
in class Window
public void takeInputQueue(InputQueue.Callback callback)
Window
takeInputQueue
in class Window
public boolean isFloating()
Window
android.R.attr#windowIsFloating
attribute in
the style/theme).isFloating
in class Window
public void setContentView(int i)
Window
Window.setContentView(View, android.view.ViewGroup.LayoutParams)
to set the screen content from a layout resource. The resource will be
inflated, adding all top-level views to the screen.setContentView
in class Window
i
- Resource ID to be inflated.Window.setContentView(View, android.view.ViewGroup.LayoutParams)
public void setContentView(View view)
Window
Window.setContentView(View, android.view.ViewGroup.LayoutParams)
set the screen content to an explicit view. This view is placed
directly into the screen's view hierarchy. It can itself be a complex
view hierarhcy.setContentView
in class Window
view
- The desired content to display.Window.setContentView(View, android.view.ViewGroup.LayoutParams)
public void setContentView(View view, ViewGroup.LayoutParams layoutParams)
Window
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 Window.requestFeature(int)
,
and certain window flags as described in Window.setFlags(int, int)
.
If Window.FEATURE_CONTENT_TRANSITIONS
is set, the window's
TransitionManager will be used to animate content from the current
content View to view.
setContentView
in class Window
view
- The desired content to display.layoutParams
- Layout parameters for the view.Window.getTransitionManager()
,
Window.setTransitionManager(android.transition.TransitionManager)
public void addContentView(View view, ViewGroup.LayoutParams layoutParams)
Window
Window.setContentView(View, android.view.ViewGroup.LayoutParams)
to add an additional content view to the screen. Added after any existing
ones in the screen -- existing views are NOT removed.addContentView
in class Window
view
- The desired content to display.layoutParams
- Layout parameters for the view.public View getCurrentFocus()
Window
getCurrentFocus
in class Window
public LayoutInflater getLayoutInflater()
Window
LayoutInflater
instance that this Window
retrieved from its Context.getLayoutInflater
in class Window
public void setTitle(CharSequence charSequence)
public void setTitleColor(int i)
setTitleColor
in class Window
public void closePanel(int i)
closePanel
in class Window
public void togglePanel(int i, KeyEvent keyEvent)
togglePanel
in class Window
public void invalidatePanelMenu(int i)
invalidatePanelMenu
in class Window
public boolean performPanelShortcut(int i, int i1, KeyEvent keyEvent, int i2)
performPanelShortcut
in class Window
public boolean performPanelIdentifierAction(int i, int i1, int i2)
performPanelIdentifierAction
in class Window
public void closeAllPanels()
closeAllPanels
in class Window
public boolean performContextMenuIdentifierAction(int i, int i1)
performContextMenuIdentifierAction
in class Window
public void onConfigurationChanged(Configuration configuration)
Window
onConfigurationChanged
in class Window
configuration
- The new configuration.public void setBackgroundDrawable(Drawable drawable)
Window
setBackgroundDrawable
in class Window
drawable
- The new Drawable to use for this window's background.public void setFeatureDrawableResource(int i, int i1)
Window
setFeatureDrawableResource
in class Window
i
- The desired drawable feature to change, defined as a
constant by Window.i1
- Resource identifier of the desired image.Resources.getDrawable(int)
public void setFeatureDrawableUri(int i, Uri uri)
Window
The only URI currently supported is "content:", specifying an image in a content provider.
setFeatureDrawableUri
in class Window
i
- The desired drawable feature to change. Features are
constants defined by Window.uri
- The desired URI.ImageView.setImageURI(android.net.Uri)
public void setFeatureDrawable(int i, Drawable drawable)
Window
setFeatureDrawable
in class Window
i
- The desired drawable feature to change. Features are
constants defined by Window.drawable
- A Drawable object to display.public void setFeatureDrawableAlpha(int i, int i1)
Window
setFeatureDrawableAlpha
in class Window
i
- The desired drawable feature to change. Features are
constants defined by Window.i1
- The alpha amount, 0 is completely transparent and 255 is
completely opaque.public void setFeatureInt(int i, int i1)
Window
Window.FEATURE_PROGRESS
, it should go from
0 to 10000. At 10000 the progress is complete and the indicator hidden.setFeatureInt
in class Window
i
- The desired feature to change. Features are constants
defined by Window.i1
- The value for the feature. The interpretation of this
value is feature-specific.public void takeKeyEvents(boolean b)
Window
takeKeyEvents
in class Window
public boolean superDispatchKeyEvent(KeyEvent keyEvent)
Window
superDispatchKeyEvent
in class Window
public boolean superDispatchKeyShortcutEvent(KeyEvent keyEvent)
Window
superDispatchKeyShortcutEvent
in class Window
public boolean superDispatchTouchEvent(MotionEvent motionEvent)
Window
superDispatchTouchEvent
in class Window
public boolean superDispatchTrackballEvent(MotionEvent motionEvent)
Window
superDispatchTrackballEvent
in class Window
public boolean superDispatchGenericMotionEvent(MotionEvent motionEvent)
Window
superDispatchGenericMotionEvent
in class Window
public View getDecorView()
Window
Note that calling this function for the first time "locks in"
various window characteristics as described in
Window.setContentView(View, android.view.ViewGroup.LayoutParams)
.
getDecorView
in class Window
public View peekDecorView()
Window
peekDecorView
in class Window
Window.getDecorView()
public Bundle saveHierarchyState()
saveHierarchyState
in class Window
public void restoreHierarchyState(Bundle bundle)
restoreHierarchyState
in class Window
public void setChildDrawable(int i, Drawable drawable)
setChildDrawable
in class Window
public void setChildInt(int i, int i1)
setChildInt
in class Window
public boolean isShortcutKey(int i, KeyEvent keyEvent)
Window
isShortcutKey
in class Window
i
- the key code from KeyEvent
to check.keyEvent
- the KeyEvent
to use to help check.public void setVolumeControlStream(int i)
setVolumeControlStream
in class Window
Activity.setVolumeControlStream(int)
public int getVolumeControlStream()
getVolumeControlStream
in class Window
Activity.getVolumeControlStream()
public int getStatusBarColor()
getStatusBarColor
in class Window
public void setStatusBarColor(int i)
Window
color
.
For this to take effect,
the window must be drawing the system bar backgrounds with
WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
and
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
must not be set.
If color
is not opaque, consider setting
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
and
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
.
The transitionName for the view background will be "android:status:background".
setStatusBarColor
in class Window
public int getNavigationBarColor()
getNavigationBarColor
in class Window
public void setNavigationBarColor(int i)
Window
WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
and
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
must not be set.
If is not opaque, consider setting
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
and
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
.
The transitionName for the view background will be "android:navigation:background".
setNavigationBarColor
in class Window