mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-13 05:37:48 +02:00
feat(core/ui_tweaks): hide suggested friend stories
This commit is contained in:
@ -761,6 +761,7 @@
|
||||
},
|
||||
"hide_story_sections": {
|
||||
"hide_friend_suggestions": "Hide friend suggestions",
|
||||
"hide_suggested_friend_stories": "Hide suggested friend stories",
|
||||
"hide_friends": "Hide friends section",
|
||||
"hide_suggested": "Hide suggested section",
|
||||
"hide_for_you": "Hide For You section"
|
||||
|
@ -35,7 +35,7 @@ class UserInterfaceTweaks : ConfigContainer() {
|
||||
val hideStreakRestore = boolean("hide_streak_restore") { requireRestart() }
|
||||
val hideQuickAddFriendFeed = boolean("hide_quick_add_friend_feed") { requireRestart() }
|
||||
val hideStorySections = multiple("hide_story_sections",
|
||||
"hide_friend_suggestions", "hide_friends", "hide_suggested", "hide_for_you") { requireRestart() }
|
||||
"hide_friend_suggestions", "hide_suggested_friend_stories", "hide_friends", "hide_suggested", "hide_for_you") { requireRestart() }
|
||||
val hideUiComponents = multiple("hide_ui_components",
|
||||
"hide_voice_record_button",
|
||||
"hide_stickers_button",
|
||||
|
@ -7,7 +7,9 @@ import android.text.SpannableString
|
||||
import android.view.View
|
||||
import android.view.ViewGroup.MarginLayoutParams
|
||||
import android.widget.FrameLayout
|
||||
import me.rhunk.snapenhance.common.util.ktx.findFieldsToString
|
||||
import me.rhunk.snapenhance.core.event.events.impl.AddViewEvent
|
||||
import me.rhunk.snapenhance.core.event.events.impl.BindViewEvent
|
||||
import me.rhunk.snapenhance.core.features.Feature
|
||||
import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
||||
import me.rhunk.snapenhance.core.util.hook.HookStage
|
||||
@ -51,6 +53,7 @@ class UITweaks : Feature("UITweaks", loadParams = FeatureLoadParams.ACTIVITY_CRE
|
||||
|
||||
val chatNoteRecordButton = getId("chat_note_record_button", "id")
|
||||
val unreadHintButton = getId("unread_hint_button", "id")
|
||||
val friendCardFrame = getId("friend_card_frame", "id")
|
||||
|
||||
View::class.java.hook("setVisibility", HookStage.BEFORE) { methodParam ->
|
||||
val viewId = (methodParam.thisObject() as View).id
|
||||
@ -71,6 +74,16 @@ class UITweaks : Feature("UITweaks", loadParams = FeatureLoadParams.ACTIVITY_CRE
|
||||
}
|
||||
}
|
||||
|
||||
context.event.subscribe(BindViewEvent::class, { hideStorySections.contains("hide_suggested_friend_stories") }) { event ->
|
||||
if (event.view.id != friendCardFrame) return@subscribe
|
||||
|
||||
val friendStoryData = event.prevModel::class.java.findFieldsToString(event.prevModel, once = true) { _, value ->
|
||||
value.contains("FriendStoryData")
|
||||
}.firstOrNull()?.get(event.prevModel) ?: return@subscribe
|
||||
|
||||
event.view.visibility = if (friendStoryData.toString().contains("isFriendOfFriend=true")) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
context.event.subscribe(AddViewEvent::class) { event ->
|
||||
val viewId = event.view.id
|
||||
val view = event.view
|
||||
|
Reference in New Issue
Block a user