Search in sources :

Example 11 with LayoutParams

use of android.view.WindowManager.LayoutParams in project weex-example by KalicyZhou.

the class Falcon method getRootViews.

// no way to check
@SuppressWarnings("unchecked")
private static List<ViewRootData> getRootViews(Activity activity) {
    List<ViewRootData> rootViews = new ArrayList<>();
    Object globalWindowManager;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        globalWindowManager = getFieldValue("mWindowManager", activity.getWindowManager());
    } else {
        globalWindowManager = getFieldValue("mGlobal", activity.getWindowManager());
    }
    Object rootObjects = getFieldValue("mRoots", globalWindowManager);
    Object paramsObject = getFieldValue("mParams", globalWindowManager);
    Object[] roots;
    LayoutParams[] params;
    //  There was a change to ArrayList implementation in 4.4
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        roots = ((List) rootObjects).toArray();
        List<LayoutParams> paramsList = (List<LayoutParams>) paramsObject;
        params = paramsList.toArray(new LayoutParams[paramsList.size()]);
    } else {
        roots = (Object[]) rootObjects;
        params = (LayoutParams[]) paramsObject;
    }
    for (int i = 0; i < roots.length; i++) {
        Object root = roots[i];
        Object attachInfo = getFieldValue("mAttachInfo", root);
        int top = (int) getFieldValue("mWindowTop", attachInfo);
        int left = (int) getFieldValue("mWindowLeft", attachInfo);
        Rect winFrame = (Rect) getFieldValue("mWinFrame", root);
        Rect area = new Rect(left, top, left + winFrame.width(), top + winFrame.height());
        View view = (View) getFieldValue("mView", root);
        rootViews.add(new ViewRootData(view, area, params[i]));
    }
    return rootViews;
}
Also used : Rect(android.graphics.Rect) LayoutParams(android.view.WindowManager.LayoutParams) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) View(android.view.View)

Example 12 with LayoutParams

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

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)

Example 13 with LayoutParams

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

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

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

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)

Example 15 with LayoutParams

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

the class WindowSurfacePlacer method handleAppTransitionReadyLocked.

/**
     * @param windows List of windows on default display.
     * @return bitmap indicating if another pass through layout must be made.
     */
