From 37ea84ffe958dcb19e598aa1c7895d8228031657 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 27 Nov 2017 20:45:09 -0500 Subject: [PATCH] rename autofill pages --- src/App/App.csproj | 2 +- ...e2.cs => ToolsAccessibilityServicePage.cs} | 124 +++++++++++++----- .../Pages/Tools/ToolsAutofillServicePage.cs | 120 ++++------------- src/App/Pages/Tools/ToolsPage.cs | 4 +- 4 files changed, 124 insertions(+), 126 deletions(-) rename src/App/Pages/Tools/{ToolsAutofillServicePage2.cs => ToolsAccessibilityServicePage.cs} (53%) diff --git a/src/App/App.csproj b/src/App/App.csproj index 8e31b095e..e1beb971c 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -182,8 +182,8 @@ - + diff --git a/src/App/Pages/Tools/ToolsAutofillServicePage2.cs b/src/App/Pages/Tools/ToolsAccessibilityServicePage.cs similarity index 53% rename from src/App/Pages/Tools/ToolsAutofillServicePage2.cs rename to src/App/Pages/Tools/ToolsAccessibilityServicePage.cs index 9ab019e20..5a54ba974 100644 --- a/src/App/Pages/Tools/ToolsAutofillServicePage2.cs +++ b/src/App/Pages/Tools/ToolsAccessibilityServicePage.cs @@ -4,17 +4,18 @@ using Xamarin.Forms; using XLabs.Ioc; using Bit.App.Abstractions; using Bit.App.Resources; +using FFImageLoading.Forms; namespace Bit.App.Pages { - public class ToolsAutofillServicePage2 : ExtendedContentPage + public class ToolsAccessibilityServicePage : ExtendedContentPage { private readonly IGoogleAnalyticsService _googleAnalyticsService; private readonly IAppInfoService _appInfoService; private readonly IDeviceActionService _deviceActionService; private bool _pageDisappeared = false; - public ToolsAutofillServicePage2() + public ToolsAccessibilityServicePage() { _googleAnalyticsService = Resolver.Resolve(); _appInfoService = Resolver.Resolve(); @@ -46,8 +47,7 @@ namespace Bit.App.Pages HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), - TextColor = Color.Black, - VerticalOptions = LayoutOptions.CenterAndExpand + TextColor = Color.Black }; var disabledFs = new FormattedString(); @@ -66,27 +66,93 @@ namespace Bit.App.Pages HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), - TextColor = Color.Black, - VerticalOptions = LayoutOptions.CenterAndExpand + TextColor = Color.Black }; - var goButton = new ExtendedButton + var step1Label = new Label { - Text = AppResources.BitwardenAutofillServiceOpenAutofillSettings, - Command = new Command(() => - { - _googleAnalyticsService.TrackAppEvent("OpenAutofillSettings"); - _deviceActionService.OpenAutofillSettings(); - }), - VerticalOptions = LayoutOptions.End, - HorizontalOptions = LayoutOptions.Fill, - Style = (Style)Application.Current.Resources["btn-primary"], - FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) + Text = AppResources.BitwardenAutofillServiceStep1, + HorizontalTextAlignment = TextAlignment.Center, + LineBreakMode = LineBreakMode.WordWrap, + FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), + TextColor = Color.Black + }; + + var step1Image = new CachedImage + { + Source = "accessibility_step1", + HorizontalOptions = LayoutOptions.Center, + Margin = new Thickness(0, 20, 0, 0), + WidthRequest = 300, + HeightRequest = 98 + }; + + var step2Label = new Label + { + Text = AppResources.BitwardenAutofillServiceStep2, + HorizontalTextAlignment = TextAlignment.Center, + LineBreakMode = LineBreakMode.WordWrap, + FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), + TextColor = Color.Black + }; + + var step2Image = new CachedImage + { + Source = "accessibility_step2", + HorizontalOptions = LayoutOptions.Center, + Margin = new Thickness(0, 20, 0, 0), + WidthRequest = 300, + HeightRequest = 67 + }; + + var stepsStackLayout = new StackLayout + { + Children = { statusDisabledLabel, step1Image, step1Label, step2Image, step2Label }, + Orientation = StackOrientation.Vertical, + Spacing = 10, + VerticalOptions = LayoutOptions.CenterAndExpand, + HorizontalOptions = LayoutOptions.Center + }; + + var notificationsLabel = new Label + { + Text = AppResources.BitwardenAutofillServiceNotification, + HorizontalTextAlignment = TextAlignment.Center, + LineBreakMode = LineBreakMode.WordWrap, + FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), + TextColor = Color.Black + }; + + var tapNotificationImage = new CachedImage + { + Source = "accessibility_notification.png", + HorizontalOptions = LayoutOptions.Center, + Margin = new Thickness(0, 20, 0, 0), + WidthRequest = 300, + HeightRequest = 74 + }; + + var tapNotificationIcon = new CachedImage + { + Source = "accessibility_notification_icon.png", + HorizontalOptions = LayoutOptions.Center, + Margin = new Thickness(0, 20, 0, 0), + WidthRequest = 300, + HeightRequest = 54 + }; + + var notificationsStackLayout = new StackLayout + { + Children = { statusEnabledLabel, tapNotificationIcon, tapNotificationImage, notificationsLabel }, + Orientation = StackOrientation.Vertical, + Spacing = 10, + VerticalOptions = LayoutOptions.CenterAndExpand, + HorizontalOptions = LayoutOptions.Center }; DisabledStackLayout = new StackLayout { - Children = { BuildServiceLabel(), statusDisabledLabel, goButton, BuildAccessibilityButton() }, + Children = { BuildServiceLabel(), stepsStackLayout, BuildGoButton() }, Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 30), @@ -95,7 +161,7 @@ namespace Bit.App.Pages EnabledStackLayout = new StackLayout { - Children = { BuildServiceLabel(), statusEnabledLabel, BuildAccessibilityButton() }, + Children = { BuildServiceLabel(), notificationsStackLayout, BuildGoButton() }, Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 30), @@ -111,7 +177,7 @@ namespace Bit.App.Pages { return false; } - + UpdateEnabled(); return true; }); @@ -134,14 +200,14 @@ namespace Bit.App.Pages private void UpdateEnabled() { - ScrollView.Content = _appInfoService.AutofillServiceEnabled ? EnabledStackLayout : DisabledStackLayout; + ScrollView.Content = _appInfoService.AutofillAccessibilityServiceEnabled ? EnabledStackLayout : DisabledStackLayout; } private Label BuildServiceLabel() { return new Label { - Text = AppResources.AutofillServiceDescription, + Text = AppResources.AutofillAccessibilityDescription, VerticalOptions = LayoutOptions.Start, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, @@ -149,21 +215,19 @@ namespace Bit.App.Pages }; } - private ExtendedButton BuildAccessibilityButton() + private ExtendedButton BuildGoButton() { return new ExtendedButton { - Text = AppResources.AutofillAccessibilityService, - Command = new Command(async () => + Text = AppResources.BitwardenAutofillServiceOpenAccessibilitySettings, + Command = new Command(() => { - await Navigation.PushAsync(new ToolsAutofillServicePage()); + _googleAnalyticsService.TrackAppEvent("OpenAccessibilitySettings"); + _deviceActionService.OpenAccessibilitySettings(); }), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, - Style = (Style)Application.Current.Resources["btn-primaryAccent"], - Uppercase = false, - BackgroundColor = Color.Transparent, - FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) + Style = (Style)Application.Current.Resources["btn-primary"] }; } } diff --git a/src/App/Pages/Tools/ToolsAutofillServicePage.cs b/src/App/Pages/Tools/ToolsAutofillServicePage.cs index 0342ea70f..b6ea66e2d 100644 --- a/src/App/Pages/Tools/ToolsAutofillServicePage.cs +++ b/src/App/Pages/Tools/ToolsAutofillServicePage.cs @@ -4,7 +4,6 @@ using Xamarin.Forms; using XLabs.Ioc; using Bit.App.Abstractions; using Bit.App.Resources; -using FFImageLoading.Forms; namespace Bit.App.Pages { @@ -47,7 +46,8 @@ namespace Bit.App.Pages HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), - TextColor = Color.Black + TextColor = Color.Black, + VerticalOptions = LayoutOptions.CenterAndExpand }; var disabledFs = new FormattedString(); @@ -66,93 +66,27 @@ namespace Bit.App.Pages HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), - TextColor = Color.Black + TextColor = Color.Black, + VerticalOptions = LayoutOptions.CenterAndExpand }; - var step1Label = new Label + var goButton = new ExtendedButton { - Text = AppResources.BitwardenAutofillServiceStep1, - HorizontalTextAlignment = TextAlignment.Center, - LineBreakMode = LineBreakMode.WordWrap, - FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), - TextColor = Color.Black - }; - - var step1Image = new CachedImage - { - Source = "accessibility_step1", - HorizontalOptions = LayoutOptions.Center, - Margin = new Thickness(0, 20, 0, 0), - WidthRequest = 300, - HeightRequest = 98 - }; - - var step2Label = new Label - { - Text = AppResources.BitwardenAutofillServiceStep2, - HorizontalTextAlignment = TextAlignment.Center, - LineBreakMode = LineBreakMode.WordWrap, - FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), - TextColor = Color.Black - }; - - var step2Image = new CachedImage - { - Source = "accessibility_step2", - HorizontalOptions = LayoutOptions.Center, - Margin = new Thickness(0, 20, 0, 0), - WidthRequest = 300, - HeightRequest = 67 - }; - - var stepsStackLayout = new StackLayout - { - Children = { statusDisabledLabel, step1Image, step1Label, step2Image, step2Label }, - Orientation = StackOrientation.Vertical, - Spacing = 10, - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.Center - }; - - var notificationsLabel = new Label - { - Text = AppResources.BitwardenAutofillServiceNotification, - HorizontalTextAlignment = TextAlignment.Center, - LineBreakMode = LineBreakMode.WordWrap, - FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), - TextColor = Color.Black - }; - - var tapNotificationImage = new CachedImage - { - Source = "accessibility_notification.png", - HorizontalOptions = LayoutOptions.Center, - Margin = new Thickness(0, 20, 0, 0), - WidthRequest = 300, - HeightRequest = 74 - }; - - var tapNotificationIcon = new CachedImage - { - Source = "accessibility_notification_icon.png", - HorizontalOptions = LayoutOptions.Center, - Margin = new Thickness(0, 20, 0, 0), - WidthRequest = 300, - HeightRequest = 54 - }; - - var notificationsStackLayout = new StackLayout - { - Children = { statusEnabledLabel, tapNotificationIcon, tapNotificationImage, notificationsLabel }, - Orientation = StackOrientation.Vertical, - Spacing = 10, - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.Center + Text = AppResources.BitwardenAutofillServiceOpenAutofillSettings, + Command = new Command(() => + { + _googleAnalyticsService.TrackAppEvent("OpenAutofillSettings"); + _deviceActionService.OpenAutofillSettings(); + }), + VerticalOptions = LayoutOptions.End, + HorizontalOptions = LayoutOptions.Fill, + Style = (Style)Application.Current.Resources["btn-primary"], + FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) }; DisabledStackLayout = new StackLayout { - Children = { BuildServiceLabel(), stepsStackLayout, BuildGoButton() }, + Children = { BuildServiceLabel(), statusDisabledLabel, goButton, BuildAccessibilityButton() }, Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 30), @@ -161,7 +95,7 @@ namespace Bit.App.Pages EnabledStackLayout = new StackLayout { - Children = { BuildServiceLabel(), notificationsStackLayout, BuildGoButton() }, + Children = { BuildServiceLabel(), statusEnabledLabel, BuildAccessibilityButton() }, Orientation = StackOrientation.Vertical, Spacing = 20, Padding = new Thickness(20, 30), @@ -177,7 +111,7 @@ namespace Bit.App.Pages { return false; } - + UpdateEnabled(); return true; }); @@ -200,14 +134,14 @@ namespace Bit.App.Pages private void UpdateEnabled() { - ScrollView.Content = _appInfoService.AutofillAccessibilityServiceEnabled ? EnabledStackLayout : DisabledStackLayout; + ScrollView.Content = _appInfoService.AutofillServiceEnabled ? EnabledStackLayout : DisabledStackLayout; } private Label BuildServiceLabel() { return new Label { - Text = AppResources.AutofillAccessibilityDescription, + Text = AppResources.AutofillServiceDescription, VerticalOptions = LayoutOptions.Start, HorizontalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.WordWrap, @@ -215,20 +149,20 @@ namespace Bit.App.Pages }; } - private ExtendedButton BuildGoButton() + private ExtendedButton BuildAccessibilityButton() { return new ExtendedButton { - Text = AppResources.BitwardenAutofillServiceOpenAccessibilitySettings, - Command = new Command(() => + Text = AppResources.AutofillAccessibilityService, + Command = new Command(async () => { - _googleAnalyticsService.TrackAppEvent("OpenAccessibilitySettings"); - _deviceActionService.OpenAccessibilitySettings(); + await Navigation.PushAsync(new ToolsAccessibilityServicePage()); }), VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, - Style = (Style)Application.Current.Resources["btn-primary"], - FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button)) + Style = (Style)Application.Current.Resources["btn-primaryAccent"], + Uppercase = false, + BackgroundColor = Color.Transparent }; } } diff --git a/src/App/Pages/Tools/ToolsPage.cs b/src/App/Pages/Tools/ToolsPage.cs index 9039cbb45..4af5d8495 100644 --- a/src/App/Pages/Tools/ToolsPage.cs +++ b/src/App/Pages/Tools/ToolsPage.cs @@ -122,11 +122,11 @@ namespace Bit.App.Pages { if(_deviceInfoService.AutofillServiceSupported) { - Navigation.PushModalAsync(new ExtendedNavigationPage(new ToolsAutofillServicePage2())); + Navigation.PushModalAsync(new ExtendedNavigationPage(new ToolsAutofillServicePage())); } else { - Navigation.PushModalAsync(new ExtendedNavigationPage(new ToolsAutofillServicePage())); + Navigation.PushModalAsync(new ExtendedNavigationPage(new ToolsAccessibilityServicePage())); } }