Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27616] Android: TextField with decimal keyboard type does not allow comma for decimal separator

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2020-08-11T14:52:55.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.1.0
ComponentsAndroid
LabelsAndroid, TextField, decimal, keyboardType
ReporterThomas Neerup
AssigneeJoshua Quick
Created2019-11-01T14:22:48.000+0000
Updated2021-01-13T00:53:55.000+0000

Description

*Summary:* When using a TextField with "keyboardType" set to KEYBOARD_TYPE_DECIMAL_PAD or KEYBOARD_TYPE_NUMBERS_PUNCTUATION, the end-user is only allowed to enter a period '.' for the decimal point. It ignores the current locale and does not allow other types of decimal separators such as a comma ',' which is used Europe and South America. *How to add languages on Android:*

Go to Android's main Settings screen.

Tap on "System".

Tap on "Language & Input".

Tap on "Languages".

Tap on "Add Language".

Select a European language such as "German"/"Deutsch".

Drag-and-drop the language to the top of the list.

*Steps to reproduce:*

Build and run the below code on Android.

Select a European language. (See language instructions above.)

Tap on the TextField.

Attempt to enter 1,5 with a comma.

Notice it won't let you use a comma ',' for the decimal separator.

Enter 1.5 with a period.

Notice that it allows a period, but this is not correct for the current locale.

var window = Ti.UI.createWindow();
window.add(Ti.UI.createTextField({
	keyboardType: Ti.UI.KEYBOARD_TYPE_DECIMAL_PAD,
	width: "90%",
}));
window.open();
*Note:* This is actually a bug on Google's end. They have a *+partial+* fix for it as of Android 8.0 by using passing the current Locale to a DigitsKeyListener constructor. https://developer.android.com/reference/android/text/method/DigitsKeyListener#DigitsKeyListener(java.util.Locale) Unfortunately, Google's fix is incomplete and has the following issues: * Fullscreen edits (when in landscape) is not fixed. Only allows period for decimal point. * Does not support Arabic decimal separator at all. * Android OS versions older than 8.0 can't use their fix. We need a solution for Android 4.4 too. \\ \\ ---- *Original Post:* In Denmark the decimal separator is comma (,) But when setting
TextField.keyboardType = Ti.UI.KEYBOARD_TYPE_NUMBERS_PUNCTUATION;
Titanium Shows a keyboard with a dot (.) instead... And when parsing a value with Danish Locale 20.50 becomes 2050 On IOS the keyboard is shown with a comma (,) and everything works as expected

Attachments

FileDateSize
keyPad.png2019-11-14T14:07:20.000+000012794
TextFieldKeyboardAdvancedTest.js2020-04-28T02:18:01.000+00008700
TextFieldKeyboardAdvancedTest1.png2020-04-28T02:52:32.000+0000165150
TextFieldKeyboardAdvancedTest2.png2020-04-28T02:52:37.000+0000191262

