Skip to content

Commit

Permalink
fix: ChatInputHint private chat for QQNT
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Jul 21, 2023
1 parent c924fc6 commit 2620ada
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions app/src/main/java/xyz/nextalone/hook/ChatInputHint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import android.widget.EditText
import android.widget.LinearLayout
import android.widget.Toast
import cc.ioctl.util.LayoutHelper
import com.github.kyuubiran.ezxhelper.utils.hookAfter
import io.github.qauxv.base.IUiItemAgent
import io.github.qauxv.base.annotation.FunctionHookEntry
import io.github.qauxv.base.annotation.UiItemAgentEntry
Expand All @@ -43,6 +42,7 @@ import io.github.qauxv.ui.CommonContextWrapper
import io.github.qauxv.util.Initiator
import io.github.qauxv.util.QQVersion
import io.github.qauxv.util.Toasts
import io.github.qauxv.util.dexkit.AIO_InputRootInit_QQNT
import io.github.qauxv.util.dexkit.DexKit
import io.github.qauxv.util.dexkit.NBaseChatPie_init
import io.github.qauxv.util.requireMinQQVersion
Expand All @@ -55,7 +55,7 @@ import xyz.nextalone.util.throwOrTrue

@FunctionHookEntry
@UiItemAgentEntry
object ChatInputHint : CommonConfigFunctionHook("na_chat_input_hint", arrayOf(NBaseChatPie_init)) {
object ChatInputHint : CommonConfigFunctionHook("na_chat_input_hint", arrayOf(NBaseChatPie_init, AIO_InputRootInit_QQNT)) {

override val name = "输入框增加提示"
override val valueState: MutableStateFlow<String?>? = null
Expand All @@ -64,10 +64,19 @@ object ChatInputHint : CommonConfigFunctionHook("na_chat_input_hint", arrayOf(NB

override fun initOnce(): Boolean = throwOrTrue {
if (requireMinQQVersion(QQVersion.QQ_8_9_63)) {
"Lcom/tencent/mobileqq/aio/input/b/c;->l()V".method.hookAfter { param ->
// 初始化后
DexKit.requireMethodFromCache(AIO_InputRootInit_QQNT).hookAfter(this) {
it.thisObject.javaClass.declaredFields.single { it.type == EditText::class.java }.apply {
isAccessible = true
val et = get(it.thisObject) as EditText
et.hint = getValue()
}
}
// 群设置hint为空后
"Lcom/tencent/mobileqq/aio/input/b/c;->l()V".method.hookAfter(this) { param ->
val f = param.thisObject.javaClass.getDeclaredField("f").apply { isAccessible = true }.get(param.thisObject)
val b = f.javaClass.getDeclaredField("b").apply { isAccessible = true }.get(f) as EditText
b.hint = getDefaultConfig().getStringOrDefault(strCfg, "Typing words...")
b.hint = getValue()
}
} else {
DexKit.requireMethodFromCache(NBaseChatPie_init).hookAfter(this) {
Expand All @@ -81,7 +90,7 @@ object ChatInputHint : CommonConfigFunctionHook("na_chat_input_hint", arrayOf(NB
break
}
}
aioRootView?.findHostView<EditText>("input")?.hint = getDefaultConfig().getStringOrDefault(strCfg, "Typing words...")
aioRootView?.findHostView<EditText>("input")?.hint = getValue()
}
}
}
Expand All @@ -92,19 +101,16 @@ object ChatInputHint : CommonConfigFunctionHook("na_chat_input_hint", arrayOf(NB
showInputHintDialog(activity)
}

private fun getValue(): String = getDefaultConfig().getStringOrDefault(strCfg, "Typing words...")

private fun showInputHintDialog(activity: Context) {
val ctx = CommonContextWrapper.createAppCompatContext(activity)
val dialog = androidx.appcompat.app.AlertDialog.Builder(ctx)
val editText = EditText(ctx)
editText.textSize = 16f
val _5 = LayoutHelper.dip2px(activity, 5f)
editText.setPadding(_5, _5, _5, _5 * 2)
editText.setText(
getDefaultConfig().getStringOrDefault(
strCfg,
"Typing words..."
)
)
editText.setText(getValue())
val checkBox = CheckBox(ctx)
checkBox.text = "开启输入框文字提示"
checkBox.isChecked = isEnabled
Expand Down

0 comments on commit 2620ada

Please sign in to comment.