From bea175b97e136579c4f310dcf8638452aa58e0c4 Mon Sep 17 00:00:00 2001 From: Daniel Frett Date: Wed, 24 May 2023 15:03:25 -0600 Subject: [PATCH] delete TractAppsFlyerDeepLinkResolver --- .../cru/godtools/tract/TractRendererModule.kt | 7 --- .../TractAppsFlyerDeepLinkResolver.kt | 27 ---------- ...ppsFlyerDeepLinkResolverRobolectricTest.kt | 44 ----------------- .../TractAppsFlyerDeepLinkResolverTest.kt | 49 ------------------- 4 files changed, 127 deletions(-) delete mode 100644 ui/tract-renderer/src/main/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolver.kt delete mode 100644 ui/tract-renderer/src/test/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolverRobolectricTest.kt delete mode 100644 ui/tract-renderer/src/test/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolverTest.kt diff --git a/ui/tract-renderer/src/main/kotlin/org/cru/godtools/tract/TractRendererModule.kt b/ui/tract-renderer/src/main/kotlin/org/cru/godtools/tract/TractRendererModule.kt index 42c7f90a71..7873e873ae 100644 --- a/ui/tract-renderer/src/main/kotlin/org/cru/godtools/tract/TractRendererModule.kt +++ b/ui/tract-renderer/src/main/kotlin/org/cru/godtools/tract/TractRendererModule.kt @@ -6,8 +6,6 @@ import dagger.Reusable import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import dagger.multibindings.IntoSet -import org.cru.godtools.analytics.appsflyer.AppsFlyerDeepLinkResolver -import org.cru.godtools.tract.analytics.appsflyer.TractAppsFlyerDeepLinkResolver import org.greenrobot.eventbus.meta.SubscriberInfoIndex @Module @@ -17,9 +15,4 @@ object TractRendererModule { @Provides @Reusable fun tractEventBusIndex(): SubscriberInfoIndex = TractEventBusIndex() - - @IntoSet - @Provides - @Reusable - fun tractAppsFlyerDeepLinkResolver(): AppsFlyerDeepLinkResolver = TractAppsFlyerDeepLinkResolver } diff --git a/ui/tract-renderer/src/main/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolver.kt b/ui/tract-renderer/src/main/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolver.kt deleted file mode 100644 index 883567a01c..0000000000 --- a/ui/tract-renderer/src/main/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolver.kt +++ /dev/null @@ -1,27 +0,0 @@ -package org.cru.godtools.tract.analytics.appsflyer - -import android.content.Context -import android.content.Intent -import android.net.Uri -import java.util.Locale -import org.cru.godtools.analytics.appsflyer.AppsFlyerDeepLinkResolver -import org.cru.godtools.base.ui.createTractActivityIntent -import org.cru.godtools.tract.activity.TractActivity -import org.cru.godtools.tract.util.isTractDeepLink - -object TractAppsFlyerDeepLinkResolver : AppsFlyerDeepLinkResolver { - override fun resolve(context: Context, uri: Uri?, data: Map) = when { - uri?.isTractDeepLink() == true -> Intent(Intent.ACTION_VIEW, uri, context, TractActivity::class.java) - else -> null - } - - override fun resolve(context: Context, deepLinkValue: String) = deepLinkValue.split("|") - .takeIf { it.size >= 4 && it[0] == "tool" && it[1] == "tract" } - ?.let { - context.createTractActivityIntent( - it[2], - Locale.forLanguageTag(it[3]), - page = it.getOrNull(4)?.toIntOrNull() ?: 0 - ) - } -} diff --git a/ui/tract-renderer/src/test/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolverRobolectricTest.kt b/ui/tract-renderer/src/test/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolverRobolectricTest.kt deleted file mode 100644 index ccbbbd56e8..0000000000 --- a/ui/tract-renderer/src/test/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolverRobolectricTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -package org.cru.godtools.tract.analytics.appsflyer - -import android.content.ComponentName -import android.content.Context -import android.content.Intent -import android.net.Uri -import androidx.test.core.app.ApplicationProvider -import androidx.test.ext.junit.runners.AndroidJUnit4 -import org.cru.godtools.tract.activity.TractActivity -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class TractAppsFlyerDeepLinkResolverRobolectricTest { - private lateinit var context: Context - - @Before - fun setup() { - context = ApplicationProvider.getApplicationContext() - } - - @Test - fun verifyResolveNoUri() { - assertNull(TractAppsFlyerDeepLinkResolver.resolve(context, null, emptyMap())) - } - - @Test - fun verifyResolveInvalidUri() { - assertNull(TractAppsFlyerDeepLinkResolver.resolve(context, Uri.parse("https://example.com/en/kgp"), emptyMap())) - } - - @Test - fun verifyResolveValidUri() { - val uri = Uri.parse("https://knowgod.com/en/kgp") - - val intent = TractAppsFlyerDeepLinkResolver.resolve(context, uri, emptyMap())!! - assertEquals(Intent.ACTION_VIEW, intent.action) - assertEquals(uri, intent.data) - assertEquals(ComponentName(context, TractActivity::class.java), intent.component) - } -} diff --git a/ui/tract-renderer/src/test/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolverTest.kt b/ui/tract-renderer/src/test/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolverTest.kt deleted file mode 100644 index d3ad3e7889..0000000000 --- a/ui/tract-renderer/src/test/kotlin/org/cru/godtools/tract/analytics/appsflyer/TractAppsFlyerDeepLinkResolverTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -package org.cru.godtools.tract.analytics.appsflyer - -import android.content.Context -import android.content.Intent -import io.mockk.Called -import io.mockk.every -import io.mockk.mockk -import io.mockk.mockkStatic -import io.mockk.verify -import io.mockk.verifyAll -import java.util.Locale -import org.cru.godtools.base.ui.createTractActivityIntent -import org.junit.Assert.assertNull -import org.junit.Assert.assertSame -import org.junit.Before -import org.junit.Test - -class TractAppsFlyerDeepLinkResolverTest { - private val context = mockk() - private val intent = mockk() - - @Before - fun setupMocks() { - mockkStatic("org.cru.godtools.base.ui.ActivitiesKt") - every { context.createTractActivityIntent(any(), *anyVararg(), page = any()) } returns intent - } - - @Test - fun testInvalidDeepLinks() { - listOf("", "dashboard", "tool|lesson|kgp|en", "tool|cyoa|", "tool|cyoa|test").forEach { - assertNull("$it should not resolve to an intent", TractAppsFlyerDeepLinkResolver.resolve(context, it)) - verify { - context.createTractActivityIntent(any(), *anyVararg(), page = any(), showTips = any()) wasNot Called - } - } - } - - @Test - fun testTractDeepLink() { - assertSame(intent, TractAppsFlyerDeepLinkResolver.resolve(context, "tool|tract|test|en-US")) - verifyAll { context.createTractActivityIntent("test", Locale.forLanguageTag("en-US")) } - } - - @Test - fun testTractDeepLinkWithPage() { - assertSame(intent, TractAppsFlyerDeepLinkResolver.resolve(context, "tool|tract|test|en-US|5")) - verifyAll { context.createTractActivityIntent("test", Locale.forLanguageTag("en-US"), page = 5) } - } -}