From bd08b2ce1da283585582e71bc8edbc16955f67ee Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Tue, 7 Feb 2023 03:25:55 +0800 Subject: [PATCH] Fix notification panel maybe freeze problem in SystemUIHooker - Remove replacement notification icon views function - Use a new way to fix notification icons color --- .../notify/hook/entity/SystemUIHooker.kt | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt b/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt index c9acdb2..f7b5e98 100644 --- a/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt +++ b/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt @@ -416,23 +416,14 @@ object SystemUIHooker : YukiBaseHooker() { iconView: ImageView ) = runInSafe { compatCustomIcon(context, isGrayscaleIcon, packageName).also { customTriple -> - /** 设置一个用于替换的图标 */ - val placeholderView = ImageView(context) - /** 克隆之前图标的所有布局信息 */ - (iconView.parent as? ViewGroup?)?.apply { addView(placeholderView.apply { layoutParams = iconView.layoutParams }) } - ?: loggerE(msg = "Cannot got the orginal notification icon's parent view \"${nf.packageName}\"(\"${nf.opPkg}\") of $nf") - /** 将之前图标的间距设置为一个超大值以达到隐藏的效果 */ - 999.also { iconView.setPadding(it, it, it, it) } - /** 清除之前图标可能存在的背景 */ - iconView.background = null when { - ConfigData.isEnableNotifyIconForceAppIcon -> placeholderView.apply { + ConfigData.isEnableNotifyIconForceAppIcon -> iconView.apply { /** 重新设置图标 */ setImageDrawable(appIcons[packageName] ?: context.appIconOf(packageName)) /** 设置默认样式 */ setDefaultNotifyIconViewStyle() } - (customTriple.first != null && customTriple.third.not()) || isGrayscaleIcon -> placeholderView.apply { + (customTriple.first != null && customTriple.third.not()) || isGrayscaleIcon -> iconView.apply { /** 设置不要裁切到边界 */ clipToOutline = false /** 重新设置图标 */ @@ -470,7 +461,7 @@ object SystemUIHooker : YukiBaseHooker() { setPadding(0, 0, 0, 0) } } - else -> placeholderView.apply { + else -> iconView.apply { /** 重新设置图标 */ setImageDrawable(nf.compatPushingIcon(drawable)) /** 设置默认样式 */ @@ -822,7 +813,7 @@ object SystemUIHooker : YukiBaseHooker() { /** 替换通知图标和样式 */ NotificationHeaderViewWrapperClass.hook { injectMember { - method { name = "resolveHeaderViews" } + method { name { it == "resolveHeaderViews" || it == "onContentUpdated" } }.all() afterHook { NotificationHeaderViewWrapperClass.toClass() .field { name = "mIcon" }.get(instance).cast()?.apply {