/*
* Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Tizen.Applications.NotificationEventListener
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
///
/// This class provides the methods and properties to get information about the posted or updated notification.
///
public partial class NotificationEventArgs : EventArgs
{
private const string LogTag = "Tizen.Applications.NotificationEventListener";
internal IDictionary Style;
internal IDictionary Extender;
internal Interop.NotificationEventListener.NotificationSafeHandle Handle;
///
/// Initializes a new instance of the class.
///
public NotificationEventArgs()
{
Style = new Dictionary();
Extender = new Dictionary();
}
///
/// Gets the unique id of Notification.
///
public int UniqueNumber { get; internal set; }
///
/// Gets the appId of Notification.
///
public string AppID { get; internal set; }
///
/// Gets the title of Notification.
///
public string Title { get; internal set; }
///
/// Gets the content text of Notification.
///
public string Content { get; internal set; }
///
/// Gets the icon's path of Notification.
///
public string Icon { get; internal set; }
///
/// Gets the sub icon path of Notification.
///
public string SubIcon { get; internal set; }
///
/// Gets the Timestamp of notification is visible or not.
///
public bool IsTimeStampVisible { get; internal set; }
///
/// Gets TimeStamp of Notification.
///
///
/// If IsTimeStampVisible property is set false, this TimeStamp property is meanless.
///
public DateTime TimeStamp { get; internal set; }
///
/// Gets the count which is displayed at the right side of notification.
///
public int Count { get; internal set; }
///
/// Gets the Tag of notification.
///
public string Tag { get; internal set; }
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsOngoing { get; internal set; } = false;
///
/// Gets a value that determines whether notification is displayed on the default viewer.
/// If IsDisplay property set false and add style, you can see only style notification.
///
public bool IsDisplay { get; internal set; } = true;
[EditorBrowsable(EditorBrowsableState.Never)]
public bool HasEventFlag { get; internal set; } = false;
///
/// Gets the AppControl which is invoked when notification is clicked.
///
public AppControl Action { get; internal set; }
///
/// Gets the object of the progress notification.
///
public ProgressArgs Progress { get; internal set; }
///
/// Gets the AccessoryArgs which has option of Sound, Vibration, LED.
///
public AccessoryArgs Accessory { get; internal set; }
///
/// Gets the key for extender.
///
public ICollection ExtenderKey
{
get
{
return Extender.Keys;
}
}
///
/// Gets the property.
///
public NotificationProperty Property { get; internal set; }
///
/// Gets the styleArgs of active, lock, indicator, bigpicture.
///
/// Type of notification style to be queried
/// The NotificationEventListener.StyleArgs object associated with the given style
/// Thrown when argument is invalid
public T GetStyle() where T : StyleArgs, new()
{
T type = new T();
StyleArgs style = null;
Style.TryGetValue(type.Key, out style);
if (style == null)
{
Log.Error(LogTag, "Invalid Style");
throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
}
else
{
return style as T;
}
}
///
/// Gets the ExtenderArgs.
///
/// The key that specifies which extender
/// Returns the bundle for key
public Bundle GetExtender(string key)
{
Bundle bundle;
if (string.IsNullOrEmpty(key))
{
throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
}
if (Extender.TryGetValue(key, out bundle) == false)
{
throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered : " + key);
}
return bundle;
}
}
}