From 72e67bd6f207466d5d64ebd4d21a9512272bb47e Mon Sep 17 00:00:00 2001 From: ifernandezdiaz Date: Thu, 29 Jun 2023 15:37:08 -0300 Subject: [PATCH] [PM-2691] Adding AutomationIDs for Vault Page sections (#2580) * Adding IDs for Vault Page sections * Removing extra spaces * Adding Matt's comments * Fixing Filters Id bug * Adding Fede's suggestions * Fixing Settings Ids issues * Fixing AutomationIds issues with RecyclerViews + implementing AutomationId helper class * Adding Fede's suggestion * Adding latest Fede's suggestions --- src/Android/Android.csproj | 1 + src/Android/Renderers/CustomLabelRenderer.cs | 31 +++++++++++++++++ src/App/App.csproj | 2 ++ src/App/Controls/CustomLabel.cs | 13 +++++++ .../Settings/SettingsPage/SettingsPage.xaml | 11 +++--- .../SettingsPage/SettingsPageListItem.cs | 30 +++++++++------- src/App/Pages/Vault/CipherDetailsPage.xaml | 7 ++-- .../Vault/GroupingsPage/GroupingsPage.xaml | 20 +++++++---- .../GroupingsPageHeaderListItem.cs | 11 +++++- .../GroupingsPage/GroupingsPageListGroup.cs | 2 ++ .../GroupingsPage/GroupingsPageListItem.cs | 34 +++++++++++++++++++ .../Automation/AutomationIdsHelper.cs | 23 +++++++++++++ src/App/Utilities/Automation/SuffixType.cs | 13 +++++++ src/iOS.Core/Renderers/CustomLabelRenderer.cs | 10 +++++- 14 files changed, 178 insertions(+), 30 deletions(-) create mode 100644 src/Android/Renderers/CustomLabelRenderer.cs create mode 100644 src/App/Controls/CustomLabel.cs create mode 100644 src/App/Utilities/Automation/AutomationIdsHelper.cs create mode 100644 src/App/Utilities/Automation/SuffixType.cs diff --git a/src/Android/Android.csproj b/src/Android/Android.csproj index 4b42db250..c5f838ff8 100644 --- a/src/Android/Android.csproj +++ b/src/Android/Android.csproj @@ -159,6 +159,7 @@ + diff --git a/src/Android/Renderers/CustomLabelRenderer.cs b/src/Android/Renderers/CustomLabelRenderer.cs new file mode 100644 index 000000000..62287087d --- /dev/null +++ b/src/Android/Renderers/CustomLabelRenderer.cs @@ -0,0 +1,31 @@ +using System; +using Bit.App.Controls; +using System.ComponentModel; +using Xamarin.Forms.Platform.Android; +using Android.Content; +using Xamarin.Forms; +using Bit.Droid.Renderers; + +[assembly: ExportRenderer(typeof(CustomLabel), typeof(CustomLabelRenderer))] +namespace Bit.Droid.Renderers +{ + public class CustomLabelRenderer : LabelRenderer + { + public CustomLabelRenderer(Context context) + : base(context) + { } + + protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) + { + var label = sender as CustomLabel; + switch (e.PropertyName) + { + case nameof(CustomLabel.AutomationId): + Control.ContentDescription = label.AutomationId; + break; + } + base.OnElementPropertyChanged(sender, e); + } + } +} + diff --git a/src/App/App.csproj b/src/App/App.csproj index 83e1ee879..54d589ef7 100644 --- a/src/App/App.csproj +++ b/src/App/App.csproj @@ -145,6 +145,7 @@ + @@ -440,5 +441,6 @@ + diff --git a/src/App/Controls/CustomLabel.cs b/src/App/Controls/CustomLabel.cs new file mode 100644 index 000000000..e822d3304 --- /dev/null +++ b/src/App/Controls/CustomLabel.cs @@ -0,0 +1,13 @@ +using System; +using Xamarin.Forms; + +namespace Bit.App.Controls +{ + public class CustomLabel : Label + { + public CustomLabel() + { + } + } +} + diff --git a/src/App/Pages/Settings/SettingsPage/SettingsPage.xaml b/src/App/Pages/Settings/SettingsPage/SettingsPage.xaml index 03400d693..4976573af 100644 --- a/src/App/Pages/Settings/SettingsPage/SettingsPage.xaml +++ b/src/App/Pages/Settings/SettingsPage/SettingsPage.xaml @@ -20,8 +20,7 @@ x:Key="regularTemplate" x:DataType="pages:SettingsPageListItem"> + StyleClass="list-row, list-row-platform"> - SubLabelTextEnabled ? ThemeManager.GetResourceColor("SuccessColor") : ThemeManager.GetResourceColor("MutedColor"); - public string AutomationId + + public string AutomationIdSettingName { get { - if (!UseFrame) + return AutomationIdsHelper.AddSuffixFor( + UseFrame ? "EnabledPolicy" + : AutomationIdsHelper.ToEnglishTitleCase(Name) + , SuffixType.Cell); + } + } + + public string AutomationIdSettingStatus + { + get + { + if (UseFrame) { - var idText = new CultureInfo("en-US", false) - .TextInfo - .ToTitleCase(Name) - .Replace(" ", String.Empty) - .Replace("-", String.Empty); - return $"{idText}Cell"; - } - else - { - return "EnabledPolicyCell"; + return null; } + + return AutomationIdsHelper.AddSuffixFor(AutomationIdsHelper.ToEnglishTitleCase(Name), SuffixType.SettingValue); } } } diff --git a/src/App/Pages/Vault/CipherDetailsPage.xaml b/src/App/Pages/Vault/CipherDetailsPage.xaml index 1f82eef19..dc1d6bdf0 100644 --- a/src/App/Pages/Vault/CipherDetailsPage.xaml +++ b/src/App/Pages/Vault/CipherDetailsPage.xaml @@ -72,8 +72,7 @@ + StyleClass="list-row, list-row-platform" + AutomationId="{Binding AutomationId}"> + StyleClass="list-title" + AutomationId="ItemNameLabel" /> @@ -96,7 +99,8 @@ Spacing="0" Padding="0" VerticalOptions="FillAndExpand" - StyleClass="list-row-header-container, list-row-header-container-platform"> + StyleClass="list-row-header-container, list-row-header-container-platform" + AutomationId="{Binding AutomationId}"> @@ -105,7 +109,8 @@ StyleClass="list-header, list-header-platform" /> @@ -148,7 +153,8 @@ IsVisible="{Binding ShowNoData}"> + HorizontalTextAlignment="Center" + AutomationId="NoDataDisplayed">