commit fca2f8a53dfb78551b6a713f7eb2be5f5b9e4980
parent 9e02806f959de91f4c3188105536e4a8f724026b
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date: Mon, 12 Jun 2023 00:47:46 +0200
fix: ff menu injection
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/ui/menus/MenuViewInjector.kt b/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/ui/menus/MenuViewInjector.kt
@@ -43,6 +43,8 @@ class MenuViewInjector : Feature("MenuViewInjector", loadParams = FeatureLoadPar
chatActionMenu.context = context
settingMenu.context = context
+ val messaging = context.feature(Messaging::class)
+
val actionSheetItemsContainerLayoutId = context.resources.getIdentifier("action_sheet_items_container", "id", Constants.SNAPCHAT_PACKAGE_NAME)
val actionSheetContainer = context.resources.getIdentifier("action_sheet_container", "id", Constants.SNAPCHAT_PACKAGE_NAME)
val actionMenu = context.resources.getIdentifier("action_menu", "id", Constants.SNAPCHAT_PACKAGE_NAME)
@@ -76,7 +78,7 @@ class MenuViewInjector : Feature("MenuViewInjector", loadParams = FeatureLoadPar
}
//inject in group chat menus
- if (viewGroup.id == actionSheetContainer && childView.id == actionMenu) {
+ if (viewGroup.id == actionSheetContainer && childView.id == actionMenu && messaging.lastFetchConversationUserUUID == null) {
val injectedLayout = LinearLayout(childView.context).apply {
orientation = LinearLayout.VERTICAL
gravity = Gravity.BOTTOM
@@ -86,7 +88,6 @@ class MenuViewInjector : Feature("MenuViewInjector", loadParams = FeatureLoadPar
Hooker.ephemeralHook(context.classCache.conversationManager, "fetchConversation", HookStage.AFTER) {
if (wasInjectedView(injectedLayout)) return@ephemeralHook
- context.feature(Messaging::class).lastFetchConversationUserUUID = null
context.runOnUiThread {
val viewList = mutableListOf<View>()
@@ -126,11 +127,18 @@ class MenuViewInjector : Feature("MenuViewInjector", loadParams = FeatureLoadPar
})
return@hook
}
- if (context.feature(Messaging::class).lastFetchConversationUserUUID == null) return@hook
+ if (messaging.lastFetchConversationUserUUID == null) return@hook
//filter by the slot index
if (viewGroup.getChildCount() != context.config.int(ConfigProperty.MENU_SLOT_ID)) return@hook
friendFeedInfoMenu.inject(viewGroup, originalAddView)
+
+ viewGroup.addOnAttachStateChangeListener(object: View.OnAttachStateChangeListener {
+ override fun onViewAttachedToWindow(v: View) {}
+ override fun onViewDetachedFromWindow(v: View) {
+ messaging.lastFetchConversationUserUUID = null
+ }
+ })
}
}