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

Commit 5091630c authored by ReallySnow's avatar ReallySnow Committed by Nishith Khanna
Browse files

SystemUI: Follow light/dark theme in SplitShade Header



* Google's default implementation is dark, which means
  it doesn't need to follow the light/dark color change,
  but we broke it, so add it to complete the SplitShade
  Header color change

Co-authored-by: default avatarCol_or <col_or@qq.com>
Change-Id: I5464039885197eeb43bd31b822bfcba7a1b08776
Signed-off-by: default avatarSaalim Quadri <danascape@gmail.com>
parent 0f9b4431
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -22,7 +22,10 @@ import android.annotation.IdRes
import android.app.PendingIntent
import android.app.StatusBarManager
import android.content.Intent
import android.content.Context
import android.content.res.ColorStateList
import android.content.res.Configuration
import android.graphics.Color
import android.graphics.Insets
import android.os.Bundle
import android.os.Trace
@@ -92,6 +95,7 @@ constructor(
    private val privacyIconsController: HeaderPrivacyIconsController,
    private val insetsProvider: StatusBarContentInsetsProvider,
    private val configurationController: ConfigurationController,
    private val context: Context,
    private val variableDateViewControllerFactory: VariableDateViewController.Factory,
    @Named(SHADE_HEADER) private val batteryMeterViewController: BatteryMeterViewController,
    private val dumpManager: DumpManager,
@@ -143,6 +147,7 @@ constructor(
    private var cutout: DisplayCutout? = null
    private var lastInsets: WindowInsets? = null
    private var nextAlarmIntent: PendingIntent? = null
    private var textColorPrimary = Color.TRANSPARENT

    private var qsDisabled = false
    private var visible = false
@@ -295,6 +300,10 @@ constructor(
                date.setTextAppearance(R.style.TextAppearance_QS_Status)
                mShadeCarrierGroup.updateTextAppearance(R.style.TextAppearance_QS_Status_Carriers)
            }

            override fun onUiModeChanged() {
                updateResources()
            }
        }

    private val nextAlarmCallback =
@@ -351,6 +360,7 @@ constructor(
        systemIconsHoverContainer.setOnHoverListener(
            statusOverlayHoverListenerFactory.createListener(systemIconsHoverContainer)
        )
        updateResources()
    }

    override fun onViewDetached() {
@@ -554,6 +564,24 @@ constructor(
        header.setPadding(padding, header.paddingTop, padding, header.paddingBottom)
        updateQQSPaddings()
        qsBatteryModeController.updateResources()

        val fillColor = Utils.getColorAttrDefaultColor(context, android.R.attr.textColorPrimary)
        val inverseColor = Utils.getColorAttrDefaultColor(context, android.R.attr.textColorPrimaryInverse)
        iconManager.setTint(fillColor, inverseColor)
        val textColor = Utils.getColorAttrDefaultColor(context, android.R.attr.textColorPrimary)
        val colorStateList = Utils.getColorAttr(context, android.R.attr.textColorPrimary)
        if (textColor != textColorPrimary) {
            val textColorSecondary = Utils.getColorAttrDefaultColor(context,
                    android.R.attr.textColorSecondary)
            textColorPrimary = textColor
            if (iconManager != null) {
                iconManager.setTint(textColor, inverseColor)
            }
            clock.setTextColor(textColorPrimary)
            date.setTextColor(textColorPrimary)
            mShadeCarrierGroup.updateColors(textColorPrimary, colorStateList)
            batteryIcon.updateColors(textColorPrimary, textColorSecondary, textColorPrimary)
        }
    }

    private fun updateQQSPaddings() {
+8 −0
Original line number Diff line number Diff line
@@ -151,6 +151,14 @@ public class ShadeCarrier extends LinearLayout {
                        com.android.settingslib.R.string.not_default_data_content_description));
    }

    public void updateColors(ColorStateList colorStateList) {
        final boolean visible = !mIsSingleCarrier;
        if (visible) {
            mMobileRoaming.setImageTintList(colorStateList);
            mMobileSignal.setImageTintList(colorStateList);
        }
    }

    @VisibleForTesting
    View getRSSIView() {
        return mMobileGroup;
+16 −0
Original line number Diff line number Diff line
@@ -18,8 +18,11 @@ package com.android.systemui.shade.carrier;

import android.annotation.StyleRes;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

@@ -57,6 +60,19 @@ public class ShadeCarrierGroup extends LinearLayout {
        return findViewById(R.id.shade_carrier_divider2);
    }

    public void updateColors(int color, ColorStateList colorStateList) {
        getNoSimTextView().setTextColor(color);
        ShadeCarrier[] shadeCarriers = { getCarrier1View(), getCarrier2View(), getCarrier3View() };
        for (ShadeCarrier shadeCarrier : shadeCarriers) {
            for (int i = 0; i < shadeCarrier.getChildCount(); i++) {
                shadeCarrier.updateColors(colorStateList);
                if (shadeCarrier.getChildAt(i) instanceof TextView) {
                    ((TextView) shadeCarrier.getChildAt(i)).setTextColor(color);
                }
            }
        }
    }

    public void updateTextAppearance(@StyleRes int resId) {
        getNoSimTextView().setTextAppearance(resId);
        getCarrier1View().updateTextAppearance(resId);