Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28312] Android: Can't enter decimal comma in TextField on some devices

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionUnresolved
Affected Version/sRelease 9.1.0
Fix Version/sRelease 9.3.1
ComponentsAndroid
LabelsTextField, android, decimal, locale, localization
ReporterJoshua Quick
AssigneeJoshua Quick
Created2021-01-13T00:52:43.000+0000
Updated2021-01-19T21:10:31.000+0000

Description

*Summary:* Some Android devices such as Samsung and Huawei do not have localized decimal keyboards. They only support a decimal point '.' which makes it impossible to enter a decimal separator into a TextField for locales that use a decimal comma ',' character. This never happens in the Android emulator or Google's own devices. This is actually a bug with some 3rd party devices, not in Titanium. We can't control the localization of the virtual keyboard. But that said, we need a work-around of some kind. *Steps to reproduce:*

Acquire a Samsung or Huawei Android device.

Go to: Settings -> System -> Languages & Input -> Languages

Select a European language such as French or German.

Build and run the below code.

Tap on the TextField.

Notice keyboard has a "," button but not a "." button. _(We can't fix this.)_

Attempt to enter a decimal value such as 1,5 or 1.5.

Notice you can't enter a decimal separator. _(This is only an issue on some devices.)_

const value = 1234.5;
const window = Ti.UI.createWindow();
const textField = Ti.UI.createTextField({
	value: value.toLocaleString(Ti.Locale.currentLocale),
	keyboardType: Ti.UI.KEYBOARD_TYPE_DECIMAL_PAD,
	width: "80%",
});
textField.addEventListener("change", (e) => {
	console.log("@@@ value: " + Ti.Locale.parseDecimal(e.value));
});
window.add(textField);
window.open();
*Recommended Solution:* For locales that do not use a decimal point, we should automatically substitute the "." character as it's typed in. This would also mean we won't allow user's to enter a thousands separator for European locales, but unfortunately there doesn't appear to be any other solution to this issue.

Comments

  1. Joshua Quick 2021-01-13

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12382
  2. Christopher Williams 2021-01-19

    merged to master, backport PR to 9_3_X merged for 9.3.1 target.

JSON Source