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.NotificationSafeHandle 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.
46 public int UniqueNumber { get; internal set; }
49 /// Gets the appId of Notification.
51 public string AppID { get; internal set; }
54 /// Gets the title of Notification.
56 public string Title { get; internal set; }
59 /// Gets the content text of Notification.
61 public string Content { get; internal set; }
64 /// Gets the icon's path of Notification.
66 public string Icon { get; internal set; }
69 /// Gets the sub icon path of Notification.
71 public string SubIcon { get; internal set; }
74 /// Gets the Timestamp of notification is visible or not.
76 public bool IsTimeStampVisible { get; internal set; }
79 /// Gets TimeStamp of Notification.
82 /// If IsTimeStampVisible property is set false, this TimeStamp property is meanless.
84 public DateTime TimeStamp { get; internal set; }
87 /// Gets the count which is displayed at the right side of notification.
89 public int Count { get; internal set; }
92 /// Gets the Tag of notification.
94 public string Tag { get; internal set; }
96 [EditorBrowsable(EditorBrowsableState.Never)]
97 public bool IsOngoing { get; internal set; } = false;
100 /// Gets a value that determines whether notification is displayed on the default viewer.
101 /// If IsDisplay property set false and add style, you can see only style notification.
103 public bool IsDisplay { get; internal set; } = true;
105 [EditorBrowsable(EditorBrowsableState.Never)]
106 public bool HasEventFlag { get; internal set; } = false;
109 /// Gets the AppControl which is invoked when notification is clicked.
111 public AppControl Action { get; internal set; }
114 /// Gets the object of the progress notification.
116 public ProgressArgs Progress { get; internal set; }
119 /// Gets the AccessoryArgs which has option of Sound, Vibration, LED.
121 public AccessoryArgs Accessory { get; internal set; }
124 /// Gets the key for extender.
126 public ICollection<string> ExtenderKey
130 return Extender.Keys;
135 /// Gets the property.
137 public NotificationProperty Property { get; internal set; }
140 /// Gets the styleArgs of active, lock, indicator, bigpicture.
142 /// <typeparam name="T">Type of notification style to be queried</typeparam>
143 /// <returns>The NotificationEventListener.StyleArgs object associated with the given style</returns>
144 /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
145 public T GetStyle<T>() where T : StyleArgs, new()
148 StyleArgs style = null;
150 Style.TryGetValue(type.Key, out style);
154 Log.Error(LogTag, "Invalid Style");
155 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
164 /// Gets the ExtenderArgs.
166 /// <param name="key">The key that specifies which extender</param>
167 /// <returns>Returns the bundle for key</returns>
168 public Bundle GetExtender(string key)
172 if (string.IsNullOrEmpty(key))
174 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
177 if (Extender.TryGetValue(key, out bundle) == false)
179 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered : " + key);