mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 10:45:20 +08:00
Update YukiHookAPI
This commit is contained in:
@@ -64,8 +64,8 @@ tasks.whenTaskAdded {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'de.robv.android.xposed:api:82'
|
compileOnly 'de.robv.android.xposed:api:82'
|
||||||
implementation 'com.highcapable.yukihookapi:api:1.0.4'
|
implementation 'com.highcapable.yukihookapi:api:1.0.5-fix'
|
||||||
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.4'
|
ksp 'com.highcapable.yukihookapi:ksp-xposed:1.0.5-fix'
|
||||||
implementation "com.github.topjohnwu.libsu:core:3.1.2"
|
implementation "com.github.topjohnwu.libsu:core:3.1.2"
|
||||||
implementation 'androidx.annotation:annotation:1.3.0'
|
implementation 'androidx.annotation:annotation:1.3.0'
|
||||||
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
implementation 'com.geyifeng.immersionbar:immersionbar:3.2.0'
|
||||||
|
@@ -122,10 +122,6 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
/** 是否显示通知图标 - 跟随 Hook 保存 */
|
/** 是否显示通知图标 - 跟随 Hook 保存 */
|
||||||
private var isShowNotificationIcons = true
|
private var isShowNotificationIcons = true
|
||||||
|
|
||||||
/** 是否有最大图标设置功能 */
|
|
||||||
private val PackageParam.hasMaxStaticIcons
|
|
||||||
get() = safeOfFalse { NotificationIconContainerClass.clazz.hasField(name = "MAX_STATIC_ICONS") }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* - 这个是修复彩色图标的关键核心代码判断
|
* - 这个是修复彩色图标的关键核心代码判断
|
||||||
*
|
*
|
||||||
@@ -469,19 +465,12 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
} else false.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = true) }
|
} else false.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = true) }
|
||||||
else true.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = false) }
|
else true.also { printLogcat(tag = "IconColor", context, expandedNf, isCustom = false, isGrayscale = false) }
|
||||||
|
|
||||||
override fun onHook() {
|
override fun onInit() = configs {
|
||||||
runConfig()
|
|
||||||
runHook()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 配置 Hook */
|
|
||||||
private fun runConfig() = configs {
|
|
||||||
debugTag = "MIUINativeNotifyIcon"
|
debugTag = "MIUINativeNotifyIcon"
|
||||||
isDebug = false
|
isDebug = false
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 开始 Hook */
|
override fun onHook() = encase {
|
||||||
private fun runHook() = encase {
|
|
||||||
loadApp(SYSTEMUI_PACKAGE_NAME) {
|
loadApp(SYSTEMUI_PACKAGE_NAME) {
|
||||||
when {
|
when {
|
||||||
/** 不是 MIUI 系统停止 Hook */
|
/** 不是 MIUI 系统停止 Hook */
|
||||||
@@ -562,42 +551,41 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasMaxStaticIcons)
|
NotificationIconContainerClass.hook {
|
||||||
NotificationIconContainerClass.hook {
|
injectMember {
|
||||||
injectMember {
|
method { name = "calculateIconTranslations" }
|
||||||
method { name = "calculateIconTranslations" }
|
afterHook {
|
||||||
afterHook {
|
/** 修复最新开发版状态栏图标只能显示一个的问题 */
|
||||||
/** 修复最新开发版状态栏图标只能显示一个的问题 */
|
instance<ViewGroup>().layoutParams.width = 9999
|
||||||
instance<ViewGroup>().layoutParams.width = 9999
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
injectMember {
|
|
||||||
method { name = "updateState" }
|
|
||||||
beforeHook {
|
|
||||||
/** 解除状态栏通知图标个数限制 */
|
|
||||||
if (isShowNotificationIcons && prefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true))
|
|
||||||
field { name = "MAX_STATIC_ICONS" }
|
|
||||||
.get(instance).set(prefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
|
|
||||||
.let { if (it in 0..100) it else 5 })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** 旧版方法 - 新版不存在 */
|
|
||||||
injectMember {
|
|
||||||
method {
|
|
||||||
name = "setMaxStaticIcons"
|
|
||||||
param(IntType)
|
|
||||||
beforeHook { isShowNotificationIcons = firstArgs as Int > 0 }
|
|
||||||
}
|
|
||||||
}.ignoredHookingFailure()
|
|
||||||
/** 新版方法 - 旧版不存在 */
|
|
||||||
injectMember {
|
|
||||||
method {
|
|
||||||
name = "miuiShowNotificationIcons"
|
|
||||||
param(BooleanType)
|
|
||||||
}
|
|
||||||
beforeHook { isShowNotificationIcons = firstArgs as Boolean }
|
|
||||||
}.ignoredHookingFailure()
|
|
||||||
}
|
}
|
||||||
|
injectMember {
|
||||||
|
method { name = "updateState" }
|
||||||
|
beforeHook {
|
||||||
|
/** 解除状态栏通知图标个数限制 */
|
||||||
|
if (isShowNotificationIcons && prefs.getBoolean(ENABLE_HOOK_STATUS_ICON_COUNT, default = true))
|
||||||
|
field { name = "MAX_STATIC_ICONS" }
|
||||||
|
.get(instance).set(prefs.getInt(HOOK_STATUS_ICON_COUNT, default = 5)
|
||||||
|
.let { if (it in 0..100) it else 5 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 旧版方法 - 新版不存在 */
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "setMaxStaticIcons"
|
||||||
|
param(IntType)
|
||||||
|
beforeHook { isShowNotificationIcons = firstArgs as Int > 0 }
|
||||||
|
}
|
||||||
|
}.ignoredNoSuchMemberFailure()
|
||||||
|
/** 新版方法 - 旧版不存在 */
|
||||||
|
injectMember {
|
||||||
|
method {
|
||||||
|
name = "miuiShowNotificationIcons"
|
||||||
|
param(BooleanType)
|
||||||
|
}
|
||||||
|
beforeHook { isShowNotificationIcons = firstArgs as Boolean }
|
||||||
|
}.ignoredNoSuchMemberFailure()
|
||||||
|
}.by { safeOfFalse { NotificationIconContainerClass.clazz.hasField(name = "MAX_STATIC_ICONS") } }
|
||||||
NotificationHeaderViewWrapperClass.hook {
|
NotificationHeaderViewWrapperClass.hook {
|
||||||
/** 修复下拉通知图标自动设置回 APP 图标的方法 */
|
/** 修复下拉通知图标自动设置回 APP 图标的方法 */
|
||||||
injectMember {
|
injectMember {
|
||||||
@@ -659,14 +647,14 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
intercept()
|
intercept()
|
||||||
}.ignoredHookingFailure()
|
}.ignoredNoSuchMemberFailure()
|
||||||
injectMember {
|
injectMember {
|
||||||
method {
|
method {
|
||||||
name = "resetIconBgAndPaddings"
|
name = "resetIconBgAndPaddings"
|
||||||
param(ImageViewClass, ExpandedNotificationClass.clazz)
|
param(ImageViewClass, ExpandedNotificationClass.clazz)
|
||||||
}
|
}
|
||||||
intercept()
|
intercept()
|
||||||
}.ignoredHookingFailure()
|
}.ignoredNoSuchMemberFailure()
|
||||||
}.ignoredHookClassNotFoundFailure()
|
}.ignoredHookClassNotFoundFailure()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user