commit b92378bffd59d6457f3c9c28c3f5cf92fa82ad34
parent b1238976858f422ef160d90f1ef6021ba65778d9
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date:   Fri, 26 Apr 2024 11:52:29 +0200

feat(core): disable custom tabs

Diffstat:
Mcommon/src/main/assets/lang/en_US.json | 4++++
Mcommon/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Global.kt | 1+
Mcore/src/main/kotlin/me/rhunk/snapenhance/core/features/FeatureManager.kt | 1+
Acore/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/global/DisableCustomTabs.kt | 20++++++++++++++++++++
4 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -648,6 +648,10 @@ "name": "Block Ads", "description": "Prevents Advertisements from being displayed" }, + "disable_custom_tabs": { + "name": "Disable Custom Tabs", + "description": "Opens links in supported applications rather than in the Web Browser" + }, "disable_permission_requests": { "name": "Disable Permission Requests", "description": "Prevents Snapchat from asking for specific permissions" diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Global.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/Global.kt @@ -32,6 +32,7 @@ class Global : ConfigContainer() { val disableMetrics = boolean("disable_metrics") { requireRestart() } val disableStorySections = multiple("disable_story_sections", "friends", "following", "discover") { requireRestart(); requireCleanCache() } val blockAds = boolean("block_ads") + val disableCustomTabs = boolean("disable_custom_tabs") { requireRestart() } val disablePermissionRequests = multiple("disable_permission_requests", *permissionMap.values.toTypedArray()) { requireRestart(); addNotices(FeatureNotice.UNSTABLE) } val disableMemoriesSnapFeed = boolean("disable_memories_snap_feed") val spotlightCommentsUsername = boolean("spotlight_comments_username") { requireRestart() } 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 @@ -127,6 +127,7 @@ class FeatureManager( AutoOpenSnaps(), CustomStreaksExpirationFormat(), ComposerHooks(), + DisableCustomTabs(), ) initializeFeatures() diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/global/DisableCustomTabs.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/global/DisableCustomTabs.kt @@ -0,0 +1,19 @@ +package me.rhunk.snapenhance.core.features.impl.global + +import android.content.Intent +import me.rhunk.snapenhance.core.features.Feature +import me.rhunk.snapenhance.core.features.FeatureLoadParams +import me.rhunk.snapenhance.core.util.hook.HookStage +import me.rhunk.snapenhance.core.util.hook.hook + +class DisableCustomTabs: Feature("Disable Custom Tabs", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) { + override fun onActivityCreate() { + if (!context.config.global.disableCustomTabs.get()) return + context.mainActivity!!.packageManager.javaClass.hook("resolveService", HookStage.BEFORE) { param -> + val intent = param.arg<Intent>(0) + if (intent.action == "android.support.customtabs.action.CustomTabsService") { + param.setResult(null) + } + } + } +}+ \ No newline at end of file