[Updates] Toast notification for new updates: Add setting (#30794)

* code changes from #30606

* Update admx revision
This commit is contained in:
Heiko
2024-01-19 16:18:05 +01:00
committed by GitHub
parent f971f3d968
commit d7c7711518
13 changed files with 100 additions and 5 deletions

View File

@@ -140,6 +140,10 @@ namespace winrt::PowerToys::GPOWrapper::implementation
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredPeekEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetDisableNewUpdateToastValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getDisableNewUpdateToastValue());
}
GpoRuleConfigured GPOWrapper::GetDisableAutomaticUpdateDownloadValue()
{
return static_cast<GpoRuleConfigured>(powertoys_gpo::getDisableAutomaticUpdateDownloadValue());

View File

@@ -41,6 +41,7 @@ namespace winrt::PowerToys::GPOWrapper::implementation
static GpoRuleConfigured GetConfiguredPastePlainEnabledValue();
static GpoRuleConfigured GetConfiguredVideoConferenceMuteEnabledValue();
static GpoRuleConfigured GetConfiguredPeekEnabledValue();
static GpoRuleConfigured GetDisableNewUpdateToastValue();
static GpoRuleConfigured GetDisableAutomaticUpdateDownloadValue();
static GpoRuleConfigured GetDisableShowWhatsNewAfterUpdatesValue();
static GpoRuleConfigured GetAllowExperimentationValue();

View File

@@ -45,6 +45,7 @@ namespace PowerToys
static GpoRuleConfigured GetConfiguredPastePlainEnabledValue();
static GpoRuleConfigured GetConfiguredVideoConferenceMuteEnabledValue();
static GpoRuleConfigured GetConfiguredPeekEnabledValue();
static GpoRuleConfigured GetDisableNewUpdateToastValue();
static GpoRuleConfigured GetDisableAutomaticUpdateDownloadValue();
static GpoRuleConfigured GetDisableShowWhatsNewAfterUpdatesValue();
static GpoRuleConfigured GetAllowExperimentationValue();

View File

@@ -64,6 +64,7 @@ namespace powertoys_gpo {
const std::wstring POLICY_DISABLE_PER_USER_INSTALLATION = L"PerUserInstallationDisabled";
const std::wstring POLICY_DISABLE_AUTOMATIC_UPDATE_DOWNLOAD = L"AutomaticUpdateDownloadDisabled";
const std::wstring POLICY_SUSPEND_NEW_UPDATE_TOAST = L"SuspendNewUpdateAvailableToast";
const std::wstring POLICY_DISABLE_NEW_UPDATE_TOAST = L"DisableNewUpdateAvailableToast";
const std::wstring POLICY_DISABLE_PERIODIC_UPDATE_CHECK = L"PeriodicUpdateCheckDisabled";
const std::wstring POLICY_DISABLE_SHOW_WHATS_NEW_AFTER_UPDATES = L"DoNotShowWhatsNewAfterUpdates";
@@ -406,6 +407,11 @@ namespace powertoys_gpo {
return getConfiguredValue(POLICY_SUSPEND_NEW_UPDATE_TOAST);
}
inline gpo_rule_configured_t getDisableNewUpdateToastValue()
{
return getConfiguredValue(POLICY_DISABLE_NEW_UPDATE_TOAST);
}
inline gpo_rule_configured_t getDisablePeriodicUpdateCheckValue()
{
return getConfiguredValue(POLICY_DISABLE_PERIODIC_UPDATE_CHECK);

View File

@@ -440,6 +440,16 @@
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<policy name="DisableNewUpdateToast" class="Both" displayName="$(string.DisableNewUpdateToast)" explainText="$(string.DisableNewUpdateToastDescription)" key="Software\Policies\PowerToys" valueName="DisableNewUpdateAvailableToast">
<parentCategory ref="InstallerUpdates" />
<supportedOn ref="SUPPORTED_POWERTOYS_0_78_0" />
<enabledValue>
<decimal value="1" />
</enabledValue>
<disabledValue>
<decimal value="0" />
</disabledValue>
</policy>
<!-- This policy is implemented for later usage (PT v1.0 and later) and therefore inactive. (To make it working please update `src/runner/UpdateUtils.cpp`)
<policy name="DisablePeriodicUpdateCheck" class="Both" displayName="$(string.DisablePeriodicUpdateCheck)" explainText="$(string.DisablePeriodicUpdateCheckDescription)" key="Software\Policies\PowerToys" valueName="PeriodicUpdateCheckDisabled">

View File

@@ -72,6 +72,14 @@ If enabled, the notification is suspended.
If disabled or not configured, the notification is shown.
Note: The notification about new major versions is always displayed.
This policy has no effect if the update notification is disabled by the policy "Disable Action Center notification for new updates" or the user setting.
</string>
<string id="DisableNewUpdateToastDescription">This policy configures whether the action center notification for new updates is shown or not.
If enabled, the notification is disabled.
If disabled or not configured, the user can control if the notification is shown or not.
</string>
<string id="DisablePeriodicUpdateCheckDescription">This policy allows you to disable automatic update checks running in the background. (The manual check in PT Settings is not affected by this policy.)
@@ -156,6 +164,7 @@ Note: Changes require a restart of PowerToys Run.
<string id="DisableAutomaticUpdateDownload">Disable automatic downloads</string>
<string id="DoNotShowWhatsNewAfterUpdates">Do not show the release notes after updates</string>
<string id="SuspendNewUpdateToast">Suspend Action Center notification for new updates</string>
<string id="DisableNewUpdateToast">Disable Action Center notification for new updates</string>
<string id="DisablePeriodicUpdateCheck">Disable automatic update checks</string>
<string id="AllowExperimentation">Allow Experimentation</string>
<string id="PowerToysRunAllPluginsEnabledState">Configure enabled state for all plugins</string>

View File

@@ -140,9 +140,16 @@ void ProcessNewVersionInfo(const github_version_info& version_info,
return;
}
// Check notification GPO.
// We check only if notifications are allowed. This is the case if we are triggered by the periodic check.
if (show_notifications && powertoys_gpo::getSuspendNewUpdateToastValue() == powertoys_gpo::gpo_rule_configured_enabled)
// Check toast notification GPOs and settings. (We check only if notifications are allowed. This is the case if we are triggered by the periodic check.)
// Disable notification GPO or setting
bool disable_notification_setting = get_general_settings().showNewUpdatesToastNotification == false;
if (show_notifications && (disable_notification_setting || powertoys_gpo::getDisableNewUpdateToastValue() == powertoys_gpo::gpo_rule_configured_enabled))
{
Logger::info(L"There is a new update available or ready to install. But the toast notification is disabled by setting or GPO.");
show_notifications = false;
}
// Suspend notification GPO
else if (show_notifications && powertoys_gpo::getSuspendNewUpdateToastValue() == powertoys_gpo::gpo_rule_configured_enabled)
{
Logger::info(L"GPO to suspend new update toast notification is enabled.");
if (new_version_info.version.major <= VERSION_MAJOR && new_version_info.version.minor - VERSION_MINOR <= UPDATE_NOTIFICATION_TOAST_SUSPEND_MINOR_VERSION_COUNT)

View File

@@ -15,6 +15,7 @@
// TODO: would be nice to get rid of these globals, since they're basically cached json settings
static std::wstring settings_theme = L"system";
static bool run_as_elevated = false;
static bool show_new_updates_toast_notification = true;
static bool download_updates_automatically = true;
static bool show_whats_new_after_updates = true;
static bool enable_experimentation = true;
@@ -39,6 +40,7 @@ json::JsonObject GeneralSettings::to_json()
result.SetNamedValue(L"is_elevated", json::value(isElevated));
result.SetNamedValue(L"run_elevated", json::value(isRunElevated));
result.SetNamedValue(L"show_new_updates_toast_notification", json::value(showNewUpdatesToastNotification));
result.SetNamedValue(L"download_updates_automatically", json::value(downloadUpdatesAutomatically));
result.SetNamedValue(L"show_whats_new_after_updates", json::value(showWhatsNewAfterUpdates));
result.SetNamedValue(L"enable_experimentation", json::value(enableExperimentation));
@@ -60,6 +62,7 @@ json::JsonObject load_general_settings()
settings_theme = L"system";
}
run_as_elevated = loaded.GetNamedBoolean(L"run_elevated", false);
show_new_updates_toast_notification = loaded.GetNamedBoolean(L"show_new_updates_toast_notification", true);
download_updates_automatically = loaded.GetNamedBoolean(L"download_updates_automatically", true) && check_user_is_admin();
show_whats_new_after_updates = loaded.GetNamedBoolean(L"show_whats_new_after_updates", true);
enable_experimentation = loaded.GetNamedBoolean(L"enable_experimentation",true);
@@ -76,6 +79,7 @@ GeneralSettings get_general_settings()
.isRunElevated = run_as_elevated,
.isAdmin = is_user_admin,
.enableWarningsElevatedApps = enable_warnings_elevated_apps,
.showNewUpdatesToastNotification = show_new_updates_toast_notification,
.downloadUpdatesAutomatically = download_updates_automatically && is_user_admin,
.showWhatsNewAfterUpdates = show_whats_new_after_updates,
.enableExperimentation = enable_experimentation,
@@ -101,6 +105,8 @@ void apply_general_settings(const json::JsonObject& general_configs, bool save)
enable_warnings_elevated_apps = general_configs.GetNamedBoolean(L"enable_warnings_elevated_apps", true);
show_new_updates_toast_notification = general_configs.GetNamedBoolean(L"show_new_updates_toast_notification", true);
download_updates_automatically = general_configs.GetNamedBoolean(L"download_updates_automatically", true);
show_whats_new_after_updates = general_configs.GetNamedBoolean(L"show_whats_new_after_updates", true);

View File

@@ -11,6 +11,7 @@ struct GeneralSettings
bool isRunElevated;
bool isAdmin;
bool enableWarningsElevatedApps;
bool showNewUpdatesToastNotification;
bool downloadUpdatesAutomatically;
bool showWhatsNewAfterUpdates;
bool enableExperimentation;

View File

@@ -51,6 +51,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("enabled")]
public EnabledModules Enabled { get; set; }
[JsonPropertyName("show_new_updates_toast_notification")]
public bool ShowNewUpdatesToastNotification { get; set; }
[JsonPropertyName("download_updates_automatically")]
public bool AutoDownloadUpdates { get; set; }
@@ -66,6 +69,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library
IsAdmin = false;
EnableWarningsElevatedApps = true;
IsElevated = false;
ShowNewUpdatesToastNotification = true;
AutoDownloadUpdates = false;
EnableExperimentation = true;
Theme = "system";

View File

@@ -198,6 +198,19 @@
IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.ShowWhatsNewAfterUpdatesIsGpoDisabled}"
IsTabStop="{x:Bind Mode=OneWay, Path=ViewModel.ShowWhatsNewAfterUpdatesIsGpoDisabled}"
Severity="Informational" />
<tkcontrols:SettingsCard
x:Uid="GeneralPage_ToggleSwitch_ShowNewUpdatesToast"
Margin="0,-6,0,0"
IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsNewUpdatesToastDisabledGpoConfigured, Converter={StaticResource BoolNegationConverter}}">
<ToggleSwitch x:Uid="ToggleSwitch" IsOn="{Binding Mode=TwoWay, Path=ShowNewUpdatesToastNotification}" />
</tkcontrols:SettingsCard>
<InfoBar
x:Uid="GPO_IsSettingForced"
IsClosable="False"
IsOpen="{x:Bind Mode=OneWay, Path=ViewModel.IsNewUpdatesToastDisabledGpoConfigured}"
IsTabStop="{x:Bind Mode=OneWay, Path=ViewModel.IsNewUpdatesToastDisabledGpoConfigured}"
Severity="Informational" />
</controls:SettingsGroup>
<controls:SettingsGroup x:Uid="Admin_Mode">

