Add default button Property in Notification, EventListener
authorSeungha Son <seungha.son@samsung.com>
Tue, 30 May 2017 00:19:58 +0000 (09:19 +0900)
committerSon seungha <seungha.son@samsung.com>
Mon, 12 Jun 2017 05:10:33 +0000 (05:10 +0000)
 This patch add Property to display default button on active notification

Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: I76d8aaffb2c45da64b3c04a47d11ed206b4457e4

src/Tizen.Applications.Notification/Interop/Interop.Notification.cs
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationActiveStyle.cs
src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationStyleBinder.cs
src/Tizen.Applications.NotificationEventListener/Interop/Interop.NotificationEventListener.cs
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationEventArgsActiveStyle.cs
src/Tizen.Applications.NotificationEventListener/Tizen.Applications.NotificationEventListener/NotificationStyleArgsBinder.cs

index 7dd5365..e865ab1 100755 (executable)
@@ -212,6 +212,12 @@ internal static partial class Interop
         [DllImport(Libraries.Notification, EntryPoint = "notification_get_args")]
         internal static extern NotificationError GetExtentionBundle(NotificationSafeHandle handle, out IntPtr args, out IntPtr group_args);
 
+        [DllImport(Libraries.Notification, EntryPoint = "notification_get_default_button")]
+        internal static extern NotificationError GetDefaultButton(NotificationSafeHandle handle, out int index);
+
+        [DllImport(Libraries.Notification, EntryPoint = "notification_set_default_button")]
+        internal static extern NotificationError SetDefaultButton(NotificationSafeHandle handle, int index);
+
         internal static NotificationError GetText(NotificationSafeHandle handle, NotificationText type, out string text)
         {
             NotificationError ret;
index d986c37..d7b9d7f 100755 (executable)
@@ -61,6 +61,15 @@ namespace Tizen.Applications.Notifications
             public bool IsAutoRemove { get; set; } = true;
 
             /// <summary>
+            /// Gets or sets the default button to display highlight on the active notification
+            /// </summary>
+            /// <remarks>
+            /// The default button for display highlight is only reflected on Tizen TV.
+            /// If you use this Property on other profile, this value have no effect
+            /// </remarks>
+            public ButtonIndex DefaultButton { get; set; } = ButtonIndex.None;
+
+            /// <summary>
             /// Gets or sets a ReplyAction to this active notification style.
             /// </summary>
             /// <remarks>
index b5a1fe1..587c6ef 100755 (executable)
@@ -100,6 +100,11 @@ namespace Tizen.Applications.Notifications
                 throw NotificationErrorFactory.GetException(ret, "unable to set background Image");
             }
 
+            if (style.DefaultButton != ButtonIndex.None)
+            {
+                Interop.Notification.SetDefaultButton(notification.Handle, (int)style.DefaultButton + 1);
+            }
+
             Interop.Notification.GetApplist(notification.Handle, out flag);
             Interop.Notification.SetApplist(notification.Handle, flag | (int)NotificationDisplayApplist.Active);
 
@@ -179,6 +184,10 @@ namespace Tizen.Applications.Notifications
                     active.BackgroundImage = path;
                 }
 
+                int defaultIndex;
+                Interop.Notification.GetDefaultButton(notification.Handle, out defaultIndex);
+                active.DefaultButton = (ButtonIndex)(defaultIndex - 1);
+
                 appcontrol = null;
                 Interop.Notification.GetImage(notification.Handle, NotificationImage.TextInputButton, out path);
                 Interop.Notification.GetText(notification.Handle, NotificationText.InputButton, out text);
index 3b3e42e..1e8b413 100755 (executable)
@@ -159,6 +159,9 @@ internal static partial class Interop
         [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_event_flag")]
         internal static extern ErrorCode GetEventFlag(NotificationSafeHandle handle, out bool eventFlag);
 
+        [DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_default_button")]
+        internal static extern ErrorCode GetDefaultButton(NotificationSafeHandle handle, out int index);
+
         internal static ErrorCode GetAppId(NotificationSafeHandle handle, out string appid)
         {
             ErrorCode err;
index 674a2b1..7495ffc 100755 (executable)
@@ -52,6 +52,11 @@ namespace Tizen.Applications.NotificationEventListener
             public string BackgroundImage { get; internal set; }
 
             /// <summary>
+            /// Gets the default button to display highlight on the active notification
+            /// </summary>
+            public ButtonIndex DefaultButton { get; internal set; }
+
+            /// <summary>
             /// Gets timeout value in second when the notification can be hidden from the viewer.
             /// </summary>
             public int HideTimeout { get; internal set; }
index 6ccb63d..f45e4aa 100755 (executable)
@@ -45,6 +45,10 @@ namespace Tizen.Applications.NotificationEventListener
                 Interop.NotificationEventListener.GetImage(eventargs.Handle, NotificationImage.Background, out path);
                 activeStyle.BackgroundImage = path;
 
+                int index;
+                Interop.NotificationEventListener.GetDefaultButton(eventargs.Handle, out index);
+                activeStyle.DefaultButton = (ButtonIndex)(index - 1);
+
                 Interop.NotificationEventListener.GetHideTimeout(eventargs.Handle, out timeout);
                 activeStyle.HideTimeout = timeout;