Comments

  1. Sharif AbuDarda 2019-11-03

    Hello, please share a full reproducible sample core for the Android platform to test. Thanks.
  2. Yordan Banev 2019-11-14

    [~thomas.neerup@eg.dk] Could you confirm that you have the issue with the Ti.UI.KEYBOARD_TYPE_NUMBERS_PUNCTUATION constant? I am able to write a comma with it. Although if you switch it to Ti.UI.KEYBOARD_TYPE_DECIMAL_PAD I get what you have described - I see the comma on the pad, but I can't use it.
  3. Thomas Neerup 2019-11-14

    Yordan Banev Yes I can with Ti.UI.KEYBOARD_TYPE_NUMBERS_PUNCTUATION gives me '.' (dot) like your keypad.png not ',' (comma) on Android Phone with Danish Locale.... Should be ',' (comma)
  4. Yordan Banev 2019-11-14

    [~thomas.neerup@eg.dk] I have attached what I get as a keypad. !keyPad.png|thumbnail! For me the comma symbol is accessible after clicking on the bottom left key that exposes more special symbols. Is that the case with you? Also some details about the device you are using could be useful for troubleshooting - what Android version is it running and a make and model.
  5. Thomas Neerup 2019-11-14

    I get the same as your kypad.png... I'm on a Nexus 6P with Android 8 As I see it... it should be comma instead of . to the right og 0... . tousand separator is not usefull to anyone... plus that how it works on IOS
  6. Yordan Banev 2019-11-21

    I am changing this to an improvement, since the it works on native Android with the proposed solution from [~jquick], but it does not show a keyboard that matches what is shown on iOS. In Android it shows the full keyboard with letters, numbers, punctuation symbols and special symbols although it only accepts the proper decimal separator. With changes in the upcoming PR the keyboard which is shown will be closer to the iOS counterpart.
  7. Yordan Banev 2019-11-21

    PR: https://github.com/appcelerator/titanium_mobile/pull/11360
  8. Thomas Neerup 2020-01-21

    Any chance this could be in the next release ? I have several customers waiting for this... /Cheers
  9. Joshua Quick 2020-04-28

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/11662
  10. Joshua Quick 2020-04-28

    The attached [^TextFieldKeyboardAdvancedTest.js] can be used to test all keyboard types with various different TextField/TextArea settings. This is needed since my PR completely refactors this code. !TextFieldKeyboardAdvancedTest1.png|thumbnail! !TextFieldKeyboardAdvancedTest2.png|thumbnail!
  11. Samir Mohammed 2020-07-13

    FR Passed, Waiting on Jenkins build.
  12. Christopher Williams 2020-07-14

    merged to master for 9.1.0 target
  13. Samir Mohammed 2020-08-11

    *Closing ticket*. bug fixed verified in SDK version 9.1.0.v20200810120239. *Test and other information can be found at:* https://github.com/appcelerator/titanium_mobile/pull/11662
  14. Samir Mohammed 2020-08-11

    Closing ticket. Bug Fixed in SDK version 9.1.0.v20200810120239. *Test and other information can be found at: *https://github.com/appcelerator/titanium_mobile/pull/11662
  15. Rodrigo Farfán 2020-11-30

    I'm experiencing a problem and I guess it's related with this issue. Using SDK 9.2.2.GA, a TextField with keyboardType: Ti.UI.KEYBOARD_TYPE_DECIMAL_PAD, on Samsung devices (tested on Android 8.1 and Android 10) and with language set to Spanish (for which decimal separator is comma "," instead of dot ".") I cannot introduce comma nor dot. This not happens on emulator with android 10. A customer has realized using a HUAWEI P Smart (Android 9). Same behaviour: cannot type comma nor dot when device language is set to Spanish.
  16. Rodrigo Farfán 2020-11-30

    Forget about HUAWEI. Issue is present with Samsung devices and SDK 9.2.2.GA
  17. Joshua Quick 2020-12-02

    [~rfarfan], I can't reproduce this on my devices with Spain Spanish. Can you give me some more details please? * Does the virtual keyboard show the "," character? * Or is the issue that entering the "," does not appear in the TextField? * Does this issue happen on your Huawei or Samsung device with other European locales such as German, French, etc.? * What was the behavior before Titanium 9.2.0? (I'm pretty sure it never worked before since this tickets is supposed to make the TextField honor the current locale.) I suspect it's an issue with your Huawei or Samsung device having a custom virtual keyboard (not made by Google) that's either not showing the decimal character or its producing a separator character not matching what's expected. Such as a unicode decimal character instead of an ASCII character. It's hard to tell at the moment.
  18. Rodrigo Farfán 2020-12-02

    Hello Joshua and thanks for your answer. I also suspect that it's an issue with Samsung device. In the next screenshots you can see the samsung keyboard for English, Spanish and French (respectively): !https://www.dropbox.com/s/0pn0yrjvvzskmrb/Samsung-S10-SDK-9.2.2.GA-en.png?dl=0! !https://www.dropbox.com/s/n9g1rf35ke3bhfr/Samsung-S10-SDK-9.2.2.GA-es.png?dl=0! !https://www.dropbox.com/s/68p8n6asdldh5p8/Samsung-S10-SDK-9.2.2.GA-fr.png?dl=0! So, the "," is shown in the virtual keyboard, but I cannot tap on it for any of the languages. Furthermore, the background doesn't react when I tap on it. I mean that when I tap on any other virtual key, the background highlights, but not for the "," key. When the device is in English, I can tap the dot (.) and it types on the TextField. When I switch to Spanish or French, I can tap too, but the character is not typed in the TextField. Building the same test app with SDK 8.3.1.GA, I can type the dot (.) as decimal separator for Spanish, what is not actually the proper locale, but at least I can type decimal numbers. It seems to be a problem with Samsung (https://stackoverflow.com/questions/3821539/decimal-separator-comma-with-numberdecimal-inputtype-in-edittext).
  19. Joshua Quick 2020-12-03

    Thanks for the info [~rfarfan]. I'm looking for someone on my end who can reproduce it. If I were to guess, it sounds like when you tap on the "," on a Huawei/Samsung virtual keyboard, it's generating a totally different character and it's getting filtered out. I'm worried that tapping "," is generating a "." instead, which is a thousands separator for your locale and would definitely be filtered out. If that's the case, I'm not sure what we can do about it. We don't want to simply replace "." with "," since copy-and-pasting numeric text such as "1.234,5" would end up being "1,2345" (a radically different number). Hmm...
  20. Michael Gangolf 2020-12-15

    I have the same issue with Samsung phones, DECIMAL and German default lang: Samsung displays *.-* (dot, dash) on the right side as a key but I can't press it because it should be a comma for German decimal numbers. A Pixel 4 is working fine. There I have a dot and a comma but only the comma works.
  21. Joshua Quick 2020-12-15

    We were able to reproduce this on 1 Samsung device on our end. It looks like tapping on "," is sending the "." instead, causing it to be filtered-out. It looks like a bug in Samsung's virtual keyboard. The problem is what to do with it since we need to allow copy-and-paste of localized numeric strings where the "." needs to be treated as a thousands separator. Hmm...
  22. Michael Gangolf 2020-12-15

    !https://migaweb.de/ti_keyboard.jpg! I wish I had a comma :) Very strange bug. Sending a comma with adb works fine, so yes the dot get's filtered out because of German locales. Perhaps a workaround would be to allow dot and comma, so at least a user can type it and then the dev is responsible to convert it before working with it. I use a "type phone" keyboard as a workaround. Samsung is fine but the stock keyboard will show a "dot" now and you can add multiple dots or a dash now. But at least you can input decimal values again ;-)
  23. Joshua Quick 2020-12-15

    The thing is we don't have much control over the virtual keyboard. The TextField (ie: the Java EditText) specifies it wants a numeric keyboard, but the stock Samsung virtual numeric keyboard isn't localized. We could substitute the "." character with "," in this case, but we don't want to do this when text is being copy-and-pasted or if the string is being assigned programmatically.
  24. Rodrigo Farfán 2020-12-22

    I 100% understand your point. As Spanish, we have to face this l10n issue all the time and in all the platforms. I also agree that this is an issue with Samsung extra UI layer. I don't know how Michael Gangolf nor Hans Knöchel do with their apps in German, but what I usually do is just display localized (using a Label) but edit non-localized, I mean, just using point as decimal separator and no separator for thousands (same as a simple calculator). Most users understand that they must type a point as decimal separator. In web apps, we can override key events to transform commas in points. The "problem" here is that we want to show a proper keyboard for decimal typing, not a QWERTY keyboard. What can we do? We have an app on which the user has to type a decimal number but cannot if using a Samsung device. The only way to solve shouldn't be just downgrade the SDK
  25. Rodrigo Farfán 2020-12-22

    I've checking Google Sheets on my Samsung and it displays a numeric keyboard with both, comma and dot (actually "," and ".-") buttons, when editing a cell. But only ".-" works and types a "." in the cell, as it considers that decimal numbers have "." as decimal separator, despite the language (my phone is in Spanish and Google Sheets app displays all the info and menus in Spanish). That would be a valid solution for me. Now I just have to find the way to force the keyboard to "think" that the device is in English so that is accepts "." as separator. I'll will update here if found.
  26. Joshua Quick 2021-01-13

    [~rfarfan], [~michael], I've written a new ticket for this issue here: [TIMOB-28312]

JSON Source