Skip to content

Commit

Permalink
fix: HideQZMTitleBarEntrance
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Jul 16, 2023
1 parent 6a92d5f commit a641cee
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
42 changes: 25 additions & 17 deletions app/src/main/java/cc/ioctl/hook/qzone/HideQZMTitleBarEntrance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ import android.view.ViewGroup
import android.widget.ImageView
import cc.ioctl.util.Reflex
import cc.ioctl.util.hookAfterIfEnabled
import com.github.kyuubiran.ezxhelper.utils.hookBefore
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.SyncUtils
import io.github.qauxv.util.dexkit.DexKit
import io.github.qauxv.util.dexkit.NQZMoment_EntranceEnabled
import io.github.qauxv.util.requireMinQQVersion

/**
* Hide QZone-Moment title bar entrance
*/
@[FunctionHookEntry UiItemAgentEntry]
object HideQZMTitleBarEntrance : CommonSwitchFunctionHook(
targetProc = SyncUtils.PROC_MAIN or SyncUtils.PROC_QZONE
targetProc = SyncUtils.PROC_MAIN or SyncUtils.PROC_QZONE,
targets = arrayOf(NQZMoment_EntranceEnabled)
) {

override val name = "隐藏QQ空间此刻按钮"
Expand All @@ -55,22 +59,26 @@ object HideQZMTitleBarEntrance : CommonSwitchFunctionHook(
override val isAvailable: Boolean get() = requireMinQQVersion(QQVersion.QQ_8_9_25)

override fun initOnce(): Boolean {
val kQZMTitleBarEntranceManager = Initiator.loadClass("com.qzone.reborn.qzmoment.itemview.QZMTitleBarEntranceManager")
// com.tencent.mobileqq.zplan_impl.R.id.qzm_entrance_root
val qzm_entrance_root = Initiator.loadClass("com.tencent.mobileqq.R\$id")
.getDeclaredField("qzm_entrance_root").get(null) as Int
check(qzm_entrance_root != 0) { "qzm_entrance_root not found" }
hookAfterIfEnabled(
Reflex.findSingleMethod(
kQZMTitleBarEntranceManager, Void.TYPE, false,
Context::class.java, ViewGroup::class.java, ImageView::class.java
),
) {
// Log.e("HideQZMTitleBarEntrance here", Throwable())
val view = it.args[1] as ViewGroup
val entrance: View? = view.findViewById(qzm_entrance_root)
entrance?.visibility = View.GONE
it.result = null
try {
val kQZMTitleBarEntranceManager = Initiator.loadClass("com.qzone.reborn.qzmoment.itemview.QZMTitleBarEntranceManager")
// com.tencent.mobileqq.zplan_impl.R.id.qzm_entrance_root
val qzm_entrance_root = Initiator.loadClass("com.tencent.mobileqq.R\$id")
.getDeclaredField("qzm_entrance_root").get(null) as Int
check(qzm_entrance_root != 0) { "qzm_entrance_root not found" }
hookAfterIfEnabled(
Reflex.findSingleMethod(
kQZMTitleBarEntranceManager, Void.TYPE, false,
Context::class.java, ViewGroup::class.java, ImageView::class.java
),
) {
// Log.e("HideQZMTitleBarEntrance here", Throwable())
val view = it.args[1] as ViewGroup
val entrance: View? = view.findViewById(qzm_entrance_root)
entrance?.visibility = View.GONE
it.result = null
}
} catch (_: Exception) {
DexKit.requireMethodFromCache(NQZMoment_EntranceEnabled).hookBefore { it.result = false }
}
return true
}
Expand Down
7 changes: 7 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 @@ -719,3 +719,10 @@ data object TroopEnterEffect_QQNT : DexKitTarget.UsingStr() {
override val filter = DexKitFilter.allowAll
// 理论上非NT也能用,但祖法不可变
}

data object NQZMoment_EntranceEnabled : DexKitTarget.UsingStr() {
override val findMethod: Boolean = true
override val traitString = arrayOf("KEY_OPEN_QZMOMENT_ENTRANCE")
override val declaringClass = ""
override val filter = DexKitFilter.strInClsName("com/qzone/reborn/qzmoment/util")
}

0 comments on commit a641cee

Please sign in to comment.