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

Adding a space between the currency code and the balance #1530

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion app/src/main/java/protect/card_locker/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ static public String formatBalance(Context context, BigDecimal value, Currency c
currencyFormat.setMinimumFractionDigits(currency.getDefaultFractionDigits());
currencyFormat.setMaximumFractionDigits(currency.getDefaultFractionDigits());

return currencyFormat.format(value);
// adding a space between the currency code and the balance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Though you're a bit too early for October :)

Are we sure there are no locales where the space should be on the left side? Or that otherwise behave differently in a way that matters here? And what about word wrapping?

I do agree "USD 5.00" probably looks nicer, but I think I'd prefer "€5.00" w/o the extra space, though not strongly.

Seems like a simple enough change, but we should make sure nothing unexpectedly breaks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only adds a space for the currency codes -> USD 5.00...
.. but doesn't add it to the currency symbols -> £5.00
It depends on the locale, per example in French, we would write 5.00 £, and not £5.00.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I overlooked you're only replacing the codes. Makes sense.

That does mean that in French, you'd get 5,00 XXX with an extra space now. Maybe only replace it at the start then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could adding .trim() to the end of return formattedCurrency.replace(currency.getCurrencyCode(), currency.getCurrencyCode() + " ") remove the extra space ?

String formattedCurrency = currencyFormat.format(value);
return formattedCurrency.replace(currency.getCurrencyCode(), currency.getCurrencyCode() + " ");
}

static public String formatBalanceWithoutCurrencySymbol(BigDecimal value, Currency currency) {
Expand Down