Skip to content

Commit 8f90918

Browse files
Copilotchsbuffer
authored andcommitted
Add DisableQuickReaction hook to disable Quick Reaction
1 parent b0623d2 commit 8f90918

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

app/src/main/java/cc/ioctl/tmoe/fragment/SettingsFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class SettingsFragment : BaseHierarchyFragment() {
7474
functionSwitch(
7575
UseSystemEmoji, "UseSystemEmoji", R.string.UseSystemEmoji
7676
)
77+
functionSwitch(
78+
DisableQuickReaction, "DisableQuickReaction", R.string.DisableQuickReaction
79+
)
7780
functionSwitch(
7881
ProhibitEnableReactions, "ProhibitEnableReactions", R.string.ProhibitEnableReactions
7982
)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package cc.ioctl.tmoe.hook.func
2+
3+
import cc.ioctl.tmoe.base.annotation.FunctionHookEntry
4+
import cc.ioctl.tmoe.hook.base.CommonDynamicHook
5+
import cc.ioctl.tmoe.util.HostInfo
6+
import cc.ioctl.tmoe.util.Initiator
7+
import cc.ioctl.tmoe.util.config.ConfigManager
8+
import cc.ioctl.tmoe.util.dex.DexMethodDescriptor
9+
import com.github.kyuubiran.ezxhelper.init.InitFields.ezXClassLoader
10+
import com.github.kyuubiran.ezxhelper.utils.findMethod
11+
import com.github.kyuubiran.ezxhelper.utils.getAllClassesList
12+
import com.github.kyuubiran.ezxhelper.utils.hookBefore
13+
import com.github.kyuubiran.ezxhelper.utils.loadClassOrNull
14+
import com.github.kyuubiran.ezxhelper.utils.tryOrLogFalse
15+
import java.lang.reflect.Method
16+
17+
@FunctionHookEntry
18+
object DisableQuickReaction : CommonDynamicHook() {
19+
fun getMethod(key: String, block: () -> Method): Method {
20+
val cache = ConfigManager.getCache()
21+
val currentHostVersionCode32 = HostInfo.getVersionCode()
22+
val lastVersion = cache.getIntOrDefault("cache_" + key + "_code", 0)
23+
24+
if (currentHostVersionCode32 == lastVersion) {
25+
return DexMethodDescriptor(cache.getString("cache_" + key + "_method")).getMethodInstance(
26+
Initiator.getHostClassLoader()
27+
)
28+
}
29+
30+
val method = block()
31+
val desc = DexMethodDescriptor(method)
32+
33+
cache.putString("cache_" + key + "_method", desc.toString())
34+
cache.putInt("cache_" + key + "_code", currentHostVersionCode32)
35+
return method
36+
}
37+
38+
override fun initOnce(): Boolean = tryOrLogFalse {
39+
getMethod("onItemClickListener_hasDoubleTap", {
40+
ezXClassLoader.getAllClassesList().asSequence()
41+
.filter { it.startsWith("org.telegram.ui.ChatActivity$") }
42+
.mapNotNull { loadClassOrNull(it) }
43+
.filter { it.methods.any { m -> m.name == "hasDoubleTap" } }.first()
44+
.findMethod { name == "hasDoubleTap" }
45+
}).hookBefore {
46+
if (isEnabled) it.result = false
47+
}
48+
49+
return true
50+
}
51+
}

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<string name="FuckTrackingHook">禁用个性化广告推荐</string>
6767
<string name="DisableInstantCamera">禁用即时相机</string>
6868
<string name="HideServiceStories">隐藏“服务通知”的动态</string>
69+
<string name="DisableQuickReaction">禁用快速表情回应</string>
6970
<string name="ShowIdInProfile">资料页显示 ID</string>
7071
<string name="GroupOrChannelId">群聊 / 频道 ID</string>
7172
<string name="UserId">用户 ID</string>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
<string name="FuckTrackingHookDesc">If you click on an ad provided by Telegram, they will track it and might use it as the basis for personalizing the ad.This function is to disable it</string>
9494
<string name="DisableInstantCamera">Disable Instant Camera</string>
9595
<string name="HideServiceStories">Hide stories from service notifications</string>
96+
<string name="DisableQuickReaction">Disable Quick Reaction</string>
9697
<string name="ShowIdInProfile">Show id in profile</string>
9798
<string name="ShowIdInProfileDesc">Show id in profile page of user, chat or channel</string>
9899
<string name="GroupOrChannelId">Group / Channel ID</string>

0 commit comments

Comments
 (0)