Skip to content

Commit

Permalink
feat: ShowMsgAt OpenProfileCard with troop info for QQNT
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Jul 23, 2023
1 parent 151c140 commit 3e94911
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 9 additions & 1 deletion app/src/main/java/cc/ioctl/hook/profile/OpenProfileCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,25 @@ 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) {
Log.e("QSecO3AddRiskRequestMitigation init fail", e);
}
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) {
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/me/ketal/hook/ShowMsgAt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -140,7 +140,7 @@ object ShowMsgAt : CommonSwitchFunctionHook(), OnBubbleBuilder {
}
}

private fun setAtSpanBySearch(textView: TextView, atElements: List<TextElement>) {
private fun setAtSpanBySearch(textView: TextView, atElements: List<TextElement>, troopUin: Long) {
val text = textView.text
val ssb = SpannableString(text)
for (at in atElements) {
Expand All @@ -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
Expand All @@ -171,9 +171,9 @@ object ShowMsgAt : CommonSwitchFunctionHook(), OnBubbleBuilder {
if (atElements.isEmpty()) {
return
}
val tv = rootView.findHostView<TextView>(NAME_TEXTVIEW) ?: throw Exception("TextView not found")
val tv = rootView.findHostView<TextView>(NAME_TEXTVIEW) ?: return
// TODO 2023-07-19 更稳定查找TextView
setAtSpanBySearch(tv, atElements)
setAtSpanBySearch(tv, atElements, chatMessage.peerUin)
}

private fun copeAtInfo(textView: TextView, atList: List<*>) {
Expand Down

0 comments on commit 3e94911

Please sign in to comment.