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

Commit a832ada6 authored by Matt Sziklay's avatar Matt Sziklay Committed by Android (Google) Code Review
Browse files

Merge "Track status bar appearance in TaskDescription." into udc-qpr-dev

parents 407c2828 24beaa0a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1083,6 +1083,16 @@ public class Activity extends ContextThemeWrapper
            setTaskDescription(mTaskDescription);
        }

        /**
         * Update the forced status bar appearance.
         * @hide
         */
        @Override
        public void updateStatusBarAppearance(int appearance) {
            mTaskDescription.setStatusBarAppearance(appearance);
            setTaskDescription(mTaskDescription);
        }

        /**
         * Update the forced navigation bar color.
         * @hide
+36 −9
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ import android.util.ArrayMap;
import android.util.DisplayMetrics;
import android.util.Singleton;
import android.util.Size;
import android.view.WindowInsetsController.Appearance;
import android.window.TaskSnapshot;

import com.android.internal.app.LocalePicker;
@@ -1553,6 +1554,8 @@ public class ActivityManager {
        private int mColorBackgroundFloating;
        private int mStatusBarColor;
        private int mNavigationBarColor;
        @Appearance
        private int mStatusBarAppearance;
        private boolean mEnsureStatusBarContrastWhenTransparent;
        private boolean mEnsureNavigationBarContrastWhenTransparent;
        private int mResizeMode;
@@ -1653,8 +1656,8 @@ public class ActivityManager {
                final Icon icon = mIconRes == Resources.ID_NULL ? null :
                        Icon.createWithResource(ActivityThread.currentPackageName(), mIconRes);
                return new TaskDescription(mLabel, icon, mPrimaryColor, mBackgroundColor,
                        mStatusBarColor, mNavigationBarColor, false, false, RESIZE_MODE_RESIZEABLE,
                        -1, -1, 0);
                        mStatusBarColor, mNavigationBarColor, 0, false, false,
                        RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            }
        }

@@ -1672,7 +1675,7 @@ public class ActivityManager {
        @Deprecated
        public TaskDescription(String label, @DrawableRes int iconRes, int colorPrimary) {
            this(label, Icon.createWithResource(ActivityThread.currentPackageName(), iconRes),
                    colorPrimary, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
                    colorPrimary, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) {
                throw new RuntimeException("A TaskDescription's primary color should be opaque");
            }
@@ -1690,7 +1693,7 @@ public class ActivityManager {
        @Deprecated
        public TaskDescription(String label, @DrawableRes int iconRes) {
            this(label, Icon.createWithResource(ActivityThread.currentPackageName(), iconRes),
                    0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
                    0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /**
@@ -1702,7 +1705,7 @@ public class ActivityManager {
         */
        @Deprecated
        public TaskDescription(String label) {
            this(label, null, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            this(label, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /**
@@ -1712,7 +1715,7 @@ public class ActivityManager {
         */
        @Deprecated
        public TaskDescription() {
            this(null, null, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            this(null, null, 0, 0, 0, 0, 0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /**
@@ -1728,7 +1731,7 @@ public class ActivityManager {
        @Deprecated
        public TaskDescription(String label, Bitmap icon, int colorPrimary) {
            this(label, icon != null ? Icon.createWithBitmap(icon) : null, colorPrimary, 0, 0, 0,
                    false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
                    0, false, false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) {
                throw new RuntimeException("A TaskDescription's primary color should be opaque");
            }
@@ -1744,14 +1747,15 @@ public class ActivityManager {
         */
        @Deprecated
        public TaskDescription(String label, Bitmap icon) {
            this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, false, false,
                    RESIZE_MODE_RESIZEABLE, -1, -1, 0);
            this(label, icon != null ? Icon.createWithBitmap(icon) : null, 0, 0, 0, 0, 0, false,
                    false, RESIZE_MODE_RESIZEABLE, -1, -1, 0);
        }

        /** @hide */
        public TaskDescription(@Nullable String label, @Nullable Icon icon,
                int colorPrimary, int colorBackground,
                int statusBarColor, int navigationBarColor,
                @Appearance int statusBarAppearance,
                boolean ensureStatusBarContrastWhenTransparent,
                boolean ensureNavigationBarContrastWhenTransparent, int resizeMode, int minWidth,
                int minHeight, int colorBackgroundFloating) {
@@ -1761,6 +1765,7 @@ public class ActivityManager {
            mColorBackground = colorBackground;
            mStatusBarColor = statusBarColor;
            mNavigationBarColor = navigationBarColor;
            mStatusBarAppearance = statusBarAppearance;
            mEnsureStatusBarContrastWhenTransparent = ensureStatusBarContrastWhenTransparent;
            mEnsureNavigationBarContrastWhenTransparent =
                    ensureNavigationBarContrastWhenTransparent;
@@ -1789,6 +1794,7 @@ public class ActivityManager {
            mColorBackground = other.mColorBackground;
            mStatusBarColor = other.mStatusBarColor;
            mNavigationBarColor = other.mNavigationBarColor;
            mStatusBarAppearance = other.mStatusBarAppearance;
            mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent;
            mEnsureNavigationBarContrastWhenTransparent =
                    other.mEnsureNavigationBarContrastWhenTransparent;
@@ -1818,6 +1824,9 @@ public class ActivityManager {
            if (other.mNavigationBarColor != 0) {
                mNavigationBarColor = other.mNavigationBarColor;
            }
            if (other.mStatusBarAppearance != 0) {
                mStatusBarAppearance = other.mStatusBarAppearance;
            }

            mEnsureStatusBarContrastWhenTransparent = other.mEnsureStatusBarContrastWhenTransparent;
            mEnsureNavigationBarContrastWhenTransparent =
@@ -2086,6 +2095,14 @@ public class ActivityManager {
            return mEnsureStatusBarContrastWhenTransparent;
        }

        /**
         * @hide
         */
        @Appearance
        public int getStatusBarAppearance() {
            return mStatusBarAppearance;
        }

        /**
         * @hide
         */
@@ -2094,6 +2111,13 @@ public class ActivityManager {
            mEnsureStatusBarContrastWhenTransparent = ensureStatusBarContrastWhenTransparent;
        }

        /**
         * @hide
         */
        public void setStatusBarAppearance(@Appearance int statusBarAppearance) {
            mStatusBarAppearance = statusBarAppearance;
        }

        /**
         * @hide
         */
@@ -2218,6 +2242,7 @@ public class ActivityManager {
            dest.writeInt(mColorBackground);
            dest.writeInt(mStatusBarColor);
            dest.writeInt(mNavigationBarColor);
            dest.writeInt(mStatusBarAppearance);
            dest.writeBoolean(mEnsureStatusBarContrastWhenTransparent);
            dest.writeBoolean(mEnsureNavigationBarContrastWhenTransparent);
            dest.writeInt(mResizeMode);
@@ -2241,6 +2266,7 @@ public class ActivityManager {
            mColorBackground = source.readInt();
            mStatusBarColor = source.readInt();
            mNavigationBarColor = source.readInt();
            mStatusBarAppearance = source.readInt();
            mEnsureStatusBarContrastWhenTransparent = source.readBoolean();
            mEnsureNavigationBarContrastWhenTransparent = source.readBoolean();
            mResizeMode = source.readInt();
@@ -2289,6 +2315,7 @@ public class ActivityManager {
                    && mColorBackground == other.mColorBackground
                    && mStatusBarColor == other.mStatusBarColor
                    && mNavigationBarColor == other.mNavigationBarColor
                    && mStatusBarAppearance == other.mStatusBarAppearance
                    && mEnsureStatusBarContrastWhenTransparent
                            == other.mEnsureStatusBarContrastWhenTransparent
                    && mEnsureNavigationBarContrastWhenTransparent
+9 −0
Original line number Diff line number Diff line
@@ -657,6 +657,12 @@ public abstract class Window {
         */
        void updateStatusBarColor(int color);

        /**
         * Update the status bar appearance.
         */

        void updateStatusBarAppearance(int appearance);

        /**
         * Update the navigation bar color to a forced one.
         */
@@ -1039,6 +1045,9 @@ public abstract class Window {
        if (mDecorCallback != null) {
            mDecorCallback.onSystemBarAppearanceChanged(appearance);
        }
        if (mWindowControllerCallback != null) {
            mWindowControllerCallback.updateStatusBarAppearance(appearance);
        }
    }

    /** @hide */
+6 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x222222,                // colorBackground
                0x333333,                // statusBarColor
                0x444444,                // navigationBarColor
                0,                       // statusBarAppearance
                true,                    // ensureStatusBarContrastWhenTransparent
                true,                    // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_RESIZEABLE,  // resizeMode
@@ -152,6 +153,7 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x222222,                  // colorBackground
                0x333333,                  // statusBarColor
                0x444444,                  // navigationBarColor
                0,                         // statusBarAppearance
                false,                     // ensureStatusBarContrastWhenTransparent
                false,                     // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_UNRESIZEABLE,  // resizeMode
@@ -167,6 +169,7 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x2222222,               // colorBackground
                0x3333332,               // statusBarColor
                0x4444442,               // navigationBarColor
                0,                       // statusBarAppearance
                true,                    // ensureStatusBarContrastWhenTransparent
                true,                    // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_RESIZEABLE,  // resizeMode
@@ -197,6 +200,7 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x222222,                  // colorBackground
                0x333333,                  // statusBarColor
                0x444444,                  // navigationBarColor
                0,                         // statusBarAppearance
                false,                     // ensureStatusBarContrastWhenTransparent
                false,                     // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_UNRESIZEABLE,  // resizeMode
@@ -219,6 +223,7 @@ public class ActivityManagerTest extends AndroidTestCase {
                0x222222,                  // colorBackground
                0x333333,                  // statusBarColor
                0x444444,                  // navigationBarColor
                0,                         // statusBarAppearance
                false,                     // ensureStatusBarContrastWhenTransparent
                false,                     // ensureNavigationBarContrastWhenTransparent
                RESIZE_MODE_UNRESIZEABLE,  // resizeMode
@@ -250,6 +255,7 @@ public class ActivityManagerTest extends AndroidTestCase {
            assertEquals(td1.getBackgroundColor(), td2.getBackgroundColor());
            assertEquals(td1.getStatusBarColor(), td2.getStatusBarColor());
            assertEquals(td1.getNavigationBarColor(), td2.getNavigationBarColor());
            assertEquals(td1.getStatusBarAppearance(), td2.getStatusBarAppearance());
            assertEquals(td1.getResizeMode(), td2.getResizeMode());
            assertEquals(td1.getMinWidth(), td2.getMinWidth());
            assertEquals(td1.getMinHeight(), td2.getMinHeight());
+3 −0
Original line number Diff line number Diff line
@@ -1847,6 +1847,9 @@ class Task extends TaskFragment {
                td.setEnsureStatusBarContrastWhenTransparent(
                        atd.getEnsureStatusBarContrastWhenTransparent());
            }
            if (td.getStatusBarAppearance() == 0) {
                td.setStatusBarAppearance(atd.getStatusBarAppearance());
            }
            if (td.getNavigationBarColor() == 0) {
                td.setNavigationBarColor(atd.getNavigationBarColor());
                td.setEnsureNavigationBarContrastWhenTransparent(