Skip to content

Commit

Permalink
Merge branch 'master' into brave
Browse files Browse the repository at this point in the history
  • Loading branch information
payini committed Aug 15, 2018
2 parents 7ebe3af + 3361779 commit 570cfad
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
15 changes: 14 additions & 1 deletion src/AppVNext.Notifier.Common/ArgumentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -355,7 +368,7 @@ public static string NormalizeArgument(string argument)

public static void DisplayHelp()
{
WriteLine(Globals.HelpText);
WriteLine(Globals.GetHelpText());
}
}
}
25 changes: 17 additions & 8 deletions src/AppVNext.Notifier.Common/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ 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: <text string>.{NewLine}" +
$"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 <command>{NewLine}{NewLine}" +
$"Commands:{NewLine}{NewLine}" +
(IsWindowsDesktopApp ?
(IsWindowsDesktopApp ?
$"[-r] <appId string><appName string> Registers notifier into the Windows machine.{NewLine}" : string.Empty) +
$"[-t] <title string> 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}" +
Expand All @@ -152,18 +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}" +
Expand All @@ -173,5 +181,6 @@ public static string GetDefaultIcon()
(IsUwpApp ?
$"notifier register com.appvnext.windows-notifier appvnext-windows-notifier{NewLine}" : string.Empty) +
$"{NewLine}";
}
}
}
}
1 change: 1 addition & 0 deletions src/AppVNext.Notifier.Common/NotificationArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

/// <summary>
/// Check if the arguments are valid or not.
Expand Down
11 changes: 10 additions & 1 deletion src/AppVNext.Notifier.ConsoleUwp/Notifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ public static async Task<ToastNotification> 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);
Expand Down
6 changes: 3 additions & 3 deletions src/AppVNext.Notifier.ConsoleUwp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>("BraveAdsNotifier");
DesktopNotificationManagerCompat.RegisterActivator<NotifierActivator>();
Expand All @@ -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)
Expand Down

0 comments on commit 570cfad

Please sign in to comment.