Search in sources :

Example 36 with LayoutParams

use of android.view.WindowManager.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class WindowStateAnimator method setWallpaperOffset.

void setWallpaperOffset(Point shownPosition) {
    final LayoutParams attrs = mWin.getAttrs();
    final int left = shownPosition.x - attrs.surfaceInsets.left;
    final int top = shownPosition.y - attrs.surfaceInsets.top;
    try {
        if (SHOW_LIGHT_TRANSACTIONS)
            Slog.i(TAG, ">>> OPEN TRANSACTION setWallpaperOffset");
        SurfaceControl.openTransaction();
        mSurfaceController.setPositionInTransaction(mWin.mFrame.left + left, mWin.mFrame.top + top, false);
        calculateSurfaceWindowCrop(mTmpClipRect, mTmpFinalClipRect);
        updateSurfaceWindowCrop(mTmpClipRect, mTmpFinalClipRect, false);
    } catch (RuntimeException e) {
        Slog.w(TAG, "Error positioning surface of " + mWin + " pos=(" + left + "," + top + ")", e);
    } finally {
        SurfaceControl.closeTransaction();
        if (SHOW_LIGHT_TRANSACTIONS)
            Slog.i(TAG, "<<< CLOSE TRANSACTION setWallpaperOffset");
    }
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) Point(android.graphics.Point)

Example 37 with LayoutParams

use of android.view.WindowManager.LayoutParams in project android_frameworks_base by ResurrectionRemix.

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);
    }
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) LayoutParams(android.view.WindowManager.LayoutParams) WindowManager(android.view.WindowManager)

Example 38 with LayoutParams

use of android.view.WindowManager.LayoutParams in project android_frameworks_base by ResurrectionRemix.

the class PopupWindow method update.

private void update(View anchor, boolean updateLocation, int xoff, int yoff, int width, int height) {
    if (!isShowing() || mContentView == null) {
        return;
    }
    final WeakReference<View> oldAnchor = mAnchor;
    final int gravity = mAnchoredGravity;
    final boolean needsUpdate = updateLocation && (mAnchorXoff != xoff || mAnchorYoff != yoff);
    if (oldAnchor == null || oldAnchor.get() != anchor || (needsUpdate && !mIsDropdown)) {
        attachToAnchor(anchor, xoff, yoff, gravity);
    } else if (needsUpdate) {
        // No need to register again if this is a DropDown, showAsDropDown already did.
        mAnchorXoff = xoff;
        mAnchorYoff = yoff;
    }
    final LayoutParams p = (LayoutParams) mDecorView.getLayoutParams();
    final int oldGravity = p.gravity;
    final int oldWidth = p.width;
    final int oldHeight = p.height;
    final int oldX = p.x;
    final int oldY = p.y;
    // explicitly specified value (either from setWidth/Height or update).
    if (width < 0) {
        width = mWidth;
    }
    if (height < 0) {
        height = mHeight;
    }
    final boolean aboveAnchor = findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff, width, height, gravity, mAllowScrollingAnchorParent);
    updateAboveAnchor(aboveAnchor);
    final boolean paramsChanged = oldGravity != p.gravity || oldX != p.x || oldY != p.y || oldWidth != p.width || oldHeight != p.height;
    // If width and mWidth were both < 0 then we have a MATCH_PARENT or
    // WRAP_CONTENT case. findDropDownPosition will have resolved this to
    // absolute values, but we don't want to update mWidth/mHeight to these
    // absolute values.
    final int newWidth = width < 0 ? width : p.width;
    final int newHeight = height < 0 ? height : p.height;
    update(p.x, p.y, newWidth, newHeight, paramsChanged);
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) View(android.view.View)

Example 39 with LayoutParams

use of android.view.WindowManager.LayoutParams in project android_frameworks_base by DirtyUnicorns.

the class PopupWindow method update.

private void update(View anchor, boolean updateLocation, int xoff, int yoff, int width, int height) {
    if (!isShowing() || mContentView == null) {
        return;
    }
    final WeakReference<View> oldAnchor = mAnchor;
    final int gravity = mAnchoredGravity;
    final boolean needsUpdate = updateLocation && (mAnchorXoff != xoff || mAnchorYoff != yoff);
    if (oldAnchor == null || oldAnchor.get() != anchor || (needsUpdate && !mIsDropdown)) {
        attachToAnchor(anchor, xoff, yoff, gravity);
    } else if (needsUpdate) {
        // No need to register again if this is a DropDown, showAsDropDown already did.
        mAnchorXoff = xoff;
        mAnchorYoff = yoff;
    }
    final LayoutParams p = (LayoutParams) mDecorView.getLayoutParams();
    final int oldGravity = p.gravity;
    final int oldWidth = p.width;
    final int oldHeight = p.height;
    final int oldX = p.x;
    final int oldY = p.y;
    // explicitly specified value (either from setWidth/Height or update).
    if (width < 0) {
        width = mWidth;
    }
    if (height < 0) {
        height = mHeight;
    }
    final boolean aboveAnchor = findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff, width, height, gravity, mAllowScrollingAnchorParent);
    updateAboveAnchor(aboveAnchor);
    final boolean paramsChanged = oldGravity != p.gravity || oldX != p.x || oldY != p.y || oldWidth != p.width || oldHeight != p.height;
    // If width and mWidth were both < 0 then we have a MATCH_PARENT or
    // WRAP_CONTENT case. findDropDownPosition will have resolved this to
    // absolute values, but we don't want to update mWidth/mHeight to these
    // absolute values.
    final int newWidth = width < 0 ? width : p.width;
    final int newHeight = height < 0 ? height : p.height;
    update(p.x, p.y, newWidth, newHeight, paramsChanged);
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) View(android.view.View)

Example 40 with LayoutParams

use of android.view.WindowManager.LayoutParams in project android_frameworks_base by DirtyUnicorns.

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.START;
    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;
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) View(android.view.View)

Aggregations

LayoutParams (android.view.WindowManager.LayoutParams)47 View (android.view.View)19 Point (android.graphics.Point)10 Rect (android.graphics.Rect)8 OnClickListener (android.view.View.OnClickListener)8 LayoutInflater (android.view.LayoutInflater)7 Transition (android.transition.Transition)5 TransitionListenerAdapter (android.transition.Transition.TransitionListenerAdapter)5 ViewGroup (android.view.ViewGroup)5 ViewParent (android.view.ViewParent)5 WindowManager (android.view.WindowManager)5 Window (android.view.Window)4 Canvas (android.graphics.Canvas)2 Surface (android.view.Surface)2 Animation (android.view.animation.Animation)2 TargetApi (android.annotation.TargetApi)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 EpicenterCallback (android.transition.Transition.EpicenterCallback)1 Display (android.view.Display)1