use proper color at the top menu icons
This commit is contained in:
parent
bcc4fcb4fc
commit
9c82d02a8d
1 changed files with 13 additions and 2 deletions
|
@ -194,11 +194,22 @@ abstract class BaseSimpleActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
fun updateMenuItemColors(menu: Menu?, useCrossAsBack: Boolean = false, baseColor: Int = baseConfig.primaryColor, updateHomeAsUpColor: Boolean = true) {
|
||||
if (menu == null || baseConfig.isUsingSystemTheme) {
|
||||
if (menu == null) {
|
||||
return
|
||||
}
|
||||
|
||||
val color = baseColor.getContrastColor()
|
||||
var color = baseColor.getContrastColor()
|
||||
if (baseConfig.isUsingSystemTheme) {
|
||||
val views = ArrayList<View>()
|
||||
try {
|
||||
window.decorView.rootView.findViewsWithText(views, supportActionBar?.title, View.FIND_VIEWS_WITH_TEXT)
|
||||
if (views.size == 1 && views[0] is TextView) {
|
||||
color = (views[0] as TextView).currentTextColor
|
||||
}
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
for (i in 0 until menu.size()) {
|
||||
try {
|
||||
menu.getItem(i)?.icon?.setTint(color)
|
||||
|
|
Loading…
Reference in a new issue