|
1 | 1 | using System;
|
2 |
| -using System.Text; |
3 | 2 | using System.Threading.Tasks;
|
4 | 3 |
|
5 | 4 | using Android.App;
|
6 |
| -using Android.Content; |
7 | 5 | using Android.OS;
|
8 | 6 | using Android.Provider;
|
9 | 7 | using Android.Runtime;
|
10 | 8 | using Android.Views;
|
11 |
| -using Android.Views.Accessibility; |
12 | 9 | using Android.Widget;
|
13 | 10 |
|
14 | 11 | using Rg.Plugins.Popup.Contracts;
|
15 | 12 | using Rg.Plugins.Popup.Droid.Extensions;
|
16 | 13 | using Rg.Plugins.Popup.Droid.Impl;
|
17 | 14 | using Rg.Plugins.Popup.Exceptions;
|
18 | 15 | using Rg.Plugins.Popup.Pages;
|
19 |
| -using Rg.Plugins.Popup.Services; |
20 | 16 |
|
21 | 17 | using Xamarin.Forms;
|
22 | 18 |
|
@@ -56,9 +52,38 @@ static void HandleAccessibilityWorkaround(PopupPage page)
|
56 | 52 | {
|
57 | 53 | if (page.AndroidTalkbackAccessibilityWorkaround)
|
58 | 54 | {
|
59 |
| - var NavCount = XApplication.Current.MainPage.Navigation.NavigationStack.Count; |
60 |
| - Page currentPage = XApplication.Current.MainPage.Navigation.NavigationStack[NavCount - 1]; |
61 |
| - currentPage.GetOrCreateRenderer().View.ImportantForAccessibility = ImportantForAccessibility.NoHideDescendants; |
| 55 | + var navCount = XApplication.Current.MainPage.Navigation.NavigationStack.Count; |
| 56 | + var modalCount = XApplication.Current.MainPage.Navigation.ModalStack.Count; |
| 57 | + XApplication.Current.MainPage.GetOrCreateRenderer().View.ImportantForAccessibility = ImportantForAccessibility.NoHideDescendants; |
| 58 | + |
| 59 | + if (navCount > 0) |
| 60 | + { |
| 61 | + XApplication.Current.MainPage.Navigation.NavigationStack[navCount - 1].GetOrCreateRenderer().View.ImportantForAccessibility = ImportantForAccessibility.NoHideDescendants; |
| 62 | + } |
| 63 | + if (modalCount > 0) |
| 64 | + { |
| 65 | + XApplication.Current.MainPage.Navigation.ModalStack[modalCount - 1].GetOrCreateRenderer().View.ImportantForAccessibility = ImportantForAccessibility.NoHideDescendants; |
| 66 | + } |
| 67 | + |
| 68 | + DisableFocusableInTouchMode(XApplication.Current.MainPage.GetOrCreateRenderer().View.Parent); |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + static void DisableFocusableInTouchMode(IViewParent? parent) |
| 73 | + { |
| 74 | + var view = parent; |
| 75 | + string className = $"{view?.GetType().Name}"; |
| 76 | + |
| 77 | + while (!className.Contains("PlatformRenderer") && view != null) |
| 78 | + { |
| 79 | + view = view.Parent; |
| 80 | + className = $"{view?.GetType().Name}"; |
| 81 | + } |
| 82 | + |
| 83 | + if (view is Android.Views.View androidView) |
| 84 | + { |
| 85 | + androidView.Focusable = false; |
| 86 | + androidView.FocusableInTouchMode = false; |
62 | 87 | }
|
63 | 88 | }
|
64 | 89 | }
|
@@ -91,9 +116,18 @@ static void HandleAccessibilityWorkaround(PopupPage page)
|
91 | 116 | {
|
92 | 117 | if (page.AndroidTalkbackAccessibilityWorkaround)
|
93 | 118 | {
|
94 |
| - var NavCount = XApplication.Current.MainPage.Navigation.NavigationStack.Count; |
95 |
| - Page currentPage = XApplication.Current.MainPage.Navigation.NavigationStack[NavCount - 1]; |
96 |
| - currentPage.GetOrCreateRenderer().View.ImportantForAccessibility = ImportantForAccessibility.Auto; |
| 119 | + var navCount = XApplication.Current.MainPage.Navigation.NavigationStack.Count; |
| 120 | + var modalCount = XApplication.Current.MainPage.Navigation.ModalStack.Count; |
| 121 | + XApplication.Current.MainPage.GetOrCreateRenderer().View.ImportantForAccessibility = ImportantForAccessibility.Auto; |
| 122 | + |
| 123 | + if (navCount > 0) |
| 124 | + { |
| 125 | + XApplication.Current.MainPage.Navigation.NavigationStack[navCount - 1].GetOrCreateRenderer().View.ImportantForAccessibility = ImportantForAccessibility.Auto; |
| 126 | + } |
| 127 | + if (modalCount > 0) |
| 128 | + { |
| 129 | + XApplication.Current.MainPage.Navigation.ModalStack[modalCount - 1].GetOrCreateRenderer().View.ImportantForAccessibility = ImportantForAccessibility.Auto; |
| 130 | + } |
97 | 131 | }
|
98 | 132 | }
|
99 | 133 | }
|
|
0 commit comments