From 46f085f006042a07edc6fb6c2bc464cbe074c275 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 14 May 2020 23:46:52 +0300 Subject: [PATCH] update decimal separator value with locale change even on newer android, where there is a dedicated key listener, we need to know how to convert strings to floats --- .../mobileledger/ui/activity/NewTransactionItemHolder.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java index 16ef747e..eee34693 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java @@ -63,11 +63,11 @@ import static net.ktnx.mobileledger.ui.activity.NewTransactionModel.ItemType; class NewTransactionItemHolder extends RecyclerView.ViewHolder implements DatePickerFragment.DatePickedListener, DescriptionSelectedCallback { - private final String decimalSeparator; private final String decimalDot; private final TextView tvCurrency; private final Observer showCommentsObserver; private final TextView tvTransactionComment; + private String decimalSeparator; private NewTransactionModel.Item item; private TextView tvDate; private AutoCompleteTextView tvDescription; @@ -186,7 +186,7 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder MLDB.hookAutocompletionAdapter(tvAccount.getContext(), tvAccount, MLDB.ACCOUNTS_TABLE, "name", true, this, mProfile); - // FIXME: react on configuration (locale) changes + // updated on locale changes by an observer below decimalSeparator = String.valueOf(DecimalFormatSymbols.getInstance() .getMonetaryDecimalSeparator()); decimalDot = "."; @@ -361,6 +361,9 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder }; localeObserver = locale -> { + decimalSeparator = String.valueOf(DecimalFormatSymbols.getInstance(locale) + .getMonetaryDecimalSeparator()); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) tvAmount.setKeyListener(DigitsKeyListener.getInstance(locale, true, true)); }; -- 2.39.5