From 81e72bacb68590a516e41756f44b934b18453a0b Mon Sep 17 00:00:00 2001 From: hd <1839732296@qq.com> Date: Sat, 26 Oct 2024 04:02:06 +0800 Subject: [PATCH] feat: HideChatPanelBtn --- .../main/java/me/hd/hook/HideChatPanelBtn.kt | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 app/src/main/java/me/hd/hook/HideChatPanelBtn.kt diff --git a/app/src/main/java/me/hd/hook/HideChatPanelBtn.kt b/app/src/main/java/me/hd/hook/HideChatPanelBtn.kt new file mode 100644 index 0000000000..137ea3a982 --- /dev/null +++ b/app/src/main/java/me/hd/hook/HideChatPanelBtn.kt @@ -0,0 +1,61 @@ +/* + * QAuxiliary - An Xposed module for QQ/TIM + * Copyright (C) 2019-2024 QAuxiliary developers + * https://github.com/cinit/QAuxiliary + * + * This software is an opensource software: you can redistribute it + * and/or modify it under the terms of the General Public License + * as published by the Free Software Foundation; either + * version 3 of the License, or any later version as published + * by QAuxiliary contributors. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the General Public License for more details. + * + * You should have received a copy of the General Public License + * along with this software. + * If not, see + * . + */ + +package me.hd.hook + +import android.view.View +import android.widget.ImageView +import cc.ioctl.util.hookAfterIfEnabled +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.Initiator +import io.github.qauxv.util.QQVersion +import io.github.qauxv.util.requireMinQQVersion +import xyz.nextalone.base.MultiItemDelayableHook + +@FunctionHookEntry +@UiItemAgentEntry +object HideChatPanelBtn : MultiItemDelayableHook( + keyName = "hd_HideChatPanelBtn" +) { + override val preferenceTitle = "屏蔽聊天面板按钮" + override val allItems = setOf("语音", "拍照", "红包", "表情", "更多功能") + override val defaultItems = setOf() + override val uiItemLocation = FunctionEntryRouter.Locations.Simplify.CHAT_OTHER + override val isAvailable = requireMinQQVersion(QQVersion.QQ_8_9_88) + + override fun initOnce(): Boolean { + val panelIconClass = Initiator.loadClass("com.tencent.qqnt.aio.shortcutbar.PanelIconLinearLayout") + val iconItemMethod = panelIconClass.declaredMethods.single { method -> + method.returnType == ImageView::class.java + } + hookAfterIfEnabled(iconItemMethod) { param -> + val imageView = param.result as ImageView + val contentDesc = imageView.contentDescription + if (activeItems.contains(contentDesc)) { + imageView.visibility = View.GONE + } + } + return true + } +} \ No newline at end of file