mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-04 01:35:26 +08:00
Fix status bar notification icons color alpha problem in SystemUIHooker
This commit is contained in:
@@ -160,6 +160,12 @@ object SystemUIHooker : YukiBaseHooker() {
|
||||
/** 仅监听一次主题壁纸颜色变化 */
|
||||
private var isWallpaperColorListenerSetUp = false
|
||||
|
||||
/**
|
||||
* 获取状态栏通知图标透明度
|
||||
* @return [Float]
|
||||
*/
|
||||
private val statusBarIconAlpha get() = if (isDarkIconMode) 0.75f else 0.95f
|
||||
|
||||
/**
|
||||
* 是否启用通知图标优化功能
|
||||
* @param isHooking 是否判断启用通知功能 - 默认:是
|
||||
@@ -559,13 +565,24 @@ object SystemUIHooker : YukiBaseHooker() {
|
||||
* 防止图标不是纯黑的问题
|
||||
* 图标在任何场景下跟随状态栏其它图标保持半透明
|
||||
*/
|
||||
iconView.alpha = if (animColor != null) 1f else (if (isDarkIconMode) 0.8f else 0.95f)
|
||||
iconView.alpha = if (animColor != null) 1f else statusBarIconAlpha
|
||||
iconView.setColorFilter(animColor ?: (if (isDarkIconMode) Color.BLACK else Color.WHITE))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新状态栏通知图标透明度
|
||||
* @param container 当前通知图标容器实例
|
||||
*/
|
||||
private fun updateStatusBarIconAlpha(container: ViewGroup) {
|
||||
val iconStateMethod = container.current().method { name = "getIconState"; param(StatusBarIconViewClass) }
|
||||
if (container.childCount > 0) container.children.forEach { iconView ->
|
||||
iconStateMethod.call(iconView)?.current()?.field { name = "alpha"; superClass() }?.set(statusBarIconAlpha)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 [NotificationViewWrapperClass] 中获取 [ExpandableNotificationRowClass]
|
||||
* @return [Pair] - ([Boolean] 通知是否展开,[Any] 通知 Row 实例)
|
||||
@@ -811,6 +828,14 @@ object SystemUIHooker : YukiBaseHooker() {
|
||||
}
|
||||
/** 注入状态栏通知图标容器实例 */
|
||||
NotificationIconContainerClass.hook {
|
||||
injectMember {
|
||||
method { name = "applyIconStates" }
|
||||
afterHook { updateStatusBarIconAlpha(instance()) }
|
||||
}
|
||||
injectMember {
|
||||
method { name = "resetViewStates" }
|
||||
afterHook { updateStatusBarIconAlpha(instance()) }
|
||||
}
|
||||
injectMember {
|
||||
method { name = "calculateIconTranslations" }
|
||||
afterHook {
|
||||
|
Reference in New Issue
Block a user