Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interfaces for "Enhanced UX Notification for Video and Audio Call Feature" #4783

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
12 changes: 12 additions & 0 deletions dev/AppNotifications/AppNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,16 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
auto lock{ m_lock.lock_exclusive() };
m_notificationId = id;
}

winrt::Microsoft::Windows::AppNotifications::AppNotificationDevicesData AppNotification::DevicesData()
{
auto lock{ m_lock.lock_shared() };
return m_devicesData;
}

void AppNotification::DevicesData(winrt::Microsoft::Windows::AppNotifications::AppNotificationDevicesData const& devicesData)
{
auto lock{ m_lock.lock_exclusive() };
m_devicesData = devicesData;
}
}
5 changes: 5 additions & 0 deletions dev/AppNotifications/AppNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
// IAppNotificationInternal
void SetNotificationId(uint32_t id);

winrt::Microsoft::Windows::AppNotifications::AppNotificationDevicesData DevicesData();
void DevicesData(winrt::Microsoft::Windows::AppNotifications::AppNotificationDevicesData const& value);

private:
winrt::hstring m_tag{};
winrt::hstring m_group{};
Expand All @@ -49,6 +52,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
{ winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority::Default };
bool m_suppressDisplay{ false };
wil::srwlock m_lock;

winrt::Microsoft::Windows::AppNotifications::AppNotificationDevicesData m_devicesData{ nullptr };
};
}
namespace winrt::Microsoft::Windows::AppNotifications::factory_implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
Expand Down Expand Up @@ -376,14 +376,15 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
// Build the actions string and fill m_useButtonStyle
std::wstring actions{ GetActions() };

