Skip to content

Commit

Permalink
fix: SendFavoriteHook
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Jul 18, 2023
1 parent 7f45e3a commit 7e746b3
Showing 1 changed file with 42 additions and 19 deletions.
61 changes: 42 additions & 19 deletions app/src/main/java/me/ketal/hook/SendFavoriteHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import android.app.Activity
import android.view.View
import android.widget.TextView
import cc.ioctl.util.Reflex
import io.github.qauxv.util.SyncUtils
import io.github.qauxv.base.annotation.FunctionHookEntry
import io.github.qauxv.base.annotation.UiItemAgentEntry
import io.github.qauxv.dsl.FunctionEntryRouter
import io.github.qauxv.util.QQVersion
import io.github.qauxv.util.SyncUtils
import io.github.qauxv.util.requireMinQQVersion
import me.ketal.base.PluginDelayableHook
import me.ketal.util.findClass
Expand Down Expand Up @@ -59,37 +59,60 @@ object SendFavoriteHook : PluginDelayableHook("ketal_send_favorite") {
val thisObj = it.thisObject as Activity
val isHooked = thisObj.intent.getBooleanExtra("bEnterToSelect", false)
if (!isHooked) return@hookAfter
val tv = findCancelTV(
val tv = findTitleTV(
thisObj,
"com.qqfav.activity.QfavBaseActivity".findClass(classLoader)
)
val logic = Reflex.newInstance(
"com.qqfav.activity.FavoriteGroupLogic".findClass(classLoader),
thisObj, tv, thisObj::class.java, View::class.java
)
tv?.setOnClickListener {
throwOrTrue {
Reflex.invokeVirtual(logic, "b")
val menu = logic.get("b", View::class.java)
?: logic.get("f", View::class.java) !!
if (menu.height == 0 || menu.visibility != View.VISIBLE) {
// show
)!!
try {
val logic = Reflex.newInstance(
"com.qqfav.activity.FavoriteGroupLogic".findClass(classLoader),
thisObj, tv, thisObj::class.java, View::class.java
)

tv.setOnClickListener {
throwOrTrue {
Reflex.invokeVirtual(logic, "b")
val menu = logic.get("b", View::class.java)
?: logic.get("f", View::class.java)!!
if (menu.height == 0 || menu.visibility != View.VISIBLE) {
// show
Reflex.invokeVirtual(logic, "a")
} else {
// hide
Reflex.invokeVirtual(logic, "a", true, Boolean::class.java)
}
}
}
} catch (_: Exception) {
val logic = Reflex.newInstance(
"com.qqfav.activity.a".findClass(classLoader),
thisObj, tv, thisObj::class.java, View::class.java
)

tv.setOnClickListener {
throwOrTrue {
Reflex.invokeVirtual(logic, "a")
} else {
// hide
Reflex.invokeVirtual(logic, "a", true, Boolean::class.java)
val menu = logic.get("h", View::class.java)!!
if (menu.height == 0 || menu.visibility != View.VISIBLE) {
// show
Reflex.invokeVirtual(logic, "f")
} else {
// hide
Reflex.invokeVirtual(logic, "b", true, Boolean::class.java)
}
}
}

}
}
}

private fun findCancelTV(thisObject: Any, clazz: Class<*>): TextView? {
private fun findTitleTV(thisObject: Any, clazz: Class<*>): TextView? {
for (field in clazz.declaredFields) {
field.isAccessible = true
if (field[thisObject] is TextView) {
val tv = field[thisObject] as TextView
if (tv.text == "取消") {
if (tv.text == "选择收藏") {
tv.text = "选择分组"
return tv
}
Expand Down

0 comments on commit 7e746b3

Please sign in to comment.