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.Notifications
20 /// Class containing common properties and methods of Notifications
23 /// A notification is a message that is displayed on the notification area.
24 /// It is created to notify information to the user through the application.
25 /// This class helps you to provide method and property for creating notification object.
27 public sealed partial class Notification
30 /// Class for displaying direct-reply at notification.
31 /// You must set a ReplyMax and Button. Otherwise user can't send written text to application which is set by AppControl.
33 public sealed class ReplyAction : MakerBase
36 /// Gets or sets the Index of Button which is appeared at Notification.
37 /// If you set ParentIndex, ReplyAction is displayed when button matched with ParentIndex click by the user.
38 /// If you don't set ParentIndex, appeared to notification directly.
40 public ButtonIndex ParentIndex { get; set; } = ButtonIndex.None;
43 /// Gets or sets the PlaceHolderText of ReplyAction which is appeared at Notification.
44 /// If you set PlaceHolderText, it is displayed to placeholder in notification.
46 public string PlaceHolderText { get; set; }
49 /// Gets or sets the ReplyMax of ReplyAction which is appeared at Notification.
50 /// You must set a ReplyMax. Otherwise user don't write text to placeholder in notification.
53 /// Default value is 160.
55 public int ReplyMax { get; set; } = 160;
58 /// Gets or sets the Button which is appeared to ReplyAction in Notification.
59 /// You must set a Button. Otherwise user can't send written text to application which is set by AppControl.
62 /// If you set it to null, the already set ButtonAction will be removed.
66 /// ReplyAction button = new ReplyAction
68 /// ParentIndex = ButtonIndex.Second;
69 /// PlaceHolderText = "Please write your reply."
71 /// Button = new ButtonAction
74 /// ImagePath = "image path",
75 /// Action = new AppControl{ ApplicationId = "org.tizen.app" };
80 public ButtonAction Button { get; set; }
82 internal override void Make(Notification notification)
84 string replyKey = "__PARENT_INDEX__";
88 Interop.Notification.SetText(notification.Handle, NotificationText.InputButton, Button.Text, null, -1);
89 Interop.Notification.SetImage(notification.Handle, NotificationImage.TextInputButton, Button.ImagePath);
91 if (this.Button.Action != null && this.Button.Action.SafeAppControlHandle.IsInvalid == false)
93 Interop.Notification.SetEventHandler(notification.Handle, (int)NotificationEventType.ClickOnTextInputButton, this.Button.Action.SafeAppControlHandle);
95 if (this.ParentIndex != ButtonIndex.None)
97 Interop.Notification.SetEventHandler(notification.Handle, (int)this.ParentIndex, this.Button.Action.SafeAppControlHandle);
102 Bundle bundle = new Bundle();
103 bundle.AddItem(replyKey, ((int)this.ParentIndex).ToString());
104 Interop.Notification.SetExtentionData(notification.Handle, replyKey, bundle.SafeBundleHandle);
106 Interop.Notification.SetPlaceHolderLength(notification.Handle, this.ReplyMax);
107 Interop.Notification.SetText(notification.Handle, NotificationText.PlaceHolder, PlaceHolderText, null, -1);