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

Commit 9035415d authored by Valter Strods's avatar Valter Strods Committed by d34d
Browse files

SystemUI: Separate system bar BGs for themes

This commit separates the navigation bar background colors from the
status bar background colors which allows more modular theme-ability.
Backwards compatibility for the old system bar values is still
preserved, but the new values are to be prioritized.

Thanks to Arz Bhatia for the suggestion.

Change-Id: Ibe579d16ea35ca5bdcfe9f98143c3f91cd24900f
parent 1317de43
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -19,4 +19,10 @@
    <!-- Color for the "No recent apps" text in the recent apps list. -->
    <color name="no_recent_apps">#bebebe</color>

    <!-- Colors for the system bars -->
    <color name="status_bar_background_opaque">@color/system_bar_background_opaque</color>
    <color name="status_bar_background_semi_transparent">@color/system_bar_background_semi_transparent</color>
    <color name="navigation_bar_background_opaque">@color/system_bar_background_opaque</color>
    <color name="navigation_bar_background_semi_transparent">@color/system_bar_background_semi_transparent</color>

</resources>
+14 −7
Original line number Diff line number Diff line
@@ -55,10 +55,12 @@ public class BarTransitions {

    private int mMode;

    public BarTransitions(View view, int gradientResourceId) {
    public BarTransitions(View view, int gradientResourceId, int opaqueColorResourceId,
            int semiTransparentColorResourceId) {
        mTag = "BarTransitions." + view.getClass().getSimpleName();
        mView = view;
        mBarBackground = new BarBackgroundDrawable(mView.getContext(), gradientResourceId);
        mBarBackground = new BarBackgroundDrawable(mView.getContext(), gradientResourceId,
                opaqueColorResourceId, semiTransparentColorResourceId);
        if (HIGH_END) {
            mView.setBackground(mBarBackground);
        }
@@ -121,6 +123,8 @@ public class BarTransitions {

    private static class BarBackgroundDrawable extends Drawable {
        private final int mGradientResourceId;
        private final int mOpaqueColorResourceId;
        private final int mSemiTransparentColorResourceId;
        private final TimeInterpolator mInterpolator;

        private int mOpaque;
@@ -137,23 +141,26 @@ public class BarTransitions {
        private int mGradientAlphaStart;
        private int mColorStart;

        public BarBackgroundDrawable(Context context, int gradientResourceId) {
        public BarBackgroundDrawable(Context context, int gradientResourceId,
                int opaqueColorResourceId, int semiTransparentColorResourceId) {
            final Resources res = context.getResources();
            if (DEBUG_COLORS) {
                mOpaque = 0xff0000ff;
                mSemiTransparent = 0x7f0000ff;
            } else {
                mOpaque = res.getColor(R.color.system_bar_background_opaque);
                mSemiTransparent = res.getColor(R.color.system_bar_background_semi_transparent);
                mOpaque = res.getColor(opaqueColorResourceId);
                mSemiTransparent = res.getColor(semiTransparentColorResourceId);
            }
            mGradient = res.getDrawable(gradientResourceId);
            mInterpolator = new LinearInterpolator();
            mGradientResourceId = gradientResourceId;
            mOpaqueColorResourceId = opaqueColorResourceId;
            mSemiTransparentColorResourceId = semiTransparentColorResourceId;
        }

        public void updateResources(Resources res)  {
            mOpaque = res.getColor(R.color.system_bar_background_opaque);
            mSemiTransparent = res.getColor(R.color.system_bar_background_semi_transparent);
            mOpaque = res.getColor(mOpaqueColorResourceId);
            mSemiTransparent = res.getColor(mSemiTransparentColorResourceId);
            // Retrieve the current bounds for mGradient so they can be set to
            // the new drawable being loaded, otherwise the bounds will be (0, 0, 0, 0)
            // and the gradient will not be drawn.
+2 −1
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ public final class NavigationBarTransitions extends BarTransitions {
    private boolean mStickyTransparent;

    public NavigationBarTransitions(NavigationBarView view) {
        super(view, R.drawable.nav_background);
        super(view, R.drawable.nav_background, R.color.navigation_bar_background_opaque,
                R.color.navigation_bar_background_semi_transparent);
        mView = view;
        mBarService = IStatusBarService.Stub.asInterface(
                ServiceManager.getService(Context.STATUS_BAR_SERVICE));
+2 −1
Original line number Diff line number Diff line
@@ -38,7 +38,8 @@ public final class PhoneStatusBarTransitions extends BarTransitions {
    private Animator mCurrentAnimation;

    public PhoneStatusBarTransitions(PhoneStatusBarView view) {
        super(view, R.drawable.status_background);
        super(view, R.drawable.status_background, R.color.status_bar_background_opaque,
                R.color.status_bar_background_semi_transparent);
        mView = view;
        final Resources res = mView.getContext().getResources();
        mIconAlphaWhenOpaque = res.getFraction(R.dimen.status_bar_icon_drawing_alpha, 1, 1);