[Chipbar] Fix the color of the start icon to match the new theme.
Fixes: 273969888 Bug: 267821684 Test: active unlock chipbar watch icon has correct tint in light and dark mode Test: media ttt chipbar with default icon and app icon has correct tint in light and dark mode Test: media ttt receiver default icon has correct tint in light and dark mode Test: atest MediaTttUtilsTest MediaTttChipControllerReceiverTest ChipbarCoordinatorTest Change-Id: I992d9f1654ee3592a3ffd7c5aa50f00af5194752
This commit is contained in:
@@ -55,7 +55,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="@dimen/chipbar_text_size"
|
||||
android:textColor="@android:color/system_accent2_900"
|
||||
android:textColor="@color/chipbar_text_and_icon_color"
|
||||
android:alpha="0.0"
|
||||
/>
|
||||
|
||||
|
||||
@@ -230,6 +230,9 @@
|
||||
|
||||
<color name="people_tile_background">@color/material_dynamic_secondary95</color>
|
||||
|
||||
<!-- Chipbar -->
|
||||
<color name="chipbar_text_and_icon_color">@android:color/system_accent2_900</color>
|
||||
|
||||
<!-- Internet Dialog -->
|
||||
<!-- Material next state on color-->
|
||||
<color name="settingslib_state_on_color">@color/settingslib_state_on</color>
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package com.android.systemui.common.shared.model
|
||||
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorRes
|
||||
|
||||
/** Models an icon with a specific tint. */
|
||||
data class TintedIcon(
|
||||
val icon: Icon,
|
||||
@AttrRes val tintAttr: Int?,
|
||||
@ColorRes val tint: Int?,
|
||||
)
|
||||
|
||||
@@ -17,15 +17,14 @@
|
||||
package com.android.systemui.common.ui.binder
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.android.settingslib.Utils
|
||||
import com.android.systemui.common.shared.model.TintedIcon
|
||||
|
||||
object TintedIconViewBinder {
|
||||
/**
|
||||
* Binds the given tinted icon to the view.
|
||||
*
|
||||
* [TintedIcon.tintAttr] will always be applied, meaning that if it is null, then the tint
|
||||
* *will* be reset to null.
|
||||
* [TintedIcon.tint] will always be applied, meaning that if it is null, then the tint *will* be
|
||||
* reset to null.
|
||||
*/
|
||||
fun bind(
|
||||
tintedIcon: TintedIcon,
|
||||
@@ -33,8 +32,8 @@ object TintedIconViewBinder {
|
||||
) {
|
||||
IconViewBinder.bind(tintedIcon.icon, view)
|
||||
view.imageTintList =
|
||||
if (tintedIcon.tintAttr != null) {
|
||||
Utils.getColorAttr(view.context, tintedIcon.tintAttr)
|
||||
if (tintedIcon.tint != null) {
|
||||
view.resources.getColorStateList(tintedIcon.tint, view.context.theme)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
@@ -19,12 +19,13 @@ package com.android.systemui.media.taptotransfer.common
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.Drawable
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.common.shared.model.ContentDescription
|
||||
import com.android.systemui.common.shared.model.Icon
|
||||
import com.android.systemui.common.shared.model.TintedIcon
|
||||
import com.android.systemui.temporarydisplay.chipbar.ChipbarInfo.Companion.DEFAULT_ICON_TINT
|
||||
|
||||
/** Utility methods for media tap-to-transfer. */
|
||||
class MediaTttUtils {
|
||||
@@ -78,7 +79,7 @@ class MediaTttUtils {
|
||||
return IconInfo(
|
||||
contentDescription,
|
||||
MediaTttIcon.Loaded(packageManager.getApplicationIcon(appPackageName)),
|
||||
tintAttr = null,
|
||||
tint = null,
|
||||
isAppIcon = true
|
||||
)
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
@@ -96,7 +97,7 @@ class MediaTttUtils {
|
||||
)
|
||||
},
|
||||
MediaTttIcon.Resource(R.drawable.ic_cast),
|
||||
tintAttr = android.R.attr.textColorPrimary,
|
||||
tint = DEFAULT_ICON_TINT,
|
||||
isAppIcon = false
|
||||
)
|
||||
}
|
||||
@@ -107,7 +108,7 @@ class MediaTttUtils {
|
||||
data class IconInfo(
|
||||
val contentDescription: ContentDescription,
|
||||
val icon: MediaTttIcon,
|
||||
@AttrRes val tintAttr: Int?,
|
||||
@ColorRes val tint: Int?,
|
||||
/**
|
||||
* True if [drawable] is the app's icon, and false if [drawable] is some generic default icon.
|
||||
*/
|
||||
@@ -120,7 +121,7 @@ data class IconInfo(
|
||||
is MediaTttIcon.Loaded -> Icon.Loaded(icon.drawable, contentDescription)
|
||||
is MediaTttIcon.Resource -> Icon.Resource(icon.res, contentDescription)
|
||||
}
|
||||
return TintedIcon(iconOutput, tintAttr)
|
||||
return TintedIcon(iconOutput, tint)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ package com.android.systemui.temporarydisplay.chipbar
|
||||
|
||||
import android.os.VibrationEffect
|
||||
import android.view.View
|
||||
import androidx.annotation.AttrRes
|
||||
import androidx.annotation.ColorRes
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.common.shared.model.Text
|
||||
import com.android.systemui.common.shared.model.TintedIcon
|
||||
import com.android.systemui.temporarydisplay.TemporaryViewInfo
|
||||
@@ -48,7 +49,7 @@ data class ChipbarInfo(
|
||||
override val priority: ViewPriority,
|
||||
) : TemporaryViewInfo() {
|
||||
companion object {
|
||||
@AttrRes const val DEFAULT_ICON_TINT_ATTR = android.R.attr.textColorPrimary
|
||||
@ColorRes val DEFAULT_ICON_TINT = R.color.chipbar_text_and_icon_color
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.common.shared.model.ContentDescription
|
||||
import com.android.systemui.common.shared.model.ContentDescription.Companion.loadContentDescription
|
||||
import com.android.systemui.common.shared.model.Icon
|
||||
import com.android.systemui.temporarydisplay.chipbar.ChipbarInfo.Companion.DEFAULT_ICON_TINT
|
||||
import com.android.systemui.util.mockito.any
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Before
|
||||
@@ -140,6 +141,7 @@ class MediaTttUtilsTest : SysuiTestCase() {
|
||||
context.getString(R.string.media_transfer_receiver_content_description_unknown_app)
|
||||
)
|
||||
assertThat(iconInfo.icon).isEqualTo(MediaTttIcon.Resource(R.drawable.ic_cast))
|
||||
assertThat(iconInfo.tint).isEqualTo(DEFAULT_ICON_TINT)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -232,40 +234,40 @@ class MediaTttUtilsTest : SysuiTestCase() {
|
||||
fun iconInfo_toTintedIcon_loaded() {
|
||||
val contentDescription = ContentDescription.Loaded("test")
|
||||
val drawable = context.getDrawable(R.drawable.ic_cake)!!
|
||||
val tintAttr = android.R.attr.textColorTertiary
|
||||
val tint = R.color.GM2_blue_500
|
||||
|
||||
val iconInfo =
|
||||
IconInfo(
|
||||
contentDescription,
|
||||
MediaTttIcon.Loaded(drawable),
|
||||
tintAttr,
|
||||
tint,
|
||||
isAppIcon = false,
|
||||
)
|
||||
|
||||
val tinted = iconInfo.toTintedIcon()
|
||||
|
||||
assertThat(tinted.icon).isEqualTo(Icon.Loaded(drawable, contentDescription))
|
||||
assertThat(tinted.tintAttr).isEqualTo(tintAttr)
|
||||
assertThat(tinted.tint).isEqualTo(tint)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun iconInfo_toTintedIcon_resource() {
|
||||
val contentDescription = ContentDescription.Loaded("test")
|
||||
val drawableRes = R.drawable.ic_cake
|
||||
val tintAttr = android.R.attr.textColorTertiary
|
||||
val tint = R.color.GM2_blue_500
|
||||
|
||||
val iconInfo =
|
||||
IconInfo(
|
||||
contentDescription,
|
||||
MediaTttIcon.Resource(drawableRes),
|
||||
tintAttr,
|
||||
tint,
|
||||
isAppIcon = false
|
||||
)
|
||||
|
||||
val tinted = iconInfo.toTintedIcon()
|
||||
|
||||
assertThat(tinted.icon).isEqualTo(Icon.Resource(drawableRes, contentDescription))
|
||||
assertThat(tinted.tintAttr).isEqualTo(tintAttr)
|
||||
assertThat(tinted.tint).isEqualTo(tint)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -685,7 +685,7 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
|
||||
allowSwipeToDismiss: Boolean = false,
|
||||
): ChipbarInfo {
|
||||
return ChipbarInfo(
|
||||
TintedIcon(startIcon, tintAttr = null),
|
||||
TintedIcon(startIcon, tint = null),
|
||||
text,
|
||||
endItem,
|
||||
vibrationEffect,
|
||||
|
||||
Reference in New Issue
Block a user