mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Merge pull request #172 from NativeScript/text-field-secure
Text field secure
This commit is contained in:
@ -13,16 +13,7 @@ export function getNativeHint(textField: textFieldModule.TextField): string {
|
|||||||
|
|
||||||
export function getNativeSecure(textField: textFieldModule.TextField): boolean {
|
export function getNativeSecure(textField: textFieldModule.TextField): boolean {
|
||||||
var inputType = textField.android.getInputType();
|
var inputType = textField.android.getInputType();
|
||||||
|
return (((inputType & android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD) === android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD) || ((inputType & android.text.InputType.TYPE_NUMBER_VARIATION_PASSWORD) === android.text.InputType.TYPE_NUMBER_VARIATION_PASSWORD));
|
||||||
if (inputType === (android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (inputType === (android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_NORMAL)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error("Unsupported input type: " + inputType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNativeFontSize(textField: textFieldModule.TextField): number {
|
export function getNativeFontSize(textField: textFieldModule.TextField): number {
|
||||||
|
@ -33,6 +33,9 @@ function onSecurePropertyChanged(data: dependencyObservable.PropertyChangeData)
|
|||||||
else if (currentClass === android.text.InputType.TYPE_CLASS_NUMBER) {
|
else if (currentClass === android.text.InputType.TYPE_CLASS_NUMBER) {
|
||||||
newInputType = currentClass | currentFlags | android.text.InputType.TYPE_NUMBER_VARIATION_PASSWORD;
|
newInputType = currentClass | currentFlags | android.text.InputType.TYPE_NUMBER_VARIATION_PASSWORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lower all autocapitalization bits, because password bits don't like them and we will receive "Unsupported input type: 16513" error for example.
|
||||||
|
newInputType = newInputType & ~28762; //28762 (0x00007000) 13,14,15bits
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (currentClass === android.text.InputType.TYPE_CLASS_TEXT) {
|
if (currentClass === android.text.InputType.TYPE_CLASS_TEXT) {
|
||||||
|
Reference in New Issue
Block a user