Skip to content

Commit

Permalink
fix: ShowMsgCount on QQ(8.9.63~9.0.0)
Browse files Browse the repository at this point in the history
Closes #1075
  • Loading branch information
HdShare committed Jul 13, 2024
1 parent 20ef3e0 commit a16b4f6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/src/main/java/cc/ioctl/hook/msg/ShowMsgCount.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ import cc.ioctl.util.HookUtils.BeforeAndAfterHookedMethod
import cc.ioctl.util.HookUtils.hookBeforeAndAfterIfEnabled
import cc.ioctl.util.LayoutHelper
import cc.ioctl.util.hookBeforeIfEnabled
import com.github.kyuubiran.ezxhelper.utils.hookAfter
import de.robv.android.xposed.XC_MethodHook.MethodHookParam
import io.github.qauxv.base.annotation.FunctionHookEntry
import io.github.qauxv.base.annotation.UiItemAgentEntry
import io.github.qauxv.dsl.FunctionEntryRouter
import io.github.qauxv.hook.CommonSwitchFunctionHook
import io.github.qauxv.util.Initiator
import io.github.qauxv.util.QQVersion
import io.github.qauxv.util.dexkit.AIOTitleVB_updateLeftTopBack_NT
import io.github.qauxv.util.dexkit.CCustomWidgetUtil_updateCustomNoteTxt_NT
import io.github.qauxv.util.dexkit.DexKit
import io.github.qauxv.util.dexkit.NCustomWidgetUtil_updateCustomNoteTxt
import io.github.qauxv.util.requireMinQQVersion
import xyz.nextalone.util.get
import xyz.nextalone.util.throwOrTrue

/**
Expand All @@ -51,6 +54,7 @@ import xyz.nextalone.util.throwOrTrue
object ShowMsgCount : CommonSwitchFunctionHook(
targets = arrayOf(
NCustomWidgetUtil_updateCustomNoteTxt,
AIOTitleVB_updateLeftTopBack_NT,
CCustomWidgetUtil_updateCustomNoteTxt_NT,
)
) {
Expand Down Expand Up @@ -78,6 +82,25 @@ object ShowMsgCount : CommonSwitchFunctionHook(
param.result = null
}
} else {
// 群聊左上角返回(8.9.63~9.0.0)
DexKit.requireMethodFromCache(AIOTitleVB_updateLeftTopBack_NT).hookAfter {
if (it.args[0] is Int) {
val count = it.args[0] as Int
if (count > 0) {
val (mTitleBinding, unreadTv) = when {
requireMinQQVersion(QQVersion.QQ_9_0_0) -> Pair("e", "v")
requireMinQQVersion(QQVersion.QQ_8_9_80) -> Pair("e", "s")
requireMinQQVersion(QQVersion.QQ_8_9_70) -> Pair("e", "t")
requireMinQQVersion(QQVersion.QQ_8_9_63) -> Pair("e", "s")
else -> Pair("", "")
}
if (mTitleBinding.isNotEmpty() && unreadTv.isNotEmpty()) {
(it.thisObject.get(mTitleBinding).get(unreadTv) as TextView).text = "$count"
}
}
}
}

val clz = DexKit.requireClassFromCache(CCustomWidgetUtil_updateCustomNoteTxt_NT)
val updateNum = clz.declaredMethods.single { method ->
val params = method.parameterTypes
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/io/github/qauxv/util/dexkit/DexKitTarget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,14 @@ data object NCustomWidgetUtil_updateCustomNoteTxt : DexKitTarget.UsingStr() {
override val filter = DexKitFilter.strInClsName("com/tencent/widget") or DexKitFilter.defpackage and DexKitFilter.notHasSuper
}

data object AIOTitleVB_updateLeftTopBack_NT : DexKitTarget.UsingStr() {
// guess
override val findMethod: Boolean = true
override val declaringClass = "com.tencent.mobileqq.aio.title.AIOTitleVB"
override val traitString = arrayOf("99+")
override val filter = DexKitFilter.strInClsName("com/tencent/mobileqq/aio/title/")
}

data object CCustomWidgetUtil_updateCustomNoteTxt_NT : DexKitTarget.UsingStr() {
// guess
override val declaringClass = "com.tencent.widget.CustomWidgetUtil"
Expand Down

0 comments on commit a16b4f6

Please sign in to comment.