fix(core/ui_tweaks): friend card frame dimension

This commit is contained in:
rhunk
2023-12-16 18:27:28 +01:00
parent 7dd4241be0
commit 22bcfbc1f1

View File

@ -4,8 +4,8 @@ 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
import android.view.ViewGroup.MarginLayoutParams
import android.widget.FrameLayout
import me.rhunk.snapenhance.common.util.ktx.findFieldsToString
@ -75,6 +75,8 @@ class UITweaks : Feature("UITweaks", loadParams = FeatureLoadParams.ACTIVITY_CRE
}
}
var friendCardFrameSize: Size? = null
context.event.subscribe(BindViewEvent::class, { hideStorySections.contains("hide_suggested_friend_stories") }) { event ->
if (event.view.id != friendCardFrame) return@subscribe
@ -83,12 +85,18 @@ class UITweaks : Feature("UITweaks", loadParams = FeatureLoadParams.ACTIVITY_CRE
}.firstOrNull()?.get(event.prevModel) ?: return@subscribe
event.view.layoutParams.apply {
if (friendCardFrameSize == null && width > 0 && height > 0) {
friendCardFrameSize = Size(width, height)
}
if (friendStoryData.toString().contains("isFriendOfFriend=true")) {
width = 0
height = 0
} else {
width = ViewGroup.LayoutParams.WRAP_CONTENT
height = ViewGroup.LayoutParams.WRAP_CONTENT
friendCardFrameSize?.let {
width = it.width
height = it.height
}
}
}
}