Add support for AutomationPeer#141
Conversation
2add77e to
405ca80
Compare
| - Avoid stacking `TextBlock`s inside a `Panel` when you can use `Inlines` inside a `TextBlock` (using `LineBreak` if necessary). This allows the screen reader to read all the text at once, instead of having the user select every part manually. | ||
| - Use a converter to trim long text. While a `TextBlock` might ellipsize long text, the screen reader will read the entire text provided. | ||
| - Avoid creating custom controls when you can use built-in ones. If you must, make sure to implement and provide an appropriate `AutomationPeer`. | ||
| - You can disable accessibility focus of native elements using `android:ImportantForAccessibility="No"` and `ios:IsAccessibilityElement="False"`. |
There was a problem hiding this comment.
Is there a UWP/Uno equivalent of these properties?
There was a problem hiding this comment.
You can disable accessibility focus of UWP/Uno elements using AutomationProperties.AccessibilityView="Raw".
It won't work on native elements, hence the ImportantFocAccessibility/IsAccessibilityElement workaround.
| } | ||
| else | ||
| { | ||
| if ("".Log().IsEnabled(LogLevel.Error)) |
There was a problem hiding this comment.
Shouldn't this be typeof(CommandBarRenderer).Log()?
| { | ||
| #region Public | ||
|
|
||
| public void InvalidatePeer() |
| { | ||
| public partial class ComboBoxAutomationPeer : SelectorAutomationPeer, Provider.IExpandCollapseProvider, Provider.IValueProvider, Provider.IWindowProvider | ||
| { | ||
| public ExpandCollapseState ExpandCollapseState |
|
|
||
| private int GetMaxTextLength() | ||
| { | ||
| return Owner is TextBox textBox ? textBox.MaxLength : 0; |
There was a problem hiding this comment.
Why is this not virtual? Should there be a TODO to use ITextProvider?
There was a problem hiding this comment.
I'm just feeding Android's AccessibilityNodeInfo what it wants. I don't know if there's an equivalent in AutomationPeer's API.
There was a problem hiding this comment.
There's an ITextProvider interface but it sounds like a mess: https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.automation.provider.itextprovider
ITextProvider, ITextProvider2 and ITextRangeProvider aren't implemented by any existing Windows Runtime automation peers using this definition of the interface. The text models supported by Windows Runtime text controls such as TextBox and RichTextBlock do implement some of these patterns, but do so at a native level that doesn't appear in the Windows Runtime definitions of the API surface. For more info, see the peer classes for the various Windows Runtime text controls.
There was a problem hiding this comment.
I can't find anything about maximum text length at first glance.
| { | ||
| if (Owner is View view && AutomationProperties.GetAccessibilityView(Owner) != AccessibilityView.Raw) | ||
| { | ||
| // TODO: How expensive is this? Is this called recursively for all children? |
There was a problem hiding this comment.
I refactored that part, confirmed this wasn't a problem, and explained why.
| public partial class ImplicitTextBlock : TextBlock | ||
| { | ||
| public ImplicitTextBlock() { } | ||
| public ImplicitTextBlock(DependencyObject parent) |
There was a problem hiding this comment.
Is the reference to the ContentControl being held? Ie is there any risk of a memory leak?
There was a problem hiding this comment.
No. It only needs its parent to retrieve its AutomationProperties.AccessibilityView value once.
| IsChecked = false; | ||
| } | ||
|
|
||
| protected virtual void OnToggle() |
There was a problem hiding this comment.
OnAutomationToggle()? Is it used/useful in any other context?
There was a problem hiding this comment.
OnToggle is part of ToggleButton's contract.
AutomationPeerToggle exists to allow OnToggle to be called from automation peers.
| { | ||
| (e as View).ContentDescription = e.GetType().ToString(); | ||
| // TODO: This causes Android to cycle through every visible IFrameworkElement every time the accessibility focus is changed | ||
| // and calls the overriden InitializeAccessibilityNodeInfo method. This could eventually cause performance issues when accessibility is enabled. |
There was a problem hiding this comment.
When is 'eventually'? Is this a serious performance concern?
There was a problem hiding this comment.
'eventually' is if we have complex UI with lots of elements. I've only noticed lags when cycling through accessible elements in debug.
The performance problem seem to be due to interop. It should only affect focus change on devices with TalkBack turned on. A possible optimization could be to set this value to false if an element's CreateAutomationPeer returns null.
There was a problem hiding this comment.
Add the second paragraph of your reply to the comment.
2b7ac0e to
afd33ac
Compare
| new XElement("string", | ||
| new XAttribute("formatted", "false"), // allows special characters (%, $, etc.) | ||
| new XAttribute("name", resource.Key), | ||
| new XAttribute("name", AndroidResourceNameEncoder.Encode(resource.Key)), |
There was a problem hiding this comment.
This change is related to AutomationPeers?
| public static IEnumerable<UIView> EnumerateAllChildren(this UIView view, int maxDepth = 20) | ||
| { | ||
| return FindSubviews(view, _ => true, maxDepth); | ||
| var children = view.GetChildren().OfType<UIElement>(); |
There was a problem hiding this comment.
children variable is not used...
| return key | ||
| .Replace('[', '_') | ||
| .Replace(']', '_') | ||
| .Replace(':', '_'); |
There was a problem hiding this comment.
Is it something called often? Could have perf issues.
| @@ -0,0 +1,47 @@ | |||
| namespace Windows.UI.Xaml.Automation.Peers | |||
| { | |||
| public enum AutomationControlType | |||
There was a problem hiding this comment.
... or is this order important? If yes needs a comment about it.
There was a problem hiding this comment.
The order is important. I added the values.
c0e02d3 to
1fe6e7e
Compare
1fe6e7e to
8aa2203
Compare
…-fix fix(snackbar): Fixed Error binding nullref
No description provided.