fix(ui): debug chat context menu

Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>
This commit is contained in:
rhunk 2025-01-18 18:35:56 +01:00
parent f9d1c9ea33
commit d217e2e86d

View File

@ -1,10 +1,10 @@
package me.rhunk.snapenhance.core.ui.menu
import android.annotation.SuppressLint
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.LinearLayout
import me.rhunk.snapenhance.core.event.events.impl.AddViewEvent
import me.rhunk.snapenhance.core.features.Feature
import me.rhunk.snapenhance.core.features.impl.COFOverride
@ -58,13 +58,17 @@ class MenuViewInjector : Feature("MenuViewInjector") {
val viewGroup: ViewGroup = event.parent
val childView: View = event.view
if (viewGroup !is LinearLayout && childView.id == chatActionMenu && context.isDeveloper) {
event.view = LinearLayout(childView.context).apply {
orientation = LinearLayout.VERTICAL
addView(
(menuMap[NewChatActionMenu::class]!! as NewChatActionMenu).createDebugInfoView(childView.context)
)
addView(event.view)
if (childView.javaClass.name.endsWith("ActionMenuChatItemContainer") && context.isDeveloper) {
childView.post {
(event.parent.parent as ViewGroup).addView(
(menuMap[NewChatActionMenu::class] as NewChatActionMenu).createDebugInfoView(context.mainActivity!!).apply {
layoutParams = FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
).apply {
gravity = Gravity.TOP or Gravity.START
}
}, 0)
}
}