Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
6fcbb11
New Notifications code
andrewleader Aug 19, 2020
1518f28
Auto register!
andrewleader Aug 21, 2020
236d1e3
Works for Desktop Bridge!
andrewleader Aug 21, 2020
568601b
Styling fixes
andrewleader Aug 21, 2020
9729eca
Icon from EXE works!
andrewleader Aug 21, 2020
6b64b85
Switch to using icon
andrewleader Aug 21, 2020
f385bb3
Fix compile error
andrewleader Aug 21, 2020
d499165
Include icon in sample app
andrewleader Aug 21, 2020
1f770c1
High quality images
andrewleader Aug 21, 2020
3800284
Switch to ToastCompat
andrewleader Aug 28, 2020
4363829
Use Compat API
andrewleader Aug 28, 2020
84b9bf3
Also check EXE path
andrewleader Aug 29, 2020
1f0bc00
Sample app update
andrewleader Aug 29, 2020
55a4332
First use AssemblyTitle for app name
andrewleader Aug 29, 2020
b8917c6
Disable Win32 apps from release
andrewleader Aug 29, 2020
dc1587c
Add uninstall method
andrewleader Aug 31, 2020
aaba4e0
Disable uninstall when under MSIX
andrewleader Aug 31, 2020
b62c968
Enable building of WPF sample app
andrewleader Sep 1, 2020
d7cf313
Merge branch 'master' into aleader/notifications-registry
andrewleader Sep 1, 2020
efcf30e
Hide InternalNotificationActivator
andrewleader Sep 1, 2020
1bfe408
Remove unnecessary usings
andrewleader Sep 1, 2020
a65c9cc
Build fixes and cleanup
andrewleader Sep 1, 2020
252bbc0
Fix sln.
azchohfi Sep 2, 2020
bb5b042
Avoid double registration
andrewleader Sep 2, 2020
2463bbd
Sparse signed package support
andrewleader Sep 3, 2020
3c37592
Simplified Show and Schedule methods
andrewleader Sep 3, 2020
9f084ff
Add tests for new builder
andrewleader Sep 3, 2020
9e1f362
Merge branch 'master' into aleader/notifications-registry
andrewleader Sep 3, 2020
0cc87d1
Update sample app samples
andrewleader Sep 3, 2020
644f307
Merge branch 'master' into aleader/notifications-registry
azchohfi Sep 3, 2020
c87a371
Fix ToastCode.bind
andrewleader Sep 3, 2020
a57ba76
Merge branch 'aleader/notifications-registry' of https://github.com/w…
andrewleader Sep 3, 2020
0b65a73
Merge branch 'master' into aleader/notifications-registry
andrewleader Sep 24, 2020
28e7730
Use shortcut
andrewleader Oct 2, 2020
5a8d9b3
Refactoring to Win32AppInfo
andrewleader Oct 2, 2020
04a7e71
Refactor into ManifestHelper
andrewleader Oct 2, 2020
389c6e1
Merge branch 'master' into aleader/notifications-registry
andrewleader Oct 5, 2020
e8cd6f0
ToastContentBuilder support for C++ UWP apps
andrewleader Oct 9, 2020
1b0c403
Catch exception on initialization to avoid crashing entire app
andrewleader Oct 13, 2020
8876688
Merge branch 'master' into aleader/notifications-registry
Rosuavio Oct 15, 2020
0288c06
Merge branch 'master' into aleader/notifications-registry
michael-hawker Oct 22, 2020
62bc118
Merge branch 'master' into aleader/notifications-registry
andrewleader Oct 29, 2020
e94afd0
Update icon
andrewleader Oct 29, 2020
8b696d4
Added ToastArguments
andrewleader Oct 29, 2020
1e45495
NIT fix
andrewleader Oct 29, 2020
bf2139d
Added enum and int helpers
andrewleader Oct 29, 2020
634478d
Tests and fixes for ToastArguments
andrewleader Oct 30, 2020
e8f8d70
Update toast samples to use ToastArguments
andrewleader Oct 30, 2020
02ff3a8
Fixed bug in TileBuilder small tile content
andrewleader Oct 30, 2020
3d96ba1
Merge branch 'master' into aleader/notifications-registry
andrewleader Oct 30, 2020
8956b81
Add headers
andrewleader Oct 30, 2020
f1a3f02
Update qmatteoq license
andrewleader Nov 4, 2020
f9045de
Simplified generic toast arguments
andrewleader Nov 5, 2020
305dd6f
Merge branch 'master' into aleader/notifications-registry
andrewleader Nov 5, 2020
89ed383
Add back top level action type in samples
andrewleader Nov 6, 2020
5c8fc1b
ToastButton builders
andrewleader Nov 7, 2020
8efdf17
Merge branch 'master' into aleader/notifications-registry
andrewleader Nov 7, 2020
0f1bdb4
Added missing header
andrewleader Nov 7, 2020
3b5dfa7
Merge branch 'master' into aleader/notifications-registry
michael-hawker Nov 9, 2020
aa6e892
Merge branch 'master' into aleader/notifications-registry
Kyaa-dost Nov 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace Microsoft.Toolkit.Uwp.Notifications
/// </summary>
public sealed class AdaptiveProgressBarValue
{
/// <summary>
/// Gets or sets the property name to bind to.
/// </summary>
public string BindingName { get; set; }

/// <summary>
/// Gets or sets the value (0-1) representing the percent complete.
/// </summary>
Expand All @@ -35,6 +40,11 @@ internal string ToXmlString()
return "indeterminate";
}

