Fix tailored notification images issue.

This commit is contained in:
Burak Kaan Köse
2026-03-08 16:26:06 +01:00
parent 9d94badb95
commit d43e2b269a
64 changed files with 3 additions and 83 deletions

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before

Width:  |  Height:  |  Size: 180 B

After

Width:  |  Height:  |  Size: 180 B

Before

Width:  |  Height:  |  Size: 234 B

After

Width:  |  Height:  |  Size: 234 B

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 283 B

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 521 B

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

@@ -5,7 +5,6 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging;
using Microsoft.Toolkit.Uwp.Notifications; using Microsoft.Toolkit.Uwp.Notifications;
using Microsoft.UI.Xaml;
using Serilog; using Serilog;
using Windows.Data.Xml.Dom; using Windows.Data.Xml.Dom;
using Windows.UI.Notifications; using Windows.UI.Notifications;
@@ -24,28 +23,24 @@ public class NotificationBuilder : INotificationBuilder
{ {
private const string MailApplicationId = "App"; private const string MailApplicationId = "App";
private const string NotificationIconRootUri = "ms-appx:///Assets/NotificationIcons/"; private const string NotificationIconRootUri = "ms-appx:///Assets/NotificationIcons/";
private static readonly int[] SupportedIconScales = [100, 125, 150, 200, 400];
private readonly IAccountService _accountService; private readonly IAccountService _accountService;
private readonly IFolderService _folderService; private readonly IFolderService _folderService;
private readonly IMailService _mailService; private readonly IMailService _mailService;
private readonly IThumbnailService _thumbnailService; private readonly IThumbnailService _thumbnailService;
private readonly IPreferencesService _preferencesService; private readonly IPreferencesService _preferencesService;
private readonly IUnderlyingThemeService _underlyingThemeService;
public NotificationBuilder(IAccountService accountService, public NotificationBuilder(IAccountService accountService,
IFolderService folderService, IFolderService folderService,
IMailService mailService, IMailService mailService,
IThumbnailService thumbnailService, IThumbnailService thumbnailService,
IPreferencesService preferencesService, IPreferencesService preferencesService)
IUnderlyingThemeService underlyingThemeService)
{ {
_accountService = accountService; _accountService = accountService;
_folderService = folderService; _folderService = folderService;
_mailService = mailService; _mailService = mailService;
_thumbnailService = thumbnailService; _thumbnailService = thumbnailService;
_preferencesService = preferencesService; _preferencesService = preferencesService;
_underlyingThemeService = underlyingThemeService;
WeakReferenceMessenger.Default.Register<MailReadStatusChanged>(this, (r, msg) => WeakReferenceMessenger.Default.Register<MailReadStatusChanged>(this, (r, msg) =>
{ {
@@ -431,23 +426,8 @@ public class NotificationBuilder : INotificationBuilder
private Uri GetNotificationIconUri(string iconName) private Uri GetNotificationIconUri(string iconName)
{ {
var theme = _underlyingThemeService.IsUnderlyingThemeDark() ? "dark" : "light"; // Keep the URI unqualified so Windows resolves the best matching theme/scale asset from the package.
var scale = GetClosestAvailableScale(); return new($"{NotificationIconRootUri}{iconName}.png");
return new($"{NotificationIconRootUri}{iconName}.theme-{theme}.scale-{scale}.png");
}
private static int GetClosestAvailableScale()
{
var rasterScale = 1.0;
if (WinoApplication.MainWindow?.Content is FrameworkElement rootElement &&
rootElement.XamlRoot != null)
{
rasterScale = rootElement.XamlRoot.RasterizationScale;
}
var requestedScale = (int)Math.Round(rasterScale * 100);
return SupportedIconScales.OrderBy(s => Math.Abs(s - requestedScale)).First();
} }
} }
-60
View File
@@ -99,66 +99,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Assets\CalendarWide310x150Logo.png" /> <None Remove="Assets\CalendarWide310x150Logo.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-dark.scale-100.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-dark.scale-125.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-dark.scale-150.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-dark.scale-200.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-dark.scale-400.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-light.scale-100.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-light.scale-125.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-light.scale-150.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-light.scale-200.png" />
<None Remove="Assets\NotificationIcons\calendar-join.theme-light.scale-400.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-dark.scale-100.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-dark.scale-125.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-dark.scale-150.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-dark.scale-200.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-dark.scale-400.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-light.scale-100.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-light.scale-125.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-light.scale-150.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-light.scale-200.png" />
<None Remove="Assets\NotificationIcons\calendar-snooze.theme-light.scale-400.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-dark.scale-100.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-dark.scale-125.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-dark.scale-150.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-dark.scale-200.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-dark.scale-400.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-light.scale-100.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-light.scale-125.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-light.scale-150.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-light.scale-200.png" />
<None Remove="Assets\NotificationIcons\dismiss.theme-light.scale-400.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-dark.scale-100.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-dark.scale-125.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-dark.scale-150.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-dark.scale-200.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-dark.scale-400.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-light.scale-100.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-light.scale-125.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-light.scale-150.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-light.scale-200.png" />
<None Remove="Assets\NotificationIcons\mail-archive.theme-light.scale-400.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-dark.scale-100.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-dark.scale-125.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-dark.scale-150.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-dark.scale-200.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-dark.scale-400.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-light.scale-100.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-light.scale-125.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-light.scale-150.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-light.scale-200.png" />
<None Remove="Assets\NotificationIcons\mail-delete.theme-light.scale-400.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-dark.scale-100.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-dark.scale-125.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-dark.scale-150.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-dark.scale-200.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-dark.scale-400.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-light.scale-100.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-light.scale-125.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-light.scale-150.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-light.scale-200.png" />
<None Remove="Assets\NotificationIcons\mail-markread.theme-light.scale-400.png" />
<None Remove="Assets\UpdateNotes\Images\Calendar.svg" /> <None Remove="Assets\UpdateNotes\Images\Calendar.svg" />
<None Remove="Assets\UpdateNotes\Images\Security.svg" /> <None Remove="Assets\UpdateNotes\Images\Security.svg" />
<None Remove="Assets\UpdateNotes\Images\Thread.svg" /> <None Remove="Assets\UpdateNotes\Images\Thread.svg" />