Skip to content
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

update subscription activation screens #5325

Open
wants to merge 1 commit 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,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:pathData="M2.874,14.978L8.5,8.919L10.388,10.951L3.631,14.852C3.385,14.994 3.119,15.028 2.874,14.978ZM2.011,14.069C2.004,14.018 2,13.965 2,13.911L2,2.089C2,2.035 2.004,1.982 2.011,1.931L7.647,8L2.011,14.069ZM2.873,1.022L8.5,7.082L10.388,5.048L3.631,1.148C3.385,1.006 3.119,0.972 2.873,1.022ZM11.498,5.69L9.353,8L11.498,10.31L13.869,8.942C14.594,8.523 14.594,7.477 13.869,7.058L11.498,5.69Z"
android:fillColor="?attr/daxColorPrimaryIcon"
android:fillType="evenOdd"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object SubscriptionsConstants {

// URLs
const val BUY_URL = "https://duckduckgo.com/subscriptions"
const val ACTIVATE_URL = "https://duckduckgo.com/subscriptions/activate"
const val ACTIVATE_URL = "https://duckduckgo.com/subscriptions/activation-flow"
const val ITR_URL = "https://duckduckgo.com/identity-theft-restoration"
const val FAQS_URL = "https://duckduckgo.com/duckduckgo-help-pages/privacy-pro/"
const val PRIVACY_PRO_ETLD = "duckduckgo.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ enum class SubscriptionPixel(
baseName = "m_privacy-pro_welcome_add-device_click",
type = Unique(),
),
ADD_DEVICE_ENTER_EMAIL_CLICK(
baseName = "m_privacy-pro_add-device_enter-email_click",
type = Count,
),
ONBOARDING_VPN_CLICK(
baseName = "m_privacy-pro_welcome_vpn_click",
type = Unique(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.duckduckgo.common.utils.extensions.toSanitizedLanguageTag
import com.duckduckgo.di.scopes.AppScope
import com.duckduckgo.subscriptions.impl.pixels.SubscriptionPixel.ACTIVATE_SUBSCRIPTION_ENTER_EMAIL_CLICK
import com.duckduckgo.subscriptions.impl.pixels.SubscriptionPixel.ACTIVATE_SUBSCRIPTION_RESTORE_PURCHASE_CLICK
import com.duckduckgo.subscriptions.impl.pixels.SubscriptionPixel.ADD_DEVICE_ENTER_EMAIL_CLICK
import com.duckduckgo.subscriptions.impl.pixels.SubscriptionPixel.APP_SETTINGS_IDTR_CLICK
import com.duckduckgo.subscriptions.impl.pixels.SubscriptionPixel.APP_SETTINGS_PIR_CLICK
import com.duckduckgo.subscriptions.impl.pixels.SubscriptionPixel.APP_SETTINGS_RESTORE_PURCHASE_CLICK
Expand Down Expand Up @@ -77,7 +76,6 @@ interface SubscriptionPixelSender {
fun reportRestoreAfterPurchaseAttemptSuccess()
fun reportSubscriptionActivated()
fun reportOnboardingAddDeviceClick()
fun reportAddDeviceEnterEmailClick()
fun reportOnboardingVpnClick()
fun reportOnboardingPirClick()
fun reportOnboardingIdtrClick()
Expand Down Expand Up @@ -164,9 +162,6 @@ class SubscriptionPixelSenderImpl @Inject constructor(
override fun reportOnboardingAddDeviceClick() =
fire(ONBOARDING_ADD_DEVICE_CLICK)

override fun reportAddDeviceEnterEmailClick() =
fire(ADD_DEVICE_ENTER_EMAIL_CLICK)

override fun reportOnboardingVpnClick() =
fire(ONBOARDING_VPN_CLICK)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ package com.duckduckgo.subscriptions.impl.settings.views
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.FrameLayout
import android.widget.LinearLayout
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.findViewTreeLifecycleOwner
import androidx.lifecycle.findViewTreeViewModelStoreOwner
Expand Down Expand Up @@ -196,13 +194,3 @@ class ProSettingView @JvmOverloads constructor(
}
}
}

class SubscriptionSettingLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
) : LinearLayout(context, attrs, defStyleAttr) {
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import com.duckduckgo.subscriptions.impl.ui.RestoreSubscriptionViewModel.Command
import com.duckduckgo.subscriptions.impl.ui.RestoreSubscriptionViewModel.Command.SubscriptionNotFound
import com.duckduckgo.subscriptions.impl.ui.RestoreSubscriptionViewModel.Command.Success
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsActivity.Companion.SubscriptionsSettingsScreenWithEmptyParams
import com.duckduckgo.subscriptions.impl.ui.SubscriptionsWebViewActivityWithParams.ToolbarConfig.CustomTitle
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand Down Expand Up @@ -78,16 +77,16 @@ class RestoreSubscriptionActivity : DuckDuckGoActivity() {
.onEach { processCommand(it) }
.launchIn(lifecycleScope)

binding.googlePlay.setOnClickListener {
viewModel.restoreFromStore()
}
// removing the click listeners from the LineListItems
// so that they don't trigger the selectable background animation when interacted with
binding.restoreSubscriptionEmailTitle.setOnClickListener(null)
binding.restoreSubscriptionGooglePlayTitle.setOnClickListener(null)

with(binding.manageEmailCard) {
emailSubtitle.setText(string.restoreSubscriptionEmailDescription)
emailButton.setText(string.restoreSubscriptionEmailButton)
emailButton.setOnClickListener {
viewModel.restoreFromEmail()
}
binding.restoreSubscriptionEmailLayout.setOnClickListener {
viewModel.restoreFromEmail()
}
binding.restoreSubscriptionGooglePlayLayout.setOnClickListener {
viewModel.restoreFromStore()
}
}

Expand All @@ -102,7 +101,6 @@ class RestoreSubscriptionActivity : DuckDuckGoActivity() {
this,
SubscriptionsWebViewActivityWithParams(
url = ACTIVATE_URL,
toolbarConfig = CustomTitle(getString(string.addEmailText)),
),
)
startForResultRestore.launch(intent)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2024 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.subscriptions.impl.ui

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.LinearLayout

/**
* A wrapper that can be used when you don't want to pass touch events to children of your layout.
*/
class SelectableLinearLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
) : LinearLayout(context, attrs, defStyleAttr) {
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import com.duckduckgo.subscriptions.api.SubscriptionStatus.EXPIRED
import com.duckduckgo.subscriptions.api.SubscriptionStatus.INACTIVE
import com.duckduckgo.subscriptions.impl.R.*
import com.duckduckgo.subscriptions.impl.SubscriptionsConstants
import com.duckduckgo.subscriptions.impl.SubscriptionsConstants.ACTIVATE_URL
import com.duckduckgo.subscriptions.impl.SubscriptionsConstants.BASIC_SUBSCRIPTION
import com.duckduckgo.subscriptions.impl.SubscriptionsConstants.FAQS_URL
import com.duckduckgo.subscriptions.impl.databinding.ActivitySubscriptionSettingsBinding
Expand All @@ -51,7 +52,7 @@ import com.duckduckgo.subscriptions.impl.ui.ChangePlanActivity.Companion.ChangeP
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsActivity.Companion.SubscriptionsSettingsScreenWithEmptyParams
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.FinishSignOut
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.GoToAddEmailScreen
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.GoToActivationScreen
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.GoToEditEmailScreen
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.GoToPortal
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.SubscriptionDuration.Monthly
Expand Down Expand Up @@ -117,7 +118,11 @@ class SubscriptionSettingsActivity : DuckDuckGoActivity() {
}

binding.manageEmail.setOnClickListener {
viewModel.onEmailButtonClicked()
viewModel.onEditEmailButtonClicked()
}

binding.addToDevice.setOnClickListener {
viewModel.onAddToDeviceButtonClicked()
}

binding.faq.setClickListener {
Expand Down Expand Up @@ -210,11 +215,12 @@ class SubscriptionSettingsActivity : DuckDuckGoActivity() {
}

if (viewState.email == null) {
binding.manageEmail.setPrimaryText(resources.getString(string.addEmailPrimaryText))
binding.manageEmail.setSecondaryText(resources.getString(string.addEmailSecondaryText))
binding.manageEmail.gone()
binding.addToDevice.setSecondaryText(resources.getString(string.addToDeviceSecondaryTextWithoutEmail))
} else {
binding.manageEmail.setPrimaryText(resources.getString(string.editEmailPrimaryText))
binding.manageEmail.setSecondaryText(viewState.email + "\n\n" + resources.getString(string.editEmailSecondaryText))
binding.manageEmail.show()
binding.manageEmail.setSecondaryText(viewState.email)
binding.addToDevice.setSecondaryText(resources.getString(string.addToDeviceSecondaryTextWithEmail))
}

if (viewState.showFeedback) {
Expand All @@ -231,7 +237,7 @@ class SubscriptionSettingsActivity : DuckDuckGoActivity() {
finish()
}

GoToAddEmailScreen -> goToAddEmail()
GoToActivationScreen -> goToActivation()
GoToEditEmailScreen -> goToEditEmail()

is GoToPortal -> {
Expand Down Expand Up @@ -285,12 +291,11 @@ class SubscriptionSettingsActivity : DuckDuckGoActivity() {
)
}

private fun goToAddEmail() {
private fun goToActivation() {
globalActivityStarter.start(
this,
SubscriptionsWebViewActivityWithParams(
url = ADD_EMAIL_URL,
toolbarConfig = CustomTitle(getString(string.addEmailText)),
url = ACTIVATE_URL,
),
)
}
Expand All @@ -307,7 +312,6 @@ class SubscriptionSettingsActivity : DuckDuckGoActivity() {

companion object {
const val URL = "https://play.google.com/store/account/subscriptions?sku=%s&package=%s"
const val ADD_EMAIL_URL = "https://duckduckgo.com/subscriptions/add-email"
const val MANAGE_URL = "https://duckduckgo.com/subscriptions/manage"
const val LEARN_MORE_URL = "https://duckduckgo.com/duckduckgo-help-pages/privacy-pro/adding-email"
const val PRIVACY_POLICY_URL = "https://duckduckgo.com/pro/privacy-terms"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import com.duckduckgo.subscriptions.impl.SubscriptionsConstants.MONTHLY_PLAN_US
import com.duckduckgo.subscriptions.impl.SubscriptionsManager
import com.duckduckgo.subscriptions.impl.pixels.SubscriptionPixelSender
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.FinishSignOut
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.GoToAddEmailScreen
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.GoToActivationScreen
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.GoToEditEmailScreen
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.Command.GoToPortal
import com.duckduckgo.subscriptions.impl.ui.SubscriptionSettingsViewModel.SubscriptionDuration.Monthly
Expand Down Expand Up @@ -102,11 +102,15 @@ class SubscriptionSettingsViewModel @Inject constructor(
)
}

fun onEmailButtonClicked() {
val state = (viewState.value as? Ready) ?: return
pixelSender.reportAddDeviceEnterEmailClick()
fun onEditEmailButtonClicked() {
viewModelScope.launch {
command.send(if (state.email == null) GoToAddEmailScreen else GoToEditEmailScreen)
command.send(GoToEditEmailScreen)
}
}

fun onAddToDeviceButtonClicked() {
viewModelScope.launch {
command.send(GoToActivationScreen)
}
}

Expand Down Expand Up @@ -134,7 +138,7 @@ class SubscriptionSettingsViewModel @Inject constructor(
sealed class Command {
data object FinishSignOut : Command()
data object GoToEditEmailScreen : Command()
data object GoToAddEmailScreen : Command()
data object GoToActivationScreen : Command()
data class GoToPortal(val url: String) : Command()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import androidx.activity.result.contract.ActivityResultContracts.StartActivityFo
import androidx.annotation.AnyThread
import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.flowWithLifecycle
Expand Down Expand Up @@ -201,8 +200,6 @@ class SubscriptionsWebViewActivity : DuckDuckGoActivity(), DownloadConfirmationD
itrJsMessaging.register(it, null)
it.webChromeClient = object : WebChromeClient() {

private var url: String? = null

override fun onCreateWindow(
view: WebView?,
isDialog: Boolean,
Expand All @@ -219,12 +216,6 @@ class SubscriptionsWebViewActivity : DuckDuckGoActivity(), DownloadConfirmationD
view: WebView?,
newProgress: Int,
) {
view?.url.let { currentUrl ->
if (currentUrl != url) {
url = currentUrl
onUrlChanged(url)
}
}
if (newProgress == 100) {
if (binding.webview.canGoBack()) {
toolbar.setNavigationIcon(R.drawable.ic_arrow_left_24)
Expand Down Expand Up @@ -421,20 +412,6 @@ class SubscriptionsWebViewActivity : DuckDuckGoActivity(), DownloadConfirmationD
}
}

private fun onUrlChanged(url: String?) {
val addEmailPath = SubscriptionSettingsActivity.ADD_EMAIL_URL.toUri().path ?: return

val shouldOverrideTitleForAddEmailFlow = url?.toUri()?.path?.startsWith(addEmailPath) ?: false

updateToolbarTitle(
if (shouldOverrideTitleForAddEmailFlow) {
CustomTitle(getString(string.addEmailText))
} else {
params.toolbarConfig
},
)
}

private fun processCommand(command: Command) {
when (command) {
is BackToSettings, BackToSettingsActivateSuccess -> backToSettings()
Expand Down

This file was deleted.

Loading
Loading