mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-05 10:15:31 +08:00
Modify make status icon count function open/close dynamic update in SystemUIHooker, MainActivity
This commit is contained in:
@@ -148,6 +148,9 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
/** 是否显示通知图标 - 跟随 Hook 保存 */
|
/** 是否显示通知图标 - 跟随 Hook 保存 */
|
||||||
private var isShowNotificationIcons = true
|
private var isShowNotificationIcons = true
|
||||||
|
|
||||||
|
/** 状态栏原始通知图标最大个数限制 */
|
||||||
|
private var statusBarMaxStaticIcons = -1
|
||||||
|
|
||||||
/** 是否已经使用过缓存刷新功能 */
|
/** 是否已经使用过缓存刷新功能 */
|
||||||
private var isUsingCachingMethod = false
|
private var isUsingCachingMethod = false
|
||||||
|
|
||||||
@@ -857,11 +860,12 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
injectMember {
|
injectMember {
|
||||||
method { name = "updateState" }
|
method { name = "updateState" }
|
||||||
beforeHook {
|
beforeHook {
|
||||||
|
val maxStaticIconsField = field { name = "MAX_STATIC_ICONS" }.get(instance)
|
||||||
|
if (statusBarMaxStaticIcons == -1) statusBarMaxStaticIcons = maxStaticIconsField.int()
|
||||||
/** 解除状态栏通知图标个数限制 */
|
/** 解除状态栏通知图标个数限制 */
|
||||||
if (isShowNotificationIcons && prefs.get(DataConst.ENABLE_HOOK_STATUS_ICON_COUNT))
|
if (isShowNotificationIcons && prefs.get(DataConst.ENABLE_HOOK_STATUS_ICON_COUNT))
|
||||||
field { name = "MAX_STATIC_ICONS" }
|
maxStaticIconsField.set(prefs.get(DataConst.HOOK_STATUS_ICON_COUNT).let { if (it in 0..100) it else 5 })
|
||||||
.get(instance).set(prefs.get(DataConst.HOOK_STATUS_ICON_COUNT)
|
else maxStaticIconsField.set(statusBarMaxStaticIcons)
|
||||||
.let { if (it in 0..100) it else 5 })
|
|
||||||
}
|
}
|
||||||
}.by { NotificationIconContainerClass.toClassOrNull()?.hasField { name = "MAX_STATIC_ICONS" } ?: false }
|
}.by { NotificationIconContainerClass.toClassOrNull()?.hasField { name = "MAX_STATIC_ICONS" } ?: false }
|
||||||
/** 旧版方法 - 新版不存在 */
|
/** 旧版方法 - 新版不存在 */
|
||||||
|
@@ -201,7 +201,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
|||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
modulePrefs.put(DataConst.ENABLE_HOOK_STATUS_ICON_COUNT, b)
|
modulePrefs.put(DataConst.ENABLE_HOOK_STATUS_ICON_COUNT, b)
|
||||||
binding.statusIconCountChildItem.isVisible = b
|
binding.statusIconCountChildItem.isVisible = b
|
||||||
SystemUITool.showNeedRestartSnake(context = this)
|
SystemUITool.refreshSystemUI(context = this) { snake(msg = "设置将在新通知推送或状态栏刷新后自动生效") }
|
||||||
}
|
}
|
||||||
binding.colorIconCompatSwitch.setOnCheckedChangeListener { btn, b ->
|
binding.colorIconCompatSwitch.setOnCheckedChangeListener { btn, b ->
|
||||||
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
if (btn.isPressed.not()) return@setOnCheckedChangeListener
|
||||||
|
Reference in New Issue
Block a user