From: Damyan Ivanov Date: Thu, 14 May 2020 20:46:52 +0000 (+0300) Subject: update decimal separator value with locale change X-Git-Tag: v0.13.1~2 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=46f085f006042a07edc6fb6c2bc464cbe074c275;p=mobile-ledger.git 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 --- 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)); };