Skip to content

Free, open-source Windows optimization tool for performance, privacy, and simplicity.

feat: add unknown risk

itsfatduck90a563ac042e
diff --git a/optimizerDuck/Core/Models/Bloatware/AppXPackage.cs b/optimizerDuck/Core/Models/Bloatware/AppXPackage.cs
index 364bbf2..858ac5b 100644
--- a/optimizerDuck/Core/Models/Bloatware/AppXPackage.cs
+++ b/optimizerDuck/Core/Models/Bloatware/AppXPackage.cs
@@ -8,7 +8,8 @@ namespace optimizerDuck.Core.Models.Bloatware;
public enum AppRisk
{
Safe,
- Caution
+ Caution,
+ Unknown
}
public partial class AppXPackage : ObservableObject
@@ -34,6 +35,11 @@ public partial class AppXPackage : ObservableObject
Display = Translations.Optimizer_UI_Risk_Moderate,
Icon = SymbolRegular.Warning24
},
+ AppRisk.Unknown => new RiskVisual
+ {
+ Display = Translations.Bloatware_UI_Risk_Unknown,
+ Icon = SymbolRegular.ShieldQuestion24
+ },
_ => new RiskVisual
{
Display = Translations.Optimizer_UI_Risk_Safe,
diff --git a/optimizerDuck/Resources/Languages/Translations.Designer.cs b/optimizerDuck/Resources/Languages/Translations.Designer.cs
index 55f8eda..4bd4e50 100644
--- a/optimizerDuck/Resources/Languages/Translations.Designer.cs
+++ b/optimizerDuck/Resources/Languages/Translations.Designer.cs
@@ -113,6 +113,15 @@ namespace optimizerDuck.Resources.Languages {
}
}
+ /// <summary>
+ /// Looks up a localized string similar to Unknown.
+ /// </summary>
+ public static string Bloatware_UI_Risk_Unknown {
+ get {
+ return ResourceManager.GetString("Bloatware.UI.Risk.Unknown", resourceCulture);
+ }
+ }
+
/// <summary>
/// Looks up a localized string similar to Removing {0} ({1}/{2}).
/// </summary>
diff --git a/optimizerDuck/Resources/Languages/Translations.resx b/optimizerDuck/Resources/Languages/Translations.resx
index 5fedb63..71c6a9e 100644
--- a/optimizerDuck/Resources/Languages/Translations.resx
+++ b/optimizerDuck/Resources/Languages/Translations.resx
@@ -824,4 +824,7 @@ Current version: {0}]]></value>
<data name="Sidebar.Bloatware" xml:space="preserve">
<value>Bloatware</value>
</data>
+ <data name="Bloatware.UI.Risk.Unknown" xml:space="preserve">
+ <value>Unknown</value>
+ </data>
</root>
\ No newline at end of file
diff --git a/optimizerDuck/Services/BloatwareService.cs b/optimizerDuck/Services/BloatwareService.cs
index e5942db..a6a36e4 100644
--- a/optimizerDuck/Services/BloatwareService.cs
+++ b/optimizerDuck/Services/BloatwareService.cs
@@ -16,52 +16,43 @@ public class BloatwareService(ILogger<BloatwareService> logger)
try
{
var result = await ShellService.PowerShellAsync($$"""
- # list the SAFE_APPS
- $safeApps = @({{string.Join(", ", Shared.SafeApps.Keys.Select(x => $"\"{x}\""))}})
-
- # list the CAUTION_APPS
- $cautionApps = @({{string.Join(", ", Shared.CautionApps.Keys.Select(x => $"\"{x}\""))}})
-
- # get installed removable apps
- $installedApps = Get-AppxPackage -AllUsers | Where-Object { $_.NonRemovable -eq 0 }
-
- $result = @()
-
- foreach ($app in $installedApps) {
-
- $nameLower = $app.Name.ToLower()
- $risk = "Unknown"
-
- foreach ($s in $safeApps) {
- if ($nameLower -like "*$($s.ToLower())*") {
- $risk = "Safe"
- break
- }
- }
-
- if ($risk -eq "Unknown") {
- foreach ($s in $cautionApps) {
- if ($nameLower -like "*$($s.ToLower())*") {
- $risk = "Caution"
- break
- }
- }
- }
-
- if ($risk -ne "Unknown") {
- $result += [PSCustomObject]@{
- Name = $app.Name
- PackageFullName = $app.PackageFullName
- Publisher = $app.Publisher
- Version = $app.Version
- InstallLocation = $app.InstallLocation
- Risk = $risk
- }
- }
- }
-
- $result | ConvertTo-Json -Depth 4
- """);
+ # SAFE_APPS
+ $safeApps = "{{string.Join(",", Shared.SafeApps.Keys)}}" -split "," |
+ ForEach-Object { $_.Trim().ToLower() }
+
+ # CAUTION_APPS
+ $cautionApps = "{{string.Join(",", Shared.CautionApps.Keys)}}" -split "," |
+ ForEach-Object { $_.Trim().ToLower() }
+
+ # Installed removable apps
+ $installedApps = Get-AppxPackage | Where-Object { $_.NonRemovable -eq 0 }
+
+ # Build result array efficiently
+ $result = foreach ($app in $installedApps) {
+
+ $nameLower = $app.Name.ToLower()
+ $risk = "Unknown"
+
+ if ($safeApps | Where-Object { $nameLower -like "*$_*" }) {
+ $risk = "Safe"
+ }
+ elseif ($cautionApps | Where-Object { $nameLower -like "*$_*" }) {
+ $risk = "Caution"
+ }
+
+ [PSCustomObject]@{
+ Name = $app.Name
+ PackageFullName = $app.PackageFullName
+ Publisher = $app.Publisher
+ Version = $app.Version.ToString()
+ InstallLocation = if ($app.InstallLocation) { $app.InstallLocation } else { "" }
+ Risk = $risk
+ }
+ }
+
+ @($result) | ConvertTo-Json -Depth 4
+
+ """);
var options = new JsonSerializerOptions
diff --git a/optimizerDuck/UI/Views/Pages/BloatwarePage.xaml b/optimizerDuck/UI/Views/Pages/BloatwarePage.xaml
index 20a4c95..084bcf2 100644
--- a/optimizerDuck/UI/Views/Pages/BloatwarePage.xaml
+++ b/optimizerDuck/UI/Views/Pages/BloatwarePage.xaml
@@ -1,5 +1,4 @@
<Page
- Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Margin="0,32,0,0"
ScrollViewer.CanContentScroll="False"
Title="BloatwarePage"
@@ -167,7 +166,7 @@
<ui:TextBlock
Appearance="Tertiary"
FontTypography="Body"
- Text="{Binding Version, StringFormat='v{0}'}"
+ Text="{Binding Version}"
VerticalAlignment="Center" />
</Border>
@@ -183,22 +182,43 @@
<DataTrigger Binding="{Binding Risk}" Value="Caution">
<Setter Property="Background" Value="{DynamicResource SystemFillColorCautionBrush}" />
</DataTrigger>
+ <DataTrigger Binding="{Binding Risk}" Value="Unknown">
+ <Setter Property="Background" Value="{DynamicResource CardBackgroundFillColorDefaultBrush}" />
+ </DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<StackPanel Orientation="Horizontal">
- <ui:SymbolIcon
- Foreground="{DynamicResource TextFillColorInverseBrush}"
- Margin="0,0,5,0"
- Symbol="{Binding RiskVisual.Icon}" />
+ <ui:SymbolIcon Margin="0,0,5,0" Symbol="{Binding RiskVisual.Icon}">
+ <ui:SymbolIcon.Style>
+ <Style TargetType="ui:SymbolIcon">
+ <Setter Property="Foreground" Value="{DynamicResource TextFillColorInverseBrush}" />
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Risk}" Value="Unknown">
+ <Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ui:SymbolIcon.Style>
+ </ui:SymbolIcon>
<ui:TextBlock
FontTypography="Caption"
- Foreground="{DynamicResource TextFillColorInverseBrush}"
HorizontalAlignment="Center"
Text="{Binding RiskVisual.Display}"
TextWrapping="Wrap"
- VerticalAlignment="Center" />
+ VerticalAlignment="Center">
+ <ui:TextBlock.Style>
+ <Style TargetType="ui:TextBlock">
+ <Setter Property="Foreground" Value="{DynamicResource TextFillColorInverseBrush}" />
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Risk}" Value="Unknown">
+ <Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ui:TextBlock.Style>
+ </ui:TextBlock>
</StackPanel>
</Border>