feat(PR): enhanced stealth mode by tnewman-afk
enhanced stealth-mode
This commit is contained in:
@@ -779,11 +779,27 @@
|
||||
}
|
||||
},
|
||||
"stealth": {
|
||||
"name": "Stealth Mode",
|
||||
"description": "Prevents anyone from knowing you've opened their Snaps/Chats and conversations",
|
||||
"name": "Full Stealth Mode",
|
||||
"description": "Applies both chat stealth and snap stealth for this conversation",
|
||||
"options": {
|
||||
"blacklist": "Exclude from Stealth Mode",
|
||||
"whitelist": "Stealth mode"
|
||||
"blacklist": "Exclude from Full Stealth Mode",
|
||||
"whitelist": "Full Stealth Mode"
|
||||
}
|
||||
},
|
||||
"snap_stealth": {
|
||||
"name": "Snap Stealth Mode",
|
||||
"description": "Prevents anyone from knowing you've opened their snaps",
|
||||
"options": {
|
||||
"blacklist": "Exclude from Snap Stealth Mode",
|
||||
"whitelist": "Snap Stealth Mode"
|
||||
}
|
||||
},
|
||||
"chat_stealth": {
|
||||
"name": "Chat Stealth Mode",
|
||||
"description": "Prevents anyone from knowing you've opened their chats or viewed their chat presence",
|
||||
"options": {
|
||||
"blacklist": "Exclude from Chat Stealth Mode",
|
||||
"whitelist": "Chat Stealth Mode"
|
||||
}
|
||||
},
|
||||
"auto_save": {
|
||||
@@ -1885,7 +1901,13 @@
|
||||
"name": "Auto Download"
|
||||
},
|
||||
"stealth": {
|
||||
"name": "Stealth Mode"
|
||||
"name": "Full Stealth Mode"
|
||||
},
|
||||
"snap_stealth": {
|
||||
"name": "Snap Stealth Mode"
|
||||
},
|
||||
"chat_stealth": {
|
||||
"name": "Chat Stealth Mode"
|
||||
},
|
||||
"auto_save": {
|
||||
"name": "Auto Save"
|
||||
@@ -2291,7 +2313,7 @@
|
||||
"auto_save": "\ud83d\udcac Auto Save Messages",
|
||||
"unsaveable_messages": "\u2b07\ufe0f Unsaveable Messages",
|
||||
"auto_open_snaps": "\ud83d\udcf7 Auto Open Snaps",
|
||||
"stealth": "\ud83d\udc7b Stealth Mode",
|
||||
"stealth": "\ud83d\udc7b Full Stealth Mode",
|
||||
"auto_reply": "\ud83d\udce8 Auto Reply",
|
||||
"auto_delete_sent_messages": "\ud83d\uddd1\ufe0f Auto Delete Sent Messages",
|
||||
"mark_snaps_as_seen": "\ud83d\udc40 Mark Snaps as seen",
|
||||
@@ -2385,6 +2407,16 @@
|
||||
"whitelist": "Whitelist",
|
||||
"disabled": "Disabled"
|
||||
},
|
||||
"snap_stealth": {
|
||||
"blacklist": "Blacklist",
|
||||
"whitelist": "Whitelist",
|
||||
"disabled": "Disabled"
|
||||
},
|
||||
"chat_stealth": {
|
||||
"blacklist": "Blacklist",
|
||||
"whitelist": "Whitelist",
|
||||
"disabled": "Disabled"
|
||||
},
|
||||
"auto_save": {
|
||||
"blacklist": "Blacklist",
|
||||
"whitelist": "Whitelist",
|
||||
|
||||
@@ -818,11 +818,27 @@
|
||||
}
|
||||
},
|
||||
"stealth": {
|
||||
"name": "Stealth Mode",
|
||||
"description": "Prevents anyone from knowing you've opened their Snaps/Chats and conversations",
|
||||
"name": "Full Stealth Mode",
|
||||
"description": "Applies both chat stealth and snap stealth for this conversation",
|
||||
"options": {
|
||||
"blacklist": "Exclude from Stealth Mode",
|
||||
"whitelist": "Stealth mode"
|
||||
"blacklist": "Exclude from Full Stealth Mode",
|
||||
"whitelist": "Full Stealth Mode"
|
||||
}
|
||||
},
|
||||
"snap_stealth": {
|
||||
"name": "Snap Stealth Mode",
|
||||
"description": "Prevents anyone from knowing you've opened their snaps",
|
||||
"options": {
|
||||
"blacklist": "Exclude from Snap Stealth Mode",
|
||||
"whitelist": "Snap Stealth Mode"
|
||||
}
|
||||
},
|
||||
"chat_stealth": {
|
||||
"name": "Chat Stealth Mode",
|
||||
"description": "Prevents anyone from knowing you've opened their chats or viewed their chat presence",
|
||||
"options": {
|
||||
"blacklist": "Exclude from Chat Stealth Mode",
|
||||
"whitelist": "Chat Stealth Mode"
|
||||
}
|
||||
},
|
||||
"auto_save": {
|
||||
@@ -2012,7 +2028,13 @@
|
||||
"name": "Auto Download"
|
||||
},
|
||||
"stealth": {
|
||||
"name": "Stealth Mode"
|
||||
"name": "Full Stealth Mode"
|
||||
},
|
||||
"snap_stealth": {
|
||||
"name": "Snap Stealth Mode"
|
||||
},
|
||||
"chat_stealth": {
|
||||
"name": "Chat Stealth Mode"
|
||||
},
|
||||
"auto_save": {
|
||||
"name": "Auto Save"
|
||||
@@ -2820,7 +2842,7 @@
|
||||
"auto_save": "\ud83d\udcac Auto Save Messages",
|
||||
"unsaveable_messages": "\u2b07\ufe0f Unsaveable Messages",
|
||||
"auto_open_snaps": "\ud83d\udcf7 Auto Open Snaps",
|
||||
"stealth": "\ud83d\udc7b Stealth Mode",
|
||||
"stealth": "\ud83d\udc7b Full Stealth Mode",
|
||||
"auto_reply": "\ud83d\udce8 Auto Reply",
|
||||
"auto_delete_sent_messages": "\ud83d\uddd1\ufe0f Auto Delete Sent Messages",
|
||||
"mark_chat_as_read": "\ud83d\udcd6 Mark Chat as Read",
|
||||
@@ -2927,6 +2949,16 @@
|
||||
"whitelist": "Whitelist",
|
||||
"disabled": "Disabled"
|
||||
},
|
||||
"snap_stealth": {
|
||||
"blacklist": "Blacklist",
|
||||
"whitelist": "Whitelist",
|
||||
"disabled": "Disabled"
|
||||
},
|
||||
"chat_stealth": {
|
||||
"blacklist": "Blacklist",
|
||||
"whitelist": "Whitelist",
|
||||
"disabled": "Disabled"
|
||||
},
|
||||
"auto_save": {
|
||||
"blacklist": "Blacklist",
|
||||
"whitelist": "Whitelist",
|
||||
|
||||
@@ -49,6 +49,8 @@ enum class MessagingRuleType(
|
||||
val configNotices: Array<FeatureNotice> = emptyArray()
|
||||
) {
|
||||
STEALTH("stealth", true, Icons.Outlined.TrackChanges),
|
||||
SNAP_STEALTH("snap_stealth", true, Icons.Outlined.PhotoCamera, showInFriendMenu = false),
|
||||
CHAT_STEALTH("chat_stealth", true, Icons.Outlined.ChatBubbleOutline, showInFriendMenu = false),
|
||||
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"),
|
||||
@@ -71,6 +73,58 @@ enum class MessagingRuleType(
|
||||
}
|
||||
}
|
||||
|
||||
private val partialStealthRuleTypes = setOf(
|
||||
MessagingRuleType.SNAP_STEALTH,
|
||||
MessagingRuleType.CHAT_STEALTH
|
||||
)
|
||||
|
||||
private val allStealthRuleTypes = partialStealthRuleTypes + MessagingRuleType.STEALTH
|
||||
|
||||
fun MessagingRuleType.isStealthRule(): Boolean = this in allStealthRuleTypes
|
||||
|
||||
fun Collection<MessagingRuleType>.normalizeStealthRules(): Set<MessagingRuleType> {
|
||||
val normalizedRules = toMutableSet()
|
||||
if (MessagingRuleType.STEALTH in normalizedRules) {
|
||||
normalizedRules.removeAll(partialStealthRuleTypes)
|
||||
return normalizedRules
|
||||
}
|
||||
|
||||
if (partialStealthRuleTypes.all { it in normalizedRules }) {
|
||||
normalizedRules.removeAll(partialStealthRuleTypes)
|
||||
normalizedRules.add(MessagingRuleType.STEALTH)
|
||||
}
|
||||
|
||||
return normalizedRules
|
||||
}
|
||||
|
||||
fun Collection<MessagingRuleType>.withNormalizedRuleToggle(
|
||||
ruleType: MessagingRuleType,
|
||||
enabled: Boolean
|
||||
): Set<MessagingRuleType> {
|
||||
val updatedRules = toMutableSet().apply {
|
||||
if (enabled) {
|
||||
add(ruleType)
|
||||
} else {
|
||||
remove(ruleType)
|
||||
}
|
||||
}
|
||||
|
||||
if (!ruleType.isStealthRule()) {
|
||||
return updatedRules
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
when (ruleType) {
|
||||
MessagingRuleType.STEALTH -> updatedRules.removeAll(partialStealthRuleTypes)
|
||||
MessagingRuleType.SNAP_STEALTH,
|
||||
MessagingRuleType.CHAT_STEALTH -> updatedRules.remove(MessagingRuleType.STEALTH)
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
return updatedRules.normalizeStealthRules()
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
data class FriendStreaks(
|
||||
val notify: Boolean = true,
|
||||
|
||||
Reference in New Issue
Block a user