2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 namespace Tizen.Applications.NotificationEventListener
20 using System.Collections.Generic;
21 using System.ComponentModel;
24 /// This class provides the methods and properties to get information about the posted or updated notification.
26 public partial class NotificationEventArgs : EventArgs
28 private const string LogTag = "Tizen.Applications.NotificationEventListener";
30 internal IDictionary<string, StyleArgs> Style;
31 internal IDictionary<string, Bundle> Extender;
32 internal Interop.NotificationEventListener.SafeNotificationHandle Handle;
35 /// Initializes a new instance of the <see cref="NotificationEventArgs"/> class.
37 public NotificationEventArgs()
39 Style = new Dictionary<string, StyleArgs>();
40 Extender = new Dictionary<string, Bundle>();
44 /// Gets the unique id of Notification.
48 /// int uniqueNumber = NotificationEventArgs.UniqueNumber;
51 public int UniqueNumber { get; internal set; }
54 /// Gets the appId of Notification.
58 /// string appId = NotificationEventArgs.AppID;
61 public string AppID { get; internal set; }
64 /// Gets the title of Notification.
68 /// string title = NotificationEventArgs.Title;
71 public string Title { get; internal set; }
74 /// Gets the content text of Notification.
78 /// string content = NotificationEventArgs.Content;
81 public string Content { get; internal set; }
84 /// Gets the icon's path of Notification.
88 /// string icon = NotificationEventArgs.Icon;
91 public string Icon { get; internal set; }
94 /// Gets the sub icon path of Notification.
98 /// string subIcon = NotificationEventArgs.SubIcon;
101 public string SubIcon { get; internal set; }
104 /// Gets the Timestamp of notification is visible or not.
106 public bool IsTimeStampVisible { get; internal set; }
109 /// Gets time of Notification.
113 /// DateTime timeStamp = NotificationEventArgs.TimeStamp;
116 public DateTime TimeStamp { get; internal set; }
119 /// Gets the count which is displayed at the right side of notification.
123 /// int count = NotificationEventArgs.Count;
126 public int Count { get; internal set; }
129 /// Gets the Tag of notification.
133 /// string tag = NotificationEventArgs.Tag;
136 public string Tag { get; internal set; }
139 /// Gets a value to check if it is an ongoing type.
143 /// bool isongoing = NotificationEventArgs.IsOngoing;
146 [EditorBrowsable(EditorBrowsableState.Never)]
147 public bool IsOngoing { get; internal set; } = false;
150 /// Gets a value that determines whether notification is displayed on the default viewer.
151 /// If you set false and add style, you can see only style notification.
155 /// bool isDisplay = NotificationEventArgs.IsDisplay;
158 public bool IsDisplay { get; internal set; } = true;
161 /// Gets the event flag.
165 /// bool eventFlag = NotificationEventArgs.HasEventFlag;
168 [EditorBrowsable(EditorBrowsableState.Never)]
169 public bool HasEventFlag { get; internal set; } = false;
172 /// Gets the AppControl which is invoked when notification is clicked.
176 /// AppControl action = NotificationEventArgs.Action;
179 public AppControl Action { get; internal set; }
182 /// Gets the object of the progress notification.
186 /// ProgressCategory category = NotificationEventArgs.Progress.Category;
187 /// double current = NotificationEventArgs.Progress.Current;
188 /// double max = NotificationEventArgs.Progress.Max;
191 public ProgressArgs Progress { get; internal set; }
194 /// Gets the AccessoryArgs which has option of Sound, Vibration, LED.
198 /// string soundPath = NotificationEventArgs.Accessory.SountPath;
201 public AccessoryArgs Accessory { get; internal set; }
204 /// Gets the key for extender.
208 /// ICollection<string> extenderkey = NotificationEventArgs.ExtenderKey;
209 /// foreach (string key in extenderkey)
215 public ICollection<string> ExtenderKey
219 return Extender.Keys;
224 /// Gets the property.
228 /// int property = NotificationEventArgs.Property;
231 public NotificationProperty Property { get; internal set; }
234 /// Gets the styleArgs of active, lock, indicator, bigpicture.
236 /// <typeparam name="T">Type of notification style to be queried</typeparam>
237 /// <returns>The Notification.Style object associated with the given style</returns>
238 /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
241 /// NotificationEventArgs.ActiveStyleArgs style = NotificationEventArgs.GetStyle<NotificationEventArgs.ActiveStyleArgs>();
242 /// autoremove = style.IsAutoRemove;
245 public T GetStyle<T>() where T : StyleArgs, new()
248 StyleArgs style = null;
250 Style.TryGetValue(type.Key, out style);
254 Log.Error(LogTag, "Invalid Style");
255 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
264 /// Gets the ExtenderArgs.
266 /// <param name="key">The key that specifies which extender</param>
267 /// <returns>Returns the bundle for key</returns>
268 /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
271 /// Bundle extender = NotificationEventArgs.GetExtender("key");
274 public Bundle GetExtender(string key)
278 if (string.IsNullOrEmpty(key))
280 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
283 if (Extender.TryGetValue(key, out bundle) == false)
285 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered : " + key);