[NUI][ATSPI] Add a function to check whether accessibility is enabled (#3463)
authorSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Tue, 31 Aug 2021 08:37:20 +0000 (17:37 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 1 Sep 2021 08:20:01 +0000 (17:20 +0900)
* [NUI][ATSPI] Add a function to check whether accessibility is enabled

- Added `IsEnabled` to check accessibility state

Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
* Change the type of Enabled to property

- Make `Enabled` both static and property.

Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
src/Tizen.NUI.Components/Controls/Button.cs
src/Tizen.NUI.Components/Controls/Pagination.cs
src/Tizen.NUI.Components/Controls/Progress.cs
src/Tizen.NUI.Components/Controls/SelectButton.cs
src/Tizen.NUI.Components/Controls/Slider.cs
src/Tizen.NUI.Components/Controls/Switch.cs
src/Tizen.NUI/src/internal/Interop/Interop.Accessibility.cs
src/Tizen.NUI/src/public/Accessibility/Accessibility.cs
src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs

index 0b045f2..857e178 100755 (executable)
@@ -98,7 +98,7 @@ namespace Tizen.NUI.Components
                         instance.UpdateState();
                     }
 
-                    if (instance.IsHighlighted)
+                    if (Accessibility.Accessibility.Enabled && instance.IsHighlighted)
                     {
                         instance.EmitAccessibilityStatesChangedEvent(AccessibilityStates.Checked, newSelected);
                     }
@@ -362,7 +362,7 @@ namespace Tizen.NUI.Components
             {
                 TextLabel.Text = value;
 
-                if (IsHighlighted && String.IsNullOrEmpty(AccessibilityName) && GetAccessibilityNameSignal().Empty())
+                if (Accessibility.Accessibility.Enabled && IsHighlighted && String.IsNullOrEmpty(AccessibilityName) && GetAccessibilityNameSignal().Empty())
                 {
                     EmitAccessibilityEvent(AccessibilityPropertyChangeEvent.Name);
                 }
index e22a2da..9da3e44 100755 (executable)
@@ -367,7 +367,7 @@ namespace Tizen.NUI.Components
 
                 SelectIn(indicatorList[selectedIndex]);
 
-                if (IsHighlighted)
+                if (Accessibility.Accessibility.Enabled && IsHighlighted)
                 {
                     EmitAccessibilityEvent(AccessibilityPropertyChangeEvent.Value);
                 }
index acd2853..5bbf963 100755 (executable)
@@ -367,7 +367,7 @@ namespace Tizen.NUI.Components
             set
             {
                 SetValue(CurrentValueProperty, value);
-                if (IsHighlighted)
+                if (Accessibility.Accessibility.Enabled && IsHighlighted)
                 {
                     EmitAccessibilityEvent(AccessibilityPropertyChangeEvent.Value);
                 }
index 8a62bc4..2afcf5a 100755 (executable)
@@ -214,7 +214,7 @@ namespace Tizen.NUI.Components
         {
             if (info.PreviousState.Contains(ControlState.Selected) != info.CurrentState.Contains(ControlState.Selected))
             {
-                if (IsHighlighted)
+                if (Accessibility.Accessibility.Enabled && IsHighlighted)
                 {
                     EmitAccessibilityStatesChangedEvent(AccessibilityStates.Checked, info.CurrentState.Contains(ControlState.Selected));
                 }
index 306fec9..7ac6ed9 100755 (executable)
@@ -176,7 +176,7 @@ namespace Tizen.NUI.Components
                 if (newValue != null)
                 {
                     instance.curValue = (float)newValue;
-                    if (instance.IsHighlighted)
+                    if (Accessibility.Accessibility.Enabled && instance.IsHighlighted)
                     {
                         instance.EmitAccessibilityEvent(AccessibilityPropertyChangeEvent.Value);
                     }
index 2a1bc1e..43bf732 100644 (file)
@@ -317,7 +317,7 @@ namespace Tizen.NUI.Components
 
         private void OnSelect()
         {
-            if (IsHighlighted)
+            if (Accessibility.Accessibility.Enabled && IsHighlighted)
             {
                 EmitAccessibilityStatesChangedEvent(AccessibilityStates.Checked, IsSelected);
             }
index 80beb45..c10b695 100755 (executable)
@@ -44,6 +44,10 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_BridgeDisableAutoInit")]
             public static extern void BridgeDisableAutoInit();
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "csharp_dali_accessibility_IsEnabled")]
+            [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
+            public static extern bool IsEnabled();
         }
     }
 }
index 7494fa2..af5d0de 100755 (executable)
@@ -61,6 +61,23 @@ namespace Tizen.NUI.Accessibility
         {
             get => accessibility;
         }
+
+        /// <summary>
+        /// Flag to check whether the state of Accessibility is enabled or not.
+        /// </summary>
+        /// <remarks>
+        /// Getter returns true if Accessibility is enabled, false otherwise.
+        /// </remarks>
+        /// This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static bool Enabled
+        {
+            get
+            {
+                return (bool)Interop.Accessibility.IsEnabled();
+            }
+        }
+
         #endregion Property
 
 
index 2552788..ed23922 100755 (executable)
@@ -307,7 +307,7 @@ namespace Tizen.NUI.BaseComponents
         /// <since_tizen> 3 </since_tizen>
         public void Show()
         {
-            if ((AccessibilityCalculateStates() & AccessibilityStates.Modal) != 0)
+            if (Accessibility.Accessibility.Enabled && ((AccessibilityCalculateStates() & AccessibilityStates.Modal) != 0))
             {
                 RegisterPopup();
             }
@@ -328,7 +328,7 @@ namespace Tizen.NUI.BaseComponents
         {
             SetVisible(false);
 
-            if ((AccessibilityCalculateStates() & AccessibilityStates.Modal) != 0)
+            if (Accessibility.Accessibility.Enabled && ((AccessibilityCalculateStates() & AccessibilityStates.Modal) != 0))
             {
                 RemovePopup();
             }