新增 解除通知图标个数上限

This commit is contained in:
LittleTurtle2333
2022-02-18 00:08:14 +08:00
parent a6166fa70a
commit 1d917f607d
4 changed files with 48 additions and 20 deletions

View File

@@ -10,8 +10,8 @@ android {
applicationId "com.lt2333.simplicitytools" applicationId "com.lt2333.simplicitytools"
minSdk 30 minSdk 30
targetSdk 32 targetSdk 32
versionCode 6 versionCode 8
versionName '1.0.5' versionName '1.0.7'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@@ -377,24 +377,48 @@ class SystemUI : IXposedHookLoadPackage {
} }
//通知图标上限 //通知图标上限
try { if (prefs.hasFileChanged()) {
val classIfExists = XposedHelpers.findClassIfExists( prefs.reload()
"com.android.systemui.statusbar.phone.NotificationIconContainer",
lpparam.classLoader
)
XposedHelpers.findAndHookMethod(
classIfExists,
"miuiShowNotificationIcons",
Boolean::class.java,
object : XC_MethodHook() {
override fun beforeHookedMethod(param: MethodHookParam) {
}
})
} catch (e: Exception) {
XposedBridge.log(e)
} }
if (prefs.getBoolean("remove_the_maximum_number_of_notification_icons", false)) {
try {
val classIfExists = XposedHelpers.findClassIfExists(
"com.android.systemui.statusbar.phone.NotificationIconContainer",
lpparam.classLoader
)
XposedHelpers.findAndHookMethod(
classIfExists,
"miuiShowNotificationIcons",
Boolean::class.java,
object : XC_MethodReplacement() {
override fun replaceHookedMethod(param: MethodHookParam) {
if (param.args[0] as Boolean) {
XposedHelpers.setIntField(param.thisObject, "MAX_DOTS", 30)
XposedHelpers.setIntField(param.thisObject, "MAX_STATIC_ICONS", 30)
XposedHelpers.setIntField(
param.thisObject,
"MAX_VISIBLE_ICONS_ON_LOCK",
30
)
} else {
XposedHelpers.setIntField(param.thisObject, "MAX_DOTS", 0)
XposedHelpers.setIntField(param.thisObject, "MAX_STATIC_ICONS", 0)
XposedHelpers.setIntField(
param.thisObject,
"MAX_VISIBLE_ICONS_ON_LOCK",
0
)
}
XposedHelpers.callMethod(param.thisObject, "updateState")
}
})
} catch (e: Exception) {
XposedBridge.log(e)
}
}
} }
} }

View File

@@ -45,5 +45,6 @@
<string name="statusbar">状态栏(重启系统界面生效)</string> <string name="statusbar">状态栏(重启系统界面生效)</string>
<string name="status_bar_time_seconds">时钟显秒</string> <string name="status_bar_time_seconds">时钟显秒</string>
<string name="status_bar_network_speed_refresh_speed">网速秒刷新</string> <string name="status_bar_network_speed_refresh_speed">网速秒刷新</string>
<string name="remove_the_maximum_number_of_notification_icons">解除通知图标个数上限</string>
</resources> </resources>

View File

@@ -1,5 +1,4 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory <PreferenceCategory
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
@@ -21,6 +20,10 @@
app:iconSpaceReserved="false" app:iconSpaceReserved="false"
app:key="status_bar_network_speed_refresh_speed" app:key="status_bar_network_speed_refresh_speed"
app:title="@string/status_bar_network_speed_refresh_speed" /> app:title="@string/status_bar_network_speed_refresh_speed" />
<SwitchPreference
app:iconSpaceReserved="false"
app:key="remove_the_maximum_number_of_notification_icons"
app:title="@string/remove_the_maximum_number_of_notification_icons" />
</PreferenceCategory> </PreferenceCategory>