This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix up Android Accessibility behind a flag (#14089)
* Fix up Android Accessibility behind a flag * - automation id * - set back button to standard "Navigate Up" * - view compat * - add flag check * - fix assigning of delegate * - add flag to forms appcompat activity * - fix nav drawer
- Loading branch information
Showing
14 changed files
with
202 additions
and
34 deletions.
There are no files selected for viewing
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
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
51 changes: 51 additions & 0 deletions
51
Xamarin.Forms.Platform.Android/AccessibilityDelegateAutomationId.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,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Android.Views.Accessibility; | ||
using AndroidX.AppCompat.Widget; | ||
using AndroidX.Core.View; | ||
using AndroidX.Core.View.Accessibiity; | ||
using Xamarin.Forms.Platform.Android.FastRenderers; | ||
|
||
namespace Xamarin.Forms.Platform.Android | ||
{ | ||
class AccessibilityDelegateAutomationId : AccessibilityDelegateCompat | ||
|
||
{ | ||
BindableObject _element; | ||
|
||
public AccessibilityDelegateAutomationId(BindableObject element) : base() | ||
{ | ||
_element = element; | ||
} | ||
|
||
|
||
public override void OnInitializeAccessibilityNodeInfo(global::Android.Views.View host, AccessibilityNodeInfoCompat info) | ||
{ | ||
base.OnInitializeAccessibilityNodeInfo(host, info); | ||
|
||
if (_element == null) | ||
return; | ||
|
||
if(Flags.IsAccessibilityExperimentalSet()) | ||
{ | ||
var value = AutomationPropertiesProvider.ConcatenateNameAndHelpText(_element); | ||
if (!string.IsNullOrWhiteSpace(value)) | ||
{ | ||
host.ContentDescription = value; | ||
} | ||
else if(host.ContentDescription == (_element as VisualElement)?.AutomationId) | ||
{ | ||
host.ContentDescription = null; | ||
} | ||
} | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
_element = null; | ||
base.Dispose(disposing); | ||
} | ||
|
||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -1,7 +1,21 @@ | ||
using System.Linq; | ||
|
||
namespace Xamarin.Forms | ||
{ | ||
internal static class Flags | ||
{ | ||
internal const string UseLegacyRenderers = "UseLegacyRenderers"; | ||
|
||
internal const string AccessibilityExperimental = "Accessibility_Experimental"; | ||
|
||
public static bool IsFlagSet(string flagName) | ||
{ | ||
return Device.Flags != null && Device.Flags.Contains(flagName); | ||
} | ||
|
||
public static bool IsAccessibilityExperimentalSet() | ||
{ | ||
return IsFlagSet(AccessibilityExperimental); | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.