[NUI][AT-SPI] Promote DoAction implementation from CustomView to View
authorArtur Świgoń <a.swigon@samsung.com>
Tue, 4 Apr 2023 11:59:36 +0000 (13:59 +0200)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 13 Apr 2023 04:51:31 +0000 (13:51 +0900)
This is a follow-up to #5109 that enables controls derived from View,
but not CustomView, that use the ViewAccessibilityMode.Custom (e.g.
FluxView), to customize their behaviour related to the AT-SPI Action
interface.

The implementation of AccessibilityDoAction() and its helper methods
is moved up from CustomView to View. Note that the events that
AccessibilityDoAction invokes have already been declared at the View
level, in ViewAccessibilityEvent.cs (e.g. AccessibilityActivated), so
they do not have to be moved anywhere in this PR.

src/Tizen.NUI/src/public/BaseComponents/CustomView.cs
src/Tizen.NUI/src/public/BaseComponents/ViewAccessibility.cs

index 92edb87..1cb9e3f 100755 (executable)
@@ -497,140 +497,14 @@ namespace Tizen.NUI.BaseComponents
         {
         }
 
+        /// <inheritdoc/>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected override bool AccessibilityDoAction(string name)
-        {
-            if (name == AccessibilityActivateAction)
-            {
-                if (ActivateSignal?.Empty() == false)
-                {
-                    ActivateSignal?.Emit();
-                    return true;
-                }
-                else
-                {
-                    return OnAccessibilityActivated();
-                }
-            }
-            else if (name == AccessibilityReadingSkippedAction)
-            {
-                if (ReadingSkippedSignal?.Empty() == false)
-                {
-                    ReadingSkippedSignal?.Emit();
-                    return true;
-                }
-                else
-                {
-                    return OnAccessibilityReadingSkipped();
-                }
-            }
-            else if (name == AccessibilityReadingCancelledAction)
-            {
-                if (ReadingCancelledSignal?.Empty() == false)
-                {
-                    ReadingCancelledSignal?.Emit();
-                    return true;
-                }
-                else
-                {
-                    return OnAccessibilityReadingCancelled();
-                }
-            }
-            else if (name == AccessibilityReadingStoppedAction)
-            {
-                if (ReadingStoppedSignal?.Empty() == false)
-                {
-                    ReadingStoppedSignal?.Emit();
-                    return true;
-                }
-                else
-                {
-                    return OnAccessibilityReadingStopped();
-                }
-            }
-            else if (name == AccessibilityReadingPausedAction)
-            {
-                if (ReadingPausedSignal?.Empty() == false)
-                {
-                    ReadingPausedSignal?.Emit();
-                    return true;
-                }
-                else
-                {
-                    return OnAccessibilityReadingPaused();
-                }
-            }
-            else if (name == AccessibilityReadingResumedAction)
-            {
-                if (ReadingResumedSignal?.Empty() == false)
-                {
-                    ReadingResumedSignal?.Emit();
-                    return true;
-                }
-                else
-                {
-                    return OnAccessibilityReadingResumed();
-                }
-            }
-            else
-            {
-                return false;
-            }
-        }
-
-        /// <summary>
-        /// This method is called when the control accessibility is activated.<br />
-        /// Derived classes should override this to perform custom accessibility activation.<br />
-        /// </summary>
-        /// <returns>True if this control can perform accessibility activation.</returns>
-        internal virtual bool OnAccessibilityActivated()
+        protected override bool OnAccessibilityActivated()
         {
             return OnKeyboardEnter();
         }
 
         /// <summary>
-        /// This method is called when reading is skipped.
-        /// </summary>
-        /// <returns>True if information was served.</returns>
-        internal virtual bool OnAccessibilityReadingSkipped()
-        {
-            return false;
-        }
-
-        /// <summary>
-        /// This method is called when reading is cancelled.
-        /// </summary>
-        /// <returns>True if information was served.</returns>
-        internal virtual bool OnAccessibilityReadingCancelled()
-        {
-            return false;
-        }
-        /// <summary>
-        /// This method is called when reading is stopped.
-        /// </summary>
-        /// <returns>True if information was served.</returns>
-        internal virtual bool OnAccessibilityReadingStopped()
-        {
-            return false;
-        }
-        /// <summary>
-        /// This method is called when reading was paused.
-        /// </summary>
-        /// <returns>True if information was served.</returns>
-        internal virtual bool OnAccessibilityReadingPaused()
-        {
-            return false;
-        }
-        /// <summary>
-        /// This method is called when reading is resumed.
-        /// </summary>
-        /// <returns>True if information was served.</returns>
-        internal virtual bool OnAccessibilityReadingResumed()
-        {
-            return false;
-        }
-
-        /// <summary>
         /// This method should be overridden by deriving classes when they wish to respond the accessibility.
         /// </summary>
         /// <param name="gestures">The pan gesture.</param>
