Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,57 @@ await InvokeOnMainThreadAsync(() =>
AssertTranslationMatches(nativeView, entry.TranslationX, entry.TranslationY);
});
}

[Fact]
[Category(TestCategory.Entry)]
public async Task KeyboardPasswordDoesNotForcePasswordVisibilityWhenIsPasswordIsFalse()
{
Comment thread
jpd21122012 marked this conversation as resolved.
var entry = new Entry
{
Keyboard = Keyboard.Password,
IsPassword = false,
Text = "Password"
};

var handler = await CreateHandlerAsync<EntryHandler>(entry);
var platformEntry = GetPlatformControl(handler);

await InvokeOnMainThreadAsync(() =>
{
Assert.False(platformEntry.InputType.HasFlag(global::Android.Text.InputTypes.TextVariationPassword));
Assert.False(platformEntry.InputType.HasFlag(global::Android.Text.InputTypes.NumberVariationPassword));
});
}

[Fact]
[Category(TestCategory.Entry)]
public async Task KeyboardPasswordRespectsIsPasswordToggle()
{
var entry = new Entry
{
Keyboard = Keyboard.Password,
IsPassword = false,
Text = "Password"
};

var handler = await CreateHandlerAsync<EntryHandler>(entry);
var platformEntry = GetPlatformControl(handler);

await InvokeOnMainThreadAsync(() =>
{
Assert.False(platformEntry.InputType.HasFlag(global::Android.Text.InputTypes.TextVariationPassword));

entry.IsPassword = true;
handler.UpdateValue(nameof(IEntry.IsPassword));

Assert.True(platformEntry.InputType.HasFlag(global::Android.Text.InputTypes.TextVariationPassword));

entry.IsPassword = false;
handler.UpdateValue(nameof(IEntry.IsPassword));

Assert.False(platformEntry.InputType.HasFlag(global::Android.Text.InputTypes.TextVariationPassword));
Assert.False(platformEntry.InputType.HasFlag(global::Android.Text.InputTypes.NumberVariationPassword));
});
}
}
}
18 changes: 13 additions & 5 deletions src/Core/src/Platform/Android/EditTextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,20 @@ internal static void SetInputType(this EditText editText, ITextInput textInput)
editText.KeyListener = LocalizedDigitsKeyListener.Create(editText.InputType);
}

if (textInput is IEntry entry && entry.IsPassword)
if (textInput is IEntry entry)
{
if (editText.InputType.HasFlag(InputTypes.ClassText))
editText.InputType |= InputTypes.TextVariationPassword;
if (editText.InputType.HasFlag(InputTypes.ClassNumber))
editText.InputType |= InputTypes.NumberVariationPassword;
if (entry.IsPassword)
{
if (editText.InputType.HasFlag(InputTypes.ClassText))
editText.InputType |= InputTypes.TextVariationPassword;

if (editText.InputType.HasFlag(InputTypes.ClassNumber))
editText.InputType |= InputTypes.NumberVariationPassword;
}
else
{
editText.InputType &= ~(InputTypes.TextVariationPassword | InputTypes.NumberVariationPassword);
Comment thread
jpd21122012 marked this conversation as resolved.
Outdated
}
Comment thread
jpd21122012 marked this conversation as resolved.
}
Comment thread
jpd21122012 marked this conversation as resolved.
Outdated

if (textInput is IEditor)
Expand Down
Loading