Skip to content

Commit

Permalink
Some cleanup for the PR!
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaMorphic committed Dec 5, 2024
1 parent 2d772a3 commit cf694f6
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 84 deletions.

This file was deleted.

17 changes: 0 additions & 17 deletions src/Android/Avalonia.Android/Automation/AutomationPeerState.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Android.OS;
using Android.OS;
using AndroidX.Core.View.Accessibility;
using Avalonia.Automation.Peers;
using Avalonia.Automation.Provider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Android.OS;
using Android.OS;
using AndroidX.Core.View.Accessibility;
using Avalonia.Automation.Peers;
using Avalonia.Automation.Provider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Android.OS;
using Android.OS;
using AndroidX.Core.View.Accessibility;
using Avalonia.Automation.Peers;
using Avalonia.Automation.Provider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Android.OS;
using Android.OS;
using AndroidX.Core.View.Accessibility;
using Avalonia.Automation.Peers;
using Avalonia.Automation.Provider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Android.OS;
using Android.OS;
using AndroidX.Core.View.Accessibility;
using Avalonia.Automation.Peers;
using Avalonia.Automation.Provider;
Expand Down
24 changes: 12 additions & 12 deletions src/Android/Avalonia.Android/AvaloniaAccessHelper.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Android.OS;
using Android.Runtime;
using AndroidX.Core.View.Accessibility;
using AndroidX.CustomView.Widget;
using Avalonia.Android.Automation;
using Avalonia.Automation.Peers;
using Avalonia.Automation.Provider;
using Avalonia.Threading;
using Java.Lang;
using Java.Nio.Channels;

namespace Avalonia.Android
{
Expand All @@ -30,17 +26,15 @@ private static readonly IReadOnlyDictionary<Type, NodeInfoProviderInitializer>
};

private readonly Dictionary<int, AutomationPeer> _peers;
private readonly Dictionary<int, AutomationPeerState> _peerStates;
private readonly Dictionary<AutomationPeer, int> _peerIds;

private readonly Dictionary<AutomationPeer, HashSet<INodeInfoProvider>> _peerNodeInfoProviders;

private readonly AvaloniaView _view;

public AvaloniaAccessHelper(AvaloniaView view) : base(view)
{
_peers = [];
_peerStates = [];

_peerIds = [];
_peerNodeInfoProviders = [];

Expand Down Expand Up @@ -78,10 +72,9 @@ private HashSet<INodeInfoProvider> GetOrCreateNodeInfoProvidersFromPeer(Automati
{
peerViewId = _peerNodeInfoProviders.Count;
_peers.Add(peerViewId, peer);
_peerStates.Add(peerViewId, new(peer));
_peerIds.Add(peer, peerViewId);

nodeInfoProviders = new();
_peerIds.Add(peer, peerViewId);
_peerNodeInfoProviders.Add(peer, nodeInfoProviders);

peer.PropertyChanged += (s, ev) => InvalidateVirtualView(peerViewId,
Expand Down Expand Up @@ -148,28 +141,34 @@ protected override void OnPopulateNodeForVirtualView(int virtualViewId, Accessib
{
if (!_peers.TryGetValue(virtualViewId, out AutomationPeer? peer))
{
return;
return; // BAIL!! No work to be done
}

// UI logical structure
foreach (AutomationPeer child in peer.GetChildren())
{
GetOrCreateNodeInfoProvidersFromPeer(child, out int childId);
nodeInfo.AddChild(_view, childId);
}

// UI labeling
AutomationPeer? labeledBy = peer.GetLabeledBy();
if (labeledBy is not null)
{
GetOrCreateNodeInfoProvidersFromPeer(labeledBy, out int labeledById);
nodeInfo.SetLabeledBy(_view.TopLevelImpl.View, labeledById);
}

// UI text contents
nodeInfo.Text = peer.GetName();
nodeInfo.ContentDescription = peer.GetHelpText();

// UI metadata
nodeInfo.ClassName = peer.GetClassName();
nodeInfo.Enabled = peer.IsEnabled();
nodeInfo.Focusable = !peer.IsOffscreen() && peer.IsContentElement();
nodeInfo.HintText = peer.GetHelpText();
nodeInfo.Focusable = peer.IsContentElement() && !peer.IsOffscreen();

// On-screen bounds
Rect bounds = peer.GetBoundingRectangle();
PixelRect screenRect = new PixelRect(
_view.TopLevelImpl.PointToScreen(bounds.TopLeft),
Expand All @@ -180,6 +179,7 @@ protected override void OnPopulateNodeForVirtualView(int virtualViewId, Accessib
screenRect.Right, screenRect.Bottom
));

// UI provider specifics
foreach (INodeInfoProvider nodeInfoProvider in _peerNodeInfoProviders[peer])
{
nodeInfoProvider.PopulateNodeInfo(nodeInfo);
Expand Down
10 changes: 0 additions & 10 deletions src/Android/Avalonia.Android/ISSUE.txt

This file was deleted.

0 comments on commit cf694f6

Please sign in to comment.