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

Commit d94c8e72 authored by Vadim Caen's avatar Vadim Caen Committed by Android (Google) Code Review
Browse files

Merge "Postpone setting background when window is set."

parents faaa4e62 6932c77d
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -249,6 +249,14 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
    private Drawable mOriginalBackgroundDrawable;
    private Drawable mLastOriginalBackgroundDrawable;
    private Drawable mResizingBackgroundDrawable;

    /**
     * Temporary holder for a window background when it is set before {@link #mWindow} is
     * initialized. It will be set as the actual background once {@link #setWindow(PhoneWindow)} is
     * called.
     */
    @Nullable
    private Drawable mPendingWindowBackground;
    private Drawable mCaptionBackgroundDrawable;
    private Drawable mUserCaptionBackgroundDrawable;

@@ -961,6 +969,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
    }

    public void setWindowBackground(Drawable drawable) {
        if (mWindow == null) {
            mPendingWindowBackground = drawable;
            return;
        }
        if (mOriginalBackgroundDrawable != drawable) {
            mOriginalBackgroundDrawable = drawable;
            updateBackgroundDrawable();
@@ -2003,6 +2015,11 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
            DecorContext decorContext = (DecorContext) context;
            decorContext.setPhoneWindow(mWindow);
        }
        if (mPendingWindowBackground != null) {
            Drawable background = mPendingWindowBackground;
            mPendingWindowBackground = null;
            setWindowBackground(background);
        }
    }

    @Override
+3 −0
Original line number Diff line number Diff line
@@ -39,4 +39,7 @@
        <item name="android:colorBackground">@null</item>
        <item name="android:windowBackgroundFallback">#0000FF</item>
    </style>
    <style name="ViewDefaultBackground">
        <item name="android:background">#00000000</item>
    </style>
</resources>
+9 −0
Original line number Diff line number Diff line
@@ -76,4 +76,13 @@ public class DecorViewTest {
        expectedBitmap.getPixels(expPixels, 0, w, 0, 0, w, h);
        assertThat(Arrays.toString(expPixels)).isEqualTo(Arrays.toString(resPixels));
    }

    @Test
    public void setBackgroundWithNoWindow() {
        PhoneWindow phoneWindow = new PhoneWindow(mContext);
        // Set a theme that defines a non-null value for android:background
        mContext.setTheme(R.style.ViewDefaultBackground);
        DecorView decorView = (DecorView) phoneWindow.getDecorView();
        assertThat(decorView.getBackground()).isNotNull();
    }
}