From a25b66a3852af02dc18869351e79a624c04fa32d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=9ET=CE=9ERNAL?= Date: Thu, 9 Oct 2025 14:01:04 +0530 Subject: [PATCH] feat: Hide typing indicator blacklist/whitelist --- common/src/main/assets/lang/en_US.json | 12 ++++++++---- .../common/config/impl/MessagingTweaks.kt | 1 - .../common/data/MessagingCoreObjects.kt | 1 + .../core/features/FeatureManager.kt | 1 + .../impl/messaging/HideTypingIndicator.kt | 18 ++++++++++++++++++ .../core/features/impl/messaging/Messaging.kt | 14 +++++--------- 6 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/HideTypingIndicator.kt diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json index 91bec032..503408b0 100644 --- a/common/src/main/assets/lang/en_US.json +++ b/common/src/main/assets/lang/en_US.json @@ -263,6 +263,14 @@ "whitelist": "Stealth mode" } }, + "hide_typing_indicator": { + "name": "Hide Typing Indicator", + "description": "Prevents anyone from knowing you're typing", + "options": { + "blacklist": "Exclude from Hide Typing Indicator", + "whitelist": "Hide Typing Indicator" + } + }, "auto_save": { "name": "Auto Save", "description": "Saves Chat Messages when viewing them", @@ -598,10 +606,6 @@ "name": "Hide Bitmoji Presence", "description": "Prevents your Bitmoji from popping up while in Chat" }, - "hide_typing_notifications": { - "name": "Hide Typing Notifications", - "description": "Prevents anyone from knowing you're typing a message" - }, "unlimited_snap_view_time": { "name": "Unlimited Snap View Time", "description": "Removes the Time Limit for viewing Snaps" diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt index 24b3848d..63e1acdb 100644 --- a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt +++ b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt @@ -60,7 +60,6 @@ class MessagingTweaks : ConfigContainer() { val preventStoryRewatchIndicator = boolean("prevent_story_rewatch_indicator") { requireRestart() } val hidePeekAPeek = boolean("hide_peek_a_peek") val hideBitmojiPresence = boolean("hide_bitmoji_presence") - val hideTypingNotifications = boolean("hide_typing_notifications") val unlimitedSnapViewTime = boolean("unlimited_snap_view_time") val autoMarkAsRead = multiple("auto_mark_as_read", "snap_reply", "conversation_read", "save_snap_in_chat") { requireRestart() } val markSnapAsSeenButton = boolean("mark_snap_as_seen_button") { requireRestart() } diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/data/MessagingCoreObjects.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/data/MessagingCoreObjects.kt index 6e03a646..a8c2fbfd 100644 --- a/common/src/main/kotlin/me/rhunk/snapenhance/common/data/MessagingCoreObjects.kt +++ b/common/src/main/kotlin/me/rhunk/snapenhance/common/data/MessagingCoreObjects.kt @@ -48,6 +48,7 @@ enum class MessagingRuleType( val configNotices: Array = emptyArray() ) { STEALTH("stealth", true, Icons.Outlined.TrackChanges), + HIDE_TYPING_INDICATOR("hide_typing_indicator", true, Icons.Outlined.KeyboardHide, defaultValue = "whitelist"), AUTO_DOWNLOAD("auto_download", true, Icons.Outlined.DownloadForOffline), AUTO_SAVE("auto_save", true, Icons.Outlined.Save, defaultValue = "blacklist"), AUTO_OPEN_SNAPS("auto_open_snaps", true, Icons.Outlined.OpenInFull, configNotices = arrayOf(FeatureNotice.BAN_RISK, FeatureNotice.UNSTABLE), defaultValue = null), diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/FeatureManager.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/FeatureManager.kt index 88d9a0e8..8b0b088c 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/FeatureManager.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/FeatureManager.kt @@ -81,6 +81,7 @@ class FeatureManager( PreventMessageSending(), Notifications(), AutoSave(), + HideTypingIndicator(), UITweaks(), ConfigurationOverride(), COFOverride(), diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/HideTypingIndicator.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/HideTypingIndicator.kt new file mode 100644 index 00000000..ad4a8829 --- /dev/null +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/HideTypingIndicator.kt @@ -0,0 +1,18 @@ +package me.rhunk.snapenhance.core.features.impl.messaging + +import me.rhunk.snapenhance.common.data.MessagingRuleType +import me.rhunk.snapenhance.core.features.MessagingRuleFeature +import me.rhunk.snapenhance.core.util.hook.HookStage +import me.rhunk.snapenhance.core.util.hook.hook + +class HideTypingIndicator : MessagingRuleFeature("Hide Typing Indicator", MessagingRuleType.HIDE_TYPING_INDICATOR) { + private val messaging: Messaging by lazy { context.feature(Messaging::class) } + + override fun init() { + context.classCache.presenceSession.hook("processTypingActivity", HookStage.BEFORE, { + messaging.openedConversationUUID?.toString()?.let { canUseRule(it) } ?: false + }) { + it.setResult(null) + } + } +} \ No newline at end of file diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/Messaging.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/Messaging.kt index 4133d99b..8d4a3d7a 100644 --- a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/Messaging.kt +++ b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/messaging/Messaging.kt @@ -98,16 +98,18 @@ class Messaging : Feature("Messaging") { } defer { - arrayOf("activate", "deactivate", "processTypingActivity").forEach { hook -> + arrayOf("activate", "deactivate").forEach { hook -> context.classCache.presenceSession.hook(hook, HookStage.BEFORE, { - context.config.messaging.hideBitmojiPresence.get() || stealthMode.canUseRule(openedConversationUUID.toString()) + val conversationId = openedConversationUUID?.toString() ?: return@hook false + context.config.messaging.hideBitmojiPresence.get() || stealthMode.canUseRule(conversationId) }) { it.setResult(null) } } context.classCache.presenceSession.hook("startPeeking", HookStage.BEFORE, { - context.config.messaging.hidePeekAPeek.get() || stealthMode.canUseRule(openedConversationUUID.toString()) + val conversationId = openedConversationUUID?.toString() ?: return@hook false + context.config.messaging.hidePeekAPeek.get() || stealthMode.canUseRule(conversationId) }) { it.setResult(null) } //get last opened snap for media downloader @@ -122,12 +124,6 @@ class Messaging : Feature("Messaging") { lastFocusedMessageId = param.arg(1) } } - - context.classCache.conversationManager.hook("sendTypingNotification", HookStage.BEFORE, { - context.config.messaging.hideTypingNotifications.get() || stealthMode.canUseRule(openedConversationUUID.toString()) - }) { - it.setResult(null) - } } onNextActivityCreate {