Search in sources :

Example 16 with LayoutParams

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

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();
    }
}
Also used : Rect(android.graphics.Rect) LayoutParams(android.view.WindowManager.LayoutParams) ViewGroup(android.view.ViewGroup) ViewParent(android.view.ViewParent) Transition(android.transition.Transition) TransitionListenerAdapter(android.transition.Transition.TransitionListenerAdapter) View(android.view.View)

Example 17 with LayoutParams

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

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 18 with LayoutParams

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

the class WindowSurfacePlacer method handleNotObscuredLocked.

/**
     * @param w WindowState this method is applied to.
     * @param dispInfo info of the display that the window's obscuring state is checked against.
     */
private void handleNotObscuredLocked(final WindowState w, final DisplayInfo dispInfo) {
    final LayoutParams attrs = w.mAttrs;
    final int attrFlags = attrs.flags;
    final boolean canBeSeen = w.isDisplayedLw();
    final int privateflags = attrs.privateFlags;
    if (canBeSeen && w.isObscuringFullscreen(dispInfo)) {
        // performance reasons).
        if (!mObscured) {
            mObsuringWindow = w;
        }
        mObscured = true;
    }
    if (w.mHasSurface && canBeSeen) {
        if ((attrFlags & FLAG_KEEP_SCREEN_ON) != 0) {
            mHoldScreen = w.mSession;
            mHoldScreenWindow = w;
        } else if (DEBUG_KEEP_SCREEN_ON && w == mService.mLastWakeLockHoldingWindow) {
            Slog.d(TAG_KEEP_SCREEN_ON, "handleNotObscuredLocked: " + w + " was holding " + "screen wakelock but no longer has FLAG_KEEP_SCREEN_ON!!! called by" + Debug.getCallers(10));
        }
        if (!mSyswin && w.mAttrs.screenBrightness >= 0 && mScreenBrightness < 0) {
            mScreenBrightness = w.mAttrs.screenBrightness;
        }
        if (!mSyswin && w.mAttrs.buttonBrightness >= 0 && mButtonBrightness < 0) {
            mButtonBrightness = w.mAttrs.buttonBrightness;
        }
        if (!mSyswin && w.mAttrs.userActivityTimeout >= 0 && mUserActivityTimeout < 0) {
            mUserActivityTimeout = w.mAttrs.userActivityTimeout;
        }
        final int type = attrs.type;
        if (type == TYPE_SYSTEM_DIALOG || type == TYPE_SYSTEM_ERROR || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
            mSyswin = true;
        }
        // This function assumes that the contents of the default display are
        // processed first before secondary displays.
        final DisplayContent displayContent = w.getDisplayContent();
        if (displayContent != null && displayContent.isDefaultDisplay) {
            // keyguard dialogs to be shown.
            if (type == TYPE_DREAM || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) {
                mObscureApplicationContentOnSecondaryDisplays = true;
            }
            mDisplayHasContent = true;
        } else if (displayContent != null && (!mObscureApplicationContentOnSecondaryDisplays || (mObscured && type == TYPE_KEYGUARD_DIALOG))) {
            // Allow full screen keyguard presentation dialogs to be seen.
            mDisplayHasContent = true;
        }
        if (mPreferredRefreshRate == 0 && w.mAttrs.preferredRefreshRate != 0) {
            mPreferredRefreshRate = w.mAttrs.preferredRefreshRate;
        }
        if (mPreferredModeId == 0 && w.mAttrs.preferredDisplayModeId != 0) {
            mPreferredModeId = w.mAttrs.preferredDisplayModeId;
        }
        if ((privateflags & PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE) != 0) {
            mSustainedPerformanceModeCurrent = true;
        }
    }
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams)

Example 19 with LayoutParams

use of android.view.WindowManager.LayoutParams in project superCleanMaster by joyoyao.

the class ShortCutActivity method setTranslucentStatus.

@TargetApi(19)
private void setTranslucentStatus(boolean on) {
    Window win = getWindow();
    LayoutParams winParams = win.getAttributes();
    final int bits = LayoutParams.FLAG_TRANSLUCENT_STATUS;
    if (on) {
        winParams.flags |= bits;
    } else {
        winParams.flags &= ~bits;
    }
    win.setAttributes(winParams);
}
Also used : Window(android.view.Window) LayoutParams(android.view.WindowManager.LayoutParams) TargetApi(android.annotation.TargetApi)

Example 20 with LayoutParams

use of android.view.WindowManager.LayoutParams in project platform_frameworks_base by android.

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)

Aggregations

LayoutParams (android.view.WindowManager.LayoutParams)46 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)3 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