From 3e94911eca4650ba3665668f3d57e4a7759a3396 Mon Sep 17 00:00:00 2001 From: klxiaoniu Date: Sun, 23 Jul 2023 13:56:24 +0800 Subject: [PATCH] feat: ShowMsgAt OpenProfileCard with troop info for QQNT --- .../java/cc/ioctl/hook/profile/OpenProfileCard.java | 10 +++++++++- app/src/main/java/me/ketal/hook/ShowMsgAt.kt | 12 ++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/cc/ioctl/hook/profile/OpenProfileCard.java b/app/src/main/java/cc/ioctl/hook/profile/OpenProfileCard.java index 296f0d298a..b01dbcf16c 100644 --- a/app/src/main/java/cc/ioctl/hook/profile/OpenProfileCard.java +++ b/app/src/main/java/cc/ioctl/hook/profile/OpenProfileCard.java @@ -155,6 +155,10 @@ public static void openTroopProfileActivity(@NonNull Context context, @NonNull S } public static void openUserProfileCard(@NonNull Context ctx, long uin) { + openUserProfileCard(ctx, uin, 0); + } + + public static void openUserProfileCard(@NonNull Context ctx, long uin, long troopUin) { try { QSecO3AddRiskRequestMitigation.INSTANCE.initialize(); } catch (Exception | LinkageError e) { @@ -162,10 +166,14 @@ public static void openUserProfileCard(@NonNull Context ctx, long uin) { } try { Parcelable allInOne = (Parcelable) Reflex.newInstance( - Initiator._AllInOne(), "" + uin, 35, + Initiator._AllInOne(), "" + uin, troopUin != 0 ? 20 : 35, String.class, int.class); Intent intent = new Intent(ctx, Initiator._FriendProfileCardActivity()); intent.putExtra("AllInOne", allInOne); + if (troopUin != 0) { + intent.putExtra("memberUin", "" + uin); + intent.putExtra("troopUin", "" + troopUin); + } intent.putExtra(QSecO3AddRiskRequestMitigation.KEY_UIN_IS_FROM_VOID, true); ctx.startActivity(intent); } catch (Exception e) { diff --git a/app/src/main/java/me/ketal/hook/ShowMsgAt.kt b/app/src/main/java/me/ketal/hook/ShowMsgAt.kt index 566f517245..1d56cd9762 100644 --- a/app/src/main/java/me/ketal/hook/ShowMsgAt.kt +++ b/app/src/main/java/me/ketal/hook/ShowMsgAt.kt @@ -119,7 +119,7 @@ object ShowMsgAt : CommonSwitchFunctionHook(), OnBubbleBuilder { }.show() } - private fun createClickSpanForUid(uid: String?): ClickableSpan { + private fun createClickSpanForUid(uid: String?, troopUin: Long): ClickableSpan { return object : ClickableSpan() { override fun onClick(widget: View) { val ctx = widget.context @@ -130,7 +130,7 @@ object ShowMsgAt : CommonSwitchFunctionHook(), OnBubbleBuilder { createUnknownUidDialog(ctx, uid) return } else { - OpenProfileCard.openUserProfileCard(ctx, uin.toLong()) + OpenProfileCard.openUserProfileCard(ctx, uin.toLong(), troopUin) } } catch (e: Exception) { FaultyDialog.show(ctx, e) @@ -140,7 +140,7 @@ object ShowMsgAt : CommonSwitchFunctionHook(), OnBubbleBuilder { } } - private fun setAtSpanBySearch(textView: TextView, atElements: List) { + private fun setAtSpanBySearch(textView: TextView, atElements: List, troopUin: Long) { val text = textView.text val ssb = SpannableString(text) for (at in atElements) { @@ -149,7 +149,7 @@ object ShowMsgAt : CommonSwitchFunctionHook(), OnBubbleBuilder { val start = text.indexOf(at.content) if (start == -1) continue val end = start + at.content.length - ssb.setSpan(createClickSpanForUid(uid), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) + ssb.setSpan(createClickSpanForUid(uid, troopUin), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) } } textView.text = ssb @@ -171,9 +171,9 @@ object ShowMsgAt : CommonSwitchFunctionHook(), OnBubbleBuilder { if (atElements.isEmpty()) { return } - val tv = rootView.findHostView(NAME_TEXTVIEW) ?: throw Exception("TextView not found") + val tv = rootView.findHostView(NAME_TEXTVIEW) ?: return // TODO 2023-07-19 更稳定查找TextView - setAtSpanBySearch(tv, atElements) + setAtSpanBySearch(tv, atElements, chatMessage.peerUin) } private fun copeAtInfo(textView: TextView, atList: List<*>) {