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

Commit 24c01661 authored by Evan Laird's avatar Evan Laird Committed by Android (Google) Code Review
Browse files

Merge "[shade] hook ModernShadeCarrierGroupMobileView up to the shade colors" into main

parents 9fdf5540 f4288e50
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -332,7 +332,11 @@ constructor(
            override fun onDensityOrFontScaleChanged() {
                clock.setTextAppearance(R.style.TextAppearance_QS_Status)
                date.setTextAppearance(R.style.TextAppearance_QS_Status)
                mShadeCarrierGroup.updateTextAppearance(R.style.TextAppearance_QS_Status)
                mShadeCarrierGroup.updateTextAppearanceAndTint(
                    R.style.TextAppearance_QS_Status,
                    getFgColor(),
                    getBgColor(),
                )
                loadConstraints()
                header.minHeight =
                    resources.getDimensionPixelSize(R.dimen.large_screen_shade_header_min_height)
@@ -537,7 +541,11 @@ constructor(
    private fun updateColors() {
        clock.setTextAppearance(R.style.TextAppearance_QS_Status)
        date.setTextAppearance(R.style.TextAppearance_QS_Status)
        mShadeCarrierGroup.updateTextAppearance(R.style.TextAppearance_QS_Status)
        mShadeCarrierGroup.updateTextAppearanceAndTint(
            R.style.TextAppearance_QS_Status,
            getFgColor(),
            getBgColor(),
        )
        iconManager.setTint(getFgColor(), getBgColor())
    }

+5 −1
Original line number Diff line number Diff line
@@ -160,8 +160,12 @@ public class ShadeCarrier extends LinearLayout {
        mCarrierText.setText(text);
    }

    public void updateTextAppearance(@StyleRes int resId) {
    /** Update the text appearance of the text and the tint of the icon */
    public void updateTextAppearanceAndTint(@StyleRes int resId, int fgColor, int bgColor) {
        mCarrierText.setTextAppearance(resId);
        if (mModernMobileView != null) {
            mModernMobileView.setStyleAndTint(resId, fgColor, bgColor);
        }
    }

    @Override
+5 −4
Original line number Diff line number Diff line
@@ -57,10 +57,11 @@ public class ShadeCarrierGroup extends LinearLayout {
        return findViewById(R.id.shade_carrier_divider2);
    }

    public void updateTextAppearance(@StyleRes int resId) {
    /** Update the text appearance of the text and the tint of the icon */
    public void updateTextAppearanceAndTint(@StyleRes int resId, int fgColor, int bgColor) {
        getNoSimTextView().setTextAppearance(resId);
        getCarrier1View().updateTextAppearance(resId);
        getCarrier2View().updateTextAppearance(resId);
        getCarrier3View().updateTextAppearance(resId);
        getCarrier1View().updateTextAppearanceAndTint(resId, fgColor, bgColor);
        getCarrier2View().updateTextAppearanceAndTint(resId, fgColor, bgColor);
        getCarrier3View().updateTextAppearanceAndTint(resId, fgColor, bgColor);
    }
}
+12 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.pipeline.mobile.ui.binder

import android.annotation.StyleRes
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
@@ -24,13 +25,17 @@ import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel.ShadeCarrierGroupMobileIconViewModel
import com.android.systemui.util.AutoMarqueeTextView

interface ShadeCarrierBinding {
    fun setTextAppearance(@StyleRes resId: Int)
}

object ShadeCarrierBinder {
    /** Binds the view to the view-model, continuing to update the former based on the latter */
    @JvmStatic
    fun bind(
        carrierTextView: AutoMarqueeTextView,
        viewModel: ShadeCarrierGroupMobileIconViewModel,
    ) {
    ): ShadeCarrierBinding {
        carrierTextView.isVisible = true

        carrierTextView.repeatWhenAttached {
@@ -38,5 +43,11 @@ object ShadeCarrierBinder {
                launch { viewModel.carrierName.collect { carrierTextView.text = it } }
            }
        }

        return object : ShadeCarrierBinding {
            override fun setTextAppearance(resId: Int) {
                carrierTextView.setTextAppearance(resId)
            }
        }
    }
}
+28 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.pipeline.mobile.ui.view

import android.annotation.StyleRes
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
@@ -39,6 +40,10 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch

interface ModernShadeCarrierGroupMobileViewBinding {
    fun setStyleAndTint(@StyleRes style: Int, fgColor: Int, bgColor: Int)
}

/**
 * ViewGroup containing a mobile carrier name and icon in the Shade Header. Can be multiple
 * instances as children under [ShadeCarrierGroup]
@@ -48,6 +53,16 @@ class ModernShadeCarrierGroupMobileView(context: Context, attrs: AttributeSet?)

    var subId: Int = -1

    private lateinit var binding: ModernShadeCarrierGroupMobileViewBinding

    /**
     * Update the appearance of the mobile carrier group. The text itself can use the text
     * appearance resId, but the mobile icon needs to know specifically about fg/bg colors.
     */
    fun setStyleAndTint(@StyleRes styleResId: Int, fgColor: Int, bgColor: Int) {
        binding.setStyleAndTint(style = styleResId, fgColor = fgColor, bgColor = bgColor)
    }

    override fun toString(): String {
        return "ModernShadeCarrierGroupMobileView(" +
            "subId=$subId, " +
@@ -82,7 +97,19 @@ class ModernShadeCarrierGroupMobileView(context: Context, attrs: AttributeSet?)
                    logger.logNewViewBinding(this, viewModel)

                    val textView = requireViewById<AutoMarqueeTextView>(R.id.mobile_carrier_text)
                    ShadeCarrierBinder.bind(textView, viewModel)
                    val shadeCarrierBinding = ShadeCarrierBinder.bind(textView, viewModel)

                    binding =
                        object : ModernShadeCarrierGroupMobileViewBinding {
                            override fun setStyleAndTint(
                                @StyleRes style: Int,
                                fgColor: Int,
                                bgColor: Int,
                            ) {
                                iconView.setStaticDrawableColor(fgColor, bgColor)
                                shadeCarrierBinding.setTextAppearance(style)
                            }
                        }
                }
        }

Loading