From 8446bec8072fccf008bf09828468d44fd11bfc54 Mon Sep 17 00:00:00 2001 From: sukhyungkang <35091460+sukhyungkang@users.noreply.github.com> Date: Tue, 20 Jun 2023 08:45:18 +0900 Subject: [PATCH] Add check box for notification (#5342) Signed-off-by: SukhyungKang --- .../Interop/Interop.Notification.cs | 6 ++++++ .../Notification.cs | 10 +++++++++ .../NotificationBinder.cs | 21 +++++++++++++++++++ .../NotificationResponseEventType.cs | 5 +++++ .../Interop/Interop.NotificationEventListener.cs | 11 ++++++++++ .../NotificationEventArgs.cs | 10 +++++++++ .../NotificationEventArgsBinder.cs | 12 +++++++++++ .../NotificationEventArgsEnumerations.cs | 5 +++++ .../NotificationListenerManager.cs | 24 ++++++++++++++++++++++ 9 files changed, 104 insertions(+) diff --git a/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs b/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs index aa900fd..44e6f7e 100644 --- a/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs +++ b/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs @@ -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; diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs index 4eef6c8..019ea0a 100755 --- a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs +++ b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/Notification.cs @@ -203,6 +203,16 @@ namespace Tizen.Applications.Notifications public bool IsVisible { get; set; } = true; /// + /// Gets a flag for do not show again checkbox. + /// + /// 11 + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CheckBox { get; set; } = false; + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CheckedValue { get; set; } = false; + + /// /// Gets or sets NotificationSafeHandle. /// internal NotificationSafeHandle Handle diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs index 06870c6..b847e69 100755 --- a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs +++ b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationBinder.cs @@ -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; + } } } diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationResponseEventType.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationResponseEventType.cs index b03f10e..674fcfa 100644 --- a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationResponseEventType.cs +++ b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationResponseEventType.cs @@ -54,5 +54,10 @@ namespace Tizen.Applications.Notifications /// Event type : Deleted by user. /// DeleteNotification = 201, + + /// + /// Event type : Do not show again. + /// + CheckBox = 300, } } diff --git a/src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs b/src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs index 255be6d..95ad7cd 100755 --- a/src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs +++ b/src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs @@ -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; diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgs.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgs.cs index 521e19d..487332c 100755 --- a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgs.cs +++ b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgs.cs @@ -127,6 +127,16 @@ namespace Tizen.Applications.NotificationEventListener public bool HasEventFlag { get; internal set; } = false; /// + /// Gets the do not show again flag. + /// + /// 11 + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CheckBox { get; internal set; } = false; + + [EditorBrowsable(EditorBrowsableState.Never)] + public bool CheckedValue { get; internal set; } = false; + + /// /// Gets the AppControl, which is invoked when notification is clicked. /// /// 4 diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs index c70c072..7fb9d72 100755 --- a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs +++ b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsBinder.cs @@ -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); diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsEnumerations.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsEnumerations.cs index 31a5b09..d9b81f4 100755 --- a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsEnumerations.cs +++ b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsEnumerations.cs @@ -174,6 +174,11 @@ namespace Tizen.Applications.NotificationEventListener /// Event type : Deleted by user. /// DeleteNotification = 201, + + /// + /// Event type : Do not show again checked by user. + /// + CheckBox = 300, } /// diff --git a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs index c1c6c36..e6c1382 100755 --- a/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs +++ b/src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationListenerManager.cs @@ -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"); + } + } + /// /// Returns NotificationEventArgs by UniqueNumber. /// -- 2.7.4