From 73616f2158af13b9af498a5275532ac773a2ffa9 Mon Sep 17 00:00:00 2001 From: imCrest <217463890+imCrest@users.noreply.github.com> Date: Fri, 17 Apr 2026 11:25:16 +0000 Subject: [PATCH] Sync: Update from upstream --- .../core/features/impl/ui/UITweaks.kt | 44 +++++++++++++++---- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/UITweaks.kt b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/UITweaks.kt index 0362baea..ebf9690b 100644 --- a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/UITweaks.kt +++ b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/UITweaks.kt @@ -74,24 +74,47 @@ class UITweaks : Feature("UITweaks") { spotlightNavIds: Set, spotlightNavNames: Set ): Boolean { - fun resourceEntryNameOrNull(id: Int): String? { + fun resourceEntryNameOrNull(view: View): String? { + val id = view.id if (id == View.NO_ID || id == 0) return null return runCatching { context.resources.getResourceEntryName(id) }.getOrNull() } - val viewId = event.view.id - val parentId = event.parent.id - if (viewId in spotlightNavIds || parentId in spotlightNavIds) return true + val views = buildList { + var current: View? = event.view + repeat(5) { + current ?: return@repeat + add(current!!) + current = current?.parent as? View + } + } - val resourceNames = listOfNotNull( - resourceEntryNameOrNull(viewId), - resourceEntryNameOrNull(parentId) - ) + if (views.any { it.id in spotlightNavIds }) return true + + val resourceNames = views.mapNotNull(::resourceEntryNameOrNull) if (resourceNames.any { it in spotlightNavNames }) return true // Keep the fallback scoped to home/bottom navigation resource names so // chat media viewers and spotlight-related content surfaces still open. + val classNames = views.map { it.javaClass.name } + val contentDescriptions = views.mapNotNull { it.contentDescription?.toString() } + + val hasSpotlightMarker = resourceNames.any { it.contains("spotlight", ignoreCase = true) } || + contentDescriptions.any { it.contains("spotlight", ignoreCase = true) } + + if (!hasSpotlightMarker) return false + + return resourceNames.any { resourceEntryName -> + ( + resourceEntryName.contains("spotlight", ignoreCase = true) || + resourceEntryName.contains("following", ignoreCase = true) + ) && + ( + resourceEntryName.contains("hova_nav", ignoreCase = true) || + resourceEntryName.contains("bottom_nav", ignoreCase = true) || + resourceEntryName.contains("nav", ignoreCase = true) || + resourceEntryName.contains("tab", ignoreCase = true) return resourceNames.any { resourceEntryName -> resourceEntryName.contains("spotlight", ignoreCase = true) && ( @@ -99,6 +122,11 @@ class UITweaks : Feature("UITweaks") { resourceEntryName.contains("bottom_nav", ignoreCase = true) || resourceEntryName.contains("nav", ignoreCase = true) ) + } || classNames.any { className -> + className.contains("navigation", ignoreCase = true) || + className.contains("bottom", ignoreCase = true) || + className.contains("tab", ignoreCase = true) || + className.contains("hova", ignoreCase = true) } }