feat(core/ui_tweaks): hide my stories
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
Reference in New Issue
Block a user