Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): decimal comma TextField handling on some devices #12382

Merged
merged 4 commits into from Jan 19, 2021

Conversation

jquick-axway
Copy link
Contributor

@jquick-axway jquick-axway commented Jan 13, 2021

JIRA:
https://jira.appcelerator.org/browse/TIMOB-28312

Summary:

  • Some devices such as Samsung and Huawei do not have localized decimal keyboards and always show a . for the decimal separator. This prevents users in locales such as Europe from entering a decimal separator because the . is filtered-out.
  • This is never an issue in the Android emulator or Google's devices.
  • This PR will substitute a . with ,. Unfortunately there doesn't appear too be any other solution.

Note:
This should be tested by @lokeshchdhry since he has a device that can reproduce this issue.

Test:

  1. Acquire a Samsung or Huawei Android device.
  2. Go to: Settings -> System -> Languages & Input -> Languages
  3. Select a European language such as French or German.
  4. Build and run the below code.
  5. Verify TextField displays 1.234,5. (Will be 1 234,5 for French.)
  6. Tap on the TextField.
  7. Delete all characters.
  8. Attempt to enter 1,5 or 1.5.
  9. Verify it displays as 1,5. (Tapping a period . will show a comma , instead.)
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();

@build
Copy link
Contributor

build commented Jan 13, 2021

Fails
🚫 Tests have failed, see below for more information.
Messages
📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.
📖 ❌ 1 tests have failed There are 1 tests failing and 673 skipped out of 10214 total tests.

Tests:

ClassnameNameTimeError
ios.macos.Titanium.Blobimage dimensions should be reported in pixels (10.15.5)0.005
Error: expected 6 to be 11
value@file:///node_modules/should/cjs/should.js:356:23
postlayout@file:///ti.blob.test.js:483:33

Generated by 🚫 dangerJS against 399c7e6

@m1ga
Copy link
Contributor

m1ga commented Jan 16, 2021

Looking good!

Pixel 4:
Screenshot_20210116-150927
both , and . will write a ,

Samsung A5:
Screenshot_20210116-150944
.- will write a , (wasn't working before) 👍

Copy link
Contributor

@sgtcoolguy sgtcoolguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lokeshchdhry
Copy link
Contributor

Looks good. , is seen for a .
FR Passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants