From d4f52bce2ba213651c5ff83a20f9eb11ba46d12e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 24 Aug 2016 00:07:46 -0400 Subject: [PATCH] Button uppercase styling enforcement --- src/Android/Controls/ExtendedButtonRenderer.cs | 11 +++++++++-- src/App/Controls/LabeledDetailCell.cs | 2 +- src/App/Pages/HomePage.cs | 4 ++-- src/App/Pages/Lock/LockFingerprintPage.cs | 9 +++++---- src/App/Pages/Lock/LockPasswordPage.cs | 5 +++-- src/App/Pages/Lock/LockPinPage.cs | 5 +++-- src/App/Pages/Settings/SettingsSyncPage.cs | 2 +- src/App/Pages/Tools/ToolsExtensionPage.cs | 8 ++++---- 8 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/Android/Controls/ExtendedButtonRenderer.cs b/src/Android/Controls/ExtendedButtonRenderer.cs index 62d28a7c0..038215f48 100644 --- a/src/Android/Controls/ExtendedButtonRenderer.cs +++ b/src/Android/Controls/ExtendedButtonRenderer.cs @@ -46,9 +46,16 @@ namespace Bit.Android.Controls private void SetUppercase() { var element = Element as ExtendedButton; - if(element != null && !element.Uppercase) + if(element != null && !string.IsNullOrWhiteSpace(element.Text)) { - Control.TransformationMethod = null; + if(element.Uppercase) + { + element.Text = element.Text.ToUpperInvariant(); + } + else + { + Control.TransformationMethod = null; + } } } } diff --git a/src/App/Controls/LabeledDetailCell.cs b/src/App/Controls/LabeledDetailCell.cs index 54e03006c..b3961353c 100644 --- a/src/App/Controls/LabeledDetailCell.cs +++ b/src/App/Controls/LabeledDetailCell.cs @@ -31,7 +31,7 @@ namespace Bit.App.Controls Spacing = 0 }; - Button = new Button + Button = new ExtendedButton { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.CenterAndExpand, diff --git a/src/App/Pages/HomePage.cs b/src/App/Pages/HomePage.cs index 37bbd1280..18799edb9 100644 --- a/src/App/Pages/HomePage.cs +++ b/src/App/Pages/HomePage.cs @@ -48,7 +48,7 @@ namespace Bit.App.Pages TextColor = Color.FromHex("333333") }; - var createAccountButton = new Button + var createAccountButton = new ExtendedButton { Text = "Create Account", Command = new Command(async () => await RegisterAsync()), @@ -58,7 +58,7 @@ namespace Bit.App.Pages FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) }; - var loginButton = new Button + var loginButton = new ExtendedButton { Text = AppResources.LogIn, Command = new Command(async () => await LoginAsync()), diff --git a/src/App/Pages/Lock/LockFingerprintPage.cs b/src/App/Pages/Lock/LockFingerprintPage.cs index 51bcb1154..d044a53fe 100644 --- a/src/App/Pages/Lock/LockFingerprintPage.cs +++ b/src/App/Pages/Lock/LockFingerprintPage.cs @@ -31,7 +31,7 @@ namespace Bit.App.Pages public void Init() { - var fingerprintIcon = new Button + var fingerprintIcon = new ExtendedButton { Image = "fingerprint", BackgroundColor = Color.Transparent, @@ -40,7 +40,7 @@ namespace Bit.App.Pages Margin = new Thickness(0, 0, 0, 15) }; - var fingerprintButton = new Button + var fingerprintButton = new ExtendedButton { Text = "Use Fingerprint to Unlock", Command = new Command(async () => await CheckFingerprintAsync()), @@ -48,13 +48,14 @@ namespace Bit.App.Pages Style = (Style)Application.Current.Resources["btn-primary"] }; - var logoutButton = new Button + var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async () => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], - BackgroundColor = Color.Transparent + BackgroundColor = Color.Transparent, + Uppercase = false }; var stackLayout = new StackLayout diff --git a/src/App/Pages/Lock/LockPasswordPage.cs b/src/App/Pages/Lock/LockPasswordPage.cs index 3bcc74bc2..799d5803e 100644 --- a/src/App/Pages/Lock/LockPasswordPage.cs +++ b/src/App/Pages/Lock/LockPasswordPage.cs @@ -61,13 +61,14 @@ namespace Bit.App.Pages } }; - var logoutButton = new Button + var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async () => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], - BackgroundColor = Color.Transparent + BackgroundColor = Color.Transparent, + Uppercase = false }; var stackLayout = new StackLayout diff --git a/src/App/Pages/Lock/LockPinPage.cs b/src/App/Pages/Lock/LockPinPage.cs index 14e27e540..e1d2f33ed 100644 --- a/src/App/Pages/Lock/LockPinPage.cs +++ b/src/App/Pages/Lock/LockPinPage.cs @@ -46,13 +46,14 @@ namespace Bit.App.Pages PinControl.Label.SetBinding(Label.TextProperty, s => s.LabelText); PinControl.Entry.SetBinding(Entry.TextProperty, s => s.PIN); - var logoutButton = new Button + var logoutButton = new ExtendedButton { Text = AppResources.LogOut, Command = new Command(async () => await LogoutAsync()), VerticalOptions = LayoutOptions.End, Style = (Style)Application.Current.Resources["btn-primaryAccent"], - BackgroundColor = Color.Transparent + BackgroundColor = Color.Transparent, + Uppercase = false }; var stackLayout = new StackLayout diff --git a/src/App/Pages/Settings/SettingsSyncPage.cs b/src/App/Pages/Settings/SettingsSyncPage.cs index 79f9b7770..0682a719e 100644 --- a/src/App/Pages/Settings/SettingsSyncPage.cs +++ b/src/App/Pages/Settings/SettingsSyncPage.cs @@ -34,7 +34,7 @@ namespace Bit.App.Pages public void Init() { - var syncButton = new Button + var syncButton = new ExtendedButton { Text = "Sync Vault Now", Command = new Command(async () => await SyncAsync()), diff --git a/src/App/Pages/Tools/ToolsExtensionPage.cs b/src/App/Pages/Tools/ToolsExtensionPage.cs index bc284790c..9b251e401 100644 --- a/src/App/Pages/Tools/ToolsExtensionPage.cs +++ b/src/App/Pages/Tools/ToolsExtensionPage.cs @@ -59,7 +59,7 @@ namespace Bit.App.Pages Margin = new Thickness(0, -10, 0, 0) }; - var notStartedButton = new Button + var notStartedButton = new ExtendedButton { Text = "Enable App Extension", Command = new Command(() => ShowExtension("NotStartedEnable")), @@ -108,7 +108,7 @@ namespace Bit.App.Pages Margin = new Thickness(0, -10, 0, 0) }; - var notActivatedButton = new Button + var notActivatedButton = new ExtendedButton { Text = "Enable App Extension", Command = new Command(() => ShowExtension("NotActivatedEnable")), @@ -158,7 +158,7 @@ namespace Bit.App.Pages Margin = new Thickness(0, -10, 0, 0) }; - var activatedButton = new Button + var activatedButton = new ExtendedButton { Text = "See Supported Apps", Command = new Command(() => @@ -171,7 +171,7 @@ namespace Bit.App.Pages Style = (Style)Application.Current.Resources["btn-primary"] }; - var activatedButtonReenable = new Button + var activatedButtonReenable = new ExtendedButton { Text = "Re-enable App Extension", Command = new Command(() => ShowExtension("Re-enable")),