Skip to content

Commit

Permalink
Bugfix/AND-136 Fix register validator screen (#224)
Browse files Browse the repository at this point in the history
* Fix number format at commission screen

* Update animation and popups logic
  • Loading branch information
zaiatsartem authored Dec 9, 2024
1 parent a0dd30a commit 29edfba
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ object CurrencyUtil {
.toBigDecimal()
.setScale(roundDecimals, RoundingMode.HALF_DOWN)

return formatter.format(bigDecimalValue)
//Format the small Decimal value for proper trailing zeros not omitted
val decimalFormatter = DecimalFormat(
"#,##0." + "0".repeat(roundDecimals),
DecimalFormatSymbols(Locale.US)
)

return decimalFormatter.format(bigDecimalValue)
}

fun toGTUValue(stringValue: String, token: Token?): BigInteger? =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class AccountsOverviewFragment : BaseFragment() {
super.onViewCreated(view, savedInstanceState)

initializeViewModel()
viewModel.initialize()
initializeViews()

val baseActivity = (activity as BaseActivity)
Expand Down Expand Up @@ -173,7 +172,7 @@ class AccountsOverviewFragment : BaseFragment() {
showDisposalBalance(totalBalance.totalAtDisposalForAllAccounts)
}
viewModel.showDialogLiveData.observe(viewLifecycleOwner) { event ->
if (viewModel.hasShowedInitialAnimation()) {
if (mainViewModel.hasCompletedOnboarding()) {
when (event.contentIfNotHandled) {
AccountsOverviewViewModel.DialogToShow.UNSHIELDING -> {
UnshieldingNoticeDialog().showSingle(
Expand All @@ -196,10 +195,6 @@ class AccountsOverviewFragment : BaseFragment() {
viewModel.stateFlow.collectWhenStarted(viewLifecycleOwner) { state ->
when (state) {
OnboardingState.DONE -> {
if (!viewModel.hasShowedInitialAnimation()) {
binding.confettiAnimation.visibility = View.VISIBLE
binding.confettiAnimation.playAnimation()
}
showStateDefault()
}

Expand All @@ -210,6 +205,13 @@ class AccountsOverviewFragment : BaseFragment() {
}
}
viewModel.onrampActive.collectWhenStarted(viewLifecycleOwner) { active ->
if (active) {
if (!viewModel.hasShowedInitialAnimation()) {
binding.confettiAnimation.visibility = View.VISIBLE
binding.confettiAnimation.playAnimation()
}
}

binding.onrampBanner.root.setOnClickListener {
App.appCore.tracker.homeOnRampBannerClicked()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ class AccountsOverviewViewModel(application: Application) : AndroidViewModel(app
updateNotificationSubscription()
}

fun initialize() {
showSingleDialogIfNeeded()
}

override fun onCleared() {
super.onCleared()
accountRepository.allAccountsWithIdentity.removeObserver(accountsObserver)
Expand Down Expand Up @@ -191,6 +187,7 @@ class AccountsOverviewViewModel(application: Application) : AndroidViewModel(app
} else {
App.appCore.session.hasCompletedOnboarding()
postState(OnboardingState.DONE, notifyWaitingLiveData = notifyWaitingLiveData)
showSingleDialogIfNeeded()
updateSubmissionStatesAndBalances()
}
}
Expand All @@ -200,6 +197,7 @@ class AccountsOverviewViewModel(application: Application) : AndroidViewModel(app
if (doneCount > 0) {
App.appCore.session.hasCompletedOnboarding()
postState(OnboardingState.DONE, notifyWaitingLiveData = notifyWaitingLiveData)
showSingleDialogIfNeeded()
updateSubmissionStatesAndBalances()
} else {
postState(OnboardingState.SAVE_PHRASE, zeroAccountBalances, notifyWaitingLiveData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.concordium.wallet.uicore.afterTextChanged
import com.concordium.wallet.util.KeyboardUtil
import java.text.DecimalFormat
import java.text.ParseException
import java.util.Locale
import kotlin.math.roundToInt


Expand All @@ -26,7 +27,7 @@ class BakerPoolSettingsActivity : BaseDelegationBakerActivity(
/**
* Formats values in range [[0.0; 1.0]].
*/
private val percentNumberFormat = (DecimalFormat.getNumberInstance() as DecimalFormat).apply {
private val percentNumberFormat = (DecimalFormat.getNumberInstance(Locale.US) as DecimalFormat).apply {
multiplier = 100
minimumFractionDigits = PERCENT_FORMAT_DECIMALS
maximumFractionDigits = PERCENT_FORMAT_DECIMALS
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,9 @@
<string name="welcome_activate_bottom_sheet_create_wallet_button">Continue</string>
<string name="welcome_activate_bottom_sheet_import_wallet_details">You can import your wallet with a secret seed phrase, wallet private key or a backup file.</string>
<string name="welcome_activate_bottom_sheet_import_wallet_button"><u>Import a wallet</u></string>
<string name="passcode_create_title">Create passcode</string>
<string name="passcode_create_title">Create Passcode</string>
<string name="template_passcode_create_details">%1$d-digit passcode to secure your wallet. Remember it to enter the wallet again</string>
<string name="passcode_repeat_title">Repeat passcode</string>
<string name="passcode_repeat_title">Repeat Passcode</string>
<string name="template_passcode_repeat_details">It should be the same %1$d-digit passcode you entered in the previous step</string>
<string name="passcode_use_full_password">Use full password instead</string>
<string name="passcode_backspace_button">Delete</string>
Expand Down

0 comments on commit 29edfba

Please sign in to comment.