private int handleAppTransitionReadyLocked(WindowList windows) {
    int appsCount = mService.mOpeningApps.size();
    if (!transitionGoodToGo(appsCount)) {
        return 0;
    }
    Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "AppTransitionReady");
    if (DEBUG_APP_TRANSITIONS)
        Slog.v(TAG, "**** GOOD TO GO");
    int transit = mService.mAppTransition.getAppTransition();
    if (mService.mSkipAppTransitionAnimation) {
        transit = AppTransition.TRANSIT_UNSET;
    }
    mService.mSkipAppTransitionAnimation = false;
    mService.mNoAnimationNotifyOnTransitionFinished.clear();
    mService.mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
    mService.rebuildAppWindowListLocked();
    mWallpaperMayChange = false;
    // The top-most window will supply the layout params,
    // and we will determine it below.
    LayoutParams animLp = null;
    int bestAnimLayer = -1;
    boolean fullscreenAnim = false;
    boolean voiceInteraction = false;
    int i;
    for (i = 0; i < appsCount; i++) {
        final AppWindowToken wtoken = mService.mOpeningApps.valueAt(i);
        // Clearing the mAnimatingExit flag before entering animation. It's set to
        // true if app window is removed, or window relayout to invisible.
        // This also affects window visibility. We need to clear it *before*
        // maybeUpdateTransitToWallpaper() as the transition selection depends on
        // wallpaper target visibility.
        wtoken.clearAnimatingFlags();
    }
    // Adjust wallpaper before we pull the lower/upper target, since pending changes
    // (like the clearAnimatingFlags() above) might affect wallpaper target result.
    final DisplayContent displayContent = mService.getDefaultDisplayContentLocked();
    if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0 && mWallpaperControllerLocked.adjustWallpaperWindows()) {
        mService.mLayersController.assignLayersLocked(windows);
        displayContent.layoutNeeded = true;
    }
    final WindowState lowerWallpaperTarget = mWallpaperControllerLocked.getLowerWallpaperTarget();
    final WindowState upperWallpaperTarget = mWallpaperControllerLocked.getUpperWallpaperTarget();
    boolean openingAppHasWallpaper = false;
    boolean closingAppHasWallpaper = false;
    final AppWindowToken lowerWallpaperAppToken;
    final AppWindowToken upperWallpaperAppToken;
    if (lowerWallpaperTarget == null) {
        lowerWallpaperAppToken = upperWallpaperAppToken = null;
    } else {
        lowerWallpaperAppToken = lowerWallpaperTarget.mAppToken;
        upperWallpaperAppToken = upperWallpaperTarget.mAppToken;
    }
    // Do a first pass through the tokens for two
    // things:
    // (1) Determine if both the closing and opening
    // app token sets are wallpaper targets, in which
    // case special animations are needed
    // (since the wallpaper needs to stay static
    // behind them).
    // (2) Find the layout params of the top-most
    // application window in the tokens, which is
    // what will control the animation theme.
    final int closingAppsCount = mService.mClosingApps.size();
    appsCount = closingAppsCount + mService.mOpeningApps.size();
    for (i = 0; i < appsCount; i++) {
        final AppWindowToken wtoken;
        if (i < closingAppsCount) {
            wtoken = mService.mClosingApps.valueAt(i);
            if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) {
                closingAppHasWallpaper = true;
            }
        } else {
            wtoken = mService.mOpeningApps.valueAt(i - closingAppsCount);
            if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) {
                openingAppHasWallpaper = true;
            }
        }
        voiceInteraction |= wtoken.voiceInteraction;
        if (wtoken.appFullscreen) {
            WindowState ws = wtoken.findMainWindow();
            if (ws != null) {
                animLp = ws.mAttrs;
                bestAnimLayer = ws.mLayer;
                fullscreenAnim = true;
            }
        } else if (!fullscreenAnim) {
            WindowState ws = wtoken.findMainWindow();
            if (ws != null) {
                if (ws.mLayer > bestAnimLayer) {
                    animLp = ws.mAttrs;
                    bestAnimLayer = ws.mLayer;
                }
            }
        }
    }
    transit = maybeUpdateTransitToWallpaper(transit, openingAppHasWallpaper, closingAppHasWallpaper, lowerWallpaperTarget, upperWallpaperTarget);
    // the lock screen.
    if (!mService.mPolicy.allowAppAnimationsLw()) {
        if (DEBUG_APP_TRANSITIONS)
            Slog.v(TAG, "Animations disallowed by keyguard or dream.");
        animLp = null;
    }
    processApplicationsAnimatingInPlace(transit);
    mTmpLayerAndToken.token = null;
    handleClosingApps(transit, animLp, voiceInteraction, mTmpLayerAndToken);
    final AppWindowToken topClosingApp = mTmpLayerAndToken.token;
    final int topClosingLayer = mTmpLayerAndToken.layer;
    final AppWindowToken topOpeningApp = handleOpeningApps(transit, animLp, voiceInteraction, topClosingLayer);
    mService.mAppTransition.setLastAppTransition(transit, topOpeningApp, topClosingApp);
    final AppWindowAnimator openingAppAnimator = (topOpeningApp == null) ? null : topOpeningApp.mAppAnimator;
    final AppWindowAnimator closingAppAnimator = (topClosingApp == null) ? null : topClosingApp.mAppAnimator;
    mService.mAppTransition.goodToGo(openingAppAnimator, closingAppAnimator, mService.mOpeningApps, mService.mClosingApps);
    mService.mAppTransition.postAnimationCallback();
    mService.mAppTransition.clear();
    mService.mOpeningApps.clear();
    mService.mClosingApps.clear();
    // This has changed the visibility of windows, so perform
    // a new layout to get them all up-to-date.
    displayContent.layoutNeeded = true;
    // TODO(multidisplay): IMEs are only supported on the default display.
    if (windows == mService.getDefaultWindowListLocked() && !mService.moveInputMethodWindowsIfNeededLocked(true)) {
        mService.mLayersController.assignLayersLocked(windows);
    }
    mService.updateFocusedWindowLocked(UPDATE_FOCUS_PLACING_SURFACES, true);
    mService.mFocusMayChange = false;
    mService.notifyActivityDrawnForKeyguard();
    Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
    return FINISH_LAYOUT_REDO_LAYOUT | FINISH_LAYOUT_REDO_CONFIG;
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams)

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