commit 1d41aef8e058ca4dcc50e145efacd0edca5d2edb parent 1a40856ae74db91023f27cb23bc064413e74fa39 Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Mon, 9 Oct 2023 21:46:17 +0200 feat: hide streak restore Diffstat:
4 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/core/src/main/assets/lang/en_US.json b/core/src/main/assets/lang/en_US.json @@ -252,6 +252,10 @@ "name": "Show Streak Expiration Info", "description": "Shows a Streak Expiration timer next to the Streaks counter" }, + "hide_streak_restore": { + "name": "Hide Streak Restore", + "description": "Hides the Restore button in the friend feed" + }, "hide_story_sections": { "name": "Hide Story Section", "description": "Hide certain UI Elements shown in the story section" diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/config/impl/UserInterfaceTweaks.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/config/impl/UserInterfaceTweaks.kt @@ -26,6 +26,7 @@ class UserInterfaceTweaks : ConfigContainer() { val bootstrapOverride = container("bootstrap_override", BootstrapOverride()) { requireRestart() } val mapFriendNameTags = boolean("map_friend_nametags") { requireRestart() } val streakExpirationInfo = boolean("streak_expiration_info") { requireRestart() } + val hideStreakRestore = boolean("hide_streak_restore") { requireRestart() } val hideStorySections = multiple("hide_story_sections", "hide_friend_suggestions", "hide_friends", "hide_suggested", "hide_for_you") { requireRestart() } val hideUiComponents = multiple("hide_ui_components", diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/features/impl/ui/HideStreakRestore.kt b/core/src/main/kotlin/me/rhunk/snapenhance/features/impl/ui/HideStreakRestore.kt @@ -0,0 +1,19 @@ +package me.rhunk.snapenhance.features.impl.ui + +import me.rhunk.snapenhance.core.util.ktx.getObjectField +import me.rhunk.snapenhance.core.util.ktx.setObjectField +import me.rhunk.snapenhance.features.Feature +import me.rhunk.snapenhance.features.FeatureLoadParams +import me.rhunk.snapenhance.hook.HookStage +import me.rhunk.snapenhance.hook.hookConstructor + +class HideStreakRestore : Feature("HideStreakRestore", loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) { + override fun onActivityCreate() { + if (!context.config.userInterface.hideStreakRestore.get()) return + + context.classCache.feedEntry.hookConstructor(HookStage.AFTER) { param -> + val streakMetadata = param.thisObject<Any>().getObjectField("mStreakMetadata") ?: return@hookConstructor + streakMetadata.setObjectField("mExpiredStreak", null) + } + } +}+ \ No newline at end of file diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt b/core/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt @@ -24,6 +24,7 @@ import me.rhunk.snapenhance.features.impl.spying.StealthMode import me.rhunk.snapenhance.features.impl.tweaks.* import me.rhunk.snapenhance.features.impl.ui.ClientBootstrapOverride import me.rhunk.snapenhance.features.impl.ui.FriendFeedMessagePreview +import me.rhunk.snapenhance.features.impl.ui.HideStreakRestore import me.rhunk.snapenhance.features.impl.ui.PinConversations import me.rhunk.snapenhance.features.impl.ui.UITweaks import me.rhunk.snapenhance.manager.Manager @@ -104,6 +105,7 @@ class FeatureManager( OldBitmojiSelfie::class, SnapToChatMedia::class, FriendFeedMessagePreview::class, + HideStreakRestore::class, ) initializeFeatures()