Skip to content

Commit 7eb251f

Browse files
authored
v.2.6.2
2 parents 1567683 + da49ee7 commit 7eb251f

14 files changed

Lines changed: 77 additions & 36 deletions

File tree

Sources/Stylophone.Common/Services/AlbumArtService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public void Stop()
9191
/// <param name="f">MpdFile to check for art</param>
9292
/// <returns>True if the art is cached, false otherwise.</returns>
9393
public async Task<bool> IsAlbumArtCachedAsync(IMpdFile f) => await _applicationStorageService.DoesFileExistAsync(Miscellaneous.GetFileIdentifier(f), "AlbumArt");
94+
public async Task<bool> IsAlbumArtCachedAsync(string albumName) => await _applicationStorageService.DoesFileExistAsync(albumName, "AlbumArt");
9495

9596
/// <summary>
9697
/// Queue up an AlbumViewModel for the service to grab its album art.
@@ -224,7 +225,7 @@ private QuantizedColor GetDominantColor(SKBitmap art)
224225

225226
private async Task SaveArtToFileAsync(string fileName, List<byte> data) => await _applicationStorageService.SaveDataToFileAsync(fileName, data.ToArray(), "AlbumArt");
226227

227-
private async Task<SKBitmap> LoadImageFromFile(string fileName)
228+
internal async Task<SKBitmap> LoadImageFromFile(string fileName)
228229
{
229230
try
230231
{

Sources/Stylophone.Common/Services/MPDConnectionService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public async Task InitializeAsync(bool withRetry = false)
8888
{
8989
System.Diagnostics.Debug.WriteLine($"Error while connecting: {e.Message}");
9090

91+
IsConnecting = false;
9192
ConnectionChanged?.Invoke(this, new EventArgs());
9293

9394
if (withRetry && !cancelToken.IsCancellationRequested)

Sources/Stylophone.Common/Stylophone.Common.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
<ItemGroup>
99
<PackageReference Include="CodeProject.ObjectPool" Version="6.0.0" />
10-
<PackageReference Include="CommunityToolkit.Common" Version="8.2.1" />
11-
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
10+
<PackageReference Include="CommunityToolkit.Common" Version="8.2.2" />
11+
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
1212
<PackageReference Include="LibVLCSharp" Version="3.7.0" />
13-
<PackageReference Include="MpcNET" Version="1.5.0" />
14-
<PackageReference Include="SkiaSharp" Version="2.88.5" />
15-
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.5" />
13+
<PackageReference Include="MpcNET" Version="1.6.5" />
14+
<PackageReference Include="SkiaSharp" Version="2.88.7" />
15+
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" />
1616
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="5.0.2" />
1717
</ItemGroup>
1818

Sources/Stylophone.Common/ViewModels/Bases/LibraryViewModelBase.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313

1414
namespace Stylophone.Common.ViewModels
1515
{
16+
1617
public abstract partial class LibraryViewModelBase : ViewModelBase
1718
{
19+
private record Album
20+
{
21+
public string Name { get; set; }
22+
public string SortName { get; set; }
23+
}
24+
1825
private INavigationService _navigationService;
1926
private MPDConnectionService _mpdService;
2027
private AlbumViewModelFactory _albumVmFactory;
@@ -40,9 +47,13 @@ public async Task LoadDataAsync()
4047
FilteredSource.CollectionChanged += (s, e) => OnPropertyChanged(nameof(IsSourceEmpty));
4148

4249
Source.Clear();
43-
var response = await _mpdService.SafelySendCommandAsync(new ListCommand(MpdTags.AlbumSort));
50+
var albumList = await _mpdService.SafelySendCommandAsync(new ListCommand(MpdTags.Album));
51+
var albumSortList = await _mpdService.SafelySendCommandAsync(new ListCommand(MpdTags.AlbumSort));
52+
53+
// Create a list of tuples
54+
var response = albumList.Zip(albumSortList, (album, albumSort) => new Album{ Name = album, SortName = albumSort });
4455

45-
if (response != null)
56+
if (albumSortList != null)
4657
GroupAlbumsByName(response);
4758

4859
if (Source.Count > 0)
@@ -63,10 +74,10 @@ public void FilterLibrary(string text)
6374
AddBack(filtered);
6475
}
6576

66-
public void GroupAlbumsByName(List<string> albums)
77+
private void GroupAlbumsByName(IEnumerable<Album> albums)
6778
{
6879
var query = from item in albums
69-
group item by GetGroupHeader(item) into g
80+
group item by GetGroupHeader(item.SortName) into g
7081
orderby g.Key
7182
select new { GroupName = g.Key, Items = g };
7283

@@ -76,9 +87,9 @@ orderby g.Key
7687
//GroupInfosList info = new GroupInfosList();
7788
//info.Key = g.GroupName + " (" + g.Items.Count() + ")";
7889

79-
foreach (var item in g.Items.OrderBy(s => s.ToLower()))
90+
foreach (var item in g.Items.OrderBy(s => s.SortName.ToLower()))
8091
{
81-
Source.Add(_albumVmFactory.GetAlbumViewModel(item));
92+
Source.Add(_albumVmFactory.GetAlbumViewModel(item.Name));
8293
}
8394
}
8495
}

Sources/Stylophone.Common/ViewModels/Items/AlbumViewModel.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
using MpcNET.Tags;
1010
using MpcNET.Types;
1111
using SkiaSharp;
12+
using Stylophone.Common.Helpers;
1213
using Stylophone.Common.Interfaces;
1314
using Stylophone.Common.Services;
1415
using Stylophone.Localization.Strings;
1516
using System;
1617
using System.Collections.Generic;
1718
using System.Linq;
19+
using System.Runtime.InteropServices.ComTypes;
1820
using System.Threading.Tasks;
1921
using System.Windows.Input;
2022

@@ -180,6 +182,16 @@ private async Task PlayAlbum()
180182
}
181183
}
182184

185+
public async Task LoadAlbumArtFromCacheAsync()
186+
{
187+
// Try to show album art early if we have it in cache
188+
var cacheName = Miscellaneous.EscapeFilename(Name);
189+
if (await _albumArtService.IsAlbumArtCachedAsync(cacheName))
190+
{
191+
AlbumArt = SKImage.FromBitmap(await _albumArtService.LoadImageFromFile(cacheName));
192+
}
193+
}
194+
183195
/// <summary>
184196
/// Load Album Data. You can either provide a MpcConnection object (for batch loading)
185197
/// or leave as empty to automatically pick up a connection from the datasource.
@@ -196,7 +208,8 @@ public async Task LoadAlbumDataAsync()
196208
public async Task LoadAlbumDataAsync(MpcConnection c)
197209
{
198210
IsDetailLoading = true;
199-
AlbumArt = await _interop.GetPlaceholderImageAsync();
211+
AlbumArt ??= await _interop.GetPlaceholderImageAsync();
212+
200213
try
201214
{
202215
var findReq = await c.SendAsync(new FindCommand(MpdTags.Album, Name));

Sources/Stylophone.iOS/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<string>zh</string>
1717
</array>
1818
<key>CFBundleShortVersionString</key>
19-
<string>2.6.0</string>
19+
<string>2.6.1</string>
2020
<key>CFBundleVersion</key>
21-
<string>2.6.0</string>
21+
<string>2.6.1</string>
2222
<key>LSRequiresIPhoneOS</key>
2323
<true/>
2424
<key>MinimumOSVersion</key>

Sources/Stylophone.iOS/Services/NotificationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public override void ShowInAppNotification(InAppNotification notification)
2020
{
2121
// Let's just use alerts until TipKit is available... This is cheap but w/e
2222
var alert = new UIAlertView(notification.NotificationTitle, notification.NotificationText, null, "Ok");
23-
alert.Show();
23+
UIApplication.SharedApplication.InvokeOnMainThread(() => alert.Show());
2424
return;
2525
}
2626

Sources/Stylophone.iOS/Stylophone.iOS.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net7.0-ios</TargetFrameworks>
3+
<TargetFrameworks>net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
44
<OutputType>Exe</OutputType>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>true</ImplicitUsings>
@@ -61,12 +61,12 @@
6161
</ItemGroup>
6262
<ItemGroup>
6363
<PackageReference Include="Xamarin.Essentials" Version="1.8.0" />
64-
<PackageReference Include="SkiaSharp.Views" Version="2.88.5" />
64+
<PackageReference Include="SkiaSharp.Views" Version="2.88.7" />
6565
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.2" />
6666
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="5.0.2" />
6767
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
6868
<PackageReference Include="VideoLAN.LibVLC.iOS" Version="3.3.18" />
69-
<PackageReference Include="MpcNET" Version="1.5.0" />
69+
<PackageReference Include="MpcNET" Version="1.6.5" />
7070
</ItemGroup>
7171
<ItemGroup>
7272
<ProjectReference Include="..\Stylophone.Common\Stylophone.Common.csproj">

Sources/Stylophone.iOS/ViewModels/LibraryViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ internal void LoadItems(IEnumerable<int> indexes, CancellationToken token = defa
7373
// Albumart loads still use their own connections.
7474
Task.Run(async () =>
7575
{
76+
// Try to show album artwork early if we have it in cache
77+
foreach (var i in indexes)
78+
{
79+
var album = BackingCollection[i];
80+
await album.LoadAlbumArtFromCacheAsync();
81+
}
82+
7683
using (var c = await _mpdService.GetConnectionAsync(token))
7784
foreach (var i in indexes)
7885
{

Sources/Stylophone/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<Identity
1313
Name="StylophoneDebug"
1414
Publisher="CN=B2F6FFCA-07C7-479C-AC33-2C75463C7DCE"
15-
Version="2.6.0.0" />
15+
Version="2.6.1.0" />
1616

1717
<mp:PhoneIdentity PhoneProductId="b9cbe0bc-1e9d-42c8-abf1-85c63af45f83" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
1818

0 commit comments

Comments
 (0)