-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement rest of providers and improve performance
- Loading branch information
1 parent
5875aef
commit 2d772a3
Showing
10 changed files
with
296 additions
and
38 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/Android/Avalonia.Android/Automation/AutomationPeerState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Avalonia.Automation.Peers; | ||
|
||
namespace Avalonia.Android.Automation | ||
{ | ||
internal class AutomationPeerState | ||
{ | ||
public AutomationPeer Instance { get; } | ||
|
||
public bool IsOffscreenCached { get; set; } | ||
|
||
public AutomationPeerState(AutomationPeer instance) | ||
{ | ||
Instance = instance; | ||
IsOffscreenCached = instance.IsOffscreen(); | ||
} | ||
} | ||
} |
18 changes: 0 additions & 18 deletions
18
src/Android/Avalonia.Android/Automation/EmbeddedRootNodeInfoProvider.cs
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
src/Android/Avalonia.Android/Automation/ExpandCollapseNodeInfoProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Android.OS; | ||
using AndroidX.Core.View.Accessibility; | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Automation.Provider; | ||
|
||
namespace Avalonia.Android.Automation | ||
{ | ||
internal class ExpandCollapseNodeInfoProvider : NodeInfoProvider<IExpandCollapseProvider> | ||
{ | ||
public ExpandCollapseNodeInfoProvider(AutomationPeer peer, int virtualViewId) : base(peer, virtualViewId) | ||
{ | ||
} | ||
|
||
public override bool PerformNodeAction(int action, Bundle? arguments) | ||
{ | ||
switch (action) | ||
{ | ||
case AccessibilityNodeInfoCompat.ActionExpand: | ||
GetProvider().Expand(); | ||
return true; | ||
case AccessibilityNodeInfoCompat.ActionCollapse: | ||
GetProvider().Collapse(); | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
public override void PopulateNodeInfo(AccessibilityNodeInfoCompat nodeInfo) | ||
{ | ||
nodeInfo.AddAction(AccessibilityNodeInfoCompat.ActionExpand); | ||
nodeInfo.AddAction(AccessibilityNodeInfoCompat.ActionCollapse); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Android/Avalonia.Android/Automation/RangeValueNodeInfoProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Android.OS; | ||
using AndroidX.Core.View.Accessibility; | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Automation.Provider; | ||
|
||
namespace Avalonia.Android.Automation | ||
{ | ||
internal class RangeValueNodeInfoProvider : NodeInfoProvider<IRangeValueProvider> | ||
{ | ||
public RangeValueNodeInfoProvider(AutomationPeer peer, int virtualViewId) : base(peer, virtualViewId) | ||
{ | ||
} | ||
|
||
public override bool PerformNodeAction(int action, Bundle? arguments) | ||
{ | ||
return false; | ||
} | ||
|
||
public override void PopulateNodeInfo(AccessibilityNodeInfoCompat nodeInfo) | ||
{ | ||
IRangeValueProvider rangeValueProvider = GetProvider(); | ||
nodeInfo.RangeInfo = new AccessibilityNodeInfoCompat.RangeInfoCompat( | ||
AccessibilityNodeInfoCompat.RangeInfoCompat.RangeTypeFloat, | ||
(float)rangeValueProvider.Minimum, (float)rangeValueProvider.Maximum, | ||
(float)rangeValueProvider.Value | ||
); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/Android/Avalonia.Android/Automation/ScrollNodeInfoProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Android.OS; | ||
using AndroidX.Core.View.Accessibility; | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Automation.Provider; | ||
|
||
namespace Avalonia.Android.Automation | ||
{ | ||
internal class ScrollNodeInfoProvider : NodeInfoProvider<IScrollProvider> | ||
{ | ||
public ScrollNodeInfoProvider(AutomationPeer peer, int virtualViewId) : base(peer, virtualViewId) | ||
{ | ||
} | ||
|
||
public override bool PerformNodeAction(int action, Bundle? arguments) | ||
{ | ||
IScrollProvider scrollProvider = GetProvider(); | ||
switch (action) | ||
{ | ||
case AccessibilityNodeInfoCompat.ActionScrollForward: | ||
if (scrollProvider.VerticallyScrollable) | ||
{ | ||
scrollProvider.Scroll(ScrollAmount.NoAmount, ScrollAmount.SmallIncrement); | ||
} | ||
else if(scrollProvider.HorizontallyScrollable) | ||
{ | ||
scrollProvider.Scroll(ScrollAmount.SmallIncrement, ScrollAmount.NoAmount); | ||
} | ||
return true; | ||
case AccessibilityNodeInfoCompat.ActionScrollBackward: | ||
if (scrollProvider.VerticallyScrollable) | ||
{ | ||
scrollProvider.Scroll(ScrollAmount.NoAmount, ScrollAmount.SmallDecrement); | ||
} | ||
else if (scrollProvider.HorizontallyScrollable) | ||
{ | ||
scrollProvider.Scroll(ScrollAmount.SmallDecrement, ScrollAmount.NoAmount); | ||
} | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
public override void PopulateNodeInfo(AccessibilityNodeInfoCompat nodeInfo) | ||
{ | ||
nodeInfo.AddAction(AccessibilityNodeInfoCompat.ActionScrollForward); | ||
nodeInfo.AddAction(AccessibilityNodeInfoCompat.ActionScrollBackward); | ||
nodeInfo.Scrollable = true; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Android/Avalonia.Android/Automation/SelectionItemNodeInfoProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Android.OS; | ||
using AndroidX.Core.View.Accessibility; | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Automation.Provider; | ||
|
||
namespace Avalonia.Android.Automation | ||
{ | ||
internal class SelectionItemNodeInfoProvider : NodeInfoProvider<ISelectionItemProvider> | ||
{ | ||
public SelectionItemNodeInfoProvider(AutomationPeer peer, int virtualViewId) : base(peer, virtualViewId) | ||
{ | ||
} | ||
|
||
public override bool PerformNodeAction(int action, Bundle? arguments) | ||
{ | ||
switch (action) | ||
{ | ||
case AccessibilityNodeInfoCompat.ActionSelect: | ||
GetProvider().Select(); | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
public override void PopulateNodeInfo(AccessibilityNodeInfoCompat nodeInfo) | ||
{ | ||
nodeInfo.AddAction(AccessibilityNodeInfoCompat.ActionSelect); | ||
nodeInfo.Selected = GetProvider().IsSelected; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Android/Avalonia.Android/Automation/ToggleNodeInfoProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Android.OS; | ||
using AndroidX.Core.View.Accessibility; | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Automation.Provider; | ||
|
||
namespace Avalonia.Android.Automation | ||
{ | ||
internal class ToggleNodeInfoProvider : NodeInfoProvider<IToggleProvider> | ||
{ | ||
public ToggleNodeInfoProvider(AutomationPeer peer, int virtualViewId) : base(peer, virtualViewId) | ||
{ | ||
} | ||
|
||
public override bool PerformNodeAction(int action, Bundle? arguments) | ||
{ | ||
switch (action) | ||
{ | ||
case AccessibilityNodeInfoCompat.ActionClick: | ||
GetProvider().Toggle(); | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
public override void PopulateNodeInfo(AccessibilityNodeInfoCompat nodeInfo) | ||
{ | ||
nodeInfo.AddAction(AccessibilityNodeInfoCompat.ActionClick); | ||
nodeInfo.Clickable = true; | ||
|
||
nodeInfo.Checked = GetProvider().ToggleState == ToggleState.On; | ||
nodeInfo.Checkable = true; | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Android/Avalonia.Android/Automation/ValueNodeInfoProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Android.OS; | ||
using AndroidX.Core.View.Accessibility; | ||
using Avalonia.Automation.Peers; | ||
using Avalonia.Automation.Provider; | ||
|
||
namespace Avalonia.Android.Automation | ||
{ | ||
internal class ValueNodeInfoProvider : NodeInfoProvider<IValueProvider> | ||
{ | ||
public ValueNodeInfoProvider(AutomationPeer peer, int virtualViewId) : base(peer, virtualViewId) | ||
{ | ||
} | ||
|
||
public override bool PerformNodeAction(int action, Bundle? arguments) | ||
{ | ||
switch (action) | ||
{ | ||
case AccessibilityNodeInfoCompat.ActionSetText: | ||
string? text = arguments?.GetCharSequence( | ||
AccessibilityNodeInfoCompat.ActionArgumentSetTextCharsequence | ||
); | ||
GetProvider().SetValue(text); | ||
return true; | ||
|
||
default: | ||
return false; | ||
} | ||
} | ||
|
||
public override void PopulateNodeInfo(AccessibilityNodeInfoCompat nodeInfo) | ||
{ | ||
nodeInfo.AddAction(AccessibilityNodeInfoCompat.ActionSetText); | ||
nodeInfo.Editable = !GetProvider().IsReadOnly; | ||
} | ||
} | ||
} |
Oops, something went wrong.