From e03234a4ea2a6ef0f26054eef46c7c8df5beb473 Mon Sep 17 00:00:00 2001 From: hd <1839732296@qq.com> Date: Sat, 9 Nov 2024 19:32:18 +0800 Subject: [PATCH] fix: TimProfileSelectable on 4.0.95+ --- .../com/xiaoniu/hook/TimProfileSelectable.kt | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/xiaoniu/hook/TimProfileSelectable.kt b/app/src/main/java/com/xiaoniu/hook/TimProfileSelectable.kt index e7a9843fe0..acb502b15b 100644 --- a/app/src/main/java/com/xiaoniu/hook/TimProfileSelectable.kt +++ b/app/src/main/java/com/xiaoniu/hook/TimProfileSelectable.kt @@ -30,25 +30,33 @@ import io.github.qauxv.hook.CommonSwitchFunctionHook import io.github.qauxv.util.TIMVersion import io.github.qauxv.util.requireMinTimVersion import xyz.nextalone.util.clazz +import xyz.nextalone.util.get import xyz.nextalone.util.hookAfterAllConstructors import xyz.nextalone.util.throwOrTrue @FunctionHookEntry @UiItemAgentEntry object TimProfileSelectable : CommonSwitchFunctionHook() { - override val name = "TIM账号资料文字可选中" + override val name = "TIM账号资料文字可选中" override val description = "解决资料卡无法复制QQ号的问题" - + override val uiItemLocation = Auxiliary.PROFILE_CATEGORY override val isAvailable = requireMinTimVersion(TIMVersion.TIM_3_1_1) + override fun initOnce() = throwOrTrue { - val clz = "com.tencent.tim.activity.profile.ProfileCellView".clazz!! - val textView = clz.declaredFields.last { it.type == TextView::class.java }.apply { isAccessible = true } - clz.hookAfterAllConstructors { param -> - val view = textView.get(param.thisObject) as TextView - view.setTextIsSelectable(true) + if (requireMinTimVersion(TIMVersion.TIM_4_0_95)) { + val clazz = "com.tencent.mobileqq.profilecard.ProfileCellView".clazz!! + clazz.hookAfterAllConstructors { param -> + val textView = param.thisObject.get("mTvProfileContent") as TextView + textView.setTextIsSelectable(true) + } + } else { + val clazz = "com.tencent.tim.activity.profile.ProfileCellView".clazz!! + val field = clazz.declaredFields.last { it.type == TextView::class.java }.apply { isAccessible = true } + clazz.hookAfterAllConstructors { param -> + val textView = field.get(param.thisObject) as TextView + textView.setTextIsSelectable(true) + } } } - - override val uiItemLocation = Auxiliary.PROFILE_CATEGORY } \ No newline at end of file