Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Notification] Add extension style #6585

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Tizen.Applications.Notification/Interop/Interop.Notification.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ internal static class Notification
[DllImport(Libraries.Notification, EntryPoint = "notification_get_pairing_type")]
internal static extern NotificationError GetPairingType(NotificationSafeHandle handle, out bool pairing);


[DllImport(Libraries.Notification, EntryPoint = "notification_set_extension_image_size")]
internal static extern NotificationError SetExtensionImageSize(NotificationSafeHandle handle, int height);

[DllImport(Libraries.Notification, EntryPoint = "notification_get_extension_image_size")]
internal static extern NotificationError GetExtensionImageSize(NotificationSafeHandle handle, out int height);

internal static NotificationError GetText(NotificationSafeHandle handle, NotificationText type, out string text)
{
NotificationError ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ public int Count
[EditorBrowsable(EditorBrowsableState.Never)]
public bool PairingType { get; set; } = false;

[EditorBrowsable(EditorBrowsableState.Never)]
public string GroupTitle { get; set; } = string.Empty;

[EditorBrowsable(EditorBrowsableState.Never)]
public string GroupContent { get; set; } = string.Empty;

/// <summary>
/// Gets or sets NotificationSafeHandle.
/// </summary>
Expand Down Expand Up @@ -542,6 +548,7 @@ internal Notification Build()
IndicatorBinder.BindSafeHandle(this);
ActiveBinder.BindSafeHandle(this);
LockBinder.BindSafehandle(this);
ExtensionBinder.BindSafehandle(this);

return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ActiveStyle()
/// IsAutoRemove option lets the active notification to be removed several seconds after it shows.
/// When 'IsAutoRemove' is set as false, the active notification will not be removed as long as the user removes
/// it or the application, which posted the active notification.
/// </remarks>>
/// </remarks>
/// <since_tizen> 3 </since_tizen>
public bool IsAutoRemove { get; set; } = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ private static void BindNotificationText(Notification notification)
Interop.Notification.SetImage(notification.Handle, NotificationImage.Icon, notification.Icon);
Interop.Notification.SetImage(notification.Handle, NotificationImage.SubIcon, notification.SubIcon);
Interop.Notification.SetText(notification.Handle, NotificationText.EventCount, notification.Count.ToString(), null, -1);

if (string.IsNullOrEmpty(notification.GroupTitle) == false) {
Interop.Notification.SetText(notification.Handle, NotificationText.GroupTitle, notification.GroupTitle, null, -1);
}

if (string.IsNullOrEmpty(notification.GroupContent) == false) {
Interop.Notification.SetText(notification.Handle, NotificationText.GroupContent, notification.GroupContent, null, -1);
}
}

private static void BindNotificationTime(Notification notification)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ internal enum NotificationEventType
SecondButton,
ThirdButton,
ClickOnIcon = 6,
ClockOnThumbnail = 7,
ClickOnThumbnail = 7,
ClickOnTextInputButton = 8,
HiddenByUser = 100,
HiddenByTimeout = 101,
Expand All @@ -184,6 +184,8 @@ internal enum NotificationText
FirstSubText,
SecondMainText,
SecondSubText,
GroupTitle = 10,
GroupContent = 11,
FirstButton = 13,
SeceondButton = 14,
ThirdButton = 15,
Expand All @@ -204,6 +206,7 @@ internal enum NotificationImage
SecondButton,
ThirdButton,
TextInputButton = 18,
Extension = 19,
}

