- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
- // only one decimal separator is allowed
- // plus and minus are allowed only at the beginning
- String allowed = "0123456789";
- String val = s.toString();
- Logger.debug("input", val);
- if (val.isEmpty() || (tvAmount.getSelectionStart() == 0))
- allowed += "-";
- if (!val.contains(decimalSeparator) && !val.contains(decimalDot))
- allowed += decimalSeparator + decimalDot;
-
- tvAmount.setKeyListener(DigitsKeyListener.getInstance(allowed));
- }