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

Commit ef160f23 authored by Evan Laird's avatar Evan Laird
Browse files

Fix battery background color in QS

Battery was only getting a foreground color, not background. Fix by
using the SystemUI context so it finds the correct light colors for both
foregorund and background.

Test: visual with light wallpaper
Change-Id: I6e18ce9331a5e78241d8c24ba96a8b843c646813
Fixes: 72431673
parent 90a82350
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -119,18 +119,10 @@ public class BatteryMeterView extends LinearLayout implements
        addView(mBatteryIconView, mlp);

        updateShowPercent();

        Context dualToneDarkTheme = new ContextThemeWrapper(context,
                Utils.getThemeAttr(context, R.attr.darkIconTheme));
        Context dualToneLightTheme = new ContextThemeWrapper(context,
                Utils.getThemeAttr(context, R.attr.lightIconTheme));
        mDarkModeBackgroundColor = Utils.getColorAttr(dualToneDarkTheme, R.attr.backgroundColor);
        mDarkModeFillColor = Utils.getColorAttr(dualToneDarkTheme, R.attr.fillColor);
        mLightModeBackgroundColor = Utils.getColorAttr(dualToneLightTheme, R.attr.backgroundColor);
        mLightModeFillColor = Utils.getColorAttr(dualToneLightTheme, R.attr.fillColor);

        setColorsFromContext(context);
        // Init to not dark at all.
        onDarkChanged(new Rect(), 0, DarkIconDispatcher.DEFAULT_ICON_TINT);

        mUserTracker = new CurrentUserTracker(mContext) {
            @Override
            public void onUserSwitched(int newUserId) {
@@ -148,6 +140,21 @@ public class BatteryMeterView extends LinearLayout implements
        updateShowPercent();
    }

    public void setColorsFromContext(Context context) {
        if (context == null) {
            return;
        }

        Context dualToneDarkTheme = new ContextThemeWrapper(context,
                Utils.getThemeAttr(context, R.attr.darkIconTheme));
        Context dualToneLightTheme = new ContextThemeWrapper(context,
                Utils.getThemeAttr(context, R.attr.lightIconTheme));
        mDarkModeBackgroundColor = Utils.getColorAttr(dualToneDarkTheme, R.attr.backgroundColor);
        mDarkModeFillColor = Utils.getColorAttr(dualToneDarkTheme, R.attr.fillColor);
        mLightModeBackgroundColor = Utils.getColorAttr(dualToneLightTheme, R.attr.backgroundColor);
        mLightModeFillColor = Utils.getColorAttr(dualToneLightTheme, R.attr.fillColor);
    }

    @Override
    public boolean hasOverlappingRendering() {
        return false;
+5 −1
Original line number Diff line number Diff line
@@ -97,7 +97,6 @@ public class QuickStatusBarHeader extends RelativeLayout
        mIconManager.setTint(fillColor);

        BatteryMeterView battery = findViewById(R.id.battery);
        battery.setFillColor(Color.WHITE);
        battery.setForceShowPercent(true);

        mActivityStarter = Dependency.get(ActivityStarter.class);
@@ -216,6 +215,11 @@ public class QuickStatusBarHeader extends RelativeLayout
        //host.setHeaderView(mExpandIndicator);
        mHeaderQsPanel.setQSPanelAndHeader(mQsPanel, this);
        mHeaderQsPanel.setHost(host, null /* No customization in header */);

        // Use SystemUI context to get battery meter colors, and let it use the default tint (white)
        BatteryMeterView battery = findViewById(R.id.battery);
        battery.setColorsFromContext(mHost.getContext());
        battery.onDarkChanged(new Rect(), 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
    }

    public void setCallback(Callback qsPanelCallback) {