internal enum LaunchOption
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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.Notifications
{
using System.ComponentModel;

/// <summary>
/// This class contains common properties and methods of notifications.
/// </summary>
/// <remarks>
/// A notification is a message that is displayed on the notification area.
/// It is created to notify information to the user through the application.
/// This class helps you to provide method and property for creating notification object.
/// </remarks>
public sealed partial class Notification
{
/// <summary>
/// Class for generating extension style notification.
/// </summary>
/// <since_tizen> 14 </since_tizen>
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class ExtensionStyle : StyleBase
{
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsActive { get; set; }

[EditorBrowsable(EditorBrowsableState.Never)]
public string ExtensionImagePath { get; set; }

[EditorBrowsable(EditorBrowsableState.Never)]
public int ExtensionImageSize { get; set; }

[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsThumbnail { get; set; } = false;

[EditorBrowsable(EditorBrowsableState.Never)]
public string ThumbnailImagePath { get; set; }

[EditorBrowsable(EditorBrowsableState.Never)]
public AppControl ThumbnailAction { get; set; }

/// <summary>
/// Gets the key of Extension.
/// </summary>
internal override string Key
{
get
{
return "Extension";
}
}

internal override void Make(Notification notification)
{
ExtensionBinder.BindObject(notification);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public enum NotificationResponseEventType
/// </summary>
ClickOnButton3,

/// <summary>
/// Event type : Click on thumbnail.
/// </summary>
ClickOnThumbnail = 7,

/// <summary>
/// Event type : Click on text_input button.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,100 @@ internal static void BindSafehandle(Notification notification)
}
}
}

internal static class ExtensionBinder
{
internal static void BindObject(Notification notification)
{
int applist;
Notification.ExtensionStyle style = (Notification.ExtensionStyle)notification.GetStyle("Extension");
Interop.Notification.GetApplist(notification.Handle, out applist);

if (style.IsThumbnail) {
Interop.Notification.SetLayout(notification.Handle, NotificationLayout.Thumbnail);

if (string.IsNullOrEmpty(style.ThumbnailImagePath) == false) {
Interop.Notification.SetImage(notification.Handle, NotificationImage.Thumbnail, style.ThumbnailImagePath);
}

if (style.ThumbnailAction != null && style.ThumbnailAction.SafeAppControlHandle.IsInvalid == false)
{
Interop.Notification.SetEventHandler(notification.Handle, (int)NotificationEventType.ClickOnThumbnail, style.ThumbnailAction.SafeAppControlHandle);
}
} else {
Interop.Notification.SetLayout(notification.Handle, NotificationLayout.Extension);

if (string.IsNullOrEmpty(style.ExtensionImagePath) == false)
{
Interop.Notification.SetImage(notification.Handle, NotificationImage.Extension, style.ExtensionImagePath);
}
Interop.Notification.SetExtensionImageSize(notification.Handle, style.ExtensionImageSize);
}

if (style.IsActive)
{
applist |= (int)NotificationDisplayApplist.Active;
Interop.Notification.SetApplist(notification.Handle, applist);
}
}

internal static void BindSafehandle(Notification notification)
{
NotificationLayout layout;
bool isExisted = false;
SafeAppControlHandle appcontrol = null;
string path;
int appList;

Interop.Notification.GetLayout(notification.Handle, out layout);
Interop.Notification.GetApplist(notification.Handle, out appList);

Notification.ExtensionStyle style = new Notification.ExtensionStyle();
if (layout == NotificationLayout.Thumbnail)
{
appcontrol = null;
Interop.Notification.GetEventHandler(notification.Handle, (int)NotificationEventType.ClickOnThumbnail, out appcontrol);
if (appcontrol != null && appcontrol.IsInvalid == false)
{
style.ThumbnailAction = new AppControl(appcontrol);
}

Interop.Notification.GetImage(notification.Handle, NotificationImage.Thumbnail, out path);
if (string.IsNullOrEmpty(path) == false)
{
style.ThumbnailImagePath = path;
}
style.IsThumbnail = true;

if ((appList & (int)NotificationDisplayApplist.Active) == 0)
{
style.IsActive = true;
}

isExisted = true;
}
else if (layout == NotificationLayout.Extension)
{
int size = 0;
Interop.Notification.GetImage(notification.Handle, NotificationImage.Extension, out path);
if (string.IsNullOrEmpty(path) == false)
{
style.ExtensionImagePath = path;
}
Interop.Notification.GetExtensionImageSize(notification.Handle, out size);
style.ExtensionImageSize = size;
style.IsThumbnail = false;

if ((appList & (int)NotificationDisplayApplist.Active) == 0)
{
style.IsActive = true;
}

isExisted = true;
}

if (isExisted)
notification.AddStyle(style);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ internal enum ErrorCode
[DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_send_event")]
internal static extern ErrorCode SendEventWithNotification(NotificationSafeHandle handle, int evnetType);


[DllImport(Libraries.NotificationEventListener, EntryPoint = "notification_get_extension_image_size")]
internal static extern ErrorCode GetExtensionImageSize(NotificationSafeHandle handle, out int height);

internal static ErrorCode GetAppId(NotificationSafeHandle handle, out string appid)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ public NotificationEventArgs()
[EditorBrowsable(EditorBrowsableState.Never)]
public bool CheckedValue { get; internal set; } = false;

[EditorBrowsable(EditorBrowsableState.Never)]
public string GroupTitle { get; internal set; } = string.Empty;

[EditorBrowsable(EditorBrowsableState.Never)]
public string GroupContent { get; internal set; } = string.Empty;

/// <summary>
/// Gets the AppControl, which is invoked when notification is clicked.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ internal static NotificationEventArgs BindObject(IntPtr notification, bool data)
eventargs.SubIcon = text;
}

Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.GroupTitle, out text);
if (string.IsNullOrEmpty(text) == false)
{
eventargs.GroupTitle = text;
}

Interop.NotificationEventListener.GetText(eventargs.Handle, NotificationText.GroupContent, out text);
if (string.IsNullOrEmpty(text) == false)
{
eventargs.GroupContent = text;
}

err = Interop.NotificationEventListener.GetTime(eventargs.Handle, out time);
if (err != Interop.NotificationEventListener.ErrorCode.None)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ public enum UserEventType
/// </summary>
ClickOnButton3,

/// <summary>
/// Event type : Click on thumbnail.
/// </summary>
ClickOnThumbnail = 7,

/// <summary>
/// Event type : Click on text_input button.
/// </summary>
Expand Down Expand Up @@ -242,6 +247,16 @@ internal enum NotificationText
/// </summary>
SecondSubText,

/// <summary>
/// Group title
/// </summary>
GroupTitle = 10,

/// <summary>
/// Group contents
/// </summary>
GroupContent = 11,

/// <summary>
/// Text on button 1.
/// </summary>
Expand Down Expand Up @@ -327,6 +342,11 @@ internal enum NotificationImage
/// Image for message reply.
/// </summary>
TextInputButton = 18,

/// <summary>
/// Image for Extension.
/// </summary>
Extension = 19,
}

/// <summary>
Expand Down Expand Up @@ -358,6 +378,11 @@ internal enum NotificationLayout
/// Layout for ongoing notification. Used to display progress.
/// </summary>
OngoingProgress = 5,

/// <summary>
/// Layout for ongoing notification. Used to display progress.
/// </summary>
Extension = 6
}

/// <summary>
Expand Down
Loading
Loading