Merge pull request #172 from NativeScript/text-field-secure

Text field secure
This commit is contained in:
Rossen Hristov
2015-03-12 17:07:01 +02:00
2 changed files with 4 additions and 10 deletions

View File

@ -13,16 +13,7 @@ export function getNativeHint(textField: textFieldModule.TextField): string {
export function getNativeSecure(textField: textFieldModule.TextField): boolean {
var inputType = textField.android.getInputType();
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);
}
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));
}
export function getNativeFontSize(textField: textFieldModule.TextField): number {

View File

@ -33,6 +33,9 @@ function onSecurePropertyChanged(data: dependencyObservable.PropertyChangeData)
else if (currentClass === android.text.InputType.TYPE_CLASS_NUMBER) {
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 {
if (currentClass === android.text.InputType.TYPE_CLASS_TEXT) {