diff --git a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ConfigurationOverride.kt b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ConfigurationOverride.kt index a9d66f63..915f21d0 100644 --- a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ConfigurationOverride.kt +++ b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ConfigurationOverride.kt @@ -69,6 +69,16 @@ class ConfigurationOverride : Feature("Configuration Override") { overrideProperty("TRANSCODING_MAX_QUALITY", { context.config.global.mediaUploadQualityConfig.forceVideoUploadSourceQuality.get() || context.config.messaging.galleryMediaSendOverride.mode.getNullable() != null }, { true }, isAppExperiment = true) + overrideProperty("BYPASS_AD_FEATURE_GATE", { context.config.global.blockAds.get() }, + { true }) + + overrideProperty("SPONSORED_SNAPS_ENABLED", { context.config.global.blockAds.get() }, { false }) + overrideProperty("SPONSORED_SNAP_UPDATE_SPONSORED_FEED_ITEM", { context.config.global.blockAds.get() }, { false }) + + arrayOf("CUSTOM_AD_TRACKER_URL", "CUSTOM_AD_INIT_SERVER_URL", "CUSTOM_AD_SERVER_URL", "INIT_PRIMARY_URL", "INIT_SHADOW_URL", "GRAPHENE_HOST").forEach { + overrideProperty(it, { context.config.global.blockAds.get() }, { "http://127.0.0.1" }) + } + run { val isForceQuality = { _: ConfigKeyInfo -> context.config.global.mediaUploadQualityConfig.forceVideoUploadSourceQuality.get() || context.config.messaging.galleryMediaSendOverride.mode.getNullable() != null } val level7Value = { _: ConfigKeyInfo -> 700 } @@ -172,15 +182,6 @@ class ConfigurationOverride : Feature("Configuration Override") { }, { false }) - overrideProperty("BYPASS_AD_FEATURE_GATE", { context.config.global.blockAds.get() }, - { true }) - - overrideProperty("SPONSORED_SNAPS_ENABLED", { context.config.global.blockAds.get() }, { false }) - overrideProperty("SPONSORED_SNAP_UPDATE_SPONSORED_FEED_ITEM", { context.config.global.blockAds.get() }, { false }) - - arrayOf("CUSTOM_AD_TRACKER_URL", "CUSTOM_AD_INIT_SERVER_URL", "CUSTOM_AD_SERVER_URL", "INIT_PRIMARY_URL", "INIT_SHADOW_URL", "GRAPHENE_HOST").forEach { - overrideProperty(it, { context.config.global.blockAds.get() }, { "http://127.0.0.1" }) - } overrideProperty("GIFTING_CHAT_BIRTHDAY_UPSELL_ENABLED", { context.config.userInterface.hideUiComponents.get().contains("hide_snapchat_plus_gift_reminders") }, { false }) classReference.getAsClass()?.hook( diff --git a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/global/AdBlockFix.kt b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/global/AdBlockFix.kt index c630f242..8cb2e4e4 100644 --- a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/global/AdBlockFix.kt +++ b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/global/AdBlockFix.kt @@ -2,7 +2,6 @@ package me.eternal.purrfectsnap.core.features.impl.global import android.os.SystemClock import android.view.View -import me.eternal.purrfectsnap.core.event.events.impl.BindViewEvent import me.eternal.purrfectsnap.core.features.Feature import me.eternal.purrfectsnap.core.ui.hideViewCompletely import me.eternal.purrfectsnap.core.ui.dispatchSyntheticTap @@ -35,7 +34,6 @@ class AdBlockFix : Feature("AdBlockFix") { hookFeedEntryTracking() hookMessagingFeedCallbacks() - hookChatFeedRowSuppression() hookOperaAutoSkip() } @@ -45,7 +43,7 @@ class AdBlockFix : Feature("AdBlockFix") { val conversationId = feedEntry.getObjectFieldOrNull("mConversationId")?.let(::SnapUUID)?.toString() ?: return@hookConstructor - if (isCampaignFeedEntry(feedEntry) || isChatAdShareFeedEntry(feedEntry)) { + if (isCampaignFeedEntry(feedEntry)) { adConversationIds.add(conversationId) } } @@ -123,36 +121,20 @@ class AdBlockFix : Feature("AdBlockFix") { } } - private fun hookChatFeedRowSuppression() { - context.event.subscribe(BindViewEvent::class) { event -> - val modelDump = event.prevModel.toString() - event.friendFeedItem { conversationId -> - if (adConversationIds.contains(conversationId) || isChatAdShareModel(modelDump)) { - hideBoundChatFeedRow(event.view) - } - } - } - } - - private fun hideBoundChatFeedRow(view: View) { - view.hideViewCompletely() - (view.parent as? View)?.hideViewCompletely() - (view.parent?.parent as? View)?.hideViewCompletely() - } - private fun hookOperaAutoSkip() { onNextActivityCreate { context.mappings.useMapper(OperaPageViewControllerMapper::class) { arrayOf(onDisplayStateChange, onDisplayStateChangeGesture).forEach { methodName -> val resolvedMethod = methodName.get() ?: return@forEach classReference.get()?.hook(resolvedMethod, HookStage.AFTER) { param -> + val instance = param.thisObject() val viewState = runCatching { - param.thisObject().getObjectField(viewStateField.get()!!)?.toString() + instance::class.java.methods.firstOrNull { it.name.contains("ViewState") || it.name == "g" }?.invoke(instance)?.toString() }.getOrNull() ?: return@hook if (viewState != "FULLY_DISPLAYED") return@hook val layerList = runCatching { - param.thisObject().getObjectField(layerListField.get()!!) as? ArrayList<*> + instance::class.java.methods.firstOrNull { it.name.contains("LayerList") || it.name == "l" }?.invoke(instance) as? ArrayList<*> }.getOrNull() ?: return@hook val paramMap = runCatching { layerList.map { Layer(it).paramMap }.firstOrNull() @@ -209,25 +191,6 @@ class AdBlockFix : Feature("AdBlockFix") { ?.getObjectFieldOrNull("mCampaignMetadata") != null } - private fun isChatAdShareFeedEntry(feedEntry: Any): Boolean { - val interactionDump = feedEntry.getObjectFieldOrNull("mInteractionInfo")?.toString().orEmpty() - val displayDump = feedEntry.getObjectFieldOrNull("mDisplayInfo")?.toString().orEmpty() - val combined = "$interactionDump $displayDump" - return isChatAdShareModel(combined) - } - - private fun isChatAdShareModel(modelDump: String): Boolean { - if (modelDump.isBlank()) return false - return modelDump.contains("CHAT_AD_SHARE") || - modelDump.contains("AD_SHARE") || - modelDump.contains("ChatAd") || - modelDump.contains("chat_ad_share") || - modelDump.contains("chat_sponsored_snap") || - modelDump.contains("CommonAttachmentViewModel") || - modelDump.contains("visibilityFeedbackURL") || - modelDump.contains("pageLoadPingURL") - } - private fun isSpotlightCommercialPage(paramMap: ParamMap): Boolean { val snapSource = paramMap["SNAP_SOURCE"]?.toString() if (snapSource != "SINGLE_SNAP_STORY" && snapSource != "SPOTLIGHT" && snapSource != "PUBLIC_STORY") { diff --git a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/FriendFeedMessagePreview.kt b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/FriendFeedMessagePreview.kt index 63b34e67..8f542f54 100644 --- a/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/FriendFeedMessagePreview.kt +++ b/core/src/main/kotlin/me/eternal/purrfectsnap/core/features/impl/ui/FriendFeedMessagePreview.kt @@ -80,7 +80,7 @@ class FriendFeedMessagePreview : Feature("FriendFeedMessagePreview") { val ffSdlPrimaryTextStartMargin = 6 * density val feedEntryHeight = ffSdlAvatarSize + ffSdlAvatarMargin * 2 + (4 * density).toInt() - val safetyGap = (12 * density).toInt() + val safetyGap = (6 * density).toInt() val textPaint = TextPaint().apply { textSize = secondaryTextSize isAntiAlias = true @@ -123,14 +123,14 @@ class FriendFeedMessagePreview : Feature("FriendFeedMessagePreview") { } ffItem.layoutParams = ffItem.layoutParams.apply { - height = feedEntryHeight + (safetyGap * 2) + previewContainerHeight + height = feedEntryHeight + (safetyGap * 1.5f).toInt() + previewContainerHeight } cachedLayouts[conversationId] = frameLayout frameLayout.addForegroundDrawable("ffItem", ShapeDrawable(object: Shape() { override fun draw(canvas: Canvas, paint: Paint) { - val startY = feedEntryHeight.toFloat() + safetyGap + val startY = feedEntryHeight.toFloat() + (1 * density).toInt() paint.textSize = secondaryTextSize paint.color = Color(context.userInterface.colorPrimary).copy(alpha = 0.7f).toArgb() paint.typeface = Typeface.DEFAULT @@ -138,7 +138,7 @@ class FriendFeedMessagePreview : Feature("FriendFeedMessagePreview") { messages?.forEachIndexed { index, messageString -> canvas.drawText(messageString, - ffSdlAvatarSize + ffSdlAvatarMargin + (ffSdlPrimaryTextStartMargin * 2), + ffSdlAvatarSize + ffSdlAvatarMargin + (ffSdlPrimaryTextStartMargin * 3), startY + (index + 1) * lineHeight + (index * spacing), paint )