commit 7bf80723c4d275f66b2b65e90824113981be90a0 parent 3d2dcec9857def6282341500117ce4f7e0c4970c Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Mon, 1 Apr 2024 23:06:52 +0200 feat(core/ui_tweaks): hide my stories Diffstat:
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -923,7 +923,8 @@ }, "hide_story_suggestions": { "hide_friend_suggestions": "Hide friend suggestions", - "hide_suggested_friend_stories": "Hide suggested friend stories" + "hide_suggested_friend_stories": "Hide suggested friend stories", + "hide_my_stories": "Hide My Stories" }, "home_tab": { "map": "Map", 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 @@ -33,7 +33,7 @@ class UserInterfaceTweaks : ConfigContainer() { val hideFriendFeedEntry = boolean("hide_friend_feed_entry") { requireRestart() } val hideStreakRestore = boolean("hide_streak_restore") { requireRestart() } val hideQuickAddFriendFeed = boolean("hide_quick_add_friend_feed") { requireRestart() } - val hideStorySuggestions = multiple("hide_story_suggestions", "hide_friend_suggestions", "hide_suggested_friend_stories") { requireRestart() } + val hideStorySuggestions = multiple("hide_story_suggestions", "hide_friend_suggestions", "hide_suggested_friend_stories", "hide_my_stories") { requireRestart() } val hideUiComponents = multiple("hide_ui_components", "hide_voice_record_button", "hide_stickers_button", diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/UITweaks.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/UITweaks.kt @@ -1,9 +1,6 @@ package me.rhunk.snapenhance.core.features.impl.ui -import android.annotation.SuppressLint -import android.content.Context import android.content.res.Resources -import android.text.SpannableString import android.util.Size import android.view.View import android.view.ViewGroup.MarginLayoutParams @@ -73,13 +70,24 @@ class UITweaks : Feature("UITweaks", loadParams = FeatureLoadParams.ACTIVITY_CRE var friendCardFrameSize: Size? = null + val fourDp by lazy { + (4 * context.androidContext.resources.displayMetrics.density).toInt() + } + context.event.subscribe(BindViewEvent::class, { hideStorySuggestions.isNotEmpty() }) { event -> - if (event.view is FrameLayout && - hideStorySuggestions.contains("hide_friend_suggestions") && - event.prevModel.toString().startsWith("DFFriendSuggestionCardViewModel") - ) { - event.view.layoutParams.apply { width = 0; height = 0 } - return@subscribe + if (event.view is FrameLayout) { + val viewModelString = event.prevModel.toString() + val isSuggestedFriend by lazy { viewModelString.startsWith("DFFriendSuggestionCardViewModel") } + val isMyStory by lazy { viewModelString.let { it.startsWith("CircularItemViewModel") && it.contains("storyId=")} } + + if ((hideStorySuggestions.contains("hide_friend_suggestions") && isSuggestedFriend) || + (hideStorySuggestions.contains("hide_my_stories") && isMyStory)) { + event.view.layoutParams.apply { + width = 0; height = 0 + if (this is MarginLayoutParams) setMargins(-fourDp, 0, -fourDp, 0) + } + return@subscribe + } } if (event.view.id == friendCardFrame && hideStorySuggestions.contains("hide_suggested_friend_stories")) {