[SystemSettings][TCSACR-215] Add properties (#684)
authorJinWang An <35290168+jinwangan@users.noreply.github.com>
Tue, 19 Feb 2019 06:04:56 +0000 (15:04 +0900)
committerGitHub <noreply@github.com>
Tue, 19 Feb 2019 06:04:56 +0000 (15:04 +0900)
* [SystemSettings][TCSACR-215] Add properties

 - AccessibilityGrayscale
 - AccessibilityNegativeColor

Signed-off-by: jinwang.an <jinwang.an@samsung.com>
* Fixed version

 - AccessibilityGrayscale
 - AccessibilityNegativeColor

Signed-off-by: jinwang.an <jinwang.an@samsung.com>
* Fixed API Version 6

 - AccessibilityGrayscaleChangedEventArgs
 - AccessibilityNegativeColorChangedEventArgs

Signed-off-by: jinwang.an <jinwang.an@samsung.com>
* Fix typo grayscale and negative descriptions

Signed-off-by: jinwang.an <jinwang.an@samsung.com>
src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettings.cs
src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEnums.cs
src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs

index 59c740d..9440cea 100755 (executable)
@@ -1069,6 +1069,74 @@ namespace Tizen.System
             }
         }
 
+        /// <summary>
+        /// Indicates whether accessibility grayscale is enabled on the device or not.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <feature>http://tizen.org/feature/accessibility.grayscale</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 6 </since_tizen>
+        public static bool AccessibilityGrayscale
+        {
+            get
+            {
+                bool isAccessibilityGrayscale;
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.AccessibilityGrayscale, out isAccessibilityGrayscale);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to get isAccessibilityGrayscale system setting.");
+                }
+                return isAccessibilityGrayscale;
+            }
+            set
+            {
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.AccessibilityGrayscale, value);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to set isAccessibilityGrayscale system setting.");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Indicates whether accessibility negative color is enabled on the device or not.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <feature>http://tizen.org/feature/accessibility.negative</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 6 </since_tizen>
+        public static bool AccessibilityNegativeColor
+        {
+            get
+            {
+                bool isAccessibilityNegativeColor;
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.AccessibilityNegativeColor, out isAccessibilityNegativeColor);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to get isAccessibilityNegativeColor system setting.");
+                }
+                return isAccessibilityNegativeColor;
+            }
+            set
+            {
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.AccessibilityNegativeColor, value);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to set isAccessibilityNegativeColor system setting.");
+                }
+            }
+        }
+
         private static readonly Interop.Settings.SystemSettingsChangedCallback s_incomingCallRingtoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
         {
             string path = SystemSettings.IncomingCallRingtone;
@@ -2803,6 +2871,102 @@ namespace Tizen.System
                 }
             }
         }
+
+        private static readonly Interop.Settings.SystemSettingsChangedCallback s_accessibilityGrayscaleChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
+        {
+            bool accessibilityGrayscale = SystemSettings.AccessibilityGrayscale;
+            AccessibilityGrayscaleChangedEventArgs eventArgs = new AccessibilityGrayscaleChangedEventArgs(accessibilityGrayscale);
+            s_accessibilityGrayscaleChanged?.Invoke(null, eventArgs);
+        };
+        private static event EventHandler<AccessibilityGrayscaleChangedEventArgs> s_accessibilityGrayscaleChanged;
+        /// <summary>
+        /// The AccessibilityGrayscaleChanged event is triggered when the AccessibilityGrayscale value is changed.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <feature>http://tizen.org/feature/accessibility.grayscale</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 6 </since_tizen>
+        public static event EventHandler<AccessibilityGrayscaleChangedEventArgs> AccessibilityGrayscaleChanged
+        {
+            add
+            {
+                if (s_accessibilityGrayscaleChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.AccessibilityGrayscale, s_accessibilityGrayscaleChangedCallback, IntPtr.Zero);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+                s_accessibilityGrayscaleChanged += value;
+            }
+
+            remove
+            {
+                s_accessibilityGrayscaleChanged -= value;
+                if (s_accessibilityGrayscaleChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.AccessibilityGrayscale, s_accessibilityGrayscaleChangedCallback);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+            }
+        }
+
+        private static readonly Interop.Settings.SystemSettingsChangedCallback s_accessibilityNegativeColorChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
+        {
+            bool accessibilityNegativeColor = SystemSettings.AccessibilityNegativeColor;
+            AccessibilityNegativeColorChangedEventArgs eventArgs = new AccessibilityNegativeColorChangedEventArgs(accessibilityNegativeColor);
+            s_accessibilityNegativeColorChanged?.Invoke(null, eventArgs);
+        };
+        private static event EventHandler<AccessibilityNegativeColorChangedEventArgs> s_accessibilityNegativeColorChanged;
+        /// <summary>
+        /// The AccessibilityNegativeColorChanged event is triggered when the AccessibilityNegativeColor value is changed.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <feature>http://tizen.org/feature/accessibility.negative</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 6 </since_tizen>
+        public static event EventHandler<AccessibilityNegativeColorChangedEventArgs> AccessibilityNegativeColorChanged
+        {
+            add
+            {
+                if (s_accessibilityNegativeColorChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.AccessibilityNegativeColor, s_accessibilityNegativeColorChangedCallback, IntPtr.Zero);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+                s_accessibilityNegativeColorChanged += value;
+            }
+
+            remove
+            {
+                s_accessibilityNegativeColorChanged -= value;
+                if (s_accessibilityNegativeColorChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.AccessibilityNegativeColor, s_accessibilityNegativeColorChangedCallback);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+            }
+        }
     }
 }
 