index 23c8af4..843c364 100755 (executable)
@@ -447,7 +447,82 @@ namespace Tizen.NUI.BaseComponents
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected virtual bool AccessibilityDoAction(string name)
         {
-            return false;
+            if (name == AccessibilityActivateAction)
+            {
+                if (ActivateSignal?.Empty() == false)
+                {
+                    ActivateSignal?.Emit();
+                    return true;
+                }
+                else
+                {
+                    return OnAccessibilityActivated();
+                }
+            }
+            else if (name == AccessibilityReadingSkippedAction)
+            {
+                if (ReadingSkippedSignal?.Empty() == false)
+                {
+                    ReadingSkippedSignal?.Emit();
+                    return true;
+                }
+                else
+                {
+                    return OnAccessibilityReadingSkipped();
+                }
+            }
+            else if (name == AccessibilityReadingCancelledAction)
+            {
+                if (ReadingCancelledSignal?.Empty() == false)
+                {
+                    ReadingCancelledSignal?.Emit();
+                    return true;
+                }
+                else
+                {
+                    return OnAccessibilityReadingCancelled();
+                }
+            }
+            else if (name == AccessibilityReadingStoppedAction)
+            {
+                if (ReadingStoppedSignal?.Empty() == false)
+                {
+                    ReadingStoppedSignal?.Emit();
+                    return true;
+                }
+                else
+                {
+                    return OnAccessibilityReadingStopped();
+                }
+            }
+            else if (name == AccessibilityReadingPausedAction)
+            {
+                if (ReadingPausedSignal?.Empty() == false)
+                {
+                    ReadingPausedSignal?.Emit();
+                    return true;
+                }
+                else
+                {
+                    return OnAccessibilityReadingPaused();
+                }
+            }
+            else if (name == AccessibilityReadingResumedAction)
+            {
+                if (ReadingResumedSignal?.Empty() == false)
+                {
+                    ReadingResumedSignal?.Emit();
+                    return true;
+                }
+                else
+                {
+                    return OnAccessibilityReadingResumed();
+                }
+            }
+            else
+            {
+                return false;
+            }
         }
 
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -492,5 +567,66 @@ namespace Tizen.NUI.BaseComponents
         {
             return false;
         }
+
+        /// <summary>
+        /// This method is called when the control accessibility is activated.<br />
+        /// Derived classes should override this to perform custom accessibility activation.<br />
+        /// </summary>
+        /// <returns>True if this control can perform accessibility activation.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual bool OnAccessibilityActivated()
+        {
+            return false;
+        }
+
+        /// <summary>
+        /// This method is called when reading is skipped.
+        /// </summary>
+        /// <returns>True if information was served.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual bool OnAccessibilityReadingSkipped()
+        {
+            return false;
+        }
+
+        /// <summary>
+        /// This method is called when reading is cancelled.
+        /// </summary>
+        /// <returns>True if information was served.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual bool OnAccessibilityReadingCancelled()
+        {
+            return false;
+        }
+
+        /// <summary>
+        /// This method is called when reading is stopped.
+        /// </summary>
+        /// <returns>True if information was served.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual bool OnAccessibilityReadingStopped()
+        {
+            return false;
+        }
+
+        /// <summary>
+        /// This method is called when reading was paused.
+        /// </summary>
+        /// <returns>True if information was served.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual bool OnAccessibilityReadingPaused()
+        {
+            return false;
+        }
+
+        /// <summary>
+        /// This method is called when reading is resumed.
+        /// </summary>
+        /// <returns>True if information was served.</returns>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected virtual bool OnAccessibilityReadingResumed()
+        {
+            return false;
+        }
     }
 }