commit 7d932f0fb4e5183de78ee3c16e3661a702ff9cb7
parent 047efccb3f3ce58b416ebf5efaf3506692537f28
Author: rhunk <101876869+rhunk@users.noreply.github.com>
Date:   Sun,  8 Dec 2024 17:44:56 +0100

feat(client_bootstrap_override): simple snapchat

Diffstat:
Mcommon/src/main/assets/lang/en_US.json | 8++++++++
Mcommon/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/UserInterfaceTweaks.kt | 5+++--
Mcore/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/ClientBootstrapOverride.kt | 24++++++++++++++++++++++--
3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -478,6 +478,10 @@ "home_tab": { "name": "Home Tab", "description": "Overrides the startup tab when opening Snapchat" + }, + "simple_snapchat":{ + "name": "Simple Snapchat", + "description": "Enables a simplified version of Snapchat" } } }, @@ -1279,6 +1283,10 @@ "discover": "Discover", "spotlight": "Spotlight" }, + "simple_snapchat": { + "always_enabled": "Always Enabled", + "always_disabled": "Always Disabled" + }, "add_friend_source_spoof": { "added_by_username": "By Username", "added_by_mention": "By Mention", diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/UserInterfaceTweaks.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/UserInterfaceTweaks.kt @@ -11,8 +11,9 @@ class UserInterfaceTweaks : ConfigContainer() { val tabs = arrayOf("map", "chat", "camera", "discover", "spotlight") } - val appAppearance = unique("app_appearance", "always_light", "always_dark") - val homeTab = unique("home_tab", *tabs) { addNotices(FeatureNotice.UNSTABLE) } + val appAppearance = unique("app_appearance", "always_light", "always_dark") { requireRestart() } + val homeTab = unique("home_tab", *tabs) { addNotices(FeatureNotice.UNSTABLE); requireRestart() } + val simpleSnapchat = unique("simple_snapchat", "always_enabled", "always_disabled") { addNotices(FeatureNotice.UNSTABLE); requireRestart() } } inner class FriendFeedMessagePreview : ConfigContainer(hasGlobalState = true) { diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/ClientBootstrapOverride.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/ui/ClientBootstrapOverride.kt @@ -1,6 +1,8 @@ package me.rhunk.snapenhance.core.features.impl.ui import me.rhunk.snapenhance.common.config.impl.UserInterfaceTweaks +import me.rhunk.snapenhance.common.util.protobuf.ProtoEditor +import me.rhunk.snapenhance.common.util.protobuf.ProtoWriter import me.rhunk.snapenhance.core.features.Feature import java.io.File @@ -28,8 +30,26 @@ class ClientBootstrapOverride: Feature("ClientBootstrapOverride") { appearanceStartupConfigFile.writeBytes(byteArrayOf(0, 0, 0, state)) } - bootstrapOverrideConfig.homeTab.getNullable()?.also { currentTab -> - plusFile.writeBytes(byteArrayOf(8, (UserInterfaceTweaks.BootstrapOverride.tabs.indexOf(currentTab) + 1).toByte())) + val homeTab = bootstrapOverrideConfig.homeTab.getNullable() + val simpleSnapchat = bootstrapOverrideConfig.simpleSnapchat.getNullable() + + if (homeTab != null || simpleSnapchat != null) { + val plusFileBytes = plusFile.exists().let { if (it) plusFile.readBytes() else ProtoWriter().toByteArray() } + + plusFile.writeBytes( + ProtoEditor(plusFileBytes).apply { + edit { + homeTab?.let { currentTab -> + remove(1) + addVarInt(1, UserInterfaceTweaks.BootstrapOverride.tabs.indexOf(currentTab) + 1) + } + simpleSnapchat?.let { simpleSnapchat -> + remove(2) + addVarInt(2, if (simpleSnapchat == "always_enabled") 1 else 0) + } + } + }.toByteArray() + ) } } } \ No newline at end of file