Skip to content

Commit 570cfad

Browse files
committed
Merge branch 'master' into brave
2 parents 7ebe3af + 3361779 commit 570cfad

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

src/AppVNext.Notifier.Common/ArgumentManager.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,19 @@ public static NotificationArguments ProcessArguments(string[] args)
304304
arguments.PushNotificationCheck = true;
305305
break;
306306

307+
//Attribution Text
308+
case "a":
309+
if (i + 1 < args.Length)
310+
{
311+
arguments.AttributionText = args[i + 1];
312+
skipLoop = 1;
313+
}
314+
else
315+
{
316+
arguments.Errors += Globals.HelpForAttributionText;
317+
}
318+
break;
319+
307320
//Clear Notifications
308321
case "v":
309322
case "version":
@@ -355,7 +368,7 @@ public static string NormalizeArgument(string argument)
355368

356369
public static void DisplayHelp()
357370
{
358-
WriteLine(Globals.HelpText);
371+
WriteLine(Globals.GetHelpText());
359372
}
360373
}
361374
}

src/AppVNext.Notifier.Common/Globals.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,18 @@ public static string GetDefaultIcon()
133133
public static readonly string HelpForRegisterFail =
134134
$"The application shortcut for '{{0}}' '{{1}}' already existed.{NewLine}";
135135

136+
public static readonly string HelpForAttributionText =
137+
$"Argument -a requires 1 value: <text string>.{NewLine}" +
138+
$"Example: -a \"Via SMS\"{NewLine}";
139+
136140
//Help text
137-
public static readonly string HelpText =
141+
public static string GetHelpText()
142+
{
143+
return
138144
$"Create a send notifications.{NewLine}{NewLine}" +
139145
$"Usage: notifier <command>{NewLine}{NewLine}" +
140146
$"Commands:{NewLine}{NewLine}" +
141-
(IsWindowsDesktopApp ?
147+
(IsWindowsDesktopApp ?
142148
$"[-r] <appId string><appName string> Registers notifier into the Windows machine.{NewLine}" : string.Empty) +
143149
$"[-t] <title string> Title is displayed on the first line of the notification.{NewLine}" +
144150
$"[-m] <message string> Message is displayed wrapped below the title of the notification.{NewLine}" +
@@ -152,18 +158,20 @@ public static string GetDefaultIcon()
152158
$"[-d] <short|long> Determines how long to display the notification for. Default is 'short'.{NewLine}" : string.Empty) +
153159
$"[-appID] <appID string> Used to display the notification.{NewLine}" +
154160
(IsUwpApp ?
155-
$"[-i] <ID string, Text string, Place Holder Text string> Display inputs.{NewLine}" : string.Empty) +
156-
(IsUwpApp ?
157-
$"[-b] <ID string, Text string> Display buttons.{NewLine}" : string.Empty) +
158-
(IsUwpApp ?
159161
$"[-l] <image URI> URI for a picture file to be displayed with the notification.{NewLine}" : string.Empty) +
160162
$"[-n] <appID string> Returns Notifications setting status for the application. Return values: Enabled, Disabled or Unknown.{NewLine}" +
161163
$"[-k] Returns Notifications setting status for the system. Return values: Enabled or Disabled.{NewLine}" +
164+
(IsUwpApp ?
165+
$"[-b] <ID string, Text string> Display buttons.{NewLine}" : string.Empty) +
166+
(IsUwpApp ?
167+
$"[-i] <ID string, Text string,{NewLine} Place Holder Text string> Display inputs.{NewLine}" : string.Empty) +
162168
$"[-close] <ID string> Closes notification. In order to be able to close a notification,{NewLine}" +
163169
$" the parameter -w must be used to create the notification.{NewLine}" +
170+
(IsUwpApp ?
171+
$"[-a] <text string> Attribution text is displayed at the bottom of the notification.{NewLine}" : string.Empty) +
164172
$"[-v] Displays version information.{NewLine}" +
165173
$"[-?] Displays this help.{NewLine}" +
166-
$"[-help] Displays this help.{NewLine}" +
174+
$"[-help] Displays this help.{NewLine}{NewLine}" +
167175
$"Exit Codes: Failed -1, Success 0, Close 1, Dismiss 2, Timeout 3.{NewLine}{NewLine}" +
168176
$"Examples:{NewLine}{NewLine}" +
169177
$"notifier -t \"Hello World!\"{NewLine}" +
@@ -173,5 +181,6 @@ public static string GetDefaultIcon()
173181
(IsUwpApp ?
174182
$"notifier register com.appvnext.windows-notifier appvnext-windows-notifier{NewLine}" : string.Empty) +
175183
$"{NewLine}";
184+
}
176185
}
177-
}
186+
}

src/AppVNext.Notifier.Common/NotificationArguments.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class NotificationArguments
3131
public string Image { get; set; }
3232
public bool ClearNotifications { get; set; }
3333
public bool VersionInformation { get; set; }
34+
public string AttributionText { get; set; }
3435

3536
/// <summary>
3637
/// Check if the arguments are valid or not.

src/AppVNext.Notifier.ConsoleUwp/Notifier.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ public static async Task<ToastNotification> ShowToast(NotificationArguments argu
4343
}
4444
}
4545
};
46-
46+
47+
//Set the attribution text
48+
if (!string.IsNullOrWhiteSpace(arguments.AttributionText))
49+
{
50+
visual.BindingGeneric.Attribution = new ToastGenericAttributionText()
51+
{
52+
Text = arguments.AttributionText
53+
};
54+
}
55+
4756
//Set the logo override
4857
var imagePath = Globals.GetImageOrDefault(arguments.PicturePath);
4958
var isInternetImage = IsInternetImage(imagePath);

src/AppVNext.Notifier.ConsoleUwp/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class Program
2525
/// <param name="args">Arguments for the notification.</param>
2626
static void Main(string[] args)
2727
{
28+
//Initialize application type. TODO: Replace this with dependency injection.
29+
Globals.ApplicationType = ApplicationTypes.UwpConsole;
30+
2831
// Register AUMID, COM server, and activator
2932
DesktopNotificationManagerCompat.RegisterAumidAndComServer<NotifierActivator>("BraveAdsNotifier");
3033
DesktopNotificationManagerCompat.RegisterActivator<NotifierActivator>();
@@ -36,9 +39,6 @@ static void Main(string[] args)
3639
}
3740
else
3841
{
39-
//Initialize application type. TODO: Replace this with dependency injection.
40-
Globals.ApplicationType = ApplicationTypes.UwpConsole;
41-
4242
var arguments = ArgumentManager.ProcessArguments(args);
4343

4444
if (arguments == null)

0 commit comments

Comments
 (0)