From 5addafc66c1a8e4538572071b302a3d0a40c081c Mon Sep 17 00:00:00 2001 From: Gerardo Melendrez Date: Tue, 14 Aug 2018 23:16:26 -0700 Subject: [PATCH 1/3] Added argument -a for Attribution Text. --- src/AppVNext.Notifier.Common/ArgumentManager.cs | 13 +++++++++++++ src/AppVNext.Notifier.Common/Globals.cs | 6 ++++++ .../NotificationArguments.cs | 1 + src/AppVNext.Notifier.ConsoleUwp/Notifier.cs | 11 ++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/AppVNext.Notifier.Common/ArgumentManager.cs b/src/AppVNext.Notifier.Common/ArgumentManager.cs index 87389dc..c684c76 100644 --- a/src/AppVNext.Notifier.Common/ArgumentManager.cs +++ b/src/AppVNext.Notifier.Common/ArgumentManager.cs @@ -304,6 +304,19 @@ public static NotificationArguments ProcessArguments(string[] args) arguments.PushNotificationCheck = true; break; + //Attribution Text + case "a": + if (i + 1 < args.Length) + { + arguments.AttributionText = args[i + 1]; + skipLoop = 1; + } + else + { + arguments.Errors += Globals.HelpForAttributionText; + } + break; + //Clear Notifications case "v": case "version": diff --git a/src/AppVNext.Notifier.Common/Globals.cs b/src/AppVNext.Notifier.Common/Globals.cs index 44d14a9..70a4481 100644 --- a/src/AppVNext.Notifier.Common/Globals.cs +++ b/src/AppVNext.Notifier.Common/Globals.cs @@ -133,6 +133,10 @@ public static string GetDefaultIcon() public static readonly string HelpForRegisterFail = $"The application shortcut for '{{0}}' '{{1}}' already existed.{NewLine}"; + public static readonly string HelpForAttributionText = + $"Argument -a requires 1 value: .{NewLine}" + + $"Example: -a \"Via SMS\"{NewLine}"; + //Help text public static readonly string HelpText = $"Create a send notifications.{NewLine}{NewLine}" + @@ -161,6 +165,8 @@ public static string GetDefaultIcon() $"[-k] Returns Notifications setting status for the system. Return values: Enabled or Disabled.{NewLine}" + $"[-close] Closes notification. In order to be able to close a notification,{NewLine}" + $" the parameter -w must be used to create the notification.{NewLine}" + + (IsUwpApp ? + $"[-a] Attribution text is displayed at the bottom of the notification.{NewLine}" : string.Empty) + $"[-v] Displays version information.{NewLine}" + $"[-?] Displays this help.{NewLine}" + $"[-help] Displays this help.{NewLine}" + diff --git a/src/AppVNext.Notifier.Common/NotificationArguments.cs b/src/AppVNext.Notifier.Common/NotificationArguments.cs index 3d916ad..5e17d0e 100644 --- a/src/AppVNext.Notifier.Common/NotificationArguments.cs +++ b/src/AppVNext.Notifier.Common/NotificationArguments.cs @@ -31,6 +31,7 @@ public class NotificationArguments public string Image { get; set; } public bool ClearNotifications { get; set; } public bool VersionInformation { get; set; } + public string AttributionText { get; set; } /// /// Check if the arguments are valid or not. diff --git a/src/AppVNext.Notifier.ConsoleUwp/Notifier.cs b/src/AppVNext.Notifier.ConsoleUwp/Notifier.cs index 59ceda3..d5cafec 100644 --- a/src/AppVNext.Notifier.ConsoleUwp/Notifier.cs +++ b/src/AppVNext.Notifier.ConsoleUwp/Notifier.cs @@ -43,7 +43,16 @@ public static async Task ShowToast(NotificationArguments argu } } }; - + + //Set the attribution text + if (!string.IsNullOrWhiteSpace(arguments.AttributionText)) + { + visual.BindingGeneric.Attribution = new ToastGenericAttributionText() + { + Text = arguments.AttributionText + }; + } + //Set the logo override var imagePath = Globals.GetImageOrDefault(arguments.PicturePath); var isInternetImage = IsInternetImage(imagePath); From fe1c8ce4ea12e08a869ed09376fbe6376eac432b Mon Sep 17 00:00:00 2001 From: Gerardo Melendrez Date: Tue, 14 Aug 2018 23:28:49 -0700 Subject: [PATCH 2/3] Changed HelpText to GetHelpMethod to fix issue where argument help wasn't being displayed properly. Aligned help better. --- .../ArgumentManager.cs | 2 +- src/AppVNext.Notifier.Common/Globals.cs | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/AppVNext.Notifier.Common/ArgumentManager.cs b/src/AppVNext.Notifier.Common/ArgumentManager.cs index c684c76..b11d14a 100644 --- a/src/AppVNext.Notifier.Common/ArgumentManager.cs +++ b/src/AppVNext.Notifier.Common/ArgumentManager.cs @@ -368,7 +368,7 @@ public static string NormalizeArgument(string argument) public static void DisplayHelp() { - WriteLine(Globals.HelpText); + WriteLine(Globals.GetHelpText()); } } } diff --git a/src/AppVNext.Notifier.Common/Globals.cs b/src/AppVNext.Notifier.Common/Globals.cs index 70a4481..8273de1 100644 --- a/src/AppVNext.Notifier.Common/Globals.cs +++ b/src/AppVNext.Notifier.Common/Globals.cs @@ -138,11 +138,13 @@ public static string GetDefaultIcon() $"Example: -a \"Via SMS\"{NewLine}"; //Help text - public static readonly string HelpText = + public static string GetHelpText() + { + return $"Create a send notifications.{NewLine}{NewLine}" + $"Usage: notifier {NewLine}{NewLine}" + $"Commands:{NewLine}{NewLine}" + - (IsWindowsDesktopApp ? + (IsWindowsDesktopApp ? $"[-r] Registers notifier into the Windows machine.{NewLine}" : string.Empty) + $"[-t] Title is displayed on the first line of the notification.{NewLine}" + $"[-m] <message string> Message is displayed wrapped below the title of the notification.{NewLine}" + @@ -156,20 +158,20 @@ public static string GetDefaultIcon() $"[-d] <short|long> Determines how long to display the notification for. Default is 'short'.{NewLine}" : string.Empty) + $"[-appID] <appID string> Used to display the notification.{NewLine}" + (IsUwpApp ? - $"[-i] <ID string, Text string, Place Holder Text string> Display inputs.{NewLine}" : string.Empty) + - (IsUwpApp ? - $"[-b] <ID string, Text string> Display buttons.{NewLine}" : string.Empty) + - (IsUwpApp ? $"[-l] <image URI> URI for a picture file to be displayed with the notification.{NewLine}" : string.Empty) + $"[-n] <appID string> Returns Notifications setting status for the application. Return values: Enabled, Disabled or Unknown.{NewLine}" + $"[-k] Returns Notifications setting status for the system. Return values: Enabled or Disabled.{NewLine}" + + (IsUwpApp ? + $"[-b] <ID string, Text string> Display buttons.{NewLine}" : string.Empty) + + (IsUwpApp ? + $"[-i] <ID string, Text string,{NewLine} Place Holder Text string> Display inputs.{NewLine}" : string.Empty) + $"[-close] <ID string> Closes notification. In order to be able to close a notification,{NewLine}" + $" the parameter -w must be used to create the notification.{NewLine}" + (IsUwpApp ? $"[-a] <text string> Attribution text is displayed at the bottom of the notification.{NewLine}" : string.Empty) + $"[-v] Displays version information.{NewLine}" + $"[-?] Displays this help.{NewLine}" + - $"[-help] Displays this help.{NewLine}" + + $"[-help] Displays this help.{NewLine}{NewLine}" + $"Exit Codes: Failed -1, Success 0, Close 1, Dismiss 2, Timeout 3.{NewLine}{NewLine}" + $"Examples:{NewLine}{NewLine}" + $"notifier -t \"Hello World!\"{NewLine}" + @@ -179,5 +181,6 @@ public static string GetDefaultIcon() (IsUwpApp ? $"notifier register com.appvnext.windows-notifier appvnext-windows-notifier{NewLine}" : string.Empty) + $"{NewLine}"; + } } -} +} \ No newline at end of file From 33617791728b892e227e3066254a585cb3a4ac1b Mon Sep 17 00:00:00 2001 From: Gerardo Melendrez <payini@hotmail.com> Date: Tue, 14 Aug 2018 23:29:00 -0700 Subject: [PATCH 3/3] Moved initialization. --- src/AppVNext.Notifier.ConsoleUwp/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AppVNext.Notifier.ConsoleUwp/Program.cs b/src/AppVNext.Notifier.ConsoleUwp/Program.cs index d9b22a8..68ae748 100644 --- a/src/AppVNext.Notifier.ConsoleUwp/Program.cs +++ b/src/AppVNext.Notifier.ConsoleUwp/Program.cs @@ -25,6 +25,9 @@ class Program /// <param name="args">Arguments for the notification.</param> static void Main(string[] args) { + //Initialize application type. TODO: Replace this with dependency injection. + Globals.ApplicationType = ApplicationTypes.UwpConsole; + // Register AUMID, COM server, and activator DesktopNotificationManagerCompat.RegisterAumidAndComServer<NotifierActivator>("AppVNextNotifier"); DesktopNotificationManagerCompat.RegisterActivator<NotifierActivator>(); @@ -36,9 +39,6 @@ static void Main(string[] args) } else { - //Initialize application type. TODO: Replace this with dependency injection. - Globals.ApplicationType = ApplicationTypes.UwpConsole; - var arguments = ArgumentManager.ProcessArguments(args); if (arguments == null)