Skip to content

Commit

Permalink
support: active checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
callng committed Aug 9, 2024
1 parent 2ed582d commit 2d310db
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/moe/qwq/miko/ActionManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import moe.qwq.miko.hooks.BrowserAccessRestrictions
import moe.qwq.miko.actions.FetchService
import moe.qwq.miko.actions.*
import moe.qwq.miko.hooks.AllowGroupFlashPic
import moe.qwq.miko.hooks.CheckBoxHook
import moe.qwq.miko.hooks.DefaultPacketHijacker
import moe.qwq.miko.hooks.DisableFlashPictures
import moe.qwq.miko.hooks.DisableQRLoginCheck
Expand Down Expand Up @@ -46,7 +47,8 @@ object ActionManager {
QQCrashHook::class.java,
OptimizeAtSort::class.java,
DisableQRLoginCheck::class.java,
DisableReplyAt::class.java
DisableReplyAt::class.java,
CheckBoxHook::class.java
)

private val instanceMap = hashMapOf<Class<*>, IAction>()
Expand Down
29 changes: 29 additions & 0 deletions app/src/main/java/moe/qwq/miko/hooks/CheckBoxHook.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package moe.qwq.miko.hooks

import android.content.Context
import android.widget.CheckBox
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedBridge
import moe.fuqiuluo.processor.HookAction
import moe.qwq.miko.actions.IAction
import moe.qwq.miko.ext.beforeHook
import moe.qwq.miko.ext.hookMethod
import moe.qwq.miko.internals.setting.QwQSetting

@HookAction(desc = "默认勾选复选框")
class CheckBoxHook: IAction {
override fun onRun(ctx: Context) {
XposedBridge.hookAllConstructors(CheckBox::class.java, object : XC_MethodHook() {
override fun afterHookedMethod(param: MethodHookParam) {
val checkBox = param.thisObject as CheckBox
checkBox.post { checkBox.isChecked = true }
}
})
val hook = beforeHook {
it.args[0] = true
}
CheckBox::class.java.hookMethod("setChecked", hook)
}

override val name: String = QwQSetting.CHECK_BOX_HOOK
}
2 changes: 2 additions & 0 deletions app/src/main/java/moe/qwq/miko/hooks/DisableReplyAt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package moe.qwq.miko.hooks
import android.content.Context
import com.tencent.mobileqq.aio.msg.AIOMsgItem
import de.robv.android.xposed.XposedBridge
import moe.fuqiuluo.processor.HookAction
import moe.fuqiuluo.xposed.loader.LuoClassloader
import moe.qwq.miko.actions.IAction
import moe.qwq.miko.ext.beforeHook
import moe.qwq.miko.internals.setting.QwQSetting

@HookAction("禁用回复At")
class DisableReplyAt: IAction {
override fun onRun(ctx: Context) {
val replyAt = LuoClassloader.load("com.tencent.mobileqq.aio.input.reply.c") // 混淆的类名
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import mqq.app.MobileQQ
import kotlin.reflect.KProperty

object QwQSetting {
const val CHECK_BOX_HOOK: String = "check_box_hook"
const val DISABLE_REPLY_AT: String = "disable_reply_at"
const val DISABLE_QRLOGIN_CHECK: String = "disable_qrlogin_check"
const val DISABLE_QQ_CRASH_REPORT: String = "disable_qq_crash_report"
Expand Down Expand Up @@ -57,7 +58,8 @@ object QwQSetting {
MESSAGE_ENCRYPT to Setting(MESSAGE_ENCRYPT, SettingType.STRING, ""), // 消息加密密钥
DISABLE_QQ_CRASH_REPORT to Setting(DISABLE_QQ_CRASH_REPORT, SettingType.BOOLEAN, true),
DISABLE_QRLOGIN_CHECK to Setting(DISABLE_QRLOGIN_CHECK, SettingType.BOOLEAN, true),
DISABLE_REPLY_AT to Setting<Boolean>(DISABLE_REPLY_AT, SettingType.BOOLEAN)
DISABLE_REPLY_AT to Setting<Boolean>(DISABLE_REPLY_AT, SettingType.BOOLEAN),
CHECK_BOX_HOOK to Setting(CHECK_BOX_HOOK, SettingType.BOOLEAN, true)
)

val settingUrl: String
Expand Down

0 comments on commit 2d310db

Please sign in to comment.