Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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));
});
}
}
}
19 changes: 19 additions & 0 deletions src/Core/src/Platform/Android/EditTextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,25 @@
if (editText.InputType.HasFlag(InputTypes.ClassNumber))
editText.InputType |= InputTypes.NumberVariationPassword;
}
else if (textInput is IEntry)
{
editText.InputType &= ~InputTypes.TextVariationPassword;
editText.InputType &= ~InputTypes.NumberVariationPassword;
Comment thread
jpd21122012 marked this conversation as resolved.
Outdated
Comment thread
jpd21122012 marked this conversation as resolved.
Outdated
if (textInput is IEntry entry)
{
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;
editText.InputType &= ~InputTypes.NumberVariationPassword;
}
Comment thread
jpd21122012 marked this conversation as resolved.
}
Comment thread
jpd21122012 marked this conversation as resolved.
Outdated

if (textInput is IEditor)
editText.InputType |= InputTypes.TextFlagMultiLine;
Expand All @@ -400,7 +419,7 @@
// If we implement the OnSelectionChanged method, this method is called after a keyboard layout change with SelectionStart = 0,
// Let's restore the cursor position to its previous location.
editText.SetSelection(previousCursorPosition);
}

Check failure on line 422 in src/Core/src/Platform/Android/EditTextExtensions.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Debug))

src/Core/src/Platform/Android/EditTextExtensions.cs#L422

src/Core/src/Platform/Android/EditTextExtensions.cs(422,4): error CS1513: (NETCORE_ENGINEERING_TELEMETRY=Build) } expected

Check failure on line 422 in src/Core/src/Platform/Android/EditTextExtensions.cs

View check run for this annotation

Azure Pipelines / maui-pr (Pack .NET MAUI Pack macOS)

src/Core/src/Platform/Android/EditTextExtensions.cs#L422

src/Core/src/Platform/Android/EditTextExtensions.cs(422,4): error CS1513: (NETCORE_ENGINEERING_TELEMETRY=Build) } expected

Check failure on line 422 in src/Core/src/Platform/Android/EditTextExtensions.cs

View check run for this annotation

Azure Pipelines / maui-pr (Pack .NET MAUI Pack macOS)

src/Core/src/Platform/Android/EditTextExtensions.cs#L422

src/Core/src/Platform/Android/EditTextExtensions.cs(422,4): error CS1513: (NETCORE_ENGINEERING_TELEMETRY=Build) } expected

Check failure on line 422 in src/Core/src/Platform/Android/EditTextExtensions.cs

View check run for this annotation

Azure Pipelines / maui-pr (Build .NET MAUI Build macOS (Release))

src/Core/src/Platform/Android/EditTextExtensions.cs#L422

src/Core/src/Platform/Android/EditTextExtensions.cs(422,4): error CS1513: (NETCORE_ENGINEERING_TELEMETRY=Build) } expected

Check failure on line 422 in src/Core/src/Platform/Android/EditTextExtensions.cs

View check run for this annotation

Azure Pipelines / maui-pr

src/Core/src/Platform/Android/EditTextExtensions.cs#L422

src/Core/src/Platform/Android/EditTextExtensions.cs(422,4): error CS1513: (NETCORE_ENGINEERING_TELEMETRY=Build) } expected

Check failure on line 422 in src/Core/src/Platform/Android/EditTextExtensions.cs

View check run for this annotation

Azure Pipelines / maui-pr

src/Core/src/Platform/Android/EditTextExtensions.cs#L422

src/Core/src/Platform/Android/EditTextExtensions.cs(422,4): error CS1513: (NETCORE_ENGINEERING_TELEMETRY=Build) } expected

Check failure on line 422 in src/Core/src/Platform/Android/EditTextExtensions.cs

View check run for this annotation

Azure Pipelines / maui-pr

src/Core/src/Platform/Android/EditTextExtensions.cs#L422

src/Core/src/Platform/Android/EditTextExtensions.cs(422,4): error CS1513: (NETCORE_ENGINEERING_TELEMETRY=Build) } expected

internal static bool IsCompletedAction(this EditorActionEventArgs e, ImeAction currentInputImeFlag)
{
Expand Down
Loading