diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index 5f4dc404c..fcd1bc500 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -217,7 +217,7 @@ class ReadRssActivity : VMBaseActivity starMenuItem?.setIcon(R.drawable.ic_star_border) starMenuItem?.setTitle(R.string.out_favorites) } - starMenuItem?.icon?.setTint(primaryTextColor) + starMenuItem?.icon?.setTintMutate(primaryTextColor) } override fun upTtsMenu(isPlaying: Boolean) { @@ -229,7 +229,7 @@ class ReadRssActivity : VMBaseActivity ttsMenuItem?.setIcon(R.drawable.ic_volume_up) ttsMenuItem?.setTitle(R.string.read_aloud) } - ttsMenuItem?.icon?.setTint(primaryTextColor) + ttsMenuItem?.icon?.setTintMutate(primaryTextColor) } } diff --git a/app/src/main/java/io/legado/app/utils/DrawableUtils.kt b/app/src/main/java/io/legado/app/utils/DrawableUtils.kt index 4ddb2e417..e8e37d5b5 100644 --- a/app/src/main/java/io/legado/app/utils/DrawableUtils.kt +++ b/app/src/main/java/io/legado/app/utils/DrawableUtils.kt @@ -42,7 +42,7 @@ fun Drawable.setTintList( DrawableCompat.setTintList(wrappedDrawable, tint) } -fun Drawable.setTint( +fun Drawable.setTintMutate( @ColorInt tint: Int, tintMode: PorterDuff.Mode = PorterDuff.Mode.SRC_ATOP ) { diff --git a/app/src/main/java/io/legado/app/utils/MenuExtensions.kt b/app/src/main/java/io/legado/app/utils/MenuExtensions.kt index e08c94d9c..d325ecdea 100644 --- a/app/src/main/java/io/legado/app/utils/MenuExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/MenuExtensions.kt @@ -22,7 +22,7 @@ fun Menu.applyTint(context: Context, theme: Theme = Theme.Auto): Menu = this.let menu.forEach { item -> (item as MenuItemImpl).let { impl -> //overflow:展开的item - impl.icon.setTint( + impl.icon?.setTintMutate( if (impl.requiresOverflow()) defaultTextColor else tintColor ) } @@ -44,7 +44,7 @@ fun Menu.applyOpenTint(context: Context) { if (menuItems is ArrayList<*>) { for (menuItem in menuItems) { if (menuItem is MenuItem) { - menuItem.icon.setTint(defaultTextColor) + menuItem.icon?.setTintMutate(defaultTextColor) } } }