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

Fix onboarding flow #179

Merged
merged 4 commits into from
Nov 6, 2024
Merged
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
Expand Up @@ -5,10 +5,9 @@ import android.content.Context
interface AppTracker {
fun installation(context: Context)
fun welcomeScreen()
fun welcomeCheckBoxChecked()
fun welcomeTermAndConditionsCheckBoxChecked()
fun welcomeActivityTrackingCheckBoxChecked()
fun welcomeGetStartedClicked()
fun welcomeHomeScreen()
fun welcomeHomeActivateAccountClicked()
fun welcomeActivateAccountDialog()
fun welcomeActivateAccountDialogCreateClicked()
fun welcomeActivateAccountDialogImportClicked()
Expand All @@ -18,12 +17,22 @@ interface AppTracker {
fun welcomePasscodeBiometricsDialog()
fun welcomePasscodeBiometricsAccepted()
fun welcomePasscodeBiometricsRejected()
fun welcomePhrase()
fun welcomePhraseCopyClicked()
fun welcomePhraseCheckboxBoxChecked()
fun seedPhraseScreen()
fun seedPhraseCopyClicked()
fun seedPhraseCheckboxBoxChecked()
fun seedPhraseContinueCLicked()
fun identityVerificationProvidersListScreen()
fun identityVerificationScreen(provider: String)
fun identityVerificationResultScreen()
fun identityVerificationResultApprovedDialog()
fun identityVerificationResultCreateAccountClicked()
fun homeScreen()
fun homeSaveSeedPhraseClicked ()
fun homeIdentityVerificationClicked()
fun homeIdentityVerificationStateChanged(state: String)
fun homeCreateAccountClicked()
fun homeOnRampScreen()
fun homeOnRampBannerClicked()
fun homeUnlockFeatureDialog()
fun homeTotalBalanceClicked()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ class MatomoAppTracker(private val tracker: Tracker) : AppTracker {
override fun welcomeScreen() =
trackScreenAndImpression(SCREEN_WELCOME)

override fun welcomeCheckBoxChecked() =
trackInteraction(SCREEN_WELCOME, "Check box", INTERACTION_CHECKED)
override fun welcomeTermAndConditionsCheckBoxChecked() =
trackInteraction(SCREEN_WELCOME, "Terms and Conditions check box", INTERACTION_CHECKED)

override fun welcomeActivityTrackingCheckBoxChecked() =
trackInteraction(SCREEN_WELCOME, "Activity Tracking check box", INTERACTION_CHECKED)

override fun welcomeGetStartedClicked() =
trackInteraction(SCREEN_WELCOME, "Get started", INTERACTION_CLICKED)

override fun welcomeHomeScreen() =
trackScreenAndImpression(SCREEN_WELCOME_HOME)

override fun welcomeHomeActivateAccountClicked() =
trackInteraction(SCREEN_WELCOME_HOME, "Activate account", INTERACTION_CLICKED)

override fun welcomeActivateAccountDialog() =
trackScreenAndImpression(DIALOG_ACTIVATE_ACCOUNT)

Expand Down Expand Up @@ -58,14 +55,20 @@ class MatomoAppTracker(private val tracker: Tracker) : AppTracker {
override fun welcomePasscodeBiometricsRejected() =
trackInteraction(DIALOG_WELCOME_PASSCODE_BIOMETRICS, "Later", INTERACTION_CLICKED)

override fun welcomePhrase() =
trackScreenAndImpression(SCREEN_WELCOME_PHRASE)
override fun seedPhraseScreen() =
trackScreenAndImpression(SCREEN_SAVE_PHRASE)

override fun seedPhraseCopyClicked() =
trackInteraction(SCREEN_SAVE_PHRASE, "Copy to clipboard", INTERACTION_CLICKED)

override fun seedPhraseCheckboxBoxChecked() =
trackInteraction(SCREEN_SAVE_PHRASE, "Check box", INTERACTION_CHECKED)

override fun welcomePhraseCopyClicked() =
trackInteraction(SCREEN_WELCOME_PHRASE, "Copy to clipboard", INTERACTION_CLICKED)
override fun seedPhraseContinueCLicked() =
trackInteraction(SCREEN_SAVE_PHRASE, "Continue", INTERACTION_CLICKED)

override fun welcomePhraseCheckboxBoxChecked() =
trackInteraction(SCREEN_WELCOME_PHRASE, "Check box", INTERACTION_CHECKED)
override fun identityVerificationProvidersListScreen() =
trackScreenAndImpression(SCREEN_ID)

override fun identityVerificationScreen(provider: String) {
track()
Expand All @@ -86,6 +89,34 @@ class MatomoAppTracker(private val tracker: Tracker) : AppTracker {
override fun homeScreen() =
trackScreenAndImpression(SCREEN_HOME)

override fun homeSaveSeedPhraseClicked() =
trackInteraction(SCREEN_HOME, "Save seed phrase", INTERACTION_CLICKED)

override fun homeIdentityVerificationClicked() =
trackInteraction(SCREEN_HOME, "Verify identity", INTERACTION_CLICKED)

override fun homeIdentityVerificationStateChanged(state: String) {
track()
.screen(SCREEN_HOME)
.dimension(0, state)
.safelyWith(tracker)
}

override fun homeCreateAccountClicked() =
trackInteraction(SCREEN_HOME, "Create account", INTERACTION_CLICKED)

override fun homeOnRampScreen() =
trackScreenAndImpression(SCREEN_ONRAMP)

override fun homeOnRampBannerClicked() =
trackInteraction(SCREEN_HOME, "OnRamp banner", INTERACTION_CLICKED)

override fun homeUnlockFeatureDialog() =
trackScreenAndImpression(DIALOG_UNLOCK_FEATURE)

override fun homeTotalBalanceClicked() =
trackInteraction(SCREEN_HOME, "Wallet total balance", INTERACTION_CLICKED)

private fun track() =
TrackHelper.track()

Expand Down Expand Up @@ -120,17 +151,17 @@ class MatomoAppTracker(private val tracker: Tracker) : AppTracker {
title = "Welcome",
path = "/welcome",
)
private val SCREEN_WELCOME_HOME = Screen(
title = "Welcome: Home",
path = "/welcome/home",
)
private val SCREEN_WELCOME_PASSCODE = Screen(
title = "Welcome: Passcode",
path = "/welcome/home/passcode_setup",
path = "/welcome/passcode_setup",
)
private val SCREEN_SAVE_PHRASE = Screen(
title = "Home: Phrase",
path = "/home/phrase",
)
private val SCREEN_WELCOME_PHRASE = Screen(
title = "Welcome: Phrase",
path = "/welcome/home/phrase",
private val SCREEN_ID = Screen(
title = "ID Screen",
path = "/id_providers",
)
private val SCREEN_ID_VERIFICATION = Screen(
title = "ID Verification",
Expand All @@ -142,21 +173,29 @@ class MatomoAppTracker(private val tracker: Tracker) : AppTracker {
)
private val SCREEN_HOME = Screen(
title = "Home",
path = "/"
path = "/home"
)
private val SCREEN_ONRAMP = Screen(
title = "Home: OnRamp",
path = "/home/onramp"
)

private val DIALOG_ACTIVATE_ACCOUNT = Screen(
title = "Welcome: Activate account dialog",
path = SCREEN_WELCOME_HOME.path + "#activate_account",
path = SCREEN_WELCOME.path + "#activate_account",
)
private val DIALOG_WELCOME_PASSCODE_BIOMETRICS = Screen(
title = "Welcome: Passcode: Biometrics dialog",
path = SCREEN_WELCOME_PASSCODE.path + "#biometrics",
path = SCREEN_WELCOME.path + "#biometrics",
)
private val DIALOG_ID_VERIFICATION_APPROVED = Screen(
title = "ID Verification approved",
path = SCREEN_ID_VERIFICATION_RESULT.path + "#approved",
)
private val DIALOG_UNLOCK_FEATURE = Screen(
title = "Home: Unlock feature dialog",
path = SCREEN_HOME.path + "#unlock_feature"
)

private const val INTERACTION_CHECKED = "checked"
private const val INTERACTION_CLICKED = "clicked"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import com.concordium.wallet.util.Log
class NoOpAppTracker : AppTracker {
override fun installation(context: Context) = Log.d("No op")
override fun welcomeScreen() = Log.d("No op")
override fun welcomeCheckBoxChecked() = Log.d("No op")
override fun welcomeTermAndConditionsCheckBoxChecked() = Log.d("No op")
override fun welcomeActivityTrackingCheckBoxChecked() = Log.d("No op")
override fun welcomeGetStartedClicked() = Log.d("No op")
override fun welcomeHomeScreen() = Log.d("No op")
override fun welcomeHomeActivateAccountClicked() = Log.d("No op")
override fun welcomeActivateAccountDialog() = Log.d("No op")
override fun welcomeActivateAccountDialogCreateClicked() = Log.d("No op")
override fun welcomeActivateAccountDialogImportClicked() = Log.d("No op")
Expand All @@ -19,12 +18,22 @@ class NoOpAppTracker : AppTracker {
override fun welcomePasscodeBiometricsDialog() = Log.d("No op")
override fun welcomePasscodeBiometricsAccepted() = Log.d("No op")
override fun welcomePasscodeBiometricsRejected() = Log.d("No op")
override fun welcomePhrase() = Log.d("No op")
override fun welcomePhraseCopyClicked() = Log.d("No op")
override fun welcomePhraseCheckboxBoxChecked() = Log.d("No op")
override fun seedPhraseScreen() = Log.d("No op")
override fun seedPhraseCopyClicked() = Log.d("No op")
override fun seedPhraseCheckboxBoxChecked() = Log.d("No op")
override fun seedPhraseContinueCLicked() = Log.d("No op")
override fun identityVerificationProvidersListScreen() = Log.d("No op")
override fun identityVerificationScreen(provider: String) = Log.d("No op")
override fun identityVerificationResultScreen() = Log.d("No op")
override fun identityVerificationResultApprovedDialog() = Log.d("No op")
override fun identityVerificationResultCreateAccountClicked() = Log.d("No op")
override fun homeScreen() = Log.d("No op")
override fun homeSaveSeedPhraseClicked() = Log.d("No op")
override fun homeIdentityVerificationClicked() = Log.d("No op")
override fun homeIdentityVerificationStateChanged(state: String) = Log.d("No op")
override fun homeCreateAccountClicked() = Log.d("No op")
override fun homeOnRampScreen() = Log.d("No op")
override fun homeOnRampBannerClicked() = Log.d("No op")
override fun homeUnlockFeatureDialog() = Log.d("No op")
override fun homeTotalBalanceClicked() = Log.d("No op")
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,24 @@ class AccountsOverviewFragment : BaseFragment() {
showDisposalBalance(totalBalance.totalAtDisposalForAllAccounts)
}
viewModel.showDialogLiveData.observe(viewLifecycleOwner) { event ->
when (event.contentIfNotHandled) {
AccountsOverviewViewModel.DialogToShow.UNSHIELDING -> {
UnshieldingNoticeDialog().showSingle(
childFragmentManager,
UnshieldingNoticeDialog.TAG
)
}
if (viewModel.hasShowedInitialAnimation()) {
when (event.contentIfNotHandled) {
AccountsOverviewViewModel.DialogToShow.UNSHIELDING -> {
UnshieldingNoticeDialog().showSingle(
childFragmentManager,
UnshieldingNoticeDialog.TAG
)
}

AccountsOverviewViewModel.DialogToShow.NOTIFICATIONS_PERMISSION -> {
NotificationsPermissionDialog().showSingle(
childFragmentManager,
NotificationsPermissionDialog.TAG,
)
}
AccountsOverviewViewModel.DialogToShow.NOTIFICATIONS_PERMISSION -> {
NotificationsPermissionDialog().showSingle(
childFragmentManager,
NotificationsPermissionDialog.TAG,
)
}

null -> {}
null -> {}
}
}
}
viewModel.stateFlow.collectWhenStarted(viewLifecycleOwner) { state ->
Expand All @@ -203,6 +205,23 @@ class AccountsOverviewFragment : BaseFragment() {
}
}
}
viewModel.onrampActive.collectWhenStarted(viewLifecycleOwner) { active ->
binding.onrampBanner.root.setOnClickListener {
App.appCore.tracker.homeOnRampBannerClicked()

if (active) {
val intent = Intent(requireContext(), CcdOnrampSitesActivity::class.java)
intent.putExtras(
CcdOnrampSitesActivity.getBundle(
accountAddress = null,
)
)
startActivity(intent)
} else {
(activity as BaseActivity).showUnlockFeatureDialog()
}
}
}

viewModel.identityFlow.collectWhenStarted(viewLifecycleOwner) { identity ->
onboardingViewModel.setIdentity(identity)
Expand All @@ -211,6 +230,13 @@ class AccountsOverviewFragment : BaseFragment() {
onboardingViewModel.identityFlow.collectWhenStarted(viewLifecycleOwner) { identity ->
onboardingStatusCard.updateViewsByIdentityStatus(identity)
}
onboardingViewModel.updateState.collectWhenStarted(viewLifecycleOwner) { update ->
if (update)
viewModel.updateState(true)
}
onboardingViewModel.showLoading.collectWhenStarted(viewLifecycleOwner) { show ->
showWaiting(show)
}
}

private fun initializeViews() {
Expand All @@ -222,6 +248,12 @@ class AccountsOverviewFragment : BaseFragment() {
gotoExport()
}

listOf(binding.totalBalanceLayout, binding.totalDetailsDisposalLayout).forEach {
it.setOnClickListener {
App.appCore.tracker.homeTotalBalanceClicked()
}
}

eventListener = object : Preferences.Listener {
override fun onChange() {
updateMissingBackup()
Expand Down Expand Up @@ -277,15 +309,6 @@ class AccountsOverviewFragment : BaseFragment() {
startActivity(intent)
}
},
onCcdOnrampBannerClicked = {
val intent = Intent(requireContext(), CcdOnrampSitesActivity::class.java)
intent.putExtras(
CcdOnrampSitesActivity.getBundle(
accountAddress = null,
)
)
startActivity(intent)
}
)
binding.accountRecyclerview.adapter = adapter
viewModel.listItemsLiveData.observe(viewLifecycleOwner, adapter::setData)
Expand Down Expand Up @@ -481,4 +504,4 @@ class AccountsOverviewFragment : BaseFragment() {
}

//endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.concordium.wallet.data.room.AccountWithIdentity

class AccountsOverviewItemAdapter(
private val accountViewClickListener: AccountView.OnItemClickListener,
private val onCcdOnrampBannerClicked: () -> Unit,
) : RecyclerView.Adapter<AccountsOverviewItemAdapter.ViewHolder>() {
private var data: List<AccountsOverviewListItem> = emptyList()

Expand All @@ -26,9 +25,6 @@ class AccountsOverviewItemAdapter(
override fun getItemViewType(position: Int): Int = when (data[position]) {
is AccountsOverviewListItem.Account ->
R.layout.list_item_accounts_overview_account

AccountsOverviewListItem.CcdOnrampBanner ->
R.layout.list_item_accounts_overview_ccd_onramp_banner
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
Expand All @@ -37,9 +33,6 @@ class AccountsOverviewItemAdapter(
R.layout.list_item_accounts_overview_account ->
ViewHolder.Account(view)

R.layout.list_item_accounts_overview_ccd_onramp_banner ->
ViewHolder.CcdOnrampBanner(view)

else ->
error("Unknown view type $viewType")
}
Expand All @@ -52,18 +45,10 @@ class AccountsOverviewItemAdapter(
holder.accountView.setAccount(item.accountWithIdentity)
holder.accountView.setOnItemClickListener(accountViewClickListener)
}

is ViewHolder.CcdOnrampBanner -> {
holder.itemView.setOnClickListener {
onCcdOnrampBannerClicked()
}
}
}
}

sealed class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
class CcdOnrampBanner(itemView: View) : ViewHolder(itemView)

class Account(itemView: View) : ViewHolder(itemView) {
val accountView = itemView as AccountView
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package com.concordium.wallet.ui.account.accountsoverview
import com.concordium.wallet.data.room.AccountWithIdentity

sealed interface AccountsOverviewListItem {
object CcdOnrampBanner: AccountsOverviewListItem

class Account(
val accountWithIdentity: AccountWithIdentity,
): AccountsOverviewListItem
Expand Down
Loading