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 diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 4a914f64..8d65f5a0 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 620c5040..41a93650 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 debede80..338bee8f 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 及之後版本被隱藏的通知重要程度設定 設定 去廣告 拿掉主題壁紙的廣告