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

Commit 238010f0 authored by George Mount's avatar George Mount
Browse files

Allow activity transitions to target nav and status bar colors.

Bug 15885062

Action bar can already be targeted via android:action_bar.
Navigation bar background is now android:navigation:background.
Status bar background is now android:status:background.

Change-Id: I4604906923f3473af3beec4f865463b2fe4a5316
parent 00dde0bd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -33884,6 +33884,7 @@ package android.view {
    field public static final int FEATURE_RIGHT_ICON = 4; // 0x4
    field public static final int FEATURE_SWIPE_TO_DISMISS = 11; // 0xb
    field public static final int ID_ANDROID_CONTENT = 16908290; // 0x1020002
    field public static final java.lang.String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME = "android:navigation:background";
    field public static final int PROGRESS_END = 10000; // 0x2710
    field public static final int PROGRESS_INDETERMINATE_OFF = -4; // 0xfffffffc
    field public static final int PROGRESS_INDETERMINATE_ON = -3; // 0xfffffffd
@@ -33892,6 +33893,7 @@ package android.view {
    field public static final int PROGRESS_START = 0; // 0x0
    field public static final int PROGRESS_VISIBILITY_OFF = -2; // 0xfffffffe
    field public static final int PROGRESS_VISIBILITY_ON = -1; // 0xffffffff
    field public static final java.lang.String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background";
  }
  public static abstract interface Window.Callback {
+20 −1
Original line number Diff line number Diff line
@@ -131,6 +131,19 @@ public abstract class Window {
    /** Highest possible value for the secondary progress */
    public static final int PROGRESS_SECONDARY_END = 30000;

    /**
     * The transitionName for the status bar background View when a custom background is used.
     * @see android.view.Window#setStatusBarColor(int)
     */
    public static final String STATUS_BAR_BACKGROUND_TRANSITION_NAME = "android:status:background";

    /**
     * The transitionName for the navigation bar background View when a custom background is used.
     * @see android.view.Window#setNavigationBarColor(int)
     */
    public static final String NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME =
            "android:navigation:background";

    /** The default features enabled */
    @SuppressWarnings({"PointlessBitwiseExpression"})
    protected static final int DEFAULT_FEATURES = (1 << FEATURE_OPTIONS_PANEL) |
@@ -1554,6 +1567,9 @@ public abstract class Window {
     * If {@param color} is not opaque, consider setting
     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.
     * <p>
     * The transitionName for the view background will be "android:status:background".
     * </p>
     */
    public abstract void setStatusBarColor(int color);

@@ -1573,6 +1589,9 @@ public abstract class Window {
     * If {@param color} is not opaque, consider setting
     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
     * {@link android.view.View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.
     * <p>
     * The transitionName for the view background will be "android:navigation:background".
     * </p>
     */
    public abstract void setNavigationBarColor(int color);

+6 −8
Original line number Diff line number Diff line
@@ -32,20 +32,15 @@ import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.view.menu.MenuDialogHelper;
import com.android.internal.view.menu.MenuPresenter;
import com.android.internal.view.menu.MenuView;
import com.android.internal.widget.ActionBarContainer;
import com.android.internal.widget.ActionBarContextView;
import com.android.internal.widget.ActionBarOverlayLayout;
import com.android.internal.widget.ActionBarView;
import com.android.internal.widget.DecorContentParent;
import com.android.internal.widget.SwipeDismissLayout;

import android.app.ActivityManager;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -2658,10 +2653,12 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                }
                mStatusColorView = updateColorViewInt(mStatusColorView,
                        SYSTEM_UI_FLAG_FULLSCREEN, FLAG_TRANSLUCENT_STATUS,
                        mStatusBarColor, mLastTopInset, Gravity.TOP);
                        mStatusBarColor, mLastTopInset, Gravity.TOP,
                        STATUS_BAR_BACKGROUND_TRANSITION_NAME);
                mNavigationColorView = updateColorViewInt(mNavigationColorView,
                        SYSTEM_UI_FLAG_HIDE_NAVIGATION, FLAG_TRANSLUCENT_NAVIGATION,
                        mNavigationBarColor, mLastBottomInset, Gravity.BOTTOM);
                        mNavigationBarColor, mLastBottomInset, Gravity.BOTTOM,
                        NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME);
            }
            if (insets != null) {
                insets = insets.consumeStableInsets();
@@ -2670,7 +2667,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
        }

        private View updateColorViewInt(View view, int systemUiHideFlag, int translucentFlag,
                int color, int height, int verticalGravity) {
                int color, int height, int verticalGravity, String transitionName) {
            boolean show = height > 0 && (mLastSystemUiVisibility & systemUiHideFlag) == 0
                    && (getAttributes().flags & translucentFlag) == 0
                    && (color & Color.BLACK) != 0
@@ -2680,6 +2677,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                if (show) {
                    view = new View(mContext);
                    view.setBackgroundColor(color);
                    view.setTransitionName(transitionName);
                    addView(view, new LayoutParams(LayoutParams.MATCH_PARENT, height,
                            Gravity.START | verticalGravity));
                }