diff --git a/app/src/main/java/cc/ioctl/hook/sideswipe/SimplifyQQSettingMe.kt b/app/src/main/java/cc/ioctl/hook/sideswipe/SimplifyQQSettingMe.kt index 6d5ebba087..8a71addb1b 100644 --- a/app/src/main/java/cc/ioctl/hook/sideswipe/SimplifyQQSettingMe.kt +++ b/app/src/main/java/cc/ioctl/hook/sideswipe/SimplifyQQSettingMe.kt @@ -52,19 +52,24 @@ import io.github.qauxv.util.QQVersion.QQ_8_6_0 import io.github.qauxv.util.QQVersion.QQ_8_6_5 import io.github.qauxv.util.QQVersion.QQ_8_8_11 import io.github.qauxv.util.QQVersion.QQ_8_9_23 +import io.github.qauxv.util.dexkit.DexKit +import io.github.qauxv.util.dexkit.QQ_SETTING_ME_CONFIG_CLASS import io.github.qauxv.util.hostInfo import io.github.qauxv.util.requireMinQQVersion import xyz.nextalone.base.MultiItemDelayableHook +import xyz.nextalone.util.* import xyz.nextalone.util.clazz import xyz.nextalone.util.get import xyz.nextalone.util.hide import xyz.nextalone.util.throwOrTrue +import java.lang.reflect.Array +import java.lang.reflect.Modifier import java.util.SortedMap //侧滑栏精简 @FunctionHookEntry @UiItemAgentEntry -object SimplifyQQSettingMe : MultiItemDelayableHook("SimplifyQQSettingMe") { +object SimplifyQQSettingMe : MultiItemDelayableHook("SimplifyQQSettingMe",targets = arrayOf(QQ_SETTING_ME_CONFIG_CLASS)) { const val MidContentName = "SimplifyQQSettingMe::MidContentName" @@ -238,6 +243,34 @@ object SimplifyQQSettingMe : MultiItemDelayableHook("SimplifyQQSettingMe") { if (requireMinQQVersion(QQVersion.QQ_8_9_88)) "com.tencent.mobileqq.QQSettingMeViewV9" else "com.tencent.mobileqq.activity.QQSettingMeViewV9" ) + + // 转化为View之前删除数据 + if (requireMinQQVersion(QQVersion.QQ_8_9_90)) { + val m = DexKit.requireClassFromCache(QQ_SETTING_ME_CONFIG_CLASS).declaredMethods.first { it.isPublic && it.returnType.name.contains("QQSettingMeBizBean") } + m.hookAfter { param -> + val qqSettingMeBizBeanArray = param.result + val cSettingMeBizBean = qqSettingMeBizBeanArray::class.java.componentType!! + // 先初始化一个可变列表 + val purifiedList = mutableListOf() + // 遍历这个数组 + for (i in 0 until Array.getLength(param.result) - 1) { + // 获取单个QQSettingMeBizBean + val item = Array.get(qqSettingMeBizBeanArray,i)!! + val itemId = item.get(String::class.java) as String + // 获取需要被删掉的列表 ( 超级QQ秀直接删除有bug[空指针(QQ你怎么不校验一下,哭)],应该在View里面隐藏 + val del = items2Hide.filter { activeItems.contains(it.key) }.values.toMutableList().apply { remove("d_zplan") } + // 如果不为需要删除的,就添加到返回列表 + if (!del.contains(itemId)){ purifiedList.add(item) } + } + val returnArray = Array.newInstance(cSettingMeBizBean,purifiedList.size) + for (i in purifiedList.indices){ + Array.set(returnArray,i,purifiedList[i]) + } + param.result = returnArray + } + } + + // View层隐藏超级QQ秀 (到这里应该只需要处理 超级QQ秀 了 if (requireMinQQVersion(QQVersion.QQ_9_0_0)) { if (clazz != null) { val cz = clazz.superclass.superclass diff --git a/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt b/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt index 77e43891b8..0b255612e9 100644 --- a/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt +++ b/app/src/main/java/io/github/qauxv/hook/CommonConfigFunctionHook.kt @@ -44,7 +44,7 @@ abstract class CommonConfigFunctionHook( constructor() : this(null, false) constructor(defaultEnabled: Boolean) : this(null, defaultEnabled) constructor(key: String) : this(key, false) - constructor(key: String, targets: Array) : this(key, false, targets) + constructor(key: String, targets: Array?) : this(key, false, targets) constructor(targets: Array) : this(null, false, targets) constructor(key: String, targetProc: Int) : this(hookKey = key, targetProc = targetProc) constructor(targetProc: Int) : this(null, targetProc = targetProc) diff --git a/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt b/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt index 94559ed215..d7143947f7 100644 --- a/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt +++ b/app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt @@ -835,3 +835,11 @@ data object EmotionDownloadEnableSwitch: DexKitTarget.UsingStringVector() { override val declaringClass: String = "" override val filter = DexKitFilter.strInClsName("com/tencent/mobileqq/emotionintegrate/") } + + +data object QQ_SETTING_ME_CONFIG_CLASS: DexKitTarget.UsingStringVector() { + override val findMethod: Boolean = false; + override val traitStringVectors: Array> = arrayOf(arrayOf("超级QQ秀","我的视频","我的文件","我的收藏","我的相册","我的小游戏","免流量","我的个性装扮","财富小金库","我的QQ钱包","开通会员","我的小世界","直播")) + override val declaringClass: String = "" + override val filter = DexKitFilter.allowAll +} diff --git a/app/src/main/java/xyz/nextalone/base/MultiItemDelayableHook.kt b/app/src/main/java/xyz/nextalone/base/MultiItemDelayableHook.kt index 1f2e70c3eb..6b0aba6aa1 100644 --- a/app/src/main/java/xyz/nextalone/base/MultiItemDelayableHook.kt +++ b/app/src/main/java/xyz/nextalone/base/MultiItemDelayableHook.kt @@ -37,12 +37,13 @@ import io.github.qauxv.hook.CommonConfigFunctionHook import io.github.qauxv.ui.CommonContextWrapper import io.github.qauxv.util.Log import io.github.qauxv.util.Toasts +import io.github.qauxv.util.dexkit.DexKitTarget import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.update import me.ketal.data.ConfigData -abstract class MultiItemDelayableHook(keyName: String) : - CommonConfigFunctionHook(keyName) { +abstract class MultiItemDelayableHook(keyName: String,targets: Array? = null) : + CommonConfigFunctionHook(keyName,targets) { abstract val preferenceTitle: String open val preferenceSummary = ""