[NUI][ATSPI] Navigator - emit accessibility event
authorShinwoo Kim <cinoo.kim@samsung.com>
Tue, 23 Nov 2021 06:17:51 +0000 (15:17 +0900)
committerhuiyu <35286162+huiyueun@users.noreply.github.com>
Mon, 29 Nov 2021 08:55:55 +0000 (17:55 +0900)
When new page appears, we need to inform it to the screen-reader to read
its name as a default label.
And we need to inform the currently highlighted component's state on the
disappeared page. If the currently highlighted component is not visible
then it will be cleared by screen-reader.

src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs

index 1be99280df253157c8ee242f7ea42b0ad69e86a3..8780afdb3e3b5b4dc997e2dac00b289258923ab7 100755 (executable)
@@ -197,12 +197,13 @@ namespace Tizen.NUI.Components
             {
                 if (page is DialogPage == false)
                 {
-                   topPage.SetVisible(false);     
+                   topPage.SetVisible(false);
                 }
 
                 //Invoke Page events
                 page.InvokeAppeared();
                 topPage.InvokeDisappeared();
+                NotifyAccessibilityStatesChangeOfPages(topPage, page);
             };
             transitionFinished = false;
         }
@@ -252,6 +253,7 @@ namespace Tizen.NUI.Components
                 //Invoke Page events
                 newTopPage.InvokeAppeared();
                 topPage.InvokeDisappeared();
+                NotifyAccessibilityStatesChangeOfPages(topPage, newTopPage);
 
                 //Invoke Popped event
                 Popped?.Invoke(this, new PoppedEventArgs() { Page = topPage });
@@ -326,6 +328,7 @@ namespace Tizen.NUI.Components
                 {
                     //Invoke Page events
                     page.InvokeAppeared();
+                    NotifyAccessibilityStatesChangeOfPages(curTop, page);
                 };
                 newAnimation.Play();
             }
@@ -399,6 +402,7 @@ namespace Tizen.NUI.Components
                 {
                     //Invoke Page events
                     newTop.InvokeAppeared();
+                    NotifyAccessibilityStatesChangeOfPages(curTop, newTop);
                 };
                 newAnimation.Play();
             }
@@ -777,6 +781,30 @@ namespace Tizen.NUI.Components
             }
         }
 
+        /// <summary>
+        /// Notify accessibility states change of pages.
+        /// </summary>
+        /// <param name="disappearedPage">Disappeared page</param>
+        /// <param name="appearedPage">Appeared page</param>
+        private void NotifyAccessibilityStatesChangeOfPages(Page disappearedPage, Page appearedPage)
+        {
+            if (disappearedPage != null)
+            {
+                //We can call disappearedPage.NotifyAccessibilityStatesChange
+                //To reduce accessibility events, we are using currently highlighted view instead
+                View curHighlightedView = Accessibility.Accessibility.Instance.GetCurrentlyHighlightedView();
+                if (curHighlightedView != null)
+                {
+                    curHighlightedView.NotifyAccessibilityStatesChange(AccessibilityStates.Visible | AccessibilityStates.Showing, false);
+                }
+            }
+
+            if (appearedPage != null)
+            {
+                appearedPage.NotifyAccessibilityStatesChange(AccessibilityStates.Visible | AccessibilityStates.Showing, false);
+            }
+        }
+
         internal void InvokeTransitionFinished()
         {
             TransitionFinished?.Invoke(this, new EventArgs());