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> ExtraData;
32 internal Interop.NotificationEventListener.NotificationSafeHandle Handle;
35 /// Initializes a new instance of the <see cref="NotificationEventArgs"/> class.
37 /// <since_tizen> 4 </since_tizen>
38 public NotificationEventArgs()
40 Style = new Dictionary<string, StyleArgs>();
41 ExtraData = new Dictionary<string, Bundle>();
45 /// Gets the unique ID of the notification.
47 /// <since_tizen> 4 </since_tizen>
48 public int UniqueNumber { get; internal set; }
51 /// Gets the appId of the notification.
53 /// <since_tizen> 4 </since_tizen>
54 public string AppID { get; internal set; }
57 /// Gets the title of the notification.
59 /// <since_tizen> 4 </since_tizen>
60 public string Title { get; internal set; }
63 /// Gets the content text of the notification.
65 /// <since_tizen> 4 </since_tizen>
66 public string Content { get; internal set; }
69 /// Gets the icon's path of the notification.
71 /// <since_tizen> 4 </since_tizen>
72 public string Icon { get; internal set; }
75 /// Gets the sub icon path of the notification.
77 /// <since_tizen> 4 </since_tizen>
78 public string SubIcon { get; internal set; }
81 /// Gets the timestamp if the notification is visible or not.
83 /// <since_tizen> 4 </since_tizen>
84 public bool IsTimeStampVisible { get; internal set; }
87 /// Gets TimeStamp of notification.
90 /// If IsTimeStampVisible property is set false, this TimeStamp property is meaningless.
92 /// <since_tizen> 4 </since_tizen>
93 public DateTime TimeStamp { get; internal set; }
96 /// Gets the count, which is displayed at the right side of notification.
98 /// <since_tizen> 4 </since_tizen>
99 public int Count { get; internal set; }
102 /// Gets the tag of notification.
104 /// <since_tizen> 4 </since_tizen>
105 public string Tag { get; internal set; }
108 /// Gets a value indicating whether the notification is Onging or not.
110 /// <since_tizen> 4 </since_tizen>
111 [EditorBrowsable(EditorBrowsableState.Never)]
112 public bool IsOngoing { get; internal set; } = false;
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.
118 /// <since_tizen> 4 </since_tizen>
119 public bool IsVisible { get; internal set; } = true;
122 /// Gets the event flag.
123 /// If this flag is true, you can do SendEvent.
125 /// <since_tizen> 4 </since_tizen>
126 [EditorBrowsable(EditorBrowsableState.Never)]
127 public bool HasEventFlag { get; internal set; } = false;
130 /// Gets the AppControl, which is invoked when notification is clicked.
132 /// <since_tizen> 4 </since_tizen>
133 public AppControl Action { get; internal set; }
136 /// Gets the object of the progress notification.
138 /// <since_tizen> 4 </since_tizen>
139 public ProgressArgs Progress { get; internal set; }
142 /// Gets the AccessoryArgs, which has option of sound, vibration, and LED.
144 /// <since_tizen> 4 </since_tizen>
145 public AccessoryArgs Accessory { get; internal set; }
148 /// Gets the key for extra data.
150 /// <since_tizen> 4 </since_tizen>
151 public ICollection<string> ExtraDataKey
155 return ExtraData.Keys;
160 /// Gets the property.
162 /// <since_tizen> 4 </since_tizen>
163 public NotificationProperty Property { get; internal set; }
166 /// Gets the styleArgs of active, lock, indicator, and bigpicture.
168 /// <typeparam name="T">Type of notification style to be queried.</typeparam>
169 /// <returns>The NotificationEventListener.StyleArgs object associated with the given style.</returns>
170 /// <exception cref="ArgumentException">Thrown when an argument is invalid.</exception>
171 /// <since_tizen> 4 </since_tizen>
172 public T GetStyle<T>() where T : StyleArgs, new()
175 StyleArgs style = null;
177 Style.TryGetValue(type.Key, out style);
181 Log.Error(LogTag, "Invalid Style");
182 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
191 /// Gets the ExtraDataArgs.
193 /// <param name="key">The key that specifies which extra data.</param>
194 /// <returns>Returns the bundle for key.</returns>
195 /// <since_tizen> 4 </since_tizen>
196 public Bundle GetExtraData(string key)
200 if (string.IsNullOrEmpty(key))
202 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
205 if (ExtraData.TryGetValue(key, out bundle) == false)
207 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered : " + key);