Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Add localized listener for Android numeric input #719

Merged
merged 2 commits into from
Feb 17, 2017
Merged

Conversation

hartez
Copy link
Contributor

@hartez hartez commented Jan 25, 2017

Description of Change

Proposing this as an alternative fix to PR 396

The DigitsKeyListener in Android has . hard-coded as the decimal separator. This change introduces a LocalizedDigitsKeyListener which checks the current decimal separator for the device language. If the separator is ., it defers to the built-in DigitsKeyListener; if not, it uses an instance of LocalizedDigitsKeyListener with the correct decimal separator.

This preserves the default Android behavior (not allowing the user to enter an invalid number format) while allowing for "alternate" decimal separators (e.g. ,).

This change also provides an easily overridable method for providing an alternate NumericKeyListener for users who need to disallow negative/decimal numbers or provide alternate acceptable characters.

A test page is included, but it's manual - there's currently no UI test facility for changing the language settings of the device mid-test.

Bugs Fixed

API Changes

  • None

Behavioral Changes

  • This change makes the numeric keyboard on Android allow negative numbers by default; the previous default did not allow negative numbers. I believe this new default follows the law of least surprise, but feel free to argue for the previous default behavior in the comments.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense

@@ -56,6 +58,14 @@ protected override void OnCellPropertyChanged(object sender, PropertyChangedEven
UpdateHeight();
}

protected NumberKeyListener GetDigitsKeyListener(InputTypes inputTypes)
Copy link
Member

Choose a reason for hiding this comment

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

virtual ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks.

@@ -86,6 +87,14 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
base.OnElementPropertyChanged(sender, e);
}

protected NumberKeyListener GetDigitsKeyListener(InputTypes inputTypes)
Copy link
Member

Choose a reason for hiding this comment

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

virtual ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks.

@hartez hartez force-pushed the fix-bugzilla42000 branch from 902d0a9 to be83984 Compare February 1, 2017 21:34
@rmarinho rmarinho merged commit 408b662 into master Feb 17, 2017
@hartez hartez deleted the fix-bugzilla42000 branch May 16, 2017 16:49
@samhouts samhouts added this to the 2.3.0 milestone Jun 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants