feat: hide peek a peek

This commit is contained in:
rhunk
2023-11-11 00:48:13 +01:00
parent a106334713
commit a568b9c1c6
3 changed files with 11 additions and 5 deletions

View File

@ -324,6 +324,10 @@
"name": "Anonymous Story Viewing", "name": "Anonymous Story Viewing",
"description": "Prevents anyone from knowing you've seen their story" "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": { "hide_bitmoji_presence": {
"name": "Hide Bitmoji Presence", "name": "Hide Bitmoji Presence",
"description": "Prevents your Bitmoji from popping up while in Chat" "description": "Prevents your Bitmoji from popping up while in Chat"

View File

@ -7,6 +7,7 @@ import me.rhunk.snapenhance.common.data.NotificationType
class MessagingTweaks : ConfigContainer() { class MessagingTweaks : ConfigContainer() {
val bypassScreenshotDetection = boolean("bypass_screenshot_detection") { requireRestart() } val bypassScreenshotDetection = boolean("bypass_screenshot_detection") { requireRestart() }
val anonymousStoryViewing = boolean("anonymous_story_viewing") val anonymousStoryViewing = boolean("anonymous_story_viewing")
val hidePeekAPeek = boolean("hide_peek_a_peek")
val hideBitmojiPresence = boolean("hide_bitmoji_presence") val hideBitmojiPresence = boolean("hide_bitmoji_presence")
val hideTypingNotifications = boolean("hide_typing_notifications") val hideTypingNotifications = boolean("hide_typing_notifications")
val unlimitedSnapViewTime = boolean("unlimited_snap_view_time") val unlimitedSnapViewTime = boolean("unlimited_snap_view_time")

View File

@ -98,17 +98,18 @@ class Messaging : Feature("Messaging", loadParams = FeatureLoadParams.ACTIVITY_C
override fun asyncInit() { override fun asyncInit() {
val stealthMode = context.feature(StealthMode::class) 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 -> arrayOf("activate", "deactivate", "processTypingActivity").forEach { hook ->
Hooker.hook(context.classCache.presenceSession, hook, HookStage.BEFORE, { 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) 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 //get last opened snap for media downloader
context.event.subscribe(OnSnapInteractionEvent::class) { event -> context.event.subscribe(OnSnapInteractionEvent::class) { event ->
openedConversationUUID = event.conversationId openedConversationUUID = event.conversationId
@ -121,7 +122,7 @@ class Messaging : Feature("Messaging", loadParams = FeatureLoadParams.ACTIVITY_C
} }
context.classCache.conversationManager.hook("sendTypingNotification", HookStage.BEFORE, { context.classCache.conversationManager.hook("sendTypingNotification", HookStage.BEFORE, {
hideTypingNotification || stealthMode.canUseRule(openedConversationUUID.toString()) context.config.messaging.hideTypingNotifications.get() || stealthMode.canUseRule(openedConversationUUID.toString())
}) { }) {
it.setResult(null) it.setResult(null)
} }