From f52d234bd23e9da602ed6d3f488751231c2f5439 Mon Sep 17 00:00:00 2001 From: YifePlayte <62252171+YifePlayte@users.noreply.github.com> Date: Fri, 3 May 2024 00:17:18 +0800 Subject: [PATCH] Sort apps by app's names in bullet screen notification settings --- app/build.gradle.kts | 1 + .../hook/hooks/multipackage/ForceSupportBarrage.kt | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a5913a0..a9e4b77 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -86,6 +86,7 @@ android { dependencies { compileOnly("de.robv.android.xposed:api:82") implementation("com.github.kyuubiran:EzXHelper:2.1.1") + implementation("io.github.ranlee1:jpinyin:1.0.1") implementation("org.luckypray:dexkit:2.0.0") implementation(project(":blockmiui")) } diff --git a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/multipackage/ForceSupportBarrage.kt b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/multipackage/ForceSupportBarrage.kt index 3a100e3..d617461 100644 --- a/app/src/main/java/com/yifeplayte/wommo/hook/hooks/multipackage/ForceSupportBarrage.kt +++ b/app/src/main/java/com/yifeplayte/wommo/hook/hooks/multipackage/ForceSupportBarrage.kt @@ -13,6 +13,8 @@ import com.github.kyuubiran.ezxhelper.ObjectUtils.getObjectOrNullAs import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder import com.yifeplayte.wommo.hook.hooks.BaseMultiHook import com.yifeplayte.wommo.hook.utils.DexKit.dexKitBridge +import io.github.ranlee1.jpinyin.PinyinFormat.WITHOUT_TONE +import io.github.ranlee1.jpinyin.PinyinHelper.convertToPinyinString @Suppress("unused") object ForceSupportBarrage : BaseMultiHook() { @@ -35,12 +37,14 @@ object ForceSupportBarrage : BaseMultiHook() { }.single().getMethodInstance(safeClassLoader).createHook { after { param -> val barragePackageList = appContext.packageManager.getInstalledApplications(0) - .filter { (it.flags and ApplicationInfo.FLAG_SYSTEM) != 1 } - .map { it.packageName }.filter { + .filter { (it.flags and ApplicationInfo.FLAG_SYSTEM) != 1 }.filter { methodAreNotificationsEnabled.invoke( - clazzNotificationFilterHelper, appContext, it + clazzNotificationFilterHelper, appContext, it.packageName ) == true - } + }.associateWith { + val label = it.loadLabel(appContext.packageManager).toString() + convertToPinyinString(label, "", WITHOUT_TONE).lowercase() + }.entries.sortedBy { it.value }.map { it.key.packageName } @Suppress("UNCHECKED_CAST") val supportedList = param.result as MutableList for (s in barragePackageList) { if (!supportedList.contains(s)) supportedList.add(s)