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

Commit 5dbc5aa2 authored by Nader Jawad's avatar Nader Jawad Committed by Android (Google) Code Review
Browse files

Merge "Fixed issue where color attributes used for window background Activity...

Merge "Fixed issue where color attributes used for window background Activity themes would not be applied"
parents b3b74392 56c68bc2
Loading
Loading
Loading
Loading
+19 −20
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.policy;

import android.annotation.Nullable;
import android.annotation.TestApi;
import android.app.WindowConfiguration;
import android.graphics.Outline;
import android.graphics.drawable.InsetDrawable;
@@ -41,7 +43,6 @@ import java.util.List;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.app.ActivityManager;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -55,7 +56,6 @@ import android.graphics.Region;
import android.graphics.Shader;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.RemoteException;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
@@ -281,11 +281,16 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
        initResizingPaints();
    }

    void setBackgroundFallback(int resId) {
        mBackgroundFallback.setDrawable(resId != 0 ? getContext().getDrawable(resId) : null);
    void setBackgroundFallback(@Nullable Drawable fallbackDrawable) {
        mBackgroundFallback.setDrawable(fallbackDrawable);
        setWillNotDraw(getBackground() == null && !mBackgroundFallback.hasFallback());
    }

    @TestApi
    public @Nullable Drawable getBackgroundFallback() {
        return mBackgroundFallback.getDrawable();
    }

    @Override
    public boolean gatherTransparentRegion(Region region) {
        boolean statusOpaque = gatherTransparentRegion(mStatusColorViewState, region);
@@ -946,7 +951,7 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
                        mWindow.isTranslucent() || mWindow.isShowingWallpaper());
            } else {
                mResizingBackgroundDrawable = getResizingBackgroundDrawable(
                        getContext(), 0, mWindow.mBackgroundFallbackResource,
                        mWindow.mBackgroundDrawable, mWindow.mBackgroundFallbackDrawable,
                        mWindow.isTranslucent() || mWindow.isShowingWallpaper());
            }
            if (mResizingBackgroundDrawable != null) {
@@ -1901,9 +1906,9 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind

    private void loadBackgroundDrawablesIfNeeded() {
        if (mResizingBackgroundDrawable == null) {
            mResizingBackgroundDrawable = getResizingBackgroundDrawable(getContext(),
                    mWindow.mBackgroundResource, mWindow.mBackgroundFallbackResource,
                    mWindow.isTranslucent() || mWindow.isShowingWallpaper());
            mResizingBackgroundDrawable = getResizingBackgroundDrawable(mWindow.mBackgroundDrawable,
                    mWindow.mBackgroundFallbackDrawable, mWindow.isTranslucent()
                    || mWindow.isShowingWallpaper());
            if (mResizingBackgroundDrawable == null) {
                // We shouldn't really get here as the background fallback should be always
                // available since it is defaulted by the system.
@@ -2011,21 +2016,15 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind
     * Returns the color used to fill areas the app has not rendered content to yet when the
     * user is resizing the window of an activity in multi-window mode.
     */
    public static Drawable getResizingBackgroundDrawable(Context context, int backgroundRes,
            int backgroundFallbackRes, boolean windowTranslucent) {
        if (backgroundRes != 0) {
            final Drawable drawable = context.getDrawable(backgroundRes);
            if (drawable != null) {
                return enforceNonTranslucentBackground(drawable, windowTranslucent);
            }
    public static Drawable getResizingBackgroundDrawable(@Nullable Drawable backgroundDrawable,
            @Nullable Drawable fallbackDrawable, boolean windowTranslucent) {
        if (backgroundDrawable != null) {
            return enforceNonTranslucentBackground(backgroundDrawable, windowTranslucent);
        }

        if (backgroundFallbackRes != 0) {
            final Drawable fallbackDrawable = context.getDrawable(backgroundFallbackRes);
        if (fallbackDrawable != null) {
            return enforceNonTranslucentBackground(fallbackDrawable, windowTranslucent);
        }
        }
        return new ColorDrawable(Color.BLACK);
    }

+19 −28
Original line number Diff line number Diff line
@@ -218,10 +218,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

    private ProgressBar mHorizontalProgressBar;

    int mBackgroundResource = 0;
    int mBackgroundFallbackResource = 0;

    private Drawable mBackgroundDrawable;
    Drawable mBackgroundDrawable = null;
    Drawable mBackgroundFallbackDrawable = null;

    private boolean mLoadElevation = true;
    private float mElevation;
@@ -1471,14 +1469,14 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {

    @Override
    public final void setBackgroundDrawable(Drawable drawable) {
        if (drawable != mBackgroundDrawable || mBackgroundResource != 0) {
            mBackgroundResource = 0;
        if (drawable != mBackgroundDrawable) {
            mBackgroundDrawable = drawable;
            if (mDecor != null) {
                mDecor.setWindowBackground(drawable);
                if (mBackgroundFallbackDrawable != null) {
                    mDecor.setBackgroundFallback(drawable != null ? null :
                            mBackgroundFallbackDrawable);
                }
            if (mBackgroundFallbackResource != 0) {
                mDecor.setBackgroundFallback(drawable != null ? 0 : mBackgroundFallbackResource);
            }
        }
    }
@@ -2511,19 +2509,18 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        // the values are inherited from our container.
        if (getContainer() == null) {
            if (mBackgroundDrawable == null) {
                if (mBackgroundResource == 0) {
                    mBackgroundResource = a.getResourceId(
                            R.styleable.Window_windowBackground, 0);
                }

                if (mFrameResource == 0) {
                    mFrameResource = a.getResourceId(R.styleable.Window_windowFrame, 0);
                }
                mBackgroundFallbackResource = a.getResourceId(
                        R.styleable.Window_windowBackgroundFallback, 0);
                if (false) {
                    System.out.println("Background: "
                            + Integer.toHexString(mBackgroundResource) + " Frame: "
                            + Integer.toHexString(mFrameResource));

                if (a.hasValue(R.styleable.Window_windowBackground)) {
                    mBackgroundDrawable = a.getDrawable(R.styleable.Window_windowBackground);
                }

                if (a.hasValue(R.styleable.Window_windowBackgroundFallback)) {
                    mBackgroundFallbackDrawable =
                            a.getDrawable(R.styleable.Window_windowBackgroundFallback);
                }
            }
            if (mLoadElevation) {
@@ -2618,13 +2615,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        // Remaining setup -- of background and title -- that only applies
        // to top-level windows.
        if (getContainer() == null) {
            final Drawable background;
            if (mBackgroundResource != 0) {
                background = getContext().getDrawable(mBackgroundResource);
            } else {
                background = mBackgroundDrawable;
            }
            mDecor.setWindowBackground(background);
            mDecor.setWindowBackground(mBackgroundDrawable);

            final Drawable frame;
            if (mFrameResource != 0) {
@@ -2734,8 +2725,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                }
            }

            if (mDecor.getBackground() == null && mBackgroundFallbackResource != 0) {
                mDecor.setBackgroundFallback(mBackgroundFallbackResource);
            if (mDecor.getBackground() == null && mBackgroundFallbackDrawable != null) {
                mDecor.setBackgroundFallback(mBackgroundFallbackDrawable);
            }

            // Only inflate or create a new TransitionManager if the caller hasn't
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

package com.android.internal.widget;

import android.annotation.Nullable;
import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
@@ -35,6 +36,10 @@ public class BackgroundFallback {
        mBackgroundFallback = d;
    }

    public @Nullable Drawable getDrawable() {
        return mBackgroundFallback;
    }

    public boolean hasFallback() {
        return mBackgroundFallback != null;
    }
+2 −2
Original line number Diff line number Diff line
@@ -339,13 +339,13 @@
                  then in code manually set your window's background to
                  null so it will not be drawn.
             </ul> -->
        <attr name="windowBackground" format="reference" />
        <attr name="windowBackground" format="reference|color" />
        <!-- Drawable to draw selectively within the inset areas when the windowBackground
             has been set to null. This protects against seeing visual garbage in the
             surface when the app has not drawn any content into this area. One example is
             when the user is resizing a window of an activity that has
             {@link android.R.attr#resizeableActivity} set for multi-window mode. -->
        <attr name="windowBackgroundFallback" format="reference" />
        <attr name="windowBackgroundFallback" format="reference|color" />
        <!-- Drawable to use as a frame around the window. -->
        <attr name="windowFrame" format="reference" />
        <!-- Flag indicating whether there should be no title on this window. -->
+8 −0
Original line number Diff line number Diff line
@@ -31,4 +31,12 @@
    <style name="LayoutInDisplayCutoutModeNever">
        <item name="android:windowLayoutInDisplayCutoutMode">never</item>
    </style>
    <style name="WindowBackgroundColorLiteral">
        <item name="android:windowBackground">#00FF00</item>
    </style>
    <style name="WindowBackgroundFallbackColorLiteral">
        <item name="android:windowBackground">@null</item>
        <item name="android:colorBackground">@null</item>
        <item name="android:windowBackgroundFallback">#0000FF</item>
    </style>
</resources>
Loading