-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(BadgeNotification): Support for Tizen
- Loading branch information
1 parent
b7237fd
commit e5dc94f
Showing
4 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Uno.UI.Runtime.Skia.Tizen/UI/Notifications/TizenBadgeUpdaterExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |