Add check box for notification (#5342)
authorsukhyungkang <35091460+sukhyungkang@users.noreply.github.com>
Mon, 19 Jun 2023 23:45:18 +0000 (08:45 +0900)
committerGitHub <noreply@github.com>
Mon, 19 Jun 2023 23:45:18 +0000 (08:45 +0900)
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
src/Tizen.Applications.Notification/Interop/Interop.Notification.cs
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationResponseEventType.cs
src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgs.cs
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsEnumerations.cs
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs

index aa900fd..44e6f7e 100644 (file)
@@ -232,6 +232,12 @@ internal static partial class Interop
         [DllImport(Libraries.Notification, EntryPoint = "notification_clone")]
         internal static extern NotificationError Clone(IntPtr handle, out IntPtr cloned);
 
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_check_box")]
+        internal static extern NotificationError SetCheckBox(NotificationSafeHandle handle, bool flag, bool checkedValue);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_check_box")]
+        internal static extern NotificationError GetCheckBox(NotificationSafeHandle handle, out bool flag, out bool checkedValue);
+
         internal static NotificationError GetText(NotificationSafeHandle handle, NotificationText type, out string text)
         {
             NotificationError ret;
index 4eef6c8..019ea0a 100755 (executable)
@@ -203,6 +203,16 @@ namespace Tizen.Applications.Notifications
         public bool IsVisible { get; set; } = true;
 
         /// <summary>
+        /// Gets a flag for do not show again checkbox.
+        /// </summary>
+        /// <since_tizen> 11 </since_tizen>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool CheckBox { get; set; } = false;
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool CheckedValue { get; set; } = false;
+
+        /// <summary>
         /// Gets or sets NotificationSafeHandle.
         /// </summary>
         internal NotificationSafeHandle Handle
index 06870c6..b847e69 100755 (executable)
@@ -57,6 +57,11 @@ namespace Tizen.Applications.Notifications
             }
 
             Interop.Notification.SetProperties(notification.Handle, (int)notification.Property);
+
+            if (notification.CheckBox == true)
+            {
+                Interop.Notification.SetCheckBox(notification.Handle, notification.CheckBox, notification.CheckedValue);
+            }
         }
 
         internal static void BindSafeHandle(Notification notification)
@@ -85,6 +90,7 @@ namespace Tizen.Applications.Notifications
             BindSafeHandleTime(notification);
             BindSafeHandleTag(notification);
             BindSafeHandleAction(notification);
+            BindSafeHandleCheckBox(notification);
         }
 
         private static void BindNotificationSafeHandle(Notification notification)
@@ -229,5 +235,20 @@ namespace Tizen.Applications.Notifications
                 notification.Action = new AppControl(appcontrol);
             }
         }
+
+        private static void BindSafeHandleCheckBox(Notification notification)
+        {
+            NotificationError ret;
+            bool checkbox = false;
+            bool checkedValue = false;
+
+            ret = Interop.Notification.GetCheckBox(notification.Handle, out checkbox, out checkedValue);
+            if (ret != NotificationError.None) {
+                Log.Error(Notification.LogTag, "Failed to get check box info");
+            }
+
+            notification.CheckBox = checkbox;
+            notification.CheckedValue = checkedValue;
+        }
     }
 }
index b03f10e..674fcfa 100644 (file)
@@ -54,5 +54,10 @@ namespace Tizen.Applications.Notifications
         /// Event type : Deleted by user.
         /// </summary>
         DeleteNotification = 201,
+
+        /// <summary>
+        /// Event type : Do not show again.
+        /// </summary>
+        CheckBox = 300,
     }
 }
index 255be6d..95ad7cd 100755 (executable)
@@ -171,6 +171,17 @@ internal static partial class Interop
         [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_all_count")]
         internal static extern ErrorCode GetAllCount(NotificationType type, out int count);
 
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_set_check_box_checked")]
+        internal static extern ErrorCode SetCheckedValue(NotificationSafeHandle handle, bool checkedValue);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_check_box")]
+        internal static extern ErrorCode GetCheckBox(NotificationSafeHandle handle, out bool flag, out bool checkedValue);
+
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_send_event")]
+        internal static extern ErrorCode SendEventWithNotification(NotificationSafeHandle handle, int evnetType);
+
+
+
         internal static ErrorCode GetAppId(NotificationSafeHandle handle, out string appid)
         {
             ErrorCode err;
index 521e19d..487332c 100755 (executable)
@@ -127,6 +127,16 @@ namespace Tizen.Applications.NotificationEventListener
         public bool HasEventFlag { get; internal set; } = false;
 
         /// <summary>
+        /// Gets the do not show again flag.
+        /// </summary>
+        /// <since_tizen> 11 </since_tizen>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool CheckBox { get; internal set; } = false;
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool CheckedValue { get; internal set; } = false;
+
+        /// <summary>
         /// Gets the AppControl, which is invoked when notification is clicked.
         /// </summary>
         /// <since_tizen> 4 </since_tizen>
index c70c072..7fb9d72 100755 (executable)
@@ -39,6 +39,9 @@ namespace Tizen.Applications.NotificationEventListener
             IntPtr dummy = IntPtr.Zero;
             SafeAppControlHandle appcontrol = null;
 
+            bool checkBoxFlag = false;
+            bool checkedValue = false;
+
             NotificationEventArgs eventargs = new NotificationEventArgs();
 
             eventargs.Handle = new Interop.NotificationEventListener.NotificationSafeHandle(notification, data);
@@ -203,6 +206,15 @@ namespace Tizen.Applications.NotificationEventListener
 
             eventargs.HasEventFlag = eventFlag;
 
+            err = Interop.NotificationEventListener.GetCheckBox(eventargs.Handle, out checkBoxFlag, out checkedValue);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                Log.Error(LogTag, "unable to get checkbox flag");
+            }
+
+            eventargs.CheckBox = checkBoxFlag;
+            eventargs.CheckedValue = checkedValue;
+
             NotificationAccessoryAgsBinder.BindObject(eventargs);
             NotificationStyleArgBinder.BindObject(eventargs);
             NotificationProgressArgBinder.BindObject(eventargs);
index 31a5b09..d9b81f4 100755 (executable)
@@ -174,6 +174,11 @@ namespace Tizen.Applications.NotificationEventListener
         /// Event type : Deleted by user.
         /// </summary>
         DeleteNotification = 201,
+
+        /// <summary>
+        /// Event type : Do not show again checked by user.
+        /// </summary>
+        CheckBox = 300,
     }
 
     /// <summary>
index c1c6c36..e6c1382 100755 (executable)
@@ -407,6 +407,30 @@ namespace Tizen.Applications.NotificationEventListener
             }
         }
 
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static void SetChecked(NotificationEventArgs eventargs, bool checkedValue)
+        {
+            Interop.NotificationEventListener.ErrorCode err;
+
+            err = Interop.NotificationEventListener.SetCheckedValue(eventargs.Handle, checkedValue);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "failed to set checked");
+            }
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static void SendEventWithNotification(NotificationEventArgs eventargs, UserEventType type)
+        {
+            Interop.NotificationEventListener.ErrorCode err;
+
+            err = Interop.NotificationEventListener.SendEventWithNotification(eventargs.Handle, (int)type);
+            if (err != Interop.NotificationEventListener.ErrorCode.None)
+            {
+                throw NotificationEventListenerErrorFactory.GetException(err, "failed to send event");
+            }
+        }
+
         /// <summary>
         /// Returns NotificationEventArgs by UniqueNumber.
         /// </summary>