if (BindingName != null)
{
return "{" + BindingName + "}";
}

return Value.ToString();
}

Expand Down Expand Up @@ -69,5 +79,18 @@ public static AdaptiveProgressBarValue FromValue(double d)
Value = d
};
}

/// <summary>
/// Returns a progress bar value using the specified binding name.
/// </summary>
/// <param name="bindingName">The property to bind to.</param>
/// <returns>A progress bar value.</returns>
public static AdaptiveProgressBarValue FromBinding(string bindingName)
{
return new AdaptiveProgressBarValue()
{
BindingName = bindingName
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,17 @@
</ItemGroup>
<PropertyGroup>
<!--Define the WINDOWS_UWP conditional symbol, since the Windows.Data.Xml and the Windows.UI.Notification namespaces are available-->
<DefineConstants>$(DefineConstants);WINDOWS_UWP</DefineConstants>
<DefineConstants>$(DefineConstants);WINDOWS_UWP;WIN32</DefineConstants>
</PropertyGroup>
</When>

<!--Non-desktop apps (UWP, libraries, ASP.NET servers)-->
<Otherwise>
<ItemGroup>
<!--Remove the DesktopNotificationManager code-->
<Compile Remove="DesktopNotificationManager\**\*" />
</ItemGroup>
</Otherwise>

</Choose>

<!--NET Core desktop apps also need the Registry NuGet package-->
<!--NET Core desktop apps also need the Registry NuGet package and System.Reflection.Emit for generating COM class dynamically-->
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, didn't see .NET 5 previews coming for this reflection package??

<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'native' ">
Expand Down
8 changes: 4 additions & 4 deletions Microsoft.Toolkit.Uwp.Notifications/Tiles/TileCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ public enum TileSize
/// <summary>
/// Small Square Tile
/// </summary>
Small = 0,
Small = 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess we'll want to document this as a breaking change too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah true that technically could be a breaking change


/// <summary>
/// Medium Square Tile
/// </summary>
Medium = 1,
Medium = 2,

/// <summary>
/// Wide Rectangle Tile
/// </summary>
Wide = 2,
Wide = 4,

/// <summary>
/// Large Square Tile
/// </summary>
Large = 4
Large = 8
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if WINDOWS_UWP

using Windows.Foundation;
using Windows.UI.Notifications;

namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Allows you to set additional properties on the <see cref="ToastNotification"/> object before the toast is displayed.
/// </summary>
/// <param name="toast">The toast to modify that will be displayed.</param>
public delegate void CustomizeToast(ToastNotification toast);

/// <summary>
/// Allows you to set additional properties on the <see cref="ToastNotification"/> object before the toast is displayed.
/// </summary>
/// <param name="toast">The toast to modify that will be displayed.</param>
/// <returns>An operation.</returns>
public delegate IAsyncAction CustomizeToastAsync(ToastNotification toast);

/// <summary>
/// Allows you to set additional properties on the <see cref="ScheduledToastNotification"/> object before the toast is scheduled.
/// </summary>
/// <param name="toast">The scheduled toast to modify that will be scheduled.</param>
public delegate void CustomizeScheduledToast(ScheduledToastNotification toast);

/// <summary>
/// Allows you to set additional properties on the <see cref="ScheduledToastNotification"/> object before the toast is scheduled.
/// </summary>
/// <param name="toast">The scheduled toast to modify that will be scheduled.</param>
/// <returns>An operation.</returns>
public delegate IAsyncAction CustomizeScheduledToastAsync(ScheduledToastNotification toast);
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

namespace Microsoft.Toolkit.Uwp.Notifications
{
#if !WINRT
#pragma warning disable SA1008
#pragma warning disable SA1009
/// <summary>
/// Builder class used to create <see cref="ToastContent"/>
/// </summary>
public partial class ToastContentBuilder
public
#if WINRT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you're using both WINRT and WINDOWS_UWP, just curious what the difference is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WINDOWS_UWP refers to whether the Windows 10 APIs are available (.NET Standard has that disabled, but all the rest have that enabled).

WINRT refers to whether it's compiled as a Windows Runtime Component (the format that allows C++ UWP apps to consume the APIs).

sealed
#endif
partial class ToastContentBuilder
{
private IToastActions Actions
{
Expand Down Expand Up @@ -45,6 +48,36 @@ private IList<IToastInput> InputList
}
}

private string SerializeArgumentsIncludingGeneric(ToastArguments arguments)
{
if (_genericArguments.Count == 0)
{
return arguments.ToString();
}

foreach (var genericArg in _genericArguments)
{
if (!arguments.Contains(genericArg.Key))
{
arguments.Add(genericArg.Key, genericArg.Value);
}
}

return arguments.ToString();
}

/// <summary>
/// Add a button to the current toast.
/// </summary>
/// <param name="content">Text to display on the button.</param>
/// <param name="activationType">Type of activation this button will use when clicked. Defaults to Foreground.</param>
/// <param name="arguments">App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.</param>
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddButton(string content, ToastActivationType activationType, string arguments)
{
return AddButton(content, activationType, arguments, default);
}

/// <summary>
/// Add a button to the current toast.
/// </summary>
Expand All @@ -53,15 +86,18 @@ private IList<IToastInput> InputList
/// <param name="arguments">App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.</param>
/// <param name="imageUri">Optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).</param>
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddButton(string content, ToastActivationType activationType, string arguments, Uri imageUri = default(Uri))
#if WINRT
[Windows.Foundation.Metadata.DefaultOverload]
#endif
public ToastContentBuilder AddButton(string content, ToastActivationType activationType, string arguments, Uri imageUri)
{
// Add new button
ToastButton button = new ToastButton(content, arguments)
{
ActivationType = activationType
};

if (imageUri != default(Uri))
if (imageUri != default)
{
button.ImageUri = imageUri.OriginalString;
}
Expand All @@ -76,17 +112,46 @@ private IList<IToastInput> InputList
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddButton(IToastButton button)
{
if (button is ToastButton toastButton && toastButton.Content == null)
{
throw new InvalidOperationException("Content is required on button.");
}

// List has max 5 buttons
if (ButtonList.Count == 5)
{
throw new InvalidOperationException("A toast can't have more than 5 buttons");
}

if (button is ToastButton b && b.CanAddArguments())
{
foreach (var arg in _genericArguments)
{
if (!b.ContainsArgument(arg.Key))
{
b.AddArgument(arg.Key, arg.Value);
}
}
}

ButtonList.Add(button);

return this;
}

/// <summary>
/// Add an button to the toast that will be display to the right of the input text box, achieving a quick reply scenario.
/// </summary>
/// <param name="textBoxId">ID of an existing <see cref="ToastTextBox"/> in order to have this button display to the right of the input, achieving a quick reply scenario.</param>
/// <param name="content">Text to display on the button.</param>
/// <param name="activationType">Type of activation this button will use when clicked. Defaults to Foreground.</param>
/// <param name="arguments">App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.</param>
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddButton(string textBoxId, string content, ToastActivationType activationType, string arguments)
{
return AddButton(textBoxId, content, activationType, arguments, default);
}

/// <summary>
/// Add an button to the toast that will be display to the right of the input text box, achieving a quick reply scenario.
/// </summary>
Expand All @@ -96,7 +161,7 @@ public ToastContentBuilder AddButton(IToastButton button)
/// <param name="arguments">App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.</param>
/// <param name="imageUri">An optional image icon for the button to display (required for buttons adjacent to inputs like quick reply)</param>
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddButton(string textBoxId, string content, ToastActivationType activationType, string arguments, Uri imageUri = default(Uri))
public ToastContentBuilder AddButton(string textBoxId, string content, ToastActivationType activationType, string arguments, Uri imageUri)
{
// Add new button
ToastButton button = new ToastButton(content, arguments)
Expand All @@ -105,38 +170,70 @@ public ToastContentBuilder AddButton(IToastButton button)
TextBoxId = textBoxId
};

if (imageUri != default(Uri))
if (imageUri != default)
{
button.ImageUri = imageUri.OriginalString;
}

return AddButton(button);
}

#if WINRT
/// <summary>
/// Add an input text box that the user can type into.
/// </summary>
/// <param name="id">Required ID property so that developers can retrieve user input once the app is activated.</param>
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddInputTextBox(string id)
{
return AddInputTextBox(id, default, default);
}

/// <summary>
/// Add an input text box that the user can type into.
/// </summary>
/// <param name="id">Required ID property so that developers can retrieve user input once the app is activated.</param>
/// <param name="placeHolderContent">Placeholder text to be displayed on the text box when the user hasn't typed any text yet.</param>
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddInputTextBox(string id, string placeHolderContent)
{
return AddInputTextBox(id, placeHolderContent, default);
}
#endif

/// <summary>
/// Add an input text box that the user can type into.
/// </summary>
/// <param name="id">Required ID property so that developers can retrieve user input once the app is activated.</param>
/// <param name="placeHolderContent">Placeholder text to be displayed on the text box when the user hasn't typed any text yet.</param>
/// <param name="title">Title text to display above the text box.</param>
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddInputTextBox(string id, string placeHolderContent = default(string), string title = default(string))
public ToastContentBuilder AddInputTextBox(
string id,
#if WINRT
string placeHolderContent,
string title)
#else
string placeHolderContent = default,
string title = default)
#endif
{
var inputTextBox = new ToastTextBox(id);

if (placeHolderContent != default(string))
if (placeHolderContent != default)
{
inputTextBox.PlaceholderContent = placeHolderContent;
}

if (title != default(string))
if (title != default)
{
inputTextBox.Title = title;
}

return AddToastInput(inputTextBox);
}

#if !WINRT
/// <summary>
/// Add a combo box / drop-down menu that contain options for user to select.
/// </summary>
Expand All @@ -145,7 +242,7 @@ public ToastContentBuilder AddButton(IToastButton button)
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddComboBox(string id, params (string comboBoxItemId, string comboBoxItemContent)[] choices)
{
return AddComboBox(id, default(string), choices);
return AddComboBox(id, default, choices);
}

/// <summary>
Expand All @@ -157,7 +254,7 @@ public ToastContentBuilder AddComboBox(string id, params (string comboBoxItemId,
/// <returns>The current instance of <see cref="ToastContentBuilder"/></returns>
public ToastContentBuilder AddComboBox(string id, string defaultSelectionBoxItemId, params (string comboBoxItemId, string comboBoxItemContent)[] choices)
{
return AddComboBox(id, default(string), defaultSelectionBoxItemId, choices);
return AddComboBox(id, default, defaultSelectionBoxItemId, choices);
}

/// <summary>
Expand Down Expand Up @@ -185,12 +282,12 @@ public ToastContentBuilder AddComboBox(string id, string title, string defaultSe
{
var box = new ToastSelectionBox(id);

if (defaultSelectionBoxItemId != default(string))
if (defaultSelectionBoxItemId != default)
{
box.DefaultSelectionBoxItemId = defaultSelectionBoxItemId;
}

if (title != default(string))
if (title != default)
{
box.Title = title;
}
Expand All @@ -203,6 +300,7 @@ public ToastContentBuilder AddComboBox(string id, string title, string defaultSe

return AddToastInput(box);
}
#endif

/// <summary>
/// Add an input option to the Toast.
Expand All @@ -218,5 +316,4 @@ public ToastContentBuilder AddToastInput(IToastInput input)
}
#pragma warning restore SA1008
#pragma warning restore SA1009
#endif
}
Loading