Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 389a3069 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge changes I284c851e,I3b1229e0,Ifbb10bac,I518521e6,I1f6a0efd

* changes:
  Drag up gesture improvements
  When dragging from the left side, dock on the right
  Draw status bar background in BackgroundFrameRenderer while resizing
  Don't remove colored bar views when relaunching
  Add flag so apps always draw status bar background
parents 680215f5 870ab5a1
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -3057,14 +3057,29 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
    /**
     * @hide
     *
     * Makes system ui transparent.
     * Makes navigation bar transparent (but not the status bar).
     */
    public static final int SYSTEM_UI_TRANSPARENT = 0x00008000;
    public static final int NAVIGATION_BAR_TRANSPARENT = 0x00008000;
    /**
     * @hide
     *
     * Makes status bar transparent (but not the navigation bar).
     */
    public static final int STATUS_BAR_TRANSPARENT = 0x0000008;
    /**
     * @hide
     *
     * Makes both status bar and navigation bar transparent.
     */
    public static final int SYSTEM_UI_TRANSPARENT = NAVIGATION_BAR_TRANSPARENT
            | STATUS_BAR_TRANSPARENT;
    /**
     * @hide
     */
    public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = 0x00003FFF;
    public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = 0x00003FF7;
    /**
     * These are the system UI flags that can be cleared by events outside
+37 −4
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.policy;

import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Looper;
import android.view.Choreographer;
@@ -44,6 +45,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
    // The render nodes for the multi threaded renderer.
    private ThreadedRenderer mRenderer;
    private RenderNode mFrameAndBackdropNode;
    private RenderNode mSystemBarBackgroundNode;

    private final Rect mOldTargetRect = new Rect();
    private final Rect mNewTargetRect = new Rect();
@@ -62,13 +64,16 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame

    private Drawable mCaptionBackgroundDrawable;
    private Drawable mResizingBackgroundDrawable;
    private ColorDrawable mStatusBarColor;

    public BackdropFrameRenderer(DecorView decorView, ThreadedRenderer renderer, Rect initialBounds,
            Drawable resizingBackgroundDrawable, Drawable captionBackgroundDrawable) {
            Drawable resizingBackgroundDrawable, Drawable captionBackgroundDrawable,
            int statusBarColor) {
        setName("ResizeFrame");

        mRenderer = renderer;
        onResourcesLoaded(decorView, resizingBackgroundDrawable, captionBackgroundDrawable);
        onResourcesLoaded(decorView, resizingBackgroundDrawable, captionBackgroundDrawable,
                statusBarColor);

        // Create a render node for the content and frame backdrop
        // which can be resized independently from the content.
@@ -87,10 +92,24 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
    }

    void onResourcesLoaded(DecorView decorView, Drawable resizingBackgroundDrawable,
            Drawable captionBackgroundDrawableDrawable) {
            Drawable captionBackgroundDrawableDrawable, int statusBarColor) {
        mDecorView = decorView;
        mResizingBackgroundDrawable = resizingBackgroundDrawable;
        mCaptionBackgroundDrawable = captionBackgroundDrawableDrawable;
        if (statusBarColor != 0) {
            mStatusBarColor = new ColorDrawable(statusBarColor);
            addSystemBarNodeIfNeeded();
        } else {
            mStatusBarColor = null;
        }
    }

    private void addSystemBarNodeIfNeeded() {
        if (mSystemBarBackgroundNode != null) {
            return;
        }
        mSystemBarBackgroundNode = RenderNode.create("SystemBarBackgroundNode", null);
        mRenderer.addRenderNode(mSystemBarBackgroundNode, false);
    }

    /**
@@ -132,6 +151,9 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
                // Remove the render node again
                // (see comment above - better to do that only once).
                mRenderer.removeRenderNode(mFrameAndBackdropNode);
                if (mSystemBarBackgroundNode != null) {
                    mRenderer.removeRenderNode(mSystemBarBackgroundNode);
                }

                mRenderer = null;

@@ -232,6 +254,8 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
        // inaccessible. For that case we remember the previous metrics to avoid flashes.
        // Note that even when there is no visible caption, the caption child will exist.
        final int captionHeight = mDecorView.getCaptionHeight();
        final int statusBarHeight = mDecorView.getStatusBarHeight();

        // The caption height will probably never dynamically change while we are resizing.
        // Once set to something other then 0 it should be kept that way.
        if (captionHeight != 0) {
@@ -256,7 +280,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
        mFrameAndBackdropNode.setLeftTopRightBottom(left, top, left + width, top + height);

        // Draw the caption and content backdrops in to our render node.
        final DisplayListCanvas canvas = mFrameAndBackdropNode.start(width, height);
        DisplayListCanvas canvas = mFrameAndBackdropNode.start(width, height);
        mCaptionBackgroundDrawable.setBounds(0, 0, left + width, top + mLastCaptionHeight);
        mCaptionBackgroundDrawable.draw(canvas);

@@ -265,6 +289,15 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
        mResizingBackgroundDrawable.draw(canvas);
        mFrameAndBackdropNode.end(canvas);

        if (mSystemBarBackgroundNode != null && mStatusBarColor != null) {
            canvas = mSystemBarBackgroundNode.start(width, height);
            mSystemBarBackgroundNode.setLeftTopRightBottom(left, top, left + width, top + height);
            mStatusBarColor.setBounds(0, 0, left + width, statusBarHeight);
            mStatusBarColor.draw(canvas);
            mSystemBarBackgroundNode.end(canvas);
            mRenderer.drawRenderNode(mSystemBarBackgroundNode);
        }

        // We need to render the node explicitly
        mRenderer.drawRenderNode(mFrameAndBackdropNode);

+66 −20
Original line number Diff line number Diff line
@@ -151,6 +151,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
    private final Interpolator mShowInterpolator;
    private final Interpolator mHideInterpolator;
    private final int mBarEnterExitDuration;
    private final boolean mForceWindowDrawsStatusBarBackground;
    private final int mSemiTransparentStatusBarColor;

    private final BackgroundFallback mBackgroundFallback = new BackgroundFallback();

@@ -197,6 +199,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind

        mBarEnterExitDuration = context.getResources().getInteger(
                R.integer.dock_enter_exit_duration);
        mForceWindowDrawsStatusBarBackground = context.getResources().getBoolean(
                R.bool.config_forceWindowDrawsStatusBarBackground);
        mSemiTransparentStatusBarColor = context.getResources().getColor(
                R.color.system_bar_background_semi_transparent, null /* theme */);

        setWindow(window);
    }
