Skip to content

Commit

Permalink
feat(BadgeNotification): Support for Tizen
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Sep 6, 2021
1 parent b7237fd commit e5dc94f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/Uno.UI.Runtime.Skia.Tizen/TizenHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
using Uno.UI.Runtime.Skia.Tizen;
using Windows.Devices.Haptics;
using Uno.UI.Runtime.Skia.Tizen.Devices.Haptics;
using Uno.UI.Notifications;
using Uno.UI.Runtime.Skia.Tizen.UI.Notifications;
using Windows.System.Profile;
using Uno.UI.Runtime.Skia.Tizen.System.Profile;
using Windows.ApplicationModel;
Expand Down Expand Up @@ -90,6 +92,7 @@ public void Run()
ApiExtensibility.Register(typeof(IDisplayInformationExtension), o => new TizenDisplayInformationExtension(o, _tizenApplication.Window));
ApiExtensibility.Register(typeof(IVibrationDeviceExtension), o => new TizenVibrationDeviceExtension(o));
ApiExtensibility.Register(typeof(ISimpleHapticsControllerExtension), o => new TizenSimpleHapticsControllerExtension(o));
ApiExtensibility.Register(typeof(IBadgeUpdaterExtension), o => new TizenBadgeUpdaterExtension(o));
ApiExtensibility.Register(typeof(IAnalyticsInfoExtension), o => new TizenAnalyticsInfoExtension(o));
ApiExtensibility.Register(typeof(IPackageIdExtension), o => new TizenPackageIdExtension(o));
ApiExtensibility.Register(typeof(IDataTransferManagerExtension), o => new TizenDataTransferManagerExtension(o));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#nullable enable

using Tizen.Applications;
using Uno.UI.Notifications;

namespace Uno.UI.Runtime.Skia.Tizen.UI.Notifications
{
internal class TizenBadgeUpdaterExtension : IBadgeUpdaterExtension
{
public TizenBadgeUpdaterExtension(object owner)
{
}

public void SetBadge(string? value)
{
var appId = Application.Current.ApplicationInfo.ApplicationId;

var existingBadge = BadgeControl.Find(appId);
if (existingBadge != null || value == null || !int.TryParse(value, out var number))
{
BadgeControl.Remove(appId);
return;
}

if (value != null)
{
Badge badge = new Badge(appId, number);
BadgeControl.Add(badge);
}
}
}
}
18 changes: 10 additions & 8 deletions src/Uno.UWP/UI/Notifications/BadgeUpdater.skia.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Uno.Foundation.Extensibility;
using Uno.UI.Notifications;

namespace Windows.UI.Notifications
{
public partial class BadgeUpdater
public partial class BadgeUpdater
{
partial void SetBadge(string? value) =>
{
private IBadgeUpdaterExtension? _badgeUpdaterExtension;

partial void InitPlatform()
{
ApiExtensibility.CreateInstance(this, out _badgeUpdaterExtension);
}

partial void SetBadge(string? value) => _badgeUpdaterExtension?.SetBadge(value);
}
}
9 changes: 9 additions & 0 deletions src/Uno.UWP/UI/Notifications/IBadgeUpdaterExtension.skia.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#nullable enable

namespace Uno.UI.Notifications
{
public interface IBadgeUpdaterExtension
{
void SetBadge(string? value);
}
}

0 comments on commit e5dc94f

Please sign in to comment.