1
1
using Flow . Launcher . Infrastructure ;
2
+ using Microsoft . Toolkit . Uwp . Notifications ;
2
3
using System ;
3
4
using System . IO ;
4
5
using Windows . Data . Xml . Dom ;
@@ -8,10 +9,17 @@ namespace Flow.Launcher
8
9
{
9
10
internal static class Notification
10
11
{
12
+ internal static bool legacy = Environment . OSVersion . Version . Build < 19041 ;
13
+ [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Interoperability" , "CA1416:Validate platform compatibility" , Justification = "<Pending>" ) ]
14
+ internal static void Uninstall ( )
15
+ {
16
+ if ( ! legacy )
17
+ ToastNotificationManagerCompat . Uninstall ( ) ;
18
+ }
19
+
11
20
[ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Interoperability" , "CA1416:Validate platform compatibility" , Justification = "<Pending>" ) ]
12
21
public static void Show ( string title , string subTitle , string iconPath )
13
22
{
14
- var legacy = Environment . OSVersion . Version . Build < 19041 ;
15
23
// Handle notification for win7/8/early win10
16
24
if ( legacy )
17
25
{
@@ -24,13 +32,11 @@ public static void Show(string title, string subTitle, string iconPath)
24
32
? Path . Combine ( Constant . ProgramDirectory , "Images\\ app.png" )
25
33
: iconPath ;
26
34
27
- var xml = $ "<?xml version=\" 1.0\" ?><toast><visual><binding template=\" ToastImageAndText04\" ><image id=\" 1\" src=\" { Icon } \" alt=\" meziantou\" /><text id=\" 1\" >{ title } </text>" +
28
- $ "<text id=\" 2\" >{ subTitle } </text></binding></visual></toast>";
29
- var toastXml = new XmlDocument ( ) ;
30
- toastXml . LoadXml ( xml ) ;
31
- var toast = new ToastNotification ( toastXml ) ;
32
- ToastNotificationManager . CreateToastNotifier ( "Flow Launcher" ) . Show ( toast ) ;
33
-
35
+ new ToastContentBuilder ( )
36
+ . AddText ( title , hintMaxLines : 1 )
37
+ . AddText ( subTitle )
38
+ . AddAppLogoOverride ( new Uri ( Icon ) )
39
+ . Show ( ) ;
34
40
}
35
41
36
42
private static void LegacyShow ( string title , string subTitle , string iconPath )
0 commit comments