mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-13 05:37:48 +02:00
feat: half swipe notifier duration range
This commit is contained in:
@ -363,7 +363,17 @@
|
||||
},
|
||||
"half_swipe_notifier": {
|
||||
"name": "Half Swipe Notifier",
|
||||
"description": "Notifies you when someone half swipes into a conversation"
|
||||
"description": "Notifies you when someone half swipes into a conversation",
|
||||
"properties": {
|
||||
"min_duration": {
|
||||
"name": "Minimum Duration",
|
||||
"description": "The minimum duration of the half swipe (in seconds)"
|
||||
},
|
||||
"max_duration": {
|
||||
"name": "Maximum Duration",
|
||||
"description": "The maximum duration of the half swipe (in seconds)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"message_preview_length": {
|
||||
"name": "Message Preview Length",
|
||||
|
@ -2,9 +2,19 @@ package me.rhunk.snapenhance.common.config.impl
|
||||
|
||||
import me.rhunk.snapenhance.common.config.ConfigContainer
|
||||
import me.rhunk.snapenhance.common.config.FeatureNotice
|
||||
import me.rhunk.snapenhance.common.config.PropertyValue
|
||||
import me.rhunk.snapenhance.common.data.NotificationType
|
||||
|
||||
class MessagingTweaks : ConfigContainer() {
|
||||
inner class HalfSwipeNotifierConfig : ConfigContainer(hasGlobalState = true) {
|
||||
val minDuration: PropertyValue<Int> = integer("min_duration", defaultValue = 0) {
|
||||
inputCheck = { it.toIntOrNull()?.coerceAtLeast(0) != null && maxDuration.get() >= it.toInt() }
|
||||
}
|
||||
val maxDuration: PropertyValue<Int> = integer("max_duration", defaultValue = 20) {
|
||||
inputCheck = { it.toIntOrNull()?.coerceAtLeast(0) != null && minDuration.get() <= it.toInt() }
|
||||
}
|
||||
}
|
||||
|
||||
val bypassScreenshotDetection = boolean("bypass_screenshot_detection") { requireRestart() }
|
||||
val anonymousStoryViewing = boolean("anonymous_story_viewing")
|
||||
val preventStoryRewatchIndicator = boolean("prevent_story_rewatch_indicator") { requireRestart() }
|
||||
@ -13,7 +23,7 @@ class MessagingTweaks : ConfigContainer() {
|
||||
val hideTypingNotifications = boolean("hide_typing_notifications")
|
||||
val unlimitedSnapViewTime = boolean("unlimited_snap_view_time")
|
||||
val disableReplayInFF = boolean("disable_replay_in_ff")
|
||||
val halfSwipeNotifier = boolean("half_swipe_notifier") { requireRestart() }
|
||||
val halfSwipeNotifier = container("half_swipe_notifier", HalfSwipeNotifierConfig()) { requireRestart()}
|
||||
val messagePreviewLength = integer("message_preview_length", defaultValue = 20)
|
||||
val callStartConfirmation = boolean("call_start_confirmation") { requireRestart() }
|
||||
val autoSaveMessagesInConversations = multiple("auto_save_messages_in_conversations",
|
||||
|
@ -36,7 +36,7 @@ class HalfSwipeNotifier : Feature("Half Swipe Notifier", loadParams = FeatureLoa
|
||||
|
||||
|
||||
override fun init() {
|
||||
if (!context.config.messaging.halfSwipeNotifier.get()) return
|
||||
if (context.config.messaging.halfSwipeNotifier.globalState != true) return
|
||||
lateinit var presenceService: Any
|
||||
|
||||
findClass("com.snapchat.talkcorev3.PresenceService\$CppProxy").hookConstructor(HookStage.AFTER) {
|
||||
@ -84,7 +84,12 @@ class HalfSwipeNotifier : Feature("Half Swipe Notifier", loadParams = FeatureLoa
|
||||
|
||||
private fun endPeeking(conversationId: String, userId: String) {
|
||||
startPeekingTimestamps[conversationId + userId]?.let { startPeekingTimestamp ->
|
||||
val peekingDuration = (System.currentTimeMillis() - startPeekingTimestamp).milliseconds.inWholeSeconds.toString()
|
||||
val peekingDuration = (System.currentTimeMillis() - startPeekingTimestamp).milliseconds.inWholeSeconds
|
||||
val minDuration = context.config.messaging.halfSwipeNotifier.minDuration.get().toLong()
|
||||
val maxDuration = context.config.messaging.halfSwipeNotifier.maxDuration.get().toLong()
|
||||
|
||||
if (minDuration > peekingDuration || maxDuration < peekingDuration) return
|
||||
|
||||
val groupName = context.database.getFeedEntryByConversationId(conversationId)?.feedDisplayName
|
||||
val friendInfo = context.database.getFriendInfo(userId) ?: return
|
||||
|
||||
@ -94,12 +99,12 @@ class HalfSwipeNotifier : Feature("Half Swipe Notifier", loadParams = FeatureLoa
|
||||
translation.format("notification_content_group",
|
||||
"friend" to (friendInfo.displayName ?: friendInfo.mutableUsername).toString(),
|
||||
"group" to groupName,
|
||||
"duration" to peekingDuration
|
||||
"duration" to peekingDuration.toString()
|
||||
)
|
||||
} else {
|
||||
translation.format("notification_content_dm",
|
||||
"friend" to (friendInfo.displayName ?: friendInfo.mutableUsername).toString(),
|
||||
"duration" to peekingDuration
|
||||
"duration" to peekingDuration.toString()
|
||||
)
|
||||
})
|
||||
.setContentIntent(
|
||||
|
Reference in New Issue
Block a user