From 4190f41980bf0f18b6b7f678ebc6cfc02f997fbf Mon Sep 17 00:00:00 2001 From: ztc1997 Date: Fri, 11 Mar 2022 22:26:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=20=E5=A2=9E=E5=BC=BA=EF=BC=9A=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=80=9A=E7=9F=A5=E9=87=8D=E8=A6=81=E7=A8=8B=E5=BA=A6?= =?UTF-8?q?=EF=BC=9A=E5=8D=B3=E6=97=B6=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/ShowNotificationImportance.kt | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/settings/ShowNotificationImportance.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/settings/ShowNotificationImportance.kt index 352cc548..cc1a9faa 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/settings/ShowNotificationImportance.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/settings/ShowNotificationImportance.kt @@ -1,73 +1,73 @@ package com.lt2333.simplicitytools.hook.app.settings import android.app.NotificationChannel -import com.lt2333.simplicitytools.util.XSPUtils +import com.lt2333.simplicitytools.util.* import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.XC_MethodHook import de.robv.android.xposed.XposedHelpers import de.robv.android.xposed.callbacks.XC_LoadPackage -class ShowNotificationImportance: IXposedHookLoadPackage { +class ShowNotificationImportance : IXposedHookLoadPackage { override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) { - if (!XSPUtils.getBoolean("show_notification_importance", false)) return - val channelNotificationSettingsClass = XposedHelpers.findClass( "com.android.settings.notification.ChannelNotificationSettings", lpparam.classLoader ) - XposedHelpers.findAndHookMethod(channelNotificationSettingsClass, "removeDefaultPrefs", + channelNotificationSettingsClass.hookMethod("removeDefaultPrefs", object : XC_MethodHook() { - override fun beforeHookedMethod(param: MethodHookParam) { - val importance = - XposedHelpers.callMethod(param.thisObject, "findPreference", "importance") - val mChannel = - XposedHelpers.getObjectField(param.thisObject, "mChannel") as NotificationChannel - val index = XposedHelpers.callMethod( - importance, - "findSpinnerIndexOfValue", - mChannel.importance.toString() - ) as Int - if (index < 0) return@beforeHookedMethod + override fun beforeHookedMethod(param: MethodHookParam) { + if (!XSPUtils.getBoolean("show_notification_importance", false)) return - XposedHelpers.callMethod(importance, "setValueIndex", index) + val importance = + param.thisObject.callMethod("findPreference", "importance") ?: return + val mChannel = + param.thisObject.getObjectField("mChannel") as NotificationChannel + val index = importance.callMethod( + "findSpinnerIndexOfValue", + mChannel.importance.toString() + ) as Int + if (index < 0) return - XposedHelpers.setAdditionalInstanceField( - importance, - "channelNotificationSettings", - param.thisObject - ) + importance.callMethod("setValueIndex", index) - param.result = null - } - }) + XposedHelpers.setAdditionalInstanceField( + importance, + "channelNotificationSettings", + param.thisObject + ) + + param.result = null + } + }) val dropDownPreferenceClass = XposedHelpers.findClass( "androidx.preference.Preference", lpparam.classLoader ) - XposedHelpers.findAndHookMethod(dropDownPreferenceClass, "callChangeListener", + dropDownPreferenceClass.hookMethod("callChangeListener", Any::class.java, object : XC_MethodHook() { - override fun afterHookedMethod(param: MethodHookParam) { - val channelNotificationSettings = XposedHelpers.getAdditionalInstanceField( - param.thisObject, - "channelNotificationSettings" - ) - ?: return@afterHookedMethod + override fun afterHookedMethod(param: MethodHookParam) { + val channelNotificationSettings = XposedHelpers.getAdditionalInstanceField( + param.thisObject, + "channelNotificationSettings" + ) ?: return@afterHookedMethod - val mChannel = XposedHelpers.getObjectField( - channelNotificationSettings, - "mChannel" - ) as NotificationChannel - XposedHelpers.callMethod(mChannel, "setImportance", (param.args[0] as String).toInt()) + val mChannel = XposedHelpers.getObjectField( + channelNotificationSettings, + "mChannel" + ) as NotificationChannel - val mBackend = XposedHelpers.getObjectField(channelNotificationSettings, "mBackend") - val mPkg = - XposedHelpers.getObjectField(channelNotificationSettings, "mPkg") as String - val mUid = XposedHelpers.getObjectField(channelNotificationSettings, "mUid") as Int - XposedHelpers.callMethod(mBackend, "updateChannel", mPkg, mUid, mChannel) - } - }) + mChannel.callMethod( + "setImportance", (param.args[0] as String).toInt() + ) + + val mBackend = channelNotificationSettings.getObjectField("mBackend") ?: return + val mPkg = channelNotificationSettings.getObjectField("mPkg") as String + val mUid = channelNotificationSettings.getIntField("mUid") + mBackend.callMethod("updateChannel", mPkg, mUid, mChannel) + } + }) } } \ No newline at end of file From b7f948a3bcd3074e226d3432a25548e9da7c5ee1 Mon Sep 17 00:00:00 2001 From: ztc1997 Date: Fri, 11 Mar 2022 22:26:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=80=9A=E7=9F=A5=E9=87=8D=E8=A6=81=E7=A8=8B=E5=BA=A6?= =?UTF-8?q?=EF=BC=9A=E4=BF=AE=E5=A4=8D=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 强迫症 --- app/src/main/res/values-zh-rCN/strings.xml | 2 +- app/src/main/res/values-zh-rHK/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 70cc9326..bfe7d2cc 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -145,7 +145,7 @@ *移除OTA验证 [实验性] - 仅支持VAB系列使用,其余系列请不要开启。\n- 无需内测试资格即可刷入完整内测包。\n- 拥有内测权限的用户将无法接收内测更新\n可用于屏蔽系统更新。\n- 跨版本类型升级后,建议清空数据。\n- 不支持非官方ROM使用。 设置 - 显示 MIUI12 及之后版本被隐藏的通知重要程度设置 + 显示 MIUI 12 及之后版本被隐藏的通知重要程度设置 显示通知重要程度 去广告 移除主题壁纸的广告 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 8464fb8c..dac2427a 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -144,7 +144,7 @@ 系統更新 *移除OTA驗證 [實驗性] - 僅支持VAB系列使用,其餘系列請不要開啟。\n- 無需內測試資格即可刷入完整內測包。\n- 擁有內測權限的用戶將無法接收內測更新\n可用於屏蔽系統更新。\n- 跨版本類型升級後,建議清空數據。\n- 不支持非官方ROM使用。 - 顯示 MIUI12 及之後版本被隱藏的通知重要程度設定 + 顯示 MIUI 12 及之後版本被隱藏的通知重要程度設定 顯示通知重要程度 設定 去廣告 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 12999e81..e3eb3c08 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -145,7 +145,7 @@ *移除OTA驗證 [實驗性] - 僅支持VAB系列使用,其餘系列請不要開啟。\n- 無需內測試資格即可刷入完整內測包。\n- 擁有內測權限的用戶將無法接收內測更新\n可用於屏蔽系統更新。\n- 跨版本類型升級後,建議清空數據。\n- 不支持非官方ROM使用。 顯示通知重要程度 - 顯示 MIUI12 及之後版本被隱藏的通知重要程度設定 + 顯示 MIUI 12 及之後版本被隱藏的通知重要程度設定 設定 去廣告 拿掉主題壁紙的廣告