commit 47a549ea2d101816a8f9c0bb900c19d7ec3f1487 parent e45e96908b9f57f07383f25a94e066b5e63d1336 Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:32:14 +0200 feat(experimental): context menu fix Attempt to repair the Friend Feed Menu as when the device is offline it cannot be displayed correctly Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com> Diffstat:
4 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -1050,6 +1050,10 @@ "name": "Edit Messages", "description": "Allows you to edit messages in conversations" }, + "context_menu_fix": { + "name": "Context Menu Fix", + "description": "Attempt to repair the Friend Feed Menu as when the device is offline it cannot be displayed correctly" + }, "app_lock": { "name": "App Lock", "description": "Prevents access to Snapchat without a passcode", diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Experimental.kt @@ -56,6 +56,7 @@ class Experimental : ConfigContainer() { val callRecorder = boolean("call_recorder") { requireRestart(); addNotices(FeatureNotice.UNSTABLE); } val accountSwitcher = container("account_switcher", AccountSwitcherConfig()) { requireRestart(); addNotices(FeatureNotice.UNSTABLE) } val editMessage = boolean("edit_message") { requireRestart() } + val contextMenuFix = boolean("context_menu_fix") { requireRestart() } val cofExperiments = multiple("cof_experiments", *cofExperimentList.toTypedArray()) { requireRestart(); addFlags(ConfigFlag.NO_TRANSLATE); addNotices(FeatureNotice.UNSTABLE) } val appLock = container("app_lock", AppLockConfig()) { requireRestart(); addNotices(FeatureNotice.UNSTABLE) } val infiniteStoryBoost = boolean("infinite_story_boost") diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/FeatureManager.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/FeatureManager.kt @@ -129,6 +129,7 @@ class FeatureManager( ComposerHooks(), DisableCustomTabs(), BestFriendPinning(), + ContextMenuFix(), ) initializeFeatures() } diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/ContextMenuFix.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/experiments/ContextMenuFix.kt @@ -0,0 +1,25 @@ +package me.rhunk.snapenhance.core.features.impl.experiments + +import me.rhunk.snapenhance.core.event.events.impl.UnaryCallEvent +import me.rhunk.snapenhance.core.features.Feature +import me.rhunk.snapenhance.core.features.FeatureLoadParams +import java.nio.ByteBuffer + +class ContextMenuFix: Feature("Context Menu Fix", loadParams = FeatureLoadParams.INIT_SYNC) { + override fun init() { + if (!context.config.experimental.contextMenuFix.get()) return + context.event.subscribe(UnaryCallEvent::class) { event -> + if (event.uri == "/snapchat.maps.device.MapDevice/IsPrimary") { + event.canceled = true + val unaryEventHandler = event.adapter.arg<Any>(3) + runCatching { + unaryEventHandler::class.java.methods.first { it.name == "onEvent" }.invoke(unaryEventHandler, ByteBuffer.wrap( + byteArrayOf(8, 1) + ), null) + }.onFailure { + context.log.error(null, it) + } + } + } + } +}+ \ No newline at end of file