fix: getStatusBarTickerIcon/getStatusBarTickerDarkIcon lost state color in SystemUIHooker

This commit is contained in:
2024-12-13 17:39:03 +08:00
parent 8b6d35fa01
commit f00f6efcf3

View File

@@ -87,6 +87,7 @@ import com.highcapable.yukihookapi.hook.factory.hasMethod
import com.highcapable.yukihookapi.hook.factory.injectModuleAppResources import com.highcapable.yukihookapi.hook.factory.injectModuleAppResources
import com.highcapable.yukihookapi.hook.factory.method import com.highcapable.yukihookapi.hook.factory.method
import com.highcapable.yukihookapi.hook.log.YLog import com.highcapable.yukihookapi.hook.log.YLog
import com.highcapable.yukihookapi.hook.param.HookParam
import com.highcapable.yukihookapi.hook.type.android.ContextClass import com.highcapable.yukihookapi.hook.type.android.ContextClass
import com.highcapable.yukihookapi.hook.type.android.DrawableClass import com.highcapable.yukihookapi.hook.type.android.DrawableClass
import com.highcapable.yukihookapi.hook.type.android.ImageViewClass import com.highcapable.yukihookapi.hook.type.android.ImageViewClass
@@ -982,24 +983,41 @@ object SystemUIHooker : YukiBaseHooker() {
} }
} }
/** 去他妈的焦点通知彩色图标 */ /** 去他妈的焦点通知彩色图标 */
FocusUtilsClass?.method { FocusUtilsClass?.apply {
name { it == "getStatusBarTickerDarkIcon" || it == "getStatusBarTickerIcon" } fun HookParam.hookTickerDarkIcon(isDark: Boolean) {
param { (it[0] == StatusBarNotificationClass || it[0] == ExpandedNotificationClass) && it.size == 1 } (globalContext ?: args().first().cast())?.also { context ->
}?.hookAll()?.after { val expandedNf = args().first().cast<StatusBarNotification?>()
(globalContext ?: args().first().cast())?.also { context -> val small = expandedNf?.notification?.smallIcon
val expandedNf = args().first().cast<StatusBarNotification?>() /** Hook 状态栏小图标 */
val small = expandedNf?.notification?.smallIcon compatStatusIcon(
/** Hook 状态栏小图标 */ context = context,
compatStatusIcon( nf = expandedNf,
context = context, iconDrawable = small?.loadDrawable(context)
nf = expandedNf, ).also { pair ->
iconDrawable = small?.loadDrawable(context) val originalBitmap = pair.first?.toBitmap()
).also { pair -> val bitmap = originalBitmap?.let { Bitmap.createScaledBitmap(it, 50, 50, true) }
val originalBitmap = pair.first?.toBitmap() result = Icon.createWithBitmap(bitmap).apply { setTint(if (isDark) Color.BLACK else Color.WHITE) }
val bitmap = originalBitmap?.let { Bitmap.createScaledBitmap(it, 50, 50, true) } }
result = Icon.createWithBitmap(bitmap).apply { setTint(Color.BLACK) }
} }
} }
method {
name = "getStatusBarTickerDarkIcon"
param(StatusBarNotificationClass)
}.remedys {
method {
name = "getStatusBarTickerDarkIcon"
param(ExpandedNotificationClass)
}
}.hook().after { hookTickerDarkIcon(isDark = true) }
method {
name = "getStatusBarTickerIcon"
param(StatusBarNotificationClass)
}.remedys {
method {
name = "getStatusBarTickerIcon"
param(ExpandedNotificationClass)
}
}.hook().after { hookTickerDarkIcon(isDark = false) }
} }
/** 注入状态栏通知图标实例 */ /** 注入状态栏通知图标实例 */
StatusBarIconViewClass.method { StatusBarIconViewClass.method {
@@ -1124,7 +1142,7 @@ object SystemUIHooker : YukiBaseHooker() {
name = "resetViewStates" name = "resetViewStates"
}.hook().after { }.hook().after {
updateStatusBarIconsAlpha(instance()) updateStatusBarIconsAlpha(instance())
/** HyperOS系统设置修改通知图标个数触发此方法 */ /** HyperOS 系统设置修改通知图标个数触发此方法 */
hookStatusBarMaxStaticIcons(instance) hookStatusBarMaxStaticIcons(instance)
} }
method { method {