Skip to content

Commit

Permalink
fix: HideTroopLevel for QQNT
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Jul 18, 2023
1 parent 7e746b3 commit a43bb7d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/io/github/qauxv/util/Initiator.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ public static Class<?> _ThemeUtil() {
}

public static Class<?> _TroopMemberLevelView() {
return findClassWithSynthetics("com.tencent.mobileqq.troop.troopMemberLevel.TroopMemberNewLevelView",
return findClassWithSynthetics("com.tencent.qqnt.aio.nick.memberlevel.TroopMemberLevelView",
"com.tencent.mobileqq.troop.troopMemberLevel.TroopMemberNewLevelView",
"com.tencent.mobileqq.troop.widget.troopmemberlevel.TroopMemberNewLevelView");
}

Expand Down
16 changes: 14 additions & 2 deletions app/src/main/java/xyz/nextalone/hook/HideTroopLevel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
package xyz.nextalone.hook

import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.core.view.children
import androidx.core.view.isVisible
import com.tencent.qqnt.kernel.nativeinterface.MsgRecord
import de.robv.android.xposed.XC_MethodHook
import io.github.qauxv.base.annotation.UiItemAgentEntry
import io.github.qauxv.bridge.ntapi.ChatTypeConstants
import io.github.qauxv.dsl.FunctionEntryRouter
import io.github.qauxv.hook.CommonSwitchFunctionHook
import io.github.qauxv.util.Initiator._TroopMemberLevelView
Expand Down Expand Up @@ -69,7 +72,16 @@ object HideTroopLevel : CommonSwitchFunctionHook(), OnBubbleBuilder {
}

override fun onGetViewNt(rootView: ViewGroup, chatMessage: MsgRecord, param: XC_MethodHook.MethodHookParam) {
if (!isEnabled) return

if (!isEnabled || chatMessage.chatType != ChatTypeConstants.GROUP) return
if (levelClass == null) return
val levelView = rootView.findViewByType(levelClass) ?: return
val sendUin = chatMessage.senderUin.toString()
val troopInfo = TroopInfo(chatMessage.peerUid)
val ownerUin = troopInfo.troopOwnerUin
val admin = troopInfo.troopAdmin
val isAdmin = admin?.contains(sendUin) == true || ownerUin == sendUin
//levelView.children.filter { it !is TextView }.forEach { it.visibility = android.view.View.GONE }
// 如果forEach,则会隐藏昵称右侧的部分图标
(levelView as LinearLayout).children.first().isVisible = isAdmin
}
}

0 comments on commit a43bb7d

Please sign in to comment.