@@ -884,14 +890,15 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
            int navBarSize = navBarToRightEdge ? mLastRightInset : mLastBottomInset;
            updateColorViewInt(mNavigationColorViewState, sysUiVisibility,
                    mWindow.mNavigationBarColor, navBarSize, navBarToRightEdge,
                    0 /* rightInset */, animate && !disallowAnimate);
                    0 /* rightInset */, animate && !disallowAnimate, false /* force */);

            boolean statusBarNeedsRightInset = navBarToRightEdge
                    && mNavigationColorViewState.present;
            int statusBarRightInset = statusBarNeedsRightInset ? mLastRightInset : 0;
            updateColorViewInt(mStatusColorViewState, sysUiVisibility, mWindow.mStatusBarColor,
                    mLastTopInset, false /* matchVertical */, statusBarRightInset,
                    animate && !disallowAnimate);
            updateColorViewInt(mStatusColorViewState, sysUiVisibility,
                    calculateStatusBarColor(), mLastTopInset,
                    false /* matchVertical */, statusBarRightInset, animate && !disallowAnimate,
                    mForceWindowDrawsStatusBarBackground);
        }

        // When we expand the window with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, we still need
@@ -935,6 +942,21 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        return insets;
    }

    private int calculateStatusBarColor() {
        int flags = mWindow.getAttributes().flags;
        return (flags & FLAG_TRANSLUCENT_STATUS) != 0 ? mSemiTransparentStatusBarColor
                : (flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0 ? mWindow.mStatusBarColor
                : Color.BLACK;
    }

    private int getCurrentColor(ColorViewState state) {
        if (state.visible) {
            return state.color;
        } else {
            return 0;
        }
    }

    /**
     * Update a color view
     *
@@ -948,13 +970,15 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
     * @param animate if true, the change will be animated.
     */
    private void updateColorViewInt(final ColorViewState state, int sysUiVis, int color,
            int size, boolean verticalBar, int rightMargin, boolean animate) {
            int size, boolean verticalBar, int rightMargin, boolean animate, boolean force) {
        state.present = size > 0 && (sysUiVis & state.systemUiHideFlag) == 0
                && (mWindow.getAttributes().flags & state.hideWindowFlag) == 0
                && (mWindow.getAttributes().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0;
                && ((mWindow.getAttributes().flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
                        || force);
        boolean show = state.present
                && (color & Color.BLACK) != 0
                && (mWindow.getAttributes().flags & state.translucentFlag) == 0;
                && ((mWindow.getAttributes().flags & state.translucentFlag) == 0  || force);
        boolean showView = show && !isResizing();

        boolean visibilityChanged = false;
        View view = state.view;
@@ -964,7 +988,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        int resolvedGravity = verticalBar ? state.horizontalGravity : state.verticalGravity;

        if (view == null) {
            if (show) {
            if (showView) {
                state.view = view = new View(mContext);
                view.setBackgroundColor(color);
                view.setTransitionName(state.transitionName);
@@ -980,7 +1004,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                updateColorViewTranslations();
            }
        } else {
            int vis = show ? VISIBLE : INVISIBLE;
            int vis = showView ? VISIBLE : INVISIBLE;
            visibilityChanged = state.targetVisibility != vis;
            state.targetVisibility = vis;
            LayoutParams lp = (LayoutParams) view.getLayoutParams();
@@ -992,14 +1016,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                lp.rightMargin = rightMargin;
                view.setLayoutParams(lp);
            }
            if (show) {
            if (showView) {
                view.setBackgroundColor(color);
            }
        }
        if (visibilityChanged) {
            view.animate().cancel();
            if (animate) {
                if (show) {
            if (animate && !isResizing()) {
                if (showView) {
                    if (view.getVisibility() != VISIBLE) {
                        view.setVisibility(VISIBLE);
                        view.setAlpha(0.0f);
@@ -1019,9 +1043,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                }
            } else {
                view.setAlpha(1.0f);
                view.setVisibility(show ? VISIBLE : INVISIBLE);
                view.setVisibility(showView ? VISIBLE : INVISIBLE);
            }
        }
        state.visible = show;
        state.color = color;
    }

    private void updateColorViewTranslations() {
@@ -1553,7 +1579,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind

        if (mBackdropFrameRenderer != null) {
            mBackdropFrameRenderer.onResourcesLoaded(
                    this, mResizingBackgroundDrawable, mCaptionBackgroundDrawable);
                    this, mResizingBackgroundDrawable, mCaptionBackgroundDrawable,
                    getCurrentColor(mStatusColorViewState));
        }

        mDecorCaptionView = createDecorCaptionView(inflater);
@@ -1668,9 +1695,15 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        if (mDecorCaptionView != null) {
            mDecorCaptionView.removeContentView();
        } else {
            // This window doesn't have caption, so we need to just remove the
            // children of the decor view.
            removeAllViews();
            // This window doesn't have caption, so we need to remove everything except our views
            // we might have added.
            for (int i = getChildCount() - 1; i >= 0; i--) {
                View v = getChildAt(i);
                if (v != mStatusColorViewState.view && v != mNavigationColorViewState.view
                        && v != mStatusGuard && v != mNavigationGuard) {
                    removeViewAt(i);
                }
            }
        }
    }

@@ -1694,18 +1727,22 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        final ThreadedRenderer renderer = (ThreadedRenderer) getHardwareRenderer();
        if (renderer != null) {
            mBackdropFrameRenderer = new BackdropFrameRenderer(this, renderer,
                    initialBounds, mResizingBackgroundDrawable, mCaptionBackgroundDrawable);
                    initialBounds, mResizingBackgroundDrawable, mCaptionBackgroundDrawable,
                    getCurrentColor(mStatusColorViewState));

            // Get rid of the shadow while we are resizing. Shadow drawing takes considerable time.
            // If we want to get the shadow shown while resizing, we would need to elevate a new
            // element which owns the caption and has the elevation.
            updateElevation();

            updateColorViews(null /* insets */, false);
        }
    }

    @Override
    public void onWindowDragResizeEnd() {
        releaseThreadedRenderer();
        updateColorViews(null /* insets */, false);
    }

    @Override
@@ -1738,6 +1775,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        }
    }

    private boolean isResizing() {
        return mBackdropFrameRenderer != null;
    }

    /**
     * The elevation gets set for the first time and the framework needs to be informed that
     * the surface layer gets created with the shadow size in mind.
@@ -1753,8 +1794,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        final boolean wasAdjustedForStack = mElevationAdjustedForStack;
        // Do not use a shadow when we are in resizing mode (mBackdropFrameRenderer not null)
        // since the shadow is bound to the content size and not the target size.
        if (ActivityManager.StackId.hasWindowShadow(mStackId)
                && mBackdropFrameRenderer == null) {
        if (ActivityManager.StackId.hasWindowShadow(mStackId) && !isResizing()) {
            elevation = hasWindowFocus() ?
                    DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP : DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP;
            // TODO(skuhne): Remove this if clause once b/22668382 got fixed.
@@ -1784,6 +1824,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        return isShowingCaption() ? mDecorCaptionView.getCaptionHeight() : 0;
    }

    int getStatusBarHeight() {
        return mStatusColorViewState.view != null ? mStatusColorViewState.view.getHeight() : 0;
    }

    /**
     * Converts a DIP measure into physical pixels.
     * @param dip The dip value.
@@ -1798,6 +1842,8 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        View view = null;
        int targetVisibility = View.INVISIBLE;
        boolean present = false;
        boolean visible;
        int color;

        final int id;
        final int systemUiHideFlag;
+7 −6
Original line number Diff line number Diff line
@@ -2406,6 +2406,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            setNeedsMenuKey(WindowManager.LayoutParams.NEEDS_MENU_SET_FALSE);
        }

        if (!mForcedStatusBarColor) {
            mStatusBarColor = a.getColor(R.styleable.Window_statusBarColor, 0xFF000000);
        }
        if (!mForcedNavigationBarColor) {
            mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000);
        }

        // Non-floating windows on high end devices must put up decor beneath the system bars and
        // therefore must know about visibility changes of those.
        if (!mIsFloating && ActivityManager.isHighEndGfx()) {
@@ -2416,12 +2423,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                        FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS & ~getForcedWindowFlags());
            }
        }
        if (!mForcedStatusBarColor) {
            mStatusBarColor = a.getColor(R.styleable.Window_statusBarColor, 0xFF000000);
        }
        if (!mForcedNavigationBarColor) {
            mNavigationBarColor = a.getColor(R.styleable.Window_navigationBarColor, 0xFF000000);
        }
        if (a.getBoolean(R.styleable.Window_windowLightStatusBar, false)) {
            decor.setSystemUiVisibility(
                    decor.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+3 −0
Original line number Diff line number Diff line
@@ -173,4 +173,7 @@
    <color name="Red_800">#ffb93221</color>

    <color name="chooser_service_row_background_color">#fff5f5f5</color>

    <!-- Status bar color for semi transparent mode. -->
    <color name="system_bar_background_semi_transparent">#66000000</color> <!-- 40% black -->
</resources>
Loading