From 6d62c02b4207a9b481b21d59e54fed1a23cbc88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=A4=AA=E7=99=BD?= <36808766+ghhccghk@users.noreply.github.com> Date: Sun, 8 Dec 2024 19:43:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D=E5=8F=8D?= =?UTF-8?q?=E8=89=B2=E5=BC=82=E5=B8=B8=EF=BC=8C=E5=B9=B6=E4=BB=A5small?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E4=B8=BA=E5=9F=BA=E5=87=86=E3=80=82=20(#218)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../miui/notify/hook/entity/SystemUIHooker.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt b/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt index 00eb978..709b957 100644 --- a/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt +++ b/app/src/main/java/com/fankes/miui/notify/hook/entity/SystemUIHooker.kt @@ -944,18 +944,18 @@ object SystemUIHooker : YukiBaseHooker() { param(ExpandedNotificationClass) } }.hook().after { - globalContext?.also { context -> + (globalContext ?: args().first().cast())?.also { context -> val expandedNf = args().first().cast() + val small = expandedNf?.notification?.smallIcon?.loadDrawable(context) + val icon = small?.toBitmap() /** Hook 状态栏小图标 */ compatStatusIcon( context = context, nf = expandedNf, - iconDrawable = result()?.loadDrawable(context) - ).also { pair -> - if (!pair.second) return@after - val bitmap = pair.first?.toBitmap()?.replaceColor(Color.WHITE, Color.BLACK, tolerance = 210) - result = Icon.createWithBitmap(bitmap) - } + iconDrawable = icon?.toDrawable(context.resources) + ).also { pair -> if (!pair.second) return@after + val bitmap = pair.first?.toBitmap()?.replaceColor(Color.WHITE, Color.BLACK, tolerance = 90) + result = Icon.createWithBitmap(bitmap)} } } method { @@ -969,14 +969,16 @@ object SystemUIHooker : YukiBaseHooker() { }.hook().after { (globalContext ?: args().first().cast())?.also { context -> val expandedNf = args(0).cast() + val small = expandedNf?.notification?.smallIcon?.loadDrawable(context) + val icon = small?.toBitmap() /** Hook 状态栏小图标 */ compatStatusIcon( context = context, nf = expandedNf, - iconDrawable = result()?.loadDrawable(context) - ).also { pair -> - if (pair.second) result = Icon.createWithBitmap(pair.first?.toBitmap()) - } + iconDrawable = icon?.toDrawable(context.resources) + ).also { pair -> if (!pair.second) return@after + val bitmap = pair.first?.toBitmap()?.replaceColor(Color.BLACK, Color.WHITE, tolerance = 90) + result = Icon.createWithBitmap(bitmap)} } } }