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

Improved onboarding flow #158

Merged
merged 23 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
eacc2b6
Update Welcome Screen
zaiatsartem Oct 11, 2024
80c8c48
Update background on all screens
zaiatsartem Oct 11, 2024
58356fd
Update toolbar icons
zaiatsartem Oct 14, 2024
3accf44
Add UnlockFeature dialog
zaiatsartem Oct 14, 2024
a249665
Update bottom navigation bar style
zaiatsartem Oct 15, 2024
43d2884
Add Onboarding status card
zaiatsartem Oct 16, 2024
cc0bc95
Add Onboarding status card to Accounts overview fragment
zaiatsartem Oct 18, 2024
3a4bcc2
Add no seed state on accounts overview
zaiatsartem Oct 21, 2024
e7d0d19
Set up OnboardingStatusCard as custom view
zaiatsartem Oct 22, 2024
b7cd967
Set up full cycle of onboarding
zaiatsartem Oct 25, 2024
f247035
Update setup wallet screen
zaiatsartem Oct 28, 2024
1e1153b
Restore seed phrase if app process killed
zaiatsartem Oct 28, 2024
12d0dfa
Change first account creation logic
zaiatsartem Oct 28, 2024
4291c5a
Add inner action button transition animation
zaiatsartem Oct 29, 2024
4748f23
Add restrictions if onboarding not passed
zaiatsartem Oct 29, 2024
88dda53
Merge branch 'main' into feature/improved-onboarding-flow
zaiatsartem Oct 29, 2024
712f8ec
Update CHANGELOG
zaiatsartem Oct 29, 2024
3a056b0
Update CHANGELOG.md
zaiatsartem Oct 29, 2024
9d911bf
Update accounts header view
zaiatsartem Oct 30, 2024
1d0c05c
Fix incorrect onboarding state after file wallet import
zaiatsartem Oct 30, 2024
811eb33
Merge branch 'feature/improved-onboarding-flow' of github.com:Concord…
zaiatsartem Oct 30, 2024
536e6f5
Fix GTU value rounding
zaiatsartem Oct 31, 2024
9320e63
Fix balance suffix for big values
zaiatsartem Oct 31, 2024
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased]

### Added

- Optimized user experience during the onboarding process

## [1.3.0] - 2024-10-18

### Added
Expand Down
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ dependencies {

// Push notifications
implementation 'com.google.firebase:firebase-messaging:24.0.0'

// Lottie animations
implementation 'com.airbnb.android:lottie:6.0.0'
}

