[TIMOB-27616] Android: TextField with decimal keyboard type does not allow comma for decimal separator
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-08-11T14:52:55.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.1.0 |
Components | Android |
Labels | Android, TextField, decimal, keyboardType |
Reporter | Thomas Neerup |
Assignee | Joshua Quick |
Created | 2019-11-01T14:22:48.000+0000 |
Updated | 2021-01-13T00:53:55.000+0000 |
Description
*Summary:*
When using a Tap on the
Attempt to enter
Enter
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
File | Date | Size |
---|---|---|
keyPad.png | 2019-11-14T14:07:20.000+0000 | 12794 |
TextFieldKeyboardAdvancedTest.js | 2020-04-28T02:18:01.000+0000 | 8700 |
TextFieldKeyboardAdvancedTest1.png | 2020-04-28T02:52:32.000+0000 | 165150 |
TextFieldKeyboardAdvancedTest2.png | 2020-04-28T02:52:37.000+0000 | 191262 |
Hello, please share a full reproducible sample core for the Android platform to test. Thanks.
[~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 toTi.UI.KEYBOARD_TYPE_DECIMAL_PAD
I get what you have described - I see the comma on the pad, but I can't use it.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)
[~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.
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
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.
PR: https://github.com/appcelerator/titanium_mobile/pull/11360
Any chance this could be in the next release ? I have several customers waiting for this... /Cheers
PR (master): https://github.com/appcelerator/titanium_mobile/pull/11662
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!
FR Passed, Waiting on Jenkins build.
merged to master for 9.1.0 target
*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/11662Closing 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
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.
Forget about HUAWEI. Issue is present with Samsung devices and SDK 9.2.2.GA
[~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.
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).
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...
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.
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...
!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 ;-)
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.
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
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.
[~rfarfan], [~michael], I've written a new ticket for this issue here: [TIMOB-28312]