commit 678ff1085c6ee5ff186017e9b683c727c5e722a9 parent c6c1df45472116de94bc8417b151e7dd3270ae06 Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Sun, 11 Jun 2023 21:28:41 +0200 feat: unlimited conversation pinning Diffstat:
6 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/app/src/main/assets/lang/en_US.json b/app/src/main/assets/lang/en_US.json @@ -72,7 +72,8 @@ "amoled_dark_mode": "AMOLED Dark Mode", "enable_friend_feed_menu_bar": "Enable New Friend Feed Menu Bar", "friend_feed_menu_buttons": "Friend Feed Menu Buttons", - "friend_feed_menu_buttons_position": "Friend Feed Buttons Position Index" + "friend_feed_menu_buttons_position": "Friend Feed Buttons Position Index", + "unlimited_conversation_pinning": "Unlimited Conversation Pinning" }, "option": { diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/bridge/common/impl/file/BridgeFileType.kt b/app/src/main/kotlin/me/rhunk/snapenhance/bridge/common/impl/file/BridgeFileType.kt @@ -8,7 +8,8 @@ enum class BridgeFileType(val value: Int, val fileName: String, val isDatabase: STEALTH(3, "stealth.txt"), ANTI_AUTO_DOWNLOAD(4, "anti_auto_download.txt"), ANTI_AUTO_SAVE(5, "anti_auto_save.txt"), - AUTO_UPDATER_TIMESTAMP(6, "auto_updater_timestamp.txt"); + AUTO_UPDATER_TIMESTAMP(6, "auto_updater_timestamp.txt"), + PINNED_CONVERSATIONS(7, "pinned_conversations.txt"); companion object { fun fromValue(value: Int): BridgeFileType? { diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/config/ConfigProperty.kt b/app/src/main/kotlin/me/rhunk/snapenhance/config/ConfigProperty.kt @@ -265,6 +265,12 @@ enum class ConfigProperty( ConfigCategory.UI_TWEAKS, ConfigIntegerValue(20) ), + UNLIMITED_CONVERSATION_PINNING( + "property.unlimited_conversation_pinning", + "description.unlimited_conversation_pinning", + ConfigCategory.UI_TWEAKS, + ConfigStateValue(false) + ), DISABLE_SPOTLIGHT( "property.disable_spotlight", "description.disable_spotlight", diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/data/SnapClassCache.kt b/app/src/main/kotlin/me/rhunk/snapenhance/data/SnapClassCache.kt @@ -14,6 +14,9 @@ class SnapClassCache ( val networkApi by lazy { findClass("com.snapchat.client.network_api.NetworkApi\$CppProxy") } val messageDestinations by lazy { findClass("com.snapchat.client.messaging.MessageDestinations") } val localMessageContent by lazy { findClass("com.snapchat.client.messaging.LocalMessageContent") } + val feedEntry by lazy { findClass("com.snapchat.client.messaging.FeedEntry") } + val conversation by lazy { findClass("com.snapchat.client.messaging.Conversation") } + val feedManager by lazy { findClass("com.snapchat.client.messaging.FeedManager\$CppProxy") } private fun findClass(className: String): Class<*> { return try { diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/ui/PinConversations.kt b/app/src/main/kotlin/me/rhunk/snapenhance/features/impl/ui/PinConversations.kt @@ -0,0 +1,39 @@ +package me.rhunk.snapenhance.features.impl.ui + +import me.rhunk.snapenhance.bridge.common.impl.file.BridgeFileType +import me.rhunk.snapenhance.data.wrapper.impl.SnapUUID +import me.rhunk.snapenhance.features.BridgeFileFeature +import me.rhunk.snapenhance.features.FeatureLoadParams +import me.rhunk.snapenhance.hook.HookStage +import me.rhunk.snapenhance.hook.hook +import me.rhunk.snapenhance.hook.hookConstructor +import me.rhunk.snapenhance.util.getObjectField +import me.rhunk.snapenhance.util.setObjectField + +class PinConversations : BridgeFileFeature("PinConversations", BridgeFileType.PINNED_CONVERSATIONS, loadParams = FeatureLoadParams.ACTIVITY_CREATE_SYNC) { + override fun onActivityCreate() { + context.classCache.feedManager.hook("setPinnedConversationStatus", HookStage.BEFORE) { param -> + val conversationUUID = SnapUUID(param.arg(0)) + val isPinned = param.arg<Any>(1).toString() == "PINNED" + + setState(conversationUUID.toString(), isPinned) + } + + context.classCache.conversation.hookConstructor(HookStage.AFTER) { param -> + val instance = param.thisObject<Any>() + val conversationUUID = SnapUUID(instance.getObjectField("mConversationId")) + if (exists(conversationUUID.toString())) { + instance.setObjectField("mPinnedTimestampMs", 1L) + } + } + + context.classCache.feedEntry.hookConstructor(HookStage.AFTER) { param -> + val instance = param.thisObject<Any>() + val conversationUUID = SnapUUID(instance.getObjectField("mConversationId")) + val isPinned = exists(conversationUUID.toString()) + if (isPinned) { + instance.setObjectField("mPinnedTimestampMs", 1L) + } + } + } +}+ \ No newline at end of file diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt b/app/src/main/kotlin/me/rhunk/snapenhance/manager/impl/FeatureManager.kt @@ -29,6 +29,7 @@ import me.rhunk.snapenhance.features.impl.spying.MessageLogger import me.rhunk.snapenhance.features.impl.spying.PreventReadReceipts import me.rhunk.snapenhance.features.impl.spying.StealthMode import me.rhunk.snapenhance.features.impl.tweaks.CameraTweaks +import me.rhunk.snapenhance.features.impl.ui.PinConversations import me.rhunk.snapenhance.features.impl.ui.UITweaks import me.rhunk.snapenhance.features.impl.ui.menus.MenuViewInjector import me.rhunk.snapenhance.manager.Manager @@ -83,6 +84,7 @@ class FeatureManager(private val context: ModContext) : Manager { register(CameraTweaks::class) register(InfiniteStoryBoost::class) register(AmoledDarkMode::class) + register(PinConversations::class) initializeFeatures() }