Add check box for notification (#5342)
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.NotificationEventListener / Tizen.Applications.NotificationEventListener / NotificationEventArgs.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 namespace Tizen.Applications.NotificationEventListener
18 {
19     using System;
20     using System.Collections.Generic;
21     using System.ComponentModel;
22
23     /// <summary>
24     /// This class provides the methods and properties to get information about the posted or updated notification.
25     /// </summary>
26     public partial class NotificationEventArgs : EventArgs
27     {
28         private const string LogTag = "Tizen.Applications.NotificationEventListener";
29
30         internal IDictionary<string, StyleArgs> Style;
31         internal IDictionary<string, Bundle> ExtraData;
32         internal Interop.NotificationEventListener.NotificationSafeHandle Handle;
33
34         /// <summary>
35         /// Initializes a new instance of the <see cref="NotificationEventArgs"/> class.
36         /// </summary>
37         /// <since_tizen> 4 </since_tizen>
38         public NotificationEventArgs()
39         {
40             Style = new Dictionary<string, StyleArgs>();
41             ExtraData = new Dictionary<string, Bundle>();
42         }
43
44         /// <summary>
45         /// Gets the unique ID of the notification.
46         /// </summary>
47         /// <since_tizen> 4 </since_tizen>
48         public int UniqueNumber { get; internal set; }
49
50         /// <summary>
51         /// Gets the appId of the notification.
52         /// </summary>
53         /// <since_tizen> 4 </since_tizen>
54         public string AppID { get; internal set; }
55
56         /// <summary>
57         /// Gets the title of the notification.
58         /// </summary>
59         /// <since_tizen> 4 </since_tizen>
60         public string Title { get; internal set; }
61
62         /// <summary>
63         /// Gets the content text of the notification.
64         /// </summary>
65         /// <since_tizen> 4 </since_tizen>
66         public string Content { get; internal set; }
67
68         /// <summary>
69         /// Gets the icon's path of the notification.
70         /// </summary>
71         /// <since_tizen> 4 </since_tizen>
72         public string Icon { get; internal set; }
73
74         /// <summary>
75         /// Gets the sub icon path of the notification.
76         /// </summary>
77         /// <since_tizen> 4 </since_tizen>
78         public string SubIcon { get; internal set; }
79
80         /// <summary>
81         /// Gets the timestamp if the notification is visible or not.
82         /// </summary>
83         /// <since_tizen> 4 </since_tizen>
84         public bool IsTimeStampVisible { get; internal set; }
85
86         /// <summary>
87         /// Gets TimeStamp of notification.
88         /// </summary>
89         /// <remarks>
90         /// If IsTimeStampVisible property is set false, this TimeStamp property is meaningless.
91         /// </remarks>
92         /// <since_tizen> 4 </since_tizen>
93         public DateTime TimeStamp { get; internal set; }
94
95         /// <summary>
96         /// Gets the count, which is displayed at the right side of notification.
97         /// </summary>
98         /// <since_tizen> 4 </since_tizen>
99         public int Count { get; internal set; }
100
101         /// <summary>
102         /// Gets the tag of notification.
103         /// </summary>
104         /// <since_tizen> 4 </since_tizen>
105         public string Tag { get; internal set; }
106
107         /// <summary>
108         /// Gets a value indicating whether the notification is Onging or not.
109         /// </summary>
110         /// <since_tizen> 4 </since_tizen>
111         [EditorBrowsable(EditorBrowsableState.Never)]
112         public bool IsOngoing { get; internal set; } = false;
113
114         /// <summary>
115         /// Gets a value that determines whether notification is displayed on the default viewer.
116         /// If IsDisplay property is set as false and add style, you can see only style notification.
117         /// </summary>
118         /// <since_tizen> 4 </since_tizen>
119         public bool IsVisible { get; internal set; } = true;
120
121         /// <summary>
122         /// Gets the event flag.
123         /// If this flag is true, you can do SendEvent.
124         /// </summary>
125         /// <since_tizen> 4 </since_tizen>
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         public bool HasEventFlag { get; internal set; } = false;
128
129         /// <summary>
130         /// Gets the do not show again flag.
131         /// </summary>
132         /// <since_tizen> 11 </since_tizen>
133         [EditorBrowsable(EditorBrowsableState.Never)]
134         public bool CheckBox { get; internal set; } = false;
135
136         [EditorBrowsable(EditorBrowsableState.Never)]
137         public bool CheckedValue { get; internal set; } = false;
138
139         /// <summary>
140         /// Gets the AppControl, which is invoked when notification is clicked.
141         /// </summary>
142         /// <since_tizen> 4 </since_tizen>
143         public AppControl Action { get; internal set; }
144
145         /// <summary>
146         /// Gets the object of the progress notification.
147         /// </summary>
148         /// <since_tizen> 4 </since_tizen>
149         public ProgressArgs Progress { get; internal set; }
150
151         /// <summary>
152         /// Gets the AccessoryArgs, which has option of sound, vibration, and LED.
153         /// </summary>
154         /// <since_tizen> 4 </since_tizen>
155         public AccessoryArgs Accessory { get; internal set; }
156
157         /// <summary>
158         /// Gets the key for extra data.
159         /// </summary>
160         /// <since_tizen> 4 </since_tizen>
161         public ICollection<string> ExtraDataKey
162         {
163             get
164             {
165                 return ExtraData.Keys;
166             }
167         }
168
169         /// <summary>
170         /// Gets the property.
171         /// </summary>
172         /// <since_tizen> 4 </since_tizen>
173         public NotificationProperty Property { get; internal set; }
174
175         /// <summary>
176         /// Gets the styleArgs of active, lock, indicator, and bigpicture.
177         /// </summary>
178         /// <typeparam name="T">Type of notification style to be queried.</typeparam>
179         /// <returns>The NotificationEventListener.StyleArgs object associated with the given style.</returns>
180         /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception>
181         /// <since_tizen> 4 </since_tizen>
182         public T GetStyle<T>() where T : StyleArgs, new()
183         {
184             T type = new T();
185             StyleArgs style = null;
186
187             Style.TryGetValue(type.Key, out style);
188
189             if (style == null)
190             {
191                 Log.Error(LogTag, "Invalid Style");
192                 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
193             }
194             else
195             {
196                 return style as T;
197             }
198         }
199
200         /// <summary>
201         /// Gets the ExtraDataArgs.
202         /// </summary>
203         /// <param name="key">The key that specifies which extra data.</param>
204         /// <returns>Returns the bundle for key.</returns>
205         /// <since_tizen> 4 </since_tizen>
206         public Bundle GetExtraData(string key)
207         {
208             Bundle bundle;
209
210             if (string.IsNullOrEmpty(key))
211             {
212                 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
213             }
214
215             if (ExtraData.TryGetValue(key, out bundle) == false)
216             {
217                 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered : " + key);
218             }
219
220             return bundle;
221         }
222     }
223 }