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

Commit f5e9b5c3 authored by Adrian Roos's avatar Adrian Roos
Browse files

Hide the increased window size due to colored bars from the view hierarchy

For windows with L-bars, the window size has been extended
to include the area below the nav bar. This change makes
DecorView hide that fact from the rest of the view hierarchy,
unless it has explicitly ask to extend below the navigation bar.

Bug: 17421744
Change-Id: I7bd32531130d199c0734ffcb800194e77b7e16c3
parent fbc3f198
Loading
Loading
Loading
Loading
+43 −4
Original line number Diff line number Diff line
@@ -149,6 +149,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
    // mDecor itself, or a child of mDecor where the contents go.
    private ViewGroup mContentParent;

    private ViewGroup mContentRoot;

    SurfaceHolder.Callback2 mTakeSurfaceCallback;

    InputQueue.Callback mTakeInputQueueCallback;
@@ -2153,6 +2155,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

        private int mLastTopInset = 0;
        private int mLastBottomInset = 0;
        private int mLastRightInset = 0;
        private int mLastSystemUiVisibility = 0;


@@ -2731,7 +2734,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        @Override
        public WindowInsets onApplyWindowInsets(WindowInsets insets) {
            mFrameOffsets.set(insets.getSystemWindowInsets());
            updateColorViews(insets);
            insets = updateColorViews(insets);
            insets = updateStatusGuard(insets);
            updateNavigationGuard(insets);
            if (getForeground() != null) {
@@ -2748,8 +2751,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        private WindowInsets updateColorViews(WindowInsets insets) {
            if (!mIsFloating && ActivityManager.isHighEndGfx()) {
                if (insets != null) {
                    mLastTopInset = insets.getStableInsetTop();
                    mLastBottomInset = insets.getStableInsetBottom();
                    mLastTopInset = Math.min(insets.getStableInsetTop(),
                            insets.getSystemWindowInsetTop());
                    mLastBottomInset = Math.min(insets.getStableInsetBottom(),
                            insets.getSystemWindowInsetBottom());
                    mLastRightInset = Math.min(insets.getStableInsetRight(),
                            insets.getSystemWindowInsetRight());
                }
                mStatusColorView = updateColorViewInt(mStatusColorView,
                        SYSTEM_UI_FLAG_FULLSCREEN, FLAG_TRANSLUCENT_STATUS,
@@ -2762,8 +2769,39 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                        NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME,
                        com.android.internal.R.id.navigationBarBackground);
            }

            WindowManager.LayoutParams attrs = getAttributes();
            int sysUiVisibility = attrs.systemUiVisibility | attrs.subtreeSystemUiVisibility;

            // When we expand the window with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, we still need
            // to ensure that the rest of the view hierarchy doesn't notice it, unless they've
            // explicitly asked for it.

            boolean consumingNavBar =
                    (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
                            && (sysUiVisibility & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) == 0
                            && (mLastSystemUiVisibility & SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;

            int consumedRight = consumingNavBar ? mLastRightInset : 0;
            int consumedBottom = consumingNavBar ? mLastBottomInset : 0;

            if (mContentRoot != null
                    && mContentRoot.getLayoutParams() instanceof MarginLayoutParams) {
                MarginLayoutParams lp = (MarginLayoutParams) mContentRoot.getLayoutParams();
                if (lp.rightMargin != consumedRight || lp.bottomMargin != consumedBottom) {
                    lp.rightMargin = consumedRight;
                    lp.bottomMargin = consumedBottom;
                    mContentRoot.setLayoutParams(lp);
                }
            }

            if (insets != null) {
                insets = insets.consumeStableInsets();
                insets = insets.consumeStableInsets().replaceSystemWindowInsets(
                        insets.getSystemWindowInsetLeft(),
                        insets.getSystemWindowInsetTop(),
                        insets.getSystemWindowInsetRight() - consumedRight,
                        insets.getSystemWindowInsetBottom() - consumedBottom
                );
            }
            return insets;
        }
@@ -3373,6 +3411,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

        View in = mLayoutInflater.inflate(layoutResource, null);
        decor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
        mContentRoot = (ViewGroup) in;

        ViewGroup contentParent = (ViewGroup)findViewById(ID_ANDROID_CONTENT);
        if (contentParent == null) {
+1 −2
Original line number Diff line number Diff line
@@ -1520,8 +1520,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        if (ActivityManager.isHighEndGfx()
                && (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) {
            attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
        }
    }