From 8053e6cb812128a7677e383a6d71fa0ffa93f657 Mon Sep 17 00:00:00 2001 From: ShirokaiLon <6662937+ShirokaiLon@users.noreply.github.com> Date: Thu, 24 Jan 2019 19:45:42 +0000 Subject: [PATCH] Set Android InputType directly for the pin lock screen to force numeric-only keyboard layout. (#451) * Set Android InputType directly for the pin lock screen to force numeric-only keyboard layout. * Renamed variable --- src/Android/Controls/ExtendedEntryRenderer.cs | 5 +++++ src/App/Controls/ExtendedEntry.cs | 3 ++- src/App/Controls/PinControl.cs | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Android/Controls/ExtendedEntryRenderer.cs b/src/Android/Controls/ExtendedEntryRenderer.cs index 10dab3ab1..f1c02291c 100644 --- a/src/Android/Controls/ExtendedEntryRenderer.cs +++ b/src/Android/Controls/ExtendedEntryRenderer.cs @@ -66,6 +66,11 @@ namespace Bit.Android.Controls Control.SetRawInputType(InputTypes.TextFlagNoSuggestions | InputTypes.TextVariationVisiblePassword); } + if(_view.NumbersOnly) + { + Control.SetRawInputType(InputTypes.ClassNumber | InputTypes.NumberVariationPassword); + } + _view.ToggleIsPassword += ToggleIsPassword; if(_view.FontFamily == "monospace") diff --git a/src/App/Controls/ExtendedEntry.cs b/src/App/Controls/ExtendedEntry.cs index c41426976..bcb67bd63 100644 --- a/src/App/Controls/ExtendedEntry.cs +++ b/src/App/Controls/ExtendedEntry.cs @@ -12,7 +12,7 @@ namespace Bit.App.Controls { PlaceholderColor = Color.FromHex("c7c7cd"); } - + IsPasswordFromToggled = IsPassword; } @@ -57,6 +57,7 @@ namespace Bit.App.Controls public bool DisableAutocapitalize { get; set; } public bool AllowClear { get; set; } public bool HideCursor { get; set; } + public bool NumbersOnly { get; set; } // Need to overwrite default handler because we cant Invoke otherwise public new event EventHandler Completed; diff --git a/src/App/Controls/PinControl.cs b/src/App/Controls/PinControl.cs index 0903fdc0d..59714cc24 100644 --- a/src/App/Controls/PinControl.cs +++ b/src/App/Controls/PinControl.cs @@ -21,7 +21,8 @@ namespace Bit.App.Controls { Keyboard = Keyboard.Numeric, TargetMaxLength = 4, - HideCursor = true + HideCursor = true, + NumbersOnly = true }; Entry.BackgroundColor = Entry.TextColor = Color.Transparent;