Skip to content

Commit

Permalink
feat(core/ui_tweaks): hide my stories
Browse files Browse the repository at this point in the history
  • Loading branch information
rhunk committed Apr 1, 2024
1 parent 3d2dcec commit 7bf8072
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
3 changes: 2 additions & 1 deletion common/src/main/assets/lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")) {
Expand Down

0 comments on commit 7bf8072

Please sign in to comment.