修复通知面板折叠通知背景异常问题,优化二级通知的背景

This commit is contained in:
2022-05-05 15:10:46 +08:00
parent b404543f47
commit 1f8022fd7c

View File

@@ -534,12 +534,20 @@ class SystemUIHooker : YukiBaseHooker() {
/** /**
* 设置通知面板背景透明度 * 设置通知面板背景透明度
* @param view 背景 View 实例
* @param drawable 背景实例 * @param drawable 背景实例
*/ */
private fun modifyNotifyPanelAlpha(drawable: Drawable?) { private fun modifyNotifyPanelAlpha(view: View?, drawable: Drawable?) {
if (prefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA)) prefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA).also { isEnabled ->
drawable?.alpha = prefs.get(DataConst.NOTIFY_PANEL_ALPHA) /** 设置通知面板背景透明度 */
else drawable?.alpha = 255 when {
isEnabled.not() -> drawable?.alpha = 255
view?.parent?.parent?.javaClass?.name?.contains(other = "ChildrenContainer") == true -> drawable?.alpha = 0
else -> drawable?.alpha = prefs.get(DataConst.NOTIFY_PANEL_ALPHA)
}
/** 移除阴影效果 */
if (isEnabled) view?.elevation = 0f
}
} }
/** 缓存图标数据 */ /** 缓存图标数据 */
@@ -704,7 +712,7 @@ class SystemUIHooker : YukiBaseHooker() {
name = "drawRegionBlur" name = "drawRegionBlur"
paramCount = 2 paramCount = 2
} }
beforeHook { modifyNotifyPanelAlpha(args().last().cast<Drawable>()) } beforeHook { modifyNotifyPanelAlpha(instance(), args().last().cast<Drawable>()) }
} }
injectMember { injectMember {
method { method {
@@ -712,22 +720,7 @@ class SystemUIHooker : YukiBaseHooker() {
paramCount = 2 paramCount = 2
superClass(isOnlySuperClass = true) superClass(isOnlySuperClass = true)
} }
beforeHook { modifyNotifyPanelAlpha(args().last().cast<Drawable>()) } beforeHook { modifyNotifyPanelAlpha(instance(), args().last().cast<Drawable>()) }
}
}.by { isOldNotificationBackground.not() }
ExpandableNotificationRowClass.hook {
injectMember {
method {
name = "updateBackgroundForGroupState"
paramCount = 0
}
beforeHook {
if (prefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA)) {
ExpandableNotificationRowClass.clazz.field {
name = "mShowGroupBackgroundWhenExpanded"
}.get(instance).setTrue()
}
}
} }
}.by { isOldNotificationBackground.not() } }.by { isOldNotificationBackground.not() }
/** 替换通知面板背景 - 旧版本 */ /** 替换通知面板背景 - 旧版本 */
@@ -737,16 +730,29 @@ class SystemUIHooker : YukiBaseHooker() {
name = "draw" name = "draw"
paramCount = 2 paramCount = 2
} }
beforeHook { modifyNotifyPanelAlpha(args().last().cast<Drawable>()) } beforeHook { modifyNotifyPanelAlpha(instance(), args().last().cast<Drawable>()) }
} }
injectMember { injectMember {
method { method {
name = "drawCustom" name = "drawCustom"
paramCount = 2 paramCount = 2
} }
beforeHook { modifyNotifyPanelAlpha(args().last().cast<Drawable>()) } beforeHook { modifyNotifyPanelAlpha(instance(), args().last().cast<Drawable>()) }
} }
}.by { isOldNotificationBackground } }.by { isOldNotificationBackground }
/** 替换通知面板背景 - 避免折叠展开通知二次修改通知面板背景 */
ExpandableNotificationRowClass.hook {
injectMember {
method {
name = "updateBackgroundForGroupState"
emptyParam()
}
beforeHook {
if (prefs.get(DataConst.ENABLE_NOTIFY_PANEL_ALPHA))
field { name = "mShowGroupBackgroundWhenExpanded" }.get(instance).setTrue()
}
}
}
/** 替换通知图标和样式 */ /** 替换通知图标和样式 */
NotificationHeaderViewWrapperClass.hook { NotificationHeaderViewWrapperClass.hook {
injectMember { injectMember {