commit 4beb63e7aa73e54499f32891c29401e92fc253f6
parent 5d2277db7c9d070ce47fa470231f84c41dcd41aa
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date:   Fri, 21 Jun 2024 21:23:30 +0200

feat(core): auto close friend feed menu
Automatically closes the Friend Feed Menu after pressing a setting button of SnapEnhance

Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>

Diffstat:
Mcommon/src/main/assets/lang/en_US.json | 4++++
Mcommon/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/UserInterfaceTweaks.kt | 1+
Mcore/src/main/kotlin/me/rhunk/snapenhance/core/ui/menu/impl/FriendFeedInfoMenu.kt | 13+++++++++----
3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -555,6 +555,10 @@ "name": "Friend Feed Menu Buttons", "description": "Select which buttons to show in the Friend Feed Menu" }, + "auto_close_friend_feed_menu": { + "name": "Auto Close Friend Feed Menu", + "description": "Automatically closes the Friend Feed Menu after pressing a setting button" + }, "vertical_story_viewer": { "name": "Vertical Story Viewer", "description": "Enables the vertical story viewer for all stories" diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/UserInterfaceTweaks.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/UserInterfaceTweaks.kt @@ -57,6 +57,7 @@ class UserInterfaceTweaks : ConfigContainer() { ).apply { set(mutableListOf("conversation_info", MessagingRuleType.STEALTH.key)) } + val autoCloseFriendFeedMenu = boolean("auto_close_friend_feed_menu") val customizeUi = container("customize_ui", CustomizeUIConfig()) { addNotices(FeatureNotice.UNSTABLE); requireRestart() } val friendFeedMessagePreview = container("friend_feed_message_preview", FriendFeedMessagePreview()) { requireRestart() } val snapPreview = boolean("snap_preview") { addNotices(FeatureNotice.UNSTABLE); requireRestart() } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/ui/menu/impl/FriendFeedInfoMenu.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/ui/menu/impl/FriendFeedInfoMenu.kt @@ -384,6 +384,11 @@ class FriendFeedInfoMenu : AbstractMenu() { val translation = context.translation.getCategory("friend_menu_option") + fun closeMenu() { + if (!context.config.userInterface.autoCloseFriendFeedMenu.get()) return + context.mainActivity?.triggerRootCloseTouchEvent() + } + @Composable fun ComposeFriendFeedMenu() { Column( @@ -418,7 +423,7 @@ class FriendFeedInfoMenu : AbstractMenu() { context.translation.format("rules.toasts.${if (state) "enabled" else "disabled"}", "ruleName" to context.translation[ruleFeature.ruleType.translateOptionKey(ruleState.key)]), durationMs = 1500 ) - context.mainActivity?.triggerRootCloseTouchEvent() + closeMenu() } MenuElement( @@ -446,7 +451,7 @@ class FriendFeedInfoMenu : AbstractMenu() { translation["mark_snaps_as_seen"], onClick = { context.apply { - mainActivity?.triggerRootCloseTouchEvent() + closeMenu() feature(AutoMarkAsRead::class).markSnapsAsSeen(conversationId) } } @@ -462,7 +467,7 @@ class FriendFeedInfoMenu : AbstractMenu() { translation["mark_stories_as_seen_locally"], onClick = { context.apply { - mainActivity?.triggerRootCloseTouchEvent() + closeMenu() inAppOverlay.showStatusToast( Icons.Default.Info, if (database.setStoriesViewedState(targetUser!!, true)) markAsSeenTranslation["seen_toast"] @@ -474,7 +479,7 @@ class FriendFeedInfoMenu : AbstractMenu() { onLongClick = { view.post { context.apply { - mainActivity?.triggerRootCloseTouchEvent() + closeMenu() inAppOverlay.showStatusToast( Icons.Default.Info, if (database.setStoriesViewedState(targetUser!!, false)) markAsSeenTranslation["unseen_toast"]