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

Commit 96bbaa77 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ifb1420e4,Ie31dd008 into main

* changes:
  [SB][Screen Chips] Don't require minWidth for the countdown chip.
  [SB][Screen Chips] Update color token for screen chips.
parents d3a34a81 d52543d8
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.chips.ui.model

import android.content.Context
import android.content.res.ColorStateList
import android.view.ContextThemeWrapper
import androidx.annotation.ColorInt
import com.android.settingslib.Utils
import com.android.systemui.res.R
@@ -41,8 +42,11 @@ sealed interface ColorsModel {

    /** The chip should have a red background with white text. */
    data object Red : ColorsModel {
        override fun background(context: Context): ColorStateList =
            ColorStateList.valueOf(context.getColor(R.color.GM2_red_600))
        override fun background(context: Context): ColorStateList {
            val themedContext =
                ContextThemeWrapper(context, com.android.internal.R.style.Theme_DeviceDefault_Light)
            return Utils.getColorAttr(themedContext, com.android.internal.R.attr.materialColorError)
        }

        override fun text(context: Context) = context.getColor(android.R.color.white)
    }
+16 −2
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ class CollapsedStatusBarViewBinderImpl @Inject constructor() : CollapsedStatusBa
                                    chipView.setOnClickListener(chipModel.onClickListener)

                                    // Accessibility
                                    setChipAccessibility(chipModel, chipView)
                                    setChipAccessibility(chipModel, chipView, chipBackgroundView)

                                    // Colors
                                    val textColor = chipModel.colors.text(chipContext)
@@ -213,7 +213,11 @@ class CollapsedStatusBarViewBinderImpl @Inject constructor() : CollapsedStatusBa
        this.setPaddingRelative(/* start= */ 0, paddingTop, paddingEnd, paddingBottom)
    }

    private fun setChipAccessibility(chipModel: OngoingActivityChipModel.Shown, chipView: View) {
    private fun setChipAccessibility(
        chipModel: OngoingActivityChipModel.Shown,
        chipView: View,
        chipBackgroundView: View,
    ) {
        when (chipModel) {
            is OngoingActivityChipModel.Shown.Countdown -> {
                // Set as assertive so talkback will announce the countdown
@@ -224,6 +228,16 @@ class CollapsedStatusBarViewBinderImpl @Inject constructor() : CollapsedStatusBa
                chipView.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_NONE
            }
        }
        // Clickable chips need to be a minimum size for accessibility purposes, but let
        // non-clickable chips be smaller.
        if (chipModel.onClickListener != null) {
            chipBackgroundView.minimumWidth =
                chipBackgroundView.context.resources.getDimensionPixelSize(
                    R.dimen.min_clickable_item_size
                )
        } else {
            chipBackgroundView.minimumWidth = 0
        }
    }

    private fun animateLightsOutView(view: View, visible: Boolean) {