handle top menu colors in Material You

This commit is contained in:
tibbi 2022-03-26 19:42:14 +01:00
parent ec733a24c6
commit bac3664e93
4 changed files with 15 additions and 1 deletions

View file

@ -182,7 +182,7 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
}
}
fun updateMenuItemColors(menu: Menu?, useCrossAsBack: Boolean = false, baseColor: Int = baseConfig.primaryColor, updateHomeAsUpColor: Boolean = true) {
fun updateMenuItemColors(menu: Menu?, useCrossAsBack: Boolean = false, baseColor: Int = getDefaultTopMenuColor(), updateHomeAsUpColor: Boolean = true) {
if (menu == null) {
return
}

View file

@ -116,6 +116,12 @@ fun Context.getAdjustedPrimaryColor() = when {
else -> baseConfig.primaryColor
}
fun Context.getDefaultTopMenuColor() = if (baseConfig.isUsingSystemTheme) {
resources.getColor(R.color.you_background_color)
} else {
baseConfig.primaryColor
}
fun Context.toast(id: Int, length: Int = Toast.LENGTH_SHORT) {
toast(getString(id), length)
}

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="you_background_color">@android:color/system_neutral1_800</color>
</resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="you_background_color">@android:color/system_neutral1_200</color>
</resources>