handle top menu colors in Material You
This commit is contained in:
parent
ec733a24c6
commit
bac3664e93
4 changed files with 15 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
4
commons/src/main/res/values-night-v31/colors.xml
Normal file
4
commons/src/main/res/values-night-v31/colors.xml
Normal 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>
|
4
commons/src/main/res/values-v31/colors.xml
Normal file
4
commons/src/main/res/values-v31/colors.xml
Normal 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>
|
Loading…
Reference in a new issue