Skip to content

Free Trial: Update Privacy Pro entry points in all locales #6370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2025 DuckDuckGo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.duckduckgo.mobile.android.vpn.ui.tracker_activity.view.message

import com.duckduckgo.anvil.annotations.ContributesRemoteFeature
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.feature.toggles.api.Toggle.DefaultFeatureValue

@ContributesRemoteFeature(
scope = AppScope::class,
featureName = "freeTrialInPProUpsell",
)
interface AppTPStateMessageToggle {
@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun self(): Toggle

@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
fun freeTrialCopy(): Toggle
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class PProUpsellBannerPlugin @Inject constructor(
private val browserNav: BrowserNav,
private val vpnStore: VpnStore,
private val deviceShieldPixels: DeviceShieldPixels,
private val appTPStateMessageToggle: AppTPStateMessageToggle,
) : AppTPStateMessagePlugin {
override fun getView(
context: Context,
Expand All @@ -55,14 +56,25 @@ class PProUpsellBannerPlugin @Inject constructor(
): View? {
val isEligible = runBlocking { subscriptions.isUpsellEligible() && !vpnStore.isPproUpsellBannerDismised() }
return if (isEligible) {
val subtitle: String
val actionText: String
runBlocking {
if (subscriptions.isFreeTrialEligible() && appTPStateMessageToggle.freeTrialCopy().isEnabled()) {
subtitle = context.getString(R.string.apptp_PproUpsellBannerMessage_freeTrial)
actionText = context.getString(R.string.apptp_PproUpsellBannerAction_freeTrial)
} else {
subtitle = context.getString(R.string.apptp_PproUpsellBannerMessage)
actionText = context.getString(R.string.apptp_PproUpsellBannerAction)
}
}
MessageCta(context)
.apply {
this.setMessage(
Message(
topIllustration = com.duckduckgo.mobile.android.R.drawable.ic_privacy_pro,
title = context.getString(R.string.apptp_PproUpsellBannerTitle),
subtitle = context.getString(R.string.apptp_PproUpsellBannerMessage),
action = context.getString(R.string.apptp_PproUpsellBannerAction),
subtitle = subtitle,
action = actionText,
messageType = REMOTE_MESSAGE,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class PproUpsellDisabledMessagePlugin @Inject constructor(
private val vpnDetector: ExternalVpnDetector,
private val browserNav: BrowserNav,
private val deviceShieldPixels: DeviceShieldPixels,
private val appTPStateMessageToggle: AppTPStateMessageToggle,
) : AppTPStateMessagePlugin {
override fun getView(
context: Context,
Expand All @@ -53,10 +54,17 @@ class PproUpsellDisabledMessagePlugin @Inject constructor(
): View? {
val isEligible = runBlocking { vpnDetector.isExternalVpnDetected() && subscriptions.isUpsellEligible() }
return if (vpnState.state == DISABLED && vpnState.stopReason is SELF_STOP && isEligible) {
val messageRes = runBlocking {
if (subscriptions.isFreeTrialEligible() && appTPStateMessageToggle.freeTrialCopy().isEnabled()) {
R.string.apptp_PproUpsellInfoDisabled_freeTrial
} else {
R.string.apptp_PproUpsellInfoDisabled
}
}
AppTpDisabledInfoPanel(context).apply {
setClickableLink(
PPRO_UPSELL_ANNOTATION,
context.getText(R.string.apptp_PproUpsellInfoDisabled),
context.getText(messageRes),
) { context.launchPPro() }
doOnAttach {
deviceShieldPixels.reportPproUpsellDisabledInfoShown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class PproUpsellRevokedMessagePlugin @Inject constructor(
private val subscriptions: Subscriptions,
private val browserNav: BrowserNav,
private val deviceShieldPixels: DeviceShieldPixels,
private val appTPStateMessageToggle: AppTPStateMessageToggle,
) : AppTPStateMessagePlugin {
override fun getView(
context: Context,
Expand All @@ -51,10 +52,17 @@ class PproUpsellRevokedMessagePlugin @Inject constructor(
): View? {
val isEligible = runBlocking { subscriptions.isUpsellEligible() }
return if (vpnState.state == DISABLED && vpnState.stopReason == REVOKED && isEligible) {
val messageRes = runBlocking {
if (subscriptions.isFreeTrialEligible() && appTPStateMessageToggle.freeTrialCopy().isEnabled()) {
R.string.apptp_PproUpsellInfoRevoked_freeTrial
} else {
R.string.apptp_PproUpsellInfoRevoked
}
}
AppTpDisabledInfoPanel(context).apply {
setClickableLink(
PPRO_UPSELL_ANNOTATION,
context.getText(R.string.apptp_PproUpsellInfoRevoked),
context.getText(messageRes),
) { context.launchPPro() }
doOnAttach {
deviceShieldPixels.reportPproUpsellRevokedInfoShown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.duckduckgo.app.tabs.BrowserNav
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.mobile.android.vpn.pixels.DeviceShieldPixels
import com.duckduckgo.mobile.android.vpn.state.VpnStateMonitor.VpnRunningState.DISABLED
import com.duckduckgo.mobile.android.vpn.state.VpnStateMonitor.VpnRunningState.ENABLED
Expand All @@ -14,6 +15,7 @@ import org.junit.Assert.assertNull
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever

Expand All @@ -23,13 +25,18 @@ class PProUpsellBannerPluginTest {
private val browserNav: BrowserNav = mock()
private val subscriptions: Subscriptions = mock()
private val deviceShieldPixels: DeviceShieldPixels = mock()
private val appTPStateMessageToggle: AppTPStateMessageToggle = mock()
private lateinit var vpnStore: FakeVPNStore
private lateinit var plugin: PProUpsellBannerPlugin

private val mockDisabledToggle: Toggle = mock { on { it.isEnabled() } doReturn false }

@Before
fun setUp() {
fun setUp() = runTest {
vpnStore = FakeVPNStore(pproUpsellBannerDismissed = false)
plugin = PProUpsellBannerPlugin(subscriptions, browserNav, vpnStore, deviceShieldPixels)
whenever(subscriptions.isFreeTrialEligible()).thenReturn(false)
whenever(appTPStateMessageToggle.freeTrialCopy()).thenReturn(mockDisabledToggle)
plugin = PProUpsellBannerPlugin(subscriptions, browserNav, vpnStore, deviceShieldPixels, appTPStateMessageToggle)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.duckduckgo.app.tabs.BrowserNav
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.mobile.android.vpn.network.ExternalVpnDetector
import com.duckduckgo.mobile.android.vpn.pixels.DeviceShieldPixels
import com.duckduckgo.mobile.android.vpn.state.VpnStateMonitor.VpnRunningState.DISABLED
Expand All @@ -18,6 +19,7 @@ import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever

Expand All @@ -28,11 +30,16 @@ class PproUpsellDisabledMessagePluginTest {
private val subscriptions: Subscriptions = mock()
private val deviceShieldPixels: DeviceShieldPixels = mock()
private val vpnDetector: ExternalVpnDetector = mock()
private val appTPStateMessageToggle: AppTPStateMessageToggle = mock()
private lateinit var plugin: PproUpsellDisabledMessagePlugin

private val mockDisabledToggle: Toggle = mock { on { it.isEnabled() } doReturn false }

@Before
fun setUp() {
plugin = PproUpsellDisabledMessagePlugin(subscriptions, vpnDetector, browserNav, deviceShieldPixels)
fun setUp() = runTest {
whenever(subscriptions.isFreeTrialEligible()).thenReturn(false)
whenever(appTPStateMessageToggle.freeTrialCopy()).thenReturn(mockDisabledToggle)
plugin = PproUpsellDisabledMessagePlugin(subscriptions, vpnDetector, browserNav, deviceShieldPixels, appTPStateMessageToggle)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.duckduckgo.app.tabs.BrowserNav
import com.duckduckgo.feature.toggles.api.Toggle
import com.duckduckgo.mobile.android.vpn.pixels.DeviceShieldPixels
import com.duckduckgo.mobile.android.vpn.state.VpnStateMonitor.VpnRunningState.DISABLED
import com.duckduckgo.mobile.android.vpn.state.VpnStateMonitor.VpnRunningState.ENABLED
Expand All @@ -17,6 +18,7 @@ import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever

Expand All @@ -26,11 +28,16 @@ class PproUpsellRevokedMessagePluginTest {
private val browserNav: BrowserNav = mock()
private val subscriptions: Subscriptions = mock()
private val deviceShieldPixels: DeviceShieldPixels = mock()
private val appTPStateMessageToggle: AppTPStateMessageToggle = mock()
private lateinit var plugin: PproUpsellRevokedMessagePlugin

private val mockDisabledToggle: Toggle = mock { on { it.isEnabled() } doReturn false }

@Before
fun setUp() {
plugin = PproUpsellRevokedMessagePlugin(subscriptions, browserNav, deviceShieldPixels)
fun setUp() = runTest {
whenever(subscriptions.isFreeTrialEligible()).thenReturn(false)
whenever(appTPStateMessageToggle.freeTrialCopy()).thenReturn(mockDisabledToggle)
plugin = PproUpsellRevokedMessagePlugin(subscriptions, browserNav, deviceShieldPixels, appTPStateMessageToggle)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ class CtaViewModelTest {
whenever(mockSubscriptions.isEligible()).thenReturn(true)
whenever(mockExtendedOnboardingFeatureToggles.noBrowserCtas()).thenReturn(mockEnabledToggle)
whenever(mockExtendedOnboardingFeatureToggles.privacyProCta()).thenReturn(mockEnabledToggle)
whenever(mockExtendedOnboardingFeatureToggles.freeTrialCopy()).thenReturn(mockDisabledToggle)
whenever(mockDismissedCtaDao.exists(CtaId.DAX_INTRO)).thenReturn(true)
whenever(mockDismissedCtaDao.exists(CtaId.DAX_INTRO_VISIT_SITE)).thenReturn(true)
whenever(mockDismissedCtaDao.exists(CtaId.DAX_END)).thenReturn(true)
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/com/duckduckgo/app/cta/ui/CtaViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ class CtaViewModel @Inject constructor(
// Privacy Pro
canShowPrivacyProCta() -> {
val titleRes: Int = R.string.onboardingPrivacyProDaxDialogTitle
val descriptionRes: Int = R.string.onboardingPrivacyProDaxDialogDescription
val descriptionRes: Int = if (freeTrialCopyAvailable()) {
R.string.onboardingPrivacyProDaxDialogFreeTrialDescription
} else {
R.string.onboardingPrivacyProDaxDialogDescription
}

DaxBubbleCta.DaxPrivacyProCta(onboardingStore, appInstallStore, titleRes, descriptionRes)
}
Expand Down Expand Up @@ -320,6 +324,9 @@ class CtaViewModel @Inject constructor(
return !widgetCapabilities.hasInstalledWidgets && !dismissedCtaDao.exists(CtaId.ADD_WIDGET)
}

private suspend fun freeTrialCopyAvailable(): Boolean =
extendedOnboardingFeatureToggles.freeTrialCopy().isEnabled() && subscriptions.isFreeTrialEligible()

@WorkerThread
private suspend fun getBrowserCta(site: Site?, detectedRefreshPatterns: Set<RefreshPattern>): Cta? {
val nonNullSite = site ?: return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ interface ExtendedOnboardingFeatureToggles {

@Toggle.DefaultValue(DefaultFeatureValue.FALSE)
@Experiment
fun highlights(): Toggle
fun freeTrialCopy(): Toggle
}
Loading