auto xmlResult{ wil::str_printf<std::wstring>(L"<toast%ls%ls%ls%ls%ls><visual><binding template='ToastGeneric'>%ls%ls%ls%ls</binding></visual>%ls%ls</toast>",
auto xmlResult{ wil::str_printf<std::wstring>(L"<toast%ls%ls%ls%ls%ls><visual><binding template='ToastGeneric'>%ls%ls%ls%ls%ls</binding></visual>%ls%ls</toast>",
m_timeStamp.c_str(),
GetDuration().c_str(),
GetScenario().c_str(),
GetArguments().c_str(),
GetButtonStyle().c_str(),
GetText().c_str(),
m_attributionText.c_str(),
GetCameraPreview().c_str(),
GetImages().c_str(),
GetProgressBars().c_str(),
m_audio.c_str(),
Expand All @@ -399,4 +400,17 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

return appNotification;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::AddCameraPreview()
{
THROW_HR_IF_MSG(E_INVALIDARG, m_useCameraPreview, "CameraPreview element is already added, only one is allowed");

m_useCameraPreview = true;
return *this;
}

std::wstring AppNotificationBuilder::GetCameraPreview()
{
return m_useCameraPreview ? L"<cameraPreview/>" : L"";
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#pragma once
Expand Down Expand Up @@ -65,6 +65,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

static bool IsUrgentScenarioSupported();

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AddCameraPreview();

private:
void ThrowIfMaxInputItemsExceeded();
std::wstring GetDuration();
Expand All @@ -75,6 +77,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
std::wstring GetImages();
std::wstring GetActions();
std::wstring GetProgressBars();
std::wstring GetCameraPreview();

std::wstring m_timeStamp{};
AppNotificationDuration m_duration{ AppNotificationDuration::Default };
Expand All @@ -93,6 +96,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
std::vector<AppNotificationComboBox> m_comboBoxList{};
winrt::hstring m_tag{};
winrt::hstring m_group{};
bool m_useCameraPreview{false};
};
}
namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

import "..\AppNotifications\AppNotifications.idl";

namespace Microsoft.Windows.AppNotifications.Builder
{
[contractversion(1)]
[contractversion(2)]
apicontract AppNotificationBuilderContract {}

[contract(AppNotificationBuilderContract, 1)]
Expand All @@ -31,6 +31,14 @@ namespace Microsoft.Windows.AppNotifications.Builder
Critical,
};

[contract(AppNotificationBuilderContract, 2)]
enum AppNotificationButtonSettingType
satkh marked this conversation as resolved.
Show resolved Hide resolved
{
none,
satkh marked this conversation as resolved.
Show resolved Hide resolved
VideoCall,
satkh marked this conversation as resolved.
Show resolved Hide resolved
AudioCall,
};

[contract(AppNotificationBuilderContract, 1)]
runtimeclass AppNotificationButton
{
Expand Down Expand Up @@ -69,6 +77,10 @@ namespace Microsoft.Windows.AppNotifications.Builder
// Launches the URI passed into the button when activated.
AppNotificationButton SetInvokeUri(Windows.Foundation.Uri protocolUri);
AppNotificationButton SetInvokeUri(Windows.Foundation.Uri protocolUri, String targetAppId);

// Sets the setting type for the button.
[contract(AppNotificationBuilderContract, 2)]
AppNotificationButton SetSettingType(AppNotificationButtonSettingType value);
satkh marked this conversation as resolved.
Show resolved Hide resolved
};

[contract(AppNotificationBuilderContract, 1)]
Expand Down Expand Up @@ -242,5 +254,9 @@ namespace Microsoft.Windows.AppNotifications.Builder
// AppNotification properties
AppNotificationBuilder SetTag(String value);
AppNotificationBuilder SetGroup(String group);

// Adds a camera preview to the AppNotification
[contract(AppNotificationBuilderContract, 2)]
AppNotificationBuilder AddCameraPreview();
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
Expand Down Expand Up @@ -121,17 +121,42 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
{
auto logTelemetry{ AppNotificationBuilderTelemetry::ButtonToString::Start(g_telemetryHelper) };

std::wstring xmlResult{ wil::str_printf<std::wstring>(L"<action content='%ls'%ls%ls%ls%ls%ls%ls/>",
std::wstring xmlResult{ wil::str_printf<std::wstring>(L"<action content='%ls'%ls%ls%ls%ls%ls%ls%ls/>",
m_content.c_str(),
GetActivationArguments().c_str(),
m_useContextMenuPlacement ? L" placement='contextMenu'" : L"",
m_iconUri ? wil::str_printf<std::wstring>(L" imageUri='%ls'", m_iconUri.ToString().c_str()).c_str() : L"",
!m_inputId.empty() ? wil::str_printf<std::wstring>(L" hint-inputId='%ls'", m_inputId.c_str()).c_str() : L"",
GetButtonStyle().c_str(),
!m_toolTip.empty() ? wil::str_printf<std::wstring>(L" hint-toolTip='%ls'", m_toolTip.c_str()).c_str() : L"") };
!m_toolTip.empty() ? wil::str_printf<std::wstring>(L" hint-toolTip='%ls'", m_toolTip.c_str()).c_str() : L"",
satkh marked this conversation as resolved.
Show resolved Hide resolved
GetSettingType().c_str()) };

logTelemetry.Stop();

return xmlResult.c_str();
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationButton AppNotificationButton::SetSettingType(AppNotificationButtonSettingType const& value)
{
m_settingType = value;
return *this;
}

std::wstring AppNotificationButton::GetSettingType()
{
if (m_settingType == AppNotificationButtonSettingType::none)
{
return L"";
}

switch (m_settingType)
{
case AppNotificationButtonSettingType::VideoCall:
return L" settingType='VideoDevices'";
case AppNotificationButtonSettingType::AudioCall:
return L" settingType='AudioDevices'";
default:
return L"";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once
Expand Down Expand Up @@ -60,9 +60,12 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

winrt::hstring ToString();

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationButton SetSettingType(AppNotificationButtonSettingType const& value);

private:
std::wstring GetActivationArguments();
std::wstring GetButtonStyle();
std::wstring GetSettingType();

winrt::hstring m_content{};
winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::hstring> m_arguments { winrt::single_threaded_map<winrt::hstring, winrt::hstring>() };
Expand All @@ -73,6 +76,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
winrt::hstring m_inputId{};
bool m_useContextMenuPlacement{};
AppNotificationButtonStyle m_buttonStyle { AppNotificationButtonStyle::Default };
AppNotificationButtonSettingType m_settingType{ AppNotificationButtonSettingType::none };
};
}
namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation
Expand Down
46 changes: 46 additions & 0 deletions dev/AppNotifications/AppNotificationDevicesData.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "pch.h"
#include "AppNotificationDevicesData.h"
#include "Microsoft.Windows.AppNotifications.AppNotificationDevicesData.g.cpp"
#include <IsWindowsVersion.h>

namespace winrt::Microsoft::Windows::AppNotifications::implementation
{
hstring AppNotificationDevicesData::CameraDeviceId()
{
return m_cameraDeviceId;
}

void AppNotificationDevicesData::CameraDeviceId(hstring const& value)
{
m_cameraDeviceId = value;
satkh marked this conversation as resolved.
Show resolved Hide resolved
}

hstring AppNotificationDevicesData::MicrophoneDeviceId()
{
return m_microphoneDeviceId;
}

void AppNotificationDevicesData::MicrophoneDeviceId(hstring const& value)
{
m_microphoneDeviceId = value;
}

hstring AppNotificationDevicesData::SpeakerDeviceId()
{
return m_speakerDeviceId;
}

void AppNotificationDevicesData::SpeakerDeviceId(hstring const& value)
{
m_speakerDeviceId = value;
}

/// <summary>
/// verifies if video calling is supported <TO DO>
/// </summary>
/// <returns>bool</returns>
bool AppNotificationDevicesData::IsVideoOrAudioCallingSupported()
{
return WindowsVersion::IsWindows11_23H1OrGreater(); // Windows 11 23H1 or greater
satkh marked this conversation as resolved.
Show resolved Hide resolved
}
}
34 changes: 34 additions & 0 deletions dev/AppNotifications/AppNotificationDevicesData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
#include "Microsoft.Windows.AppNotifications.AppNotificationDevicesData.g.h"

namespace winrt::Microsoft::Windows::AppNotifications::implementation
{
struct AppNotificationDevicesData : AppNotificationDevicesDataT<AppNotificationDevicesData>
{
AppNotificationDevicesData() = default;

// Getters
hstring CameraDeviceId();
hstring MicrophoneDeviceId();
hstring SpeakerDeviceId();

// Setters
void CameraDeviceId(hstring const& value);
void MicrophoneDeviceId(hstring const& value);
void SpeakerDeviceId(hstring const& value);

static bool IsVideoOrAudioCallingSupported();

private:

hstring m_cameraDeviceId{};
hstring m_microphoneDeviceId{};
hstring m_speakerDeviceId{};
};
}
namespace winrt::Microsoft::Windows::AppNotifications::factory_implementation
{
struct AppNotificationDevicesData : AppNotificationDevicesDataT<AppNotificationDevicesData, implementation::AppNotificationDevicesData>
{
};
}
26 changes: 25 additions & 1 deletion dev/AppNotifications/AppNotifications.idl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
import "..\AppLifecycle\AppLifecycle.idl";

Expand Down Expand Up @@ -111,6 +111,30 @@ namespace Microsoft.Windows.AppNotifications

// Gets or sets whether a Notification's pop-up UI is displayed on the user's screen.
Boolean SuppressDisplay;

// Gets or sets the Notification Device Data
[contract(AppNotificationsContract, 2)]
satkh marked this conversation as resolved.
Show resolved Hide resolved
AppNotificationDevicesData DevicesData;
satkh marked this conversation as resolved.
Show resolved Hide resolved
satkh marked this conversation as resolved.
Show resolved Hide resolved
satkh marked this conversation as resolved.
Show resolved Hide resolved
satkh marked this conversation as resolved.
Show resolved Hide resolved
}

// The Notification Device Data
[contract(AppNotificationsContract, 2)]
satkh marked this conversation as resolved.
Show resolved Hide resolved
runtimeclass AppNotificationDevicesData
satkh marked this conversation as resolved.
Show resolved Hide resolved
satkh marked this conversation as resolved.
Show resolved Hide resolved
{
// Initializes a new Instance of NotificationDevicesData
AppNotificationDevicesData();

// Checks if Video or Audio Calling is supported
static Boolean IsVideoOrAudioCallingSupported();
satkh marked this conversation as resolved.
Show resolved Hide resolved

// Gets or sets the Camera Device Id
String CameraDeviceId{ get; set; };
satkh marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

If this is set to the empty string (note: String cannot be null) or an invalid device identifier, I presume your toast will not show anything?

Choose a reason for hiding this comment

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

Toast will show system default device id as the ticked one if it's null / empty
image

Copy link
Author

Choose a reason for hiding this comment

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

Device validation is performed within the shell code. First, the shell invokes the existing enumerate API to retrieve a list of connected devices. It then compares these devices with those provided by the aforementioned APIs. If a match is found, the device is selected for preview and selected in the list (as shown in last mock image above). Otherwise, 'system default' devices will be displayed for preview and selection.

satkh marked this conversation as resolved.
Show resolved Hide resolved

// Gets or sets the Microphone Device Id
String MicrophoneDeviceId{ get; set; };
satkh marked this conversation as resolved.
Show resolved Hide resolved

// Gets or sets the Speaker Device Id
String SpeakerDeviceId{ get; set; };
satkh marked this conversation as resolved.
Show resolved Hide resolved
}

// The manager class which encompasses all App Notification API Functionality
Expand Down
4 changes: 4 additions & 0 deletions dev/AppNotifications/AppNotifications.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<ClInclude Include="$(MSBuildThisFileDirectory)NotificationTransientProperties.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)NotificationProgressData.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)ShellLocalization.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)AppNotificationDevicesData.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)NotificationDevicesData.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)AppNotificationActivatedEventArgs.cpp" />
Expand All @@ -35,6 +37,8 @@
<ClCompile Include="$(MSBuildThisFileDirectory)NotificationTransientProperties.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)NotificationProgressData.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)ShellLocalization.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)AppNotificationDevicesData.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)NotificationDevicesData.cpp" />
</ItemGroup>
<ItemGroup>
<Midl Include="$(MSBuildThisFileDirectory)AppNotifications.idl" />
Expand Down
Loading