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;
23 public partial class NotificationEventArgs
25 private const string LogTag = "Tizen.Applications.NotificationEventListener";
27 internal IDictionary<string, StyleArgs> Style;
28 internal IDictionary<string, Bundle> Extender;
29 internal Interop.NotificationEventListener.SafeNotificationHandle Handle;
31 public NotificationEventArgs()
33 Style = new Dictionary<string, StyleArgs>();
34 Extender = new Dictionary<string, Bundle>();
38 /// Gets the unique id of Notification.
42 /// int uniqueNumber = NotificationEventArgs.UniqueNumber;
45 public int UniqueNumber { get; internal set; }
48 /// Gets the appId of Notification.
52 /// string appId = NotificationEventArgs.AppID;
55 public string AppID { get; internal set; }
58 /// Gets the title of Notification.
62 /// string title = NotificationEventArgs.Title;
65 public string Title { get; internal set; }
68 /// Gets the content text of Notification.
72 /// string content = NotificationEventArgs.Content;
75 public string Content { get; internal set; }
78 /// Gets the icon's path of Notification.
82 /// string icon = NotificationEventArgs.Icon;
85 public string Icon { get; internal set; }
88 /// Gets the sub icon path of Notification.
92 /// string subIcon = NotificationEventArgs.SubIcon;
95 public string SubIcon { get; internal set; }
98 /// Gets the Timestamp of notification is visible or not.
100 public bool IsTimeStampVisible { get; internal set; }
103 /// Gets time of Notification.
107 /// DateTime timeStamp = NotificationEventArgs.TimeStamp;
110 public DateTime TimeStamp { get; internal set; }
113 /// Gets the count which is displayed at the right side of notification.
117 /// int count = NotificationEventArgs.Count;
120 public int Count { get; internal set; }
123 /// Gets the Tag of notification.
127 /// string tag = NotificationEventArgs.Tag;
130 public string Tag { get; internal set; }
133 /// Gets a value to check if it is an ongoing type.
137 /// bool isongoing = NotificationEventArgs.IsOngoing;
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public bool IsOngoing { get; internal set; } = false;
144 /// Gets a value that determines whether notification is displayed on the default viewer.
145 /// If you set false and add style, you can see only style notification.
149 /// bool isDisplay = NotificationEventArgs.IsDisplay;
152 public bool IsDisplay { get; internal set; } = true;
155 /// Gets the event flag.
159 /// bool eventFlag = NotificationEventArgs.HasEventFlag;
162 [EditorBrowsable(EditorBrowsableState.Never)]
163 public bool HasEventFlag { get; internal set; } = false;
166 /// Gets the AppControl which is invoked when notification is clicked.
170 /// AppControl action = NotificationEventArgs.Action;
173 public AppControl Action { get; internal set; }
176 /// Gets the object of the progress notification.
180 /// ProgressCategory category = NotificationEventArgs.Progress.Category;
181 /// double current = NotificationEventArgs.Progress.Current;
182 /// double max = NotificationEventArgs.Progress.Max;
185 public ProgressArgs Progress { get; internal set; }
188 /// Gets the AccessoryArgs which has option of Sound, Vibration, LED.
192 /// string soundPath = NotificationEventArgs.Accessory.SountPath;
195 public AccessoryArgs Accessory { get; internal set; }
198 /// Gets the key for extender.
202 /// ICollection<string> extenderkey = NotificationEventArgs.ExtenderKey;
203 /// foreach (string key in extenderkey)
209 public ICollection<string> ExtenderKey
213 return Extender.Keys;
218 /// Gets the property.
222 /// int property = NotificationEventArgs.Property;
225 public NotificationProperty Property { get; internal set; }
228 /// Gets the styleArgs of active, lock, indicator, bigpicture.
230 /// <typeparam name="T">Type of notification style to be queried</typeparam>
231 /// <returns>The Notification.Style object associated with the given style</returns>
232 /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
235 /// NotificationEventArgs.ActiveStyleArgs style = NotificationEventArgs.GetStyle<NotificationEventArgs.ActiveStyleArgs>();
236 /// autoremove = style.IsAutoRemove;
239 public T GetStyle<T>() where T : StyleArgs, new()
242 StyleArgs style = null;
244 Style.TryGetValue(type.Key, out style);
248 Log.Error(LogTag, "Invalid Style");
249 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
258 /// Gets the ExtenderArgs.
260 /// <param name="key">The key that specifies which extender</param>
261 /// <returns>Returns the bundle for key</returns>
262 /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
265 /// Bundle extender = NotificationEventArgs.GetExtender("key");
268 public Bundle GetExtender(string key)
272 if (string.IsNullOrEmpty(key))
274 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
277 if (Extender.TryGetValue(key, out bundle) == false)
279 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered : " + key);