@ -8,13 +8,42 @@ using Avalonia.Android.Automation;
using Avalonia.Automation ;
using Avalonia.Automation.Peers ;
using Avalonia.Automation.Provider ;
using Avalonia.Controls ;
using Java.Lang ;
namespace Avalonia.Android
{
internal class AvaloniaAccessHelper : ExploreByTouchHelper
{
private static readonly HashSet < AutomationControlType > s_containerTypes =
new HashSet < AutomationControlType > ( )
{
AutomationControlType . Calendar ,
AutomationControlType . ComboBoxItem ,
AutomationControlType . Custom ,
AutomationControlType . DataGrid ,
AutomationControlType . DataItem ,
AutomationControlType . Document ,
AutomationControlType . Expander ,
AutomationControlType . Group ,
AutomationControlType . List ,
AutomationControlType . ListItem ,
AutomationControlType . Menu ,
AutomationControlType . MenuBar ,
AutomationControlType . MenuItem ,
AutomationControlType . None ,
AutomationControlType . Pane ,
AutomationControlType . ScrollViewer ,
AutomationControlType . SplitButton ,
AutomationControlType . Tab ,
AutomationControlType . TabItem ,
AutomationControlType . Table ,
AutomationControlType . TitleBar ,
AutomationControlType . ToolBar ,
AutomationControlType . Tree ,
AutomationControlType . TreeItem ,
AutomationControlType . Window ,
} ;
private readonly Dictionary < int , AutomationPeer > _ peers ;
private readonly Dictionary < AutomationPeer , int > _ peerIds ;
@ -109,7 +138,17 @@ namespace Avalonia.Android
AutomationPeer ? peer = embeddedRootProvider ? . GetPeerFromPoint ( p ) ;
if ( peer is not null )
{
GetOrCreateNodeInfoProvidersFromPeer ( peer , out int virtualViewId ) ;
int virtualViewId ;
if ( peer . GetParent ( ) is AutomationPeer parent & &
! s_containerTypes . Contains ( parent . GetAutomationControlType ( ) ) )
{
GetOrCreateNodeInfoProvidersFromPeer ( parent , out virtualViewId ) ;
}
else
{
GetOrCreateNodeInfoProvidersFromPeer ( peer , out virtualViewId ) ;
}
return virtualViewId = = 0 ? InvalidId : virtualViewId ;
}
else
@ -199,7 +238,7 @@ namespace Avalonia.Android
nodeInfo . Enabled = peer . IsEnabled ( ) ;
// Control focus state
bool canFocusAtAll = peer . IsContent Element ( ) & & ! peer . IsOffscreen ( ) ;
bool canFocusAtAll = peer . IsControl Element ( ) & & ! peer . IsOffscreen ( ) ;
nodeInfo . ScreenReaderFocusable = canFocusAtAll ;
nodeInfo . Focusable = canFocusAtAll & & peer . IsKeyboardFocusable ( ) ;