From dc2db6447a2ad6c03083ddc9d12b7bfc16b0b6ba Mon Sep 17 00:00:00 2001 From: Mattia Date: Mon, 30 Nov 2020 19:29:56 +0100 Subject: [PATCH] update --- .../SampleApp.Android/AndroidFocusEvents.cs | 4 +-- SampleApp/SampleApp.iOS/iOSFocusEvents.cs | 4 +-- SampleApp/SampleApp.iOS/iOSMagicTap.cs | 16 +++-------- .../SampleApp/CustomRenderers/CustomImage.cs | 13 +++++++++ .../DependencyServices/IFocusEvents.cs | 13 --------- .../SampleApp/Views/Functionality17.xaml | 4 +-- .../SampleApp/Views/Functionality2.xaml.cs | 2 -- .../SampleApp/Views/Functionality22.xaml | 2 +- .../SampleApp/Views/Functionality22.xaml.cs | 2 +- .../SampleApp/Views/Functionality23.xaml | 2 +- .../SampleApp/Views/Functionality23.xaml.cs | 3 +- .../SampleApp/Views/Functionality3.xaml.cs | 28 +++++++++++-------- .../SampleApp/Views/Functionality4.xaml.cs | 4 +-- .../SampleApp/Views/Functionality6.xaml.cs | 9 ++---- 14 files changed, 48 insertions(+), 58 deletions(-) create mode 100644 SampleApp/SampleApp/CustomRenderers/CustomImage.cs delete mode 100644 SampleApp/SampleApp/DependencyServices/IFocusEvents.cs diff --git a/SampleApp/SampleApp.Android/AndroidFocusEvents.cs b/SampleApp/SampleApp.Android/AndroidFocusEvents.cs index 190d40cc..e416be62 100644 --- a/SampleApp/SampleApp.Android/AndroidFocusEvents.cs +++ b/SampleApp/SampleApp.Android/AndroidFocusEvents.cs @@ -3,12 +3,12 @@ using Android.Content; using Android.Service.Autofill; using Android.Views.Accessibility; using CustomViewAccessibility.Droid; -using SampleApp.DependencyServices; +using SampleApp.CustomRenderers; using SampleApp.Views; using Xamarin.Forms; using Xamarin.Forms.Platform.Android; -[assembly: ExportRenderer(typeof(IFocusEvents), typeof(AndroidFocusEvents))] +[assembly: ExportRenderer(typeof(CustomImage), typeof(AndroidFocusEvents))] namespace CustomViewAccessibility.Droid { public class AndroidFocusEvents : ImageRenderer diff --git a/SampleApp/SampleApp.iOS/iOSFocusEvents.cs b/SampleApp/SampleApp.iOS/iOSFocusEvents.cs index ab28680e..15902c3e 100644 --- a/SampleApp/SampleApp.iOS/iOSFocusEvents.cs +++ b/SampleApp/SampleApp.iOS/iOSFocusEvents.cs @@ -1,11 +1,11 @@ using System; -using SampleApp.DependencyServices; +using SampleApp.CustomRenderers; using Xamarin.Forms; using SampleApp.iOS; using Xamarin.Forms.Platform.iOS; using SampleApp.Views; -[assembly: ExportRenderer(typeof(IFocusEvents), typeof(iOSFocusEvents))] +[assembly: ExportRenderer(typeof(CustomImage), typeof(iOSFocusEvents))] namespace SampleApp.iOS { public class iOSFocusEvents : ImageRenderer diff --git a/SampleApp/SampleApp.iOS/iOSMagicTap.cs b/SampleApp/SampleApp.iOS/iOSMagicTap.cs index b1e7f220..e9b4cda8 100644 --- a/SampleApp/SampleApp.iOS/iOSMagicTap.cs +++ b/SampleApp/SampleApp.iOS/iOSMagicTap.cs @@ -21,11 +21,6 @@ namespace SampleApp.iOS SetNativeControl(new MyView()); } } - - - - - } public class MyView : UITextView @@ -34,22 +29,19 @@ namespace SampleApp.iOS public MyView() : base() { - base.Text = "Select this label with the accessibility focus and perform a magic tap (tap with two fingers) to change the background color."; - Console.WriteLine("My View created"); + base.Text = "Perform a magic tap (tap with two fingers) to change the background color."; base.AccessibilityPerformMagicTap(); base.Editable = false; + base.Font = base.Font.WithSize(30); + Functionality23.customEditor.BackgroundColor = Color.White; + Functionality23.customEditor.TextColor = Color.Black; } - - public override bool AccessibilityPerformMagicTap() { - Console.WriteLine("MAGIC TAP"); - //random color Color randomColor = Color.FromRgb(rnd.Next(256), rnd.Next(256), rnd.Next(256)); - Functionality23.customEditor.Text = "MAGIC TAP"; Functionality23.customEditor.BackgroundColor = randomColor; Functionality23.customEditor.TextColor = Color.White; diff --git a/SampleApp/SampleApp/CustomRenderers/CustomImage.cs b/SampleApp/SampleApp/CustomRenderers/CustomImage.cs new file mode 100644 index 00000000..cc033122 --- /dev/null +++ b/SampleApp/SampleApp/CustomRenderers/CustomImage.cs @@ -0,0 +1,13 @@ +using System; +using Xamarin.Forms; + +namespace SampleApp.CustomRenderers +{ + public class CustomImage : Image + { + public CustomImage() + { + } + + } +} diff --git a/SampleApp/SampleApp/DependencyServices/IFocusEvents.cs b/SampleApp/SampleApp/DependencyServices/IFocusEvents.cs deleted file mode 100644 index dc1d2039..00000000 --- a/SampleApp/SampleApp/DependencyServices/IFocusEvents.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using Xamarin.Forms; - -namespace SampleApp.DependencyServices -{ - public class IFocusEvents : Image - { - public IFocusEvents() - { - } - - } -} diff --git a/SampleApp/SampleApp/Views/Functionality17.xaml b/SampleApp/SampleApp/Views/Functionality17.xaml index 232c1167..72a5b280 100644 --- a/SampleApp/SampleApp/Views/Functionality17.xaml +++ b/SampleApp/SampleApp/Views/Functionality17.xaml @@ -5,11 +5,11 @@ - + - + diff --git a/SampleApp/SampleApp/Views/Functionality2.xaml.cs b/SampleApp/SampleApp/Views/Functionality2.xaml.cs index d18afc6b..d7aefbb8 100644 --- a/SampleApp/SampleApp/Views/Functionality2.xaml.cs +++ b/SampleApp/SampleApp/Views/Functionality2.xaml.cs @@ -32,7 +32,6 @@ namespace SampleApp.Views { if (topDown) { - label2.Text = "3"; label2.TabIndex = 3; label3.Text = "2"; @@ -50,7 +49,6 @@ namespace SampleApp.Views FocusOrderLabel.Text = "Focus order is: TOP-DOWN"; } topDown = !topDown; - } } } diff --git a/SampleApp/SampleApp/Views/Functionality22.xaml b/SampleApp/SampleApp/Views/Functionality22.xaml index 7dfde7a5..cd3089ea 100644 --- a/SampleApp/SampleApp/Views/Functionality22.xaml +++ b/SampleApp/SampleApp/Views/Functionality22.xaml @@ -3,7 +3,7 @@ - + diff --git a/SampleApp/SampleApp/Views/Functionality22.xaml.cs b/SampleApp/SampleApp/Views/Functionality22.xaml.cs index 4011a374..54f88a8f 100644 --- a/SampleApp/SampleApp/Views/Functionality22.xaml.cs +++ b/SampleApp/SampleApp/Views/Functionality22.xaml.cs @@ -85,7 +85,7 @@ namespace SampleApp.Views { Heading.SetHeading(label1); - Pane.SetPane(label2, "test"); + Pane.SetPane(label2, "PaneTitle"); } } diff --git a/SampleApp/SampleApp/Views/Functionality23.xaml b/SampleApp/SampleApp/Views/Functionality23.xaml index 91f384b2..fcbecb25 100644 --- a/SampleApp/SampleApp/Views/Functionality23.xaml +++ b/SampleApp/SampleApp/Views/Functionality23.xaml @@ -1,5 +1,5 @@  - + diff --git a/SampleApp/SampleApp/Views/Functionality23.xaml.cs b/SampleApp/SampleApp/Views/Functionality23.xaml.cs index acde902d..5745277c 100644 --- a/SampleApp/SampleApp/Views/Functionality23.xaml.cs +++ b/SampleApp/SampleApp/Views/Functionality23.xaml.cs @@ -8,7 +8,7 @@ namespace SampleApp.Views { public partial class Functionality23 : ContentPage { - public static CustomView customEditor = new CustomView { Text = "", IsReadOnly=true}; + public static CustomView customEditor = new CustomView { Text = "", HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand}; public Functionality23() { InitializeComponent(); @@ -19,7 +19,6 @@ namespace SampleApp.Views AutomationProperties.SetIsInAccessibleTree(customEditor, true); background.Children.Add(customEditor); - } } } diff --git a/SampleApp/SampleApp/Views/Functionality3.xaml.cs b/SampleApp/SampleApp/Views/Functionality3.xaml.cs index 4b5d5a9c..3356bfd4 100644 --- a/SampleApp/SampleApp/Views/Functionality3.xaml.cs +++ b/SampleApp/SampleApp/Views/Functionality3.xaml.cs @@ -9,29 +9,35 @@ namespace SampleApp.Views public partial class Functionality3 : ContentPage { IAssignFocus assignFocus; + IScreenReaderEnabled screenReaderEnabled; Boolean focus = true; public Functionality3() { InitializeComponent(); assignFocus = DependencyService.Get(); + screenReaderEnabled = DependencyService.Resolve(); AutomationProperties.SetIsInAccessibleTree(label, true); } void Button_Clicked(System.Object sender, System.EventArgs e) { - if (focus) + if (screenReaderEnabled.IsScreenReaderEnabled()) { - assignFocus.AssignFocus(label); - label.Text = "I Have Focus"; - button.Text = "Reset"; + if (focus) + { + assignFocus.AssignFocus(label); + label.Text = "I Have Focus"; + button.Text = "Reset"; + } + else + { + assignFocus.AssignFocus(button); + label.Text = "I Don't Have Focus"; + button.Text = "Assign focus to the label above"; + } + focus = !focus; } - else - { - assignFocus.AssignFocus(button); - label.Text = "I Don't Have Focus"; - button.Text = "Assign focus to the label above"; - } - focus = !focus; + } } } diff --git a/SampleApp/SampleApp/Views/Functionality4.xaml.cs b/SampleApp/SampleApp/Views/Functionality4.xaml.cs index 1253f345..048cf190 100644 --- a/SampleApp/SampleApp/Views/Functionality4.xaml.cs +++ b/SampleApp/SampleApp/Views/Functionality4.xaml.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Reflection; -using SampleApp.DependencyServices; +using SampleApp.CustomRenderers; using Xamarin.Forms; @@ -19,7 +19,7 @@ namespace SampleApp.Views InitializeComponent(); // immagine campanello - IFocusEvents BellImage = new IFocusEvents + CustomImage BellImage = new CustomImage { Source = ImageSource.FromResource("SampleApp.images.bell.png", typeof(Functionality4).GetTypeInfo().Assembly) }; diff --git a/SampleApp/SampleApp/Views/Functionality6.xaml.cs b/SampleApp/SampleApp/Views/Functionality6.xaml.cs index 4c2cf20f..f78cf0ed 100644 --- a/SampleApp/SampleApp/Views/Functionality6.xaml.cs +++ b/SampleApp/SampleApp/Views/Functionality6.xaml.cs @@ -18,16 +18,11 @@ namespace SampleApp.Views void EntryName_TextChanged(object sender, TextChangedEventArgs e) { - - var newText = e.NewTextValue; - AutomationProperties.SetName(forkImage, e.NewTextValue); - + AutomationProperties.SetName(forkImage, e.NewTextValue); } + void EntryHelpText_TextChanged(object sender, TextChangedEventArgs e) { - - var newText = e.NewTextValue; - AutomationProperties.SetHelpText(forkImage, e.NewTextValue); } } -- 2.18.1