task printVersionName {
Expand Down
49 changes: 29 additions & 20 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<activity
android:name=".ui.MainActivity"
android:exported="true"
android:launchMode="singleTask"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar.Launcher">
<intent-filter>
Expand Down Expand Up @@ -281,12 +281,14 @@
android:launchMode="singleTop"
android:parentActivityName=".ui.MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysVisible|adjustResize" />
android:windowSoftInputMode="stateAlwaysVisible|adjustResize"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.account.newaccountidentity.NewAccountIdentityActivity"
android:launchMode="singleTop"
android:parentActivityName=".ui.account.newaccountname.NewAccountNameActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.account.newaccountsetup.NewAccountSetupActivity"
android:launchMode="singleTop"
Expand All @@ -301,7 +303,8 @@
android:name=".ui.account.accountdetails.AccountDetailsActivity"
android:launchMode="singleTop"
android:parentActivityName=".ui.MainActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.account.accountdetails.AccountReleaseScheduleActivity"
android:launchMode="singleTop"
Expand Down Expand Up @@ -337,7 +340,8 @@
android:name=".ui.more.export.ExportActivity"
android:launchMode="singleTop"
android:parentActivityName=".ui.MainActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.more.import.ImportActivity"
android:launchMode="singleTop"
Expand All @@ -360,22 +364,26 @@
android:name=".ui.recipient.recipientlist.RecipientListActivity"
android:launchMode="singleTop"
android:parentActivityName=".ui.MainActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.identity.identitiesoverview.IdentitiesOverviewActivity"
android:launchMode="singleTop"
android:parentActivityName=".ui.MainActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.recipient.recipient.RecipientActivity"
android:launchMode="singleTop"
android:parentActivityName=".ui.recipient.recipientlist.RecipientListActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.scanqr.ScanQRActivity"
android:launchMode="singleTop"
android:parentActivityName=".ui.recipient.recipient.RecipientActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.cis2.TokenDetailsActivity"
android:launchMode="singleTop"
Expand Down Expand Up @@ -408,7 +416,8 @@
<activity
android:name=".ui.more.export.ExportAccountKeysActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.more.export.ExportTransactionLogActivity"
android:launchMode="singleTop"
Expand All @@ -417,7 +426,8 @@
android:name=".ui.account.accountdetails.AccountSettingsActivity"
android:launchMode="singleTop"
android:parentActivityName=".ui.account.accountdetails.AccountDetailsActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.account.earn.EarnInfoActivity"
android:launchMode="singleTop"
Expand Down Expand Up @@ -509,11 +519,6 @@
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.welcome.WelcomePromoActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/CCX_WelcomePromoScreen" />
<activity
android:name=".ui.auth.passcode.PasscodeSetupActivity"
android:launchMode="singleTop"
Expand All @@ -538,15 +543,18 @@
android:name=".ui.more.unshielding.UnshieldingAccountsActivity"
android:launchMode="singleTop"
android:parentActivityName=".ui.MainActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.more.unshielding.UnshieldingActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.more.tracking.TrackingPreferencesActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen" />
<activity
android:name=".ui.onramp.CcdOnrampSitesActivity"
android:launchMode="singleTop"
Expand All @@ -560,7 +568,8 @@
<activity
android:name=".ui.more.notifications.NotificationsPreferencesActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/CCX_Screen"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Session {
var hasCompletedInitialSetup = true
private set

var hasCompleteOnboarding = false
private set

private val _isLoggedIn = MutableLiveData<Boolean>(false)
val isLoggedIn: LiveData<Boolean>
get() = _isLoggedIn
Expand All @@ -37,6 +40,7 @@ class Session {
authPreferences = AuthPreferences(context)
hasSetupPassword = authPreferences.getHasSetupUser()
hasCompletedInitialSetup = authPreferences.getHasCompletedInitialSetup()
hasCompleteOnboarding = authPreferences.getHasCompletedOnboarding()
filterPreferences = FilterPreferences(context)
}

Expand Down Expand Up @@ -84,6 +88,19 @@ class Session {
hasCompletedInitialSetup = true
}

fun hasCompletedOnboarding() {
authPreferences.setHasCompletedOnboarding(true)
hasCompleteOnboarding = true
}

fun setHasShowedInitialAnimation() {
authPreferences.setHasShowedInitialAnimation(true)
}

fun getHasShowedInitialAnimation(): Boolean {
return authPreferences.getShowedInitialAnimation()
}

fun startPasswordSetup(password: String) {
tempPassword = password
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class AuthPreferences(val context: Context) :
companion object {
const val PREFKEY_HAS_SETUP_USER = "PREFKEY_HAS_SETUP_USER"
const val PREFKEY_HAS_COMPLETED_INITIAL_SETUP = "PREFKEY_HAS_COMPLETED_INITIAL_SETUP"
const val PREFKEY_HAS_COMPLETED_ONBOARDING = "PREFKEY_HAS_COMPLETED_ONBOARDING"
const val PREFKEY_USE_PASSCODE = "PREFKEY_USE_PASSCODE"
const val PREFKEY_USE_BIOMETRICS = "PREFKEY_USE_BIOMETRICS"
const val PREFKEY_PASSWORD_CHECK = "PREFKEY_PASSWORD_CHECK"
Expand All @@ -28,6 +29,7 @@ class AuthPreferences(val context: Context) :
const val PREFKEY_ENCRYPTED_SEED_ENTROPY_HEX =
"PREFKEY_ENCRYPTED_SEED_ENTROPY_HEX"
const val PREFKEY_LEGACY_SEED_HEX_ENCRYPTED = "SEED_PHRASE_ENCRYPTED"
const val PREFKEY_HAS_SHOWED_INITIAL_ANIMATION = "PREFKEY_HAS_SHOWED_INITIAL_ANIMATION"
}

fun setHasSetupUser(value: Boolean) {
Expand All @@ -47,6 +49,22 @@ class AuthPreferences(val context: Context) :
return getBoolean(PREFKEY_HAS_COMPLETED_INITIAL_SETUP, true)
}

fun setHasCompletedOnboarding(value: Boolean) {
setBoolean(PREFKEY_HAS_COMPLETED_ONBOARDING, value)
}

fun getHasCompletedOnboarding(): Boolean {
return getBoolean(PREFKEY_HAS_COMPLETED_ONBOARDING, false)
}

fun setHasShowedInitialAnimation(value: Boolean) {
setBoolean(PREFKEY_HAS_SHOWED_INITIAL_ANIMATION, value)
}

fun getShowedInitialAnimation(): Boolean {
return getBoolean(PREFKEY_HAS_SHOWED_INITIAL_ANIMATION, false)
}

fun setUsePasscode(appendix: String, value: Boolean) {
setBoolean(PREFKEY_USE_PASSCODE + appendix, value)
}
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/concordium/wallet/data/util/CurrencyUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package com.concordium.wallet.data.util

import com.concordium.wallet.data.model.Token
import com.concordium.wallet.util.toBigInteger
import java.math.BigDecimal
import java.math.BigInteger
import java.math.RoundingMode
import java.text.DecimalFormatSymbols
import java.util.Locale
import java.util.regex.Pattern

object CurrencyUtil {
Expand Down Expand Up @@ -67,6 +70,16 @@ object CurrencyUtil {
return strBuilder.toString().removeSuffix(separator.toString())
}

fun formatAndRoundGTU(value: BigInteger, roundDecimals: Int): String {
val bigDecimalValue = formatGTU(value)
.replace(separator, '.')
.toBigDecimal()
.setScale(roundDecimals, RoundingMode.HALF_UP)

//replace '.' to initial separator
return bigDecimalValue.toString().replace('.', separator)
}

fun toGTUValue(stringValue: String, token: Token?): BigInteger? =
toGTUValue(stringValue, token?.decimals ?: 0)

Expand Down
37 changes: 28 additions & 9 deletions app/src/main/java/com/concordium/wallet/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.concordium.wallet.App
import com.concordium.wallet.BuildConfig
import com.concordium.wallet.R
Expand All @@ -22,11 +23,13 @@ import com.concordium.wallet.ui.identity.identityproviderlist.IdentityProviderLi
import com.concordium.wallet.ui.more.import.ImportActivity
import com.concordium.wallet.ui.more.moreoverview.MoreOverviewFragment
import com.concordium.wallet.ui.news.NewsOverviewFragment
import com.concordium.wallet.ui.onboarding.OnboardingSharedViewModel
import com.concordium.wallet.ui.tokens.provider.ProvidersOverviewFragment
import com.concordium.wallet.ui.walletconnect.WalletConnectView
import com.concordium.wallet.ui.walletconnect.WalletConnectViewModel
import com.concordium.wallet.ui.welcome.WelcomeActivity
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.launch

class MainActivity : BaseActivity(R.layout.activity_main, R.string.accounts_overview_title),
AuthDelegate by AuthDelegateImpl(),
Expand All @@ -41,6 +44,7 @@ class MainActivity : BaseActivity(R.layout.activity_main, R.string.accounts_over
ActivityMainBinding.bind(findViewById(R.id.root_layout))
}
private lateinit var viewModel: MainViewModel
private lateinit var onboardingViewModel: OnboardingSharedViewModel
private lateinit var walletConnectViewModel: WalletConnectViewModel
private var hasHandledPossibleImportFile = false

Expand All @@ -49,13 +53,13 @@ class MainActivity : BaseActivity(R.layout.activity_main, R.string.accounts_over

override fun onCreate(savedInstanceState: Bundle?) {
// Set theme to default to remove launcher theme.
setTheme(R.style.CCX_Screen)
setTheme(R.style.CCX_MainScreen)

super.onCreate(savedInstanceState)

// Make the navigation bar color match the bottom navigation bar.
window.navigationBarColor =
ContextCompat.getColor(this, R.color.bottom_navigation_bar_background)
ContextCompat.getColor(this, R.color.cryptox_black_main)

initializeViewModel()
viewModel.initialize()
Expand Down Expand Up @@ -108,7 +112,15 @@ class MainActivity : BaseActivity(R.layout.activity_main, R.string.accounts_over
}

viewModel.startIdentityUpdate()
startCheckForPendingIdentity(this, null, false) {}
if (!viewModel.hasCompletedOnboarding()) {
startCheckForPendingIdentity(this, null, true) { identity ->
lifecycleScope.launch {
onboardingViewModel.setIdentity(identity)
}
}
} else {
startCheckForPendingIdentity(this, null, false) {}
}

App.appCore.tracker.homeScreen()
}
Expand Down Expand Up @@ -155,6 +167,11 @@ class MainActivity : BaseActivity(R.layout.activity_main, R.string.accounts_over
replaceFragment(state)
}

onboardingViewModel = ViewModelProvider(
this,
ViewModelProvider.AndroidViewModelFactory.getInstance(application)
)[OnboardingSharedViewModel::class.java]

walletConnectViewModel = ViewModelProvider(
this,
ViewModelProvider.AndroidViewModelFactory.getInstance(application)
Expand Down Expand Up @@ -208,7 +225,14 @@ class MainActivity : BaseActivity(R.layout.activity_main, R.string.accounts_over
val fragment = when (state) {
MainViewModel.State.AccountOverview -> AccountsOverviewFragment()
MainViewModel.State.NewsOverview -> NewsOverviewFragment()
MainViewModel.State.TokensOverview -> ProvidersOverviewFragment()
MainViewModel.State.TokensOverview -> {
if (viewModel.hasCompletedOnboarding()) {
ProvidersOverviewFragment()
} else {
showUnlockFeatureDialog()
null
}
}
MainViewModel.State.More -> MoreOverviewFragment()
}
replaceFragment(fragment)
Expand Down Expand Up @@ -259,11 +283,6 @@ class MainActivity : BaseActivity(R.layout.activity_main, R.string.accounts_over
}
}

private fun gotoIdentityProviderList() {
val intent = Intent(this, IdentityProviderListActivity::class.java)
startActivity(intent)
}

private fun goToFirstIdentityCreation() {
val intent = Intent(this, IdentityProviderListActivity::class.java)
intent.putExtra(IdentityProviderListActivity.SHOW_FOR_FIRST_IDENTITY, true)
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/concordium/wallet/ui/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
return session.hasSetupPassword && !session.hasCompletedInitialSetup
}

fun hasCompletedOnboarding(): Boolean {
return session.hasCompleteOnboarding
}

fun startIdentityUpdate() {
val updateListener = object : IdentityUpdater.UpdateListener {
override fun onError(identity: Identity, account: Account?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class AccountView(context: Context, attrs: AttributeSet?) : ConstraintLayout(con
this.accountWithIdentity = accountWithIdentity

binding.totalTextview.text =
CurrencyUtil.formatGTU(accountWithIdentity.account.balance, withGStroke = true)
CurrencyUtil.formatAndRoundGTU(accountWithIdentity.account.balance, roundDecimals = 2)

binding.balanceAtDisposalTextview.text = CurrencyUtil.formatGTU(
binding.balanceAtDisposalTextview.text = CurrencyUtil.formatAndRoundGTU(
accountWithIdentity.account.balanceAtDisposal,
withGStroke = true
roundDecimals = 2
)

binding.accountNameArea.setData(accountWithIdentity)
Expand Down
Loading