-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved notification system, also need HUGE refactoring
- Loading branch information
DjArt
committed
Jul 27, 2019
1 parent
3470a38
commit cb15f3e
Showing
13 changed files
with
336 additions
and
174 deletions.
There are no files selected for viewing
Submodule Internal.Windows.Calls
updated
8 files
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
This file was deleted.
Oops, something went wrong.
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,49 @@ | ||
using Internal.Windows.Calls; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Windows.ApplicationModel.Background; | ||
using Windows.ApplicationModel.LockScreen; | ||
|
||
using Microsoft.Toolkit.Uwp.Notifications; | ||
using Windows.UI.Notifications; | ||
using Windows.ApplicationModel.Calls.Background; | ||
|
||
namespace WoADialer.Model | ||
{ | ||
public sealed class CallWaiter | ||
{ | ||
public event EventHandler<Call> CallAppeared; | ||
|
||
public CallWaiter() | ||
{ | ||
|
||
} | ||
|
||
private void CallManager_CallAppeared(CallManager sender, Call args) | ||
{ | ||
if (args.State == CallState.Incoming) | ||
{ | ||
CallAppeared?.Invoke(this, args); | ||
} | ||
} | ||
|
||
public void RegisterListener() | ||
{ | ||
MainEntities.CallManager.CallAppeared += CallManager_CallAppeared; | ||
Call call = MainEntities.CallManager.CurrentCalls.FirstOrDefault(x => x.State == CallState.Incoming); | ||
if (call?.State == CallState.Incoming) | ||
{ | ||
CallAppeared?.Invoke(this, call); | ||
} | ||
} | ||
|
||
public void UnregisterListener() | ||
{ | ||
MainEntities.CallManager.CallAppeared -= CallManager_CallAppeared; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
using Microsoft.Toolkit.Uwp.Notifications; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.ApplicationModel.Background; | ||
using Windows.UI.Notifications; | ||
using Windows.UI.Notifications.Management; | ||
|
||
namespace WoADialer.Background | ||
{ | ||
public sealed class NotificationShredder | ||
{ | ||
private const string WINDOWS_SYSTEM_TOAST_CALLING = "Windows.SystemToast.Calling"; | ||
|
||
public event EventHandler NotificationRemoved; | ||
|
||
public NotificationShredder() | ||
{ | ||
|
||
} | ||
|
||
public async void RegisterListener() | ||
{ | ||
UserNotificationListener.Current.NotificationChanged += Listener_NotificationChanged; | ||
IReadOnlyList<UserNotification> notifications = await UserNotificationListener.Current.GetNotificationsAsync(NotificationKinds.Toast); | ||
UserNotification callToast = notifications.FirstOrDefault(x => x.AppInfo.AppUserModelId == WINDOWS_SYSTEM_TOAST_CALLING); | ||
if (callToast != null) | ||
{ | ||
UserNotificationListener.Current.RemoveNotification(callToast.Id); | ||
NotificationRemoved?.Invoke(this, null); | ||
} | ||
} | ||
|
||
public void UnregisterListener() | ||
{ | ||
UserNotificationListener.Current.NotificationChanged -= Listener_NotificationChanged; | ||
} | ||
|
||
private void Listener_NotificationChanged(UserNotificationListener sender, UserNotificationChangedEventArgs args) | ||
{ | ||
if (args.ChangeKind == UserNotificationChangedKind.Added) | ||
{ | ||
UserNotification notification = sender.GetNotification(args.UserNotificationId); | ||
if (notification.AppInfo.AppUserModelId == WINDOWS_SYSTEM_TOAST_CALLING) | ||
{ | ||
sender.RemoveNotification(notification.Id); | ||
NotificationRemoved?.Invoke(this, null); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.