View File

@@ -4017,4 +4017,10 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="CmdNotFound_Arm64ArchBar.Title" xml:space="preserve">
<value>Command Not Found is not supported on the ARM64 architecture currently. We are actively working on a solution.</value>
</data>
</root>
<data name="GeneralPage_ToggleSwitch_ShowNewUpdatesToast.Description" xml:space="preserve">
<value>Notifications in the settings and the tray flyout are always shown</value>
</data>
<data name="GeneralPage_ToggleSwitch_ShowNewUpdatesToast.Header" xml:space="preserve">
<value>Show notifications for new updates</value>
</data>
</root>

View File

@@ -121,6 +121,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
_startup = GeneralSettingsConfig.Startup;
_showNewUpdatesToastNotification = GeneralSettingsConfig.ShowNewUpdatesToastNotification;
_autoDownloadUpdates = GeneralSettingsConfig.AutoDownloadUpdates;
_showWhatsNewAfterUpdates = GeneralSettingsConfig.ShowWhatsNewAfterUpdates;
_enableExperimentation = GeneralSettingsConfig.EnableExperimentation;
@@ -139,8 +140,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_newAvailableVersionLink = UpdatingSettingsConfig.ReleasePageLink;
_updateCheckedDate = UpdatingSettingsConfig.LastCheckedDateLocalized;
_experimentationIsGpoDisallowed = GPOWrapper.GetAllowExperimentationValue() == GpoRuleConfigured.Disabled;
_newUpdatesToastIsGpoDisabled = GPOWrapper.GetDisableNewUpdateToastValue() == GpoRuleConfigured.Enabled;
_autoDownloadUpdatesIsGpoDisabled = GPOWrapper.GetDisableAutomaticUpdateDownloadValue() == GpoRuleConfigured.Enabled;
_experimentationIsGpoDisallowed = GPOWrapper.GetAllowExperimentationValue() == GpoRuleConfigured.Disabled;
_showWhatsNewAfterUpdatesIsGpoDisabled = GPOWrapper.GetDisableShowWhatsNewAfterUpdatesValue() == GpoRuleConfigured.Enabled;
if (dispatcherAction != null)
@@ -156,6 +158,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private bool _enableWarningsElevatedApps;
private int _themeIndex;
private bool _showNewUpdatesToastNotification;
private bool _newUpdatesToastIsGpoDisabled;
private bool _autoDownloadUpdates;
private bool _autoDownloadUpdatesIsGpoDisabled;
private bool _showWhatsNewAfterUpdates;
@@ -303,6 +307,29 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
}
public bool ShowNewUpdatesToastNotification
{
get
{
return _showNewUpdatesToastNotification && !_newUpdatesToastIsGpoDisabled;
}
set
{
if (_showNewUpdatesToastNotification != value)
{
_showNewUpdatesToastNotification = value;
GeneralSettingsConfig.ShowNewUpdatesToastNotification = value;
NotifyPropertyChanged();
}
}
}
public bool IsNewUpdatesToastDisabledGpoConfigured
{
get => _newUpdatesToastIsGpoDisabled;
}
public bool AutoDownloadUpdates
{
get