use of android.view.WindowManager.LayoutParams in project platform_frameworks_base by android.
the class PopupWindow method update.
/**
* Updates the position and the dimension of the popup window.
* <p>
* Width and height can be set to -1 to update location only. Calling this
* function also updates the window with the current popup state as
* described for {@link #update()}.
*
* @param x the new x location
* @param y the new y location
* @param width the new width in pixels, must be >= 0 or -1 to ignore
* @param height the new height in pixels, must be >= 0 or -1 to ignore
* @param force {@code true} to reposition the window even if the specified
* position already seems to correspond to the LayoutParams,
* {@code false} to only reposition if needed
*/
public void update(int x, int y, int width, int height, boolean force) {
if (width >= 0) {
mLastWidth = width;
setWidth(width);
}
if (height >= 0) {
mLastHeight = height;
setHeight(height);
}
if (!isShowing() || mContentView == null) {
return;
}
final WindowManager.LayoutParams p = (WindowManager.LayoutParams) mDecorView.getLayoutParams();
boolean update = force;
final int finalWidth = mWidthMode < 0 ? mWidthMode : mLastWidth;
if (width != -1 && p.width != finalWidth) {
p.width = mLastWidth = finalWidth;
update = true;
}
final int finalHeight = mHeightMode < 0 ? mHeightMode : mLastHeight;
if (height != -1 && p.height != finalHeight) {
p.height = mLastHeight = finalHeight;
update = true;
}
if (p.x != x) {
p.x = x;
update = true;
}
if (p.y != y) {
p.y = y;
update = true;
}
final int newAnim = computeAnimationResource();
if (newAnim != p.windowAnimations) {
p.windowAnimations = newAnim;
update = true;
}
final int newFlags = computeFlags(p.flags);
if (newFlags != p.flags) {
p.flags = newFlags;
update = true;
}
final int newGravity = computeGravity();
if (newGravity != p.gravity) {
p.gravity = newGravity;
update = true;
}
int newAccessibilityIdOfAnchor = (mAnchor != null) ? mAnchor.get().getAccessibilityViewId() : -1;
if (newAccessibilityIdOfAnchor != p.accessibilityIdOfAnchor) {
p.accessibilityIdOfAnchor = newAccessibilityIdOfAnchor;
update = true;
}
if (update) {
setLayoutDirectionFromAnchor();
mWindowManager.updateViewLayout(mDecorView, p);
}
}
use of android.view.WindowManager.LayoutParams in project XobotOS by xamarin.
the class ZoomButtonsController method createContainer.
private FrameLayout createContainer() {
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
// Controls are positioned BOTTOM | CENTER with respect to the owner view.
lp.gravity = Gravity.TOP | Gravity.LEFT;
lp.flags = LayoutParams.FLAG_NOT_TOUCHABLE | LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_LAYOUT_NO_LIMITS | LayoutParams.FLAG_ALT_FOCUSABLE_IM;
lp.height = LayoutParams.WRAP_CONTENT;
lp.width = LayoutParams.MATCH_PARENT;
lp.type = LayoutParams.TYPE_APPLICATION_PANEL;
lp.format = PixelFormat.TRANSLUCENT;
lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons;
mContainerLayoutParams = lp;
FrameLayout container = new Container(mContext);
container.setLayoutParams(lp);
container.setMeasureAllChildren(true);
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(com.android.internal.R.layout.zoom_container, container);
mControls = (ZoomControls) container.findViewById(com.android.internal.R.id.zoomControls);
mControls.setOnZoomInClickListener(new OnClickListener() {
public void onClick(View v) {
dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
if (mCallback != null)
mCallback.onZoom(true);
}
});
mControls.setOnZoomOutClickListener(new OnClickListener() {
public void onClick(View v) {
dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
if (mCallback != null)
mCallback.onZoom(false);
}
});
return container;
}
use of android.view.WindowManager.LayoutParams in project android_frameworks_base by DirtyUnicorns.
the class PopupWindow method update.
/**
* Updates the position and the dimension of the popup window.
* <p>
* Width and height can be set to -1 to update location only. Calling this
* function also updates the window with the current popup state as
* described for {@link #update()}.
*
* @param x the new x location
* @param y the new y location
* @param width the new width in pixels, must be >= 0 or -1 to ignore
* @param height the new height in pixels, must be >= 0 or -1 to ignore
* @param force {@code true} to reposition the window even if the specified
* position already seems to correspond to the LayoutParams,
* {@code false} to only reposition if needed
*/
public void update(int x, int y, int width, int height, boolean force) {
if (width >= 0) {
mLastWidth = width;
setWidth(width);
}
if (height >= 0) {
mLastHeight = height;
setHeight(height);
}
if (!isShowing() || mContentView == null) {
return;
}
final WindowManager.LayoutParams p = (WindowManager.LayoutParams) mDecorView.getLayoutParams();
boolean update = force;
final int finalWidth = mWidthMode < 0 ? mWidthMode : mLastWidth;
if (width != -1 && p.width != finalWidth) {
p.width = mLastWidth = finalWidth;
update = true;
}
final int finalHeight = mHeightMode < 0 ? mHeightMode : mLastHeight;
if (height != -1 && p.height != finalHeight) {
p.height = mLastHeight = finalHeight;
update = true;
}
if (p.x != x) {
p.x = x;
update = true;
}
if (p.y != y) {
p.y = y;
update = true;
}
final int newAnim = computeAnimationResource();
if (newAnim != p.windowAnimations) {
p.windowAnimations = newAnim;
update = true;
}
final int newFlags = computeFlags(p.flags);
if (newFlags != p.flags) {
p.flags = newFlags;
update = true;
}
final int newGravity = computeGravity();
if (newGravity != p.gravity) {
p.gravity = newGravity;
update = true;
}
int newAccessibilityIdOfAnchor = (mAnchor != null) ? mAnchor.get().getAccessibilityViewId() : -1;
if (newAccessibilityIdOfAnchor != p.accessibilityIdOfAnchor) {
p.accessibilityIdOfAnchor = newAccessibilityIdOfAnchor;
update = true;
}
if (update) {
setLayoutDirectionFromAnchor();
mWindowManager.updateViewLayout(mDecorView, p);
}
}
use of android.view.WindowManager.LayoutParams in project android_frameworks_base by DirtyUnicorns.
the class PopupWindow method dismiss.
/**
* Disposes of the popup window. This method can be invoked only after
* {@link #showAsDropDown(android.view.View)} has been executed. Failing
* that, calling this method will have no effect.
*
* @see #showAsDropDown(android.view.View)
*/
public void dismiss() {
if (!isShowing() || mIsTransitioningToDismiss) {
return;
}
final PopupDecorView decorView = mDecorView;
final View contentView = mContentView;
final ViewGroup contentHolder;
final ViewParent contentParent = contentView.getParent();
if (contentParent instanceof ViewGroup) {
contentHolder = ((ViewGroup) contentParent);
} else {
contentHolder = null;
}
// Ensure any ongoing or pending transitions are canceled.
decorView.cancelTransitions();
mIsShowing = false;
mIsTransitioningToDismiss = true;
// This method may be called as part of window detachment, in which
// case the anchor view (and its root) will still return true from
// isAttachedToWindow() during execution of this method; however, we
// can expect the OnAttachStateChangeListener to have been called prior
// to executing this method, so we can rely on that instead.
final Transition exitTransition = mExitTransition;
if (exitTransition != null && decorView.isLaidOut() && (mIsAnchorRootAttached || mAnchorRoot == null)) {
// The decor view is non-interactive and non-IME-focusable during exit transitions.
final LayoutParams p = (LayoutParams) decorView.getLayoutParams();
p.flags |= LayoutParams.FLAG_NOT_TOUCHABLE;
p.flags |= LayoutParams.FLAG_NOT_FOCUSABLE;
p.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM;
mWindowManager.updateViewLayout(decorView, p);
final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null;
final Rect epicenter = getTransitionEpicenter();
// Once we start dismissing the decor view, all state (including
// the anchor root) needs to be moved to the decor view since we
// may open another popup while it's busy exiting.
decorView.startExitTransition(exitTransition, anchorRoot, epicenter, new TransitionListenerAdapter() {
@Override
public void onTransitionEnd(Transition transition) {
dismissImmediate(decorView, contentHolder, contentView);
}
});
} else {
dismissImmediate(decorView, contentHolder, contentView);
}
// Clears the anchor view.
detachFromAnchor();
if (mOnDismissListener != null) {
mOnDismissListener.onDismiss();
}
}
use of android.view.WindowManager.LayoutParams in project android_frameworks_base by DirtyUnicorns.
the class WindowStateAnimator method tryChangeFormatInPlaceLocked.
/**
* Try to change the pixel format without recreating the surface. This
* will be common in the case of changing from PixelFormat.OPAQUE to
* PixelFormat.TRANSLUCENT in the hardware-accelerated case as both
* requested formats resolve to the same underlying SurfaceControl format
* @return True if format was succesfully changed, false otherwise
*/
boolean tryChangeFormatInPlaceLocked() {
if (mSurfaceController == null) {
return false;
}
final LayoutParams attrs = mWin.getAttrs();
final boolean isHwAccelerated = (attrs.flags & FLAG_HARDWARE_ACCELERATED) != 0;
final int format = isHwAccelerated ? PixelFormat.TRANSLUCENT : attrs.format;
if (format == mSurfaceFormat) {
setOpaqueLocked(!PixelFormat.formatHasAlpha(attrs.format));
return true;
}
return false;
}
Aggregations