index 4b4dc75..2842e84 100755 (executable)
@@ -172,6 +172,16 @@ namespace Tizen.System
         /// </summary>
         /// <since_tizen> 5 </since_tizen>
         DeveloperOptionState,
+        /// <summary>
+        /// GET (bool) Indicates whether accessibility grayscale  is enabled on the device.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        AccessibilityGrayscale,
+        /// <summary>
+        /// GET (bool) Indicates whether accessibility negative color is enabled on the device.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        AccessibilityNegativeColor
     }
     /// <summary>
     /// Enumeration for the Idle Lock State.
index 8b5e10c..e078ff9 100755 (executable)
@@ -1120,4 +1120,70 @@ namespace Tizen.System
             }
         }
     }
+
+    /// <summary>
+    /// EventArgs type for the AccessibilityGrayscaleChanged event.
+    /// </summary>
+    /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+    /// <privlevel>platform</privlevel>
+    /// <feature>http://tizen.org/feature/systemsetting</feature>
+    /// <feature>http://tizen.org/feature/accessibility.grayscale</feature>
+    /// <exception cref="ArgumentException">Invalid Argument</exception>
+    /// <exception cref="NotSupportedException">Not Supported feature</exception>
+    /// <exception cref="InvalidOperationException">Invalid operation</exception>
+    /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+    /// <since_tizen> 6 </since_tizen>
+    public class AccessibilityGrayscaleChangedEventArgs : EventArgs
+    {
+        private readonly bool _accessibilityGrayscale;
+        internal AccessibilityGrayscaleChangedEventArgs(bool val)
+        {
+            _accessibilityGrayscale = val;
+        }
+
+        /// <summary>
+        /// Indicates whether developer option state is enabled on the device or not.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public bool Value
+        {
+            get
+            {
+                return _accessibilityGrayscale;
+            }
+        }
+    }
+
+    /// <summary>
+    /// EventArgs type for the AccessibilityNegativeColorChanged event.
+    /// </summary>
+    /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+    /// <privlevel>platform</privlevel>
+    /// <feature>http://tizen.org/feature/systemsetting</feature>
+    /// <feature>http://tizen.org/feature/accessibility.negative</feature>
+    /// <exception cref="ArgumentException">Invalid Argument</exception>
+    /// <exception cref="NotSupportedException">Not Supported feature</exception>
+    /// <exception cref="InvalidOperationException">Invalid operation</exception>
+    /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+    /// <since_tizen> 6 </since_tizen>
+    public class AccessibilityNegativeColorChangedEventArgs : EventArgs
+    {
+        private readonly bool _accessibilityNegativeColor;
+        internal AccessibilityNegativeColorChangedEventArgs(bool val)
+        {
+            _accessibilityNegativeColor = val;
+        }
+
+        /// <summary>
+        /// Indicates whether developer option state is enabled on the device or not.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public bool Value
+        {
+            get
+            {
+                return _accessibilityNegativeColor;
+            }
+        }
+    }
 }