commit a568b9c1c615d1d09d232bce960adc4fc747ebb7 parent a106334713ab7d6f4c0e3a844c0b4f88f9781066 Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Sat, 11 Nov 2023 00:48:13 +0100 feat: hide peek a peek Diffstat:
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -324,6 +324,10 @@ "name": "Anonymous Story Viewing", "description": "Prevents anyone from knowing you've seen their story" }, + "hide_peek_a_peek": { + "name": "Hide Peek-a-Peek", + "description": "Prevents notification from being sent when you half swipe into a chat" + }, "hide_bitmoji_presence": { "name": "Hide Bitmoji Presence", "description": "Prevents your Bitmoji from popping up while in Chat" 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 @@ -7,6 +7,7 @@ import me.rhunk.snapenhance.common.data.NotificationType class MessagingTweaks : ConfigContainer() { val bypassScreenshotDetection = boolean("bypass_screenshot_detection") { requireRestart() } val anonymousStoryViewing = boolean("anonymous_story_viewing") + 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") 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 @@ -98,17 +98,18 @@ class Messaging : Feature("Messaging", loadParams = FeatureLoadParams.ACTIVITY_C override fun asyncInit() { val stealthMode = context.feature(StealthMode::class) - val hideBitmojiPresence by context.config.messaging.hideBitmojiPresence - val hideTypingNotification by context.config.messaging.hideTypingNotifications - arrayOf("activate", "deactivate", "processTypingActivity").forEach { hook -> Hooker.hook(context.classCache.presenceSession, hook, HookStage.BEFORE, { - hideBitmojiPresence || stealthMode.canUseRule(openedConversationUUID.toString()) + context.config.messaging.hideBitmojiPresence.get() || stealthMode.canUseRule(openedConversationUUID.toString()) }) { it.setResult(null) } } + context.classCache.presenceSession.hook("startPeeking", HookStage.BEFORE, { + context.config.messaging.hidePeekAPeek.get() || stealthMode.canUseRule(openedConversationUUID.toString()) + }) { it.setResult(null) } + //get last opened snap for media downloader context.event.subscribe(OnSnapInteractionEvent::class) { event -> openedConversationUUID = event.conversationId @@ -121,7 +122,7 @@ class Messaging : Feature("Messaging", loadParams = FeatureLoadParams.ACTIVITY_C } context.classCache.conversationManager.hook("sendTypingNotification", HookStage.BEFORE, { - hideTypingNotification || stealthMode.canUseRule(openedConversationUUID.toString()) + context.config.messaging.hideTypingNotifications.get() || stealthMode.canUseRule(openedConversationUUID.toString()) }) { it.setResult(null) }