Skip to content

Commit

Permalink
Merge pull request #13 from Difegue/dev
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
Difegue committed Dec 5, 2020
2 parents a5d0521 + 9405a34 commit 170782c
Show file tree
Hide file tree
Showing 29 changed files with 491 additions and 211 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# To configure this workflow:
#
# 1. Configure environment variables
# GitHub sets default environment variables for every workflow run.
# Replace the variables relative to your project in the "env" section below.
#
# 2. Signing
# Generate a signing certificate in the Windows Application
# Packaging Project or add an existing signing certificate to the project.
# Next, use PowerShell to encode the .pfx file using Base64 encoding
# by running the following Powershell script to generate the output string:
#
# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte
# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt'
#
# Open the output file, SigningCertificate_Encoded.txt, and copy the
# string inside. Then, add the string to the repo as a GitHub secret
# and name it "Base64_Encoded_Pfx."
# For more information on how to configure your signing certificate for
# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing
#
# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key".
# See "Build the Windows Application Packaging project" below to see how the secret is used.
#
# For more information on GitHub Actions, refer to https://github.com/features/actions
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
# refer to https://github.com/microsoft/github-actions-for-desktop-apps

name: Build and Test Stylophone

on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]

jobs:

build:

strategy:
matrix:
configuration: [Debug, Release]

runs-on: windows-latest # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on

env:
Solution_Name: MpcNET
Uap_Project_Path: FluentMPC\FluentMPC.csproj
Uap_Project_Directory: FluentMPC

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/[email protected]

# Restore the application
- name: Restore the application
working-directory: ./Sources
run: |
msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
msbuild $env:Uap_Project_Directory /t:Restore /p:Configuration=$env:Configuration
env:
Configuration: ${{ matrix.configuration }}

# Execute all unit tests in the solution
# TODO: This only runs the tests for MpcNET right now, since it's .NET Standard-based. Running the UWP tests would be nice too.
- name: Execute unit tests
working-directory: ./Sources
run: dotnet test

# Decode the base 64 encoded pfx and save the Signing_Certificate
- name: Decode the pfx
working-directory: ./Sources
run: |
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
$certificatePath = Join-Path -Path $env:Uap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx
[IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
# Create the app package by building and packaging the Windows Application Packaging project
- name: Create the app package
working-directory: ./Sources
run: msbuild $env:Uap_Project_Path /p:AppxBundlePlatforms="x86" /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:AppxPackageSigningEnabled=False #/p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }}
env:
Appx_Bundle: Always
Appx_Bundle_Platforms: x86|x64
Appx_Package_Build_Mode: StoreUpload
Configuration: ${{ matrix.configuration }}

# Remove the pfx
- name: Remove the pfx
working-directory: ./Sources
run: Remove-Item -path $env:Uap_Project_Directory\GitHubActionsWorkflow.pfx

# Upload the MSIX package: https://github.com/marketplace/actions/upload-artifact
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: MSIX Package
path: .\Sources\${{ env.Uap_Project_Directory }}\AppPackages
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ There is a workaround you can use with checknetisolation which should work:
checknetisolation loopbackexempt -a -n="13459Difegue.Stylophone_zd7bwy3j4yjfy"
```

## Translation

You can easily contribute translations to Stylophone! To help translate, follow these instructions.

### Adding a new language (requires Visual Studio 2019)
- Create a new issue with the subject `[Translation] fr-CA` where you replace `fr-CA` with whatever language-region code you'll be translating into.
- If an issue already exists, then don't do this step.
- Fork and clone this repo
- Open in VS 2019
- In the `FluentMPC` project, find the `Strings` folder.
- Create a new folder inside `Strings` that looks like this: `en-US` but using the language you're translating into.
- Add a new `Resources.resw` item in that new folder
- Copy all the existing data from `Strings > en-US` into your new `Resources.resw`
- Translate the strings from english to your language
- Once done, then commit > push > create pull request!

### Improving an existing language (can be done with any text editor)
- Fork and clone this repo
- Open the the `.resw` file (e.g. `en-US > Resources.resw`) you want to edit. Choose any text editor
- Translate
- Commit > push > create pull request!

## Screenshots

![Screen1](Screenshots/Screen1.png)
Expand Down
Binary file modified Sources/FluentMPC/Assets/AlbumPlaceholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Sources/FluentMPC/FluentMPC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<Version>6.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.4.2</Version>
<Version>2.4.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
<Version>2.0.1</Version>
Expand Down Expand Up @@ -202,6 +202,7 @@
<Compile Include="ViewModels\AlbumDetailViewModel.cs" />
<Compile Include="ViewModels\LibraryViewModel.cs" />
<Compile Include="ViewModels\Items\AlbumViewModel.cs" />
<Compile Include="ViewModels\Playback\VisualizationType.cs" />
<Compile Include="ViewModels\QueueViewModel.cs" />
<Compile Include="ViewModels\Playback\PlaybackViewModel.cs" />
<Compile Include="ViewModels\Items\TrackViewModel.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Sources/FluentMPC/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Identity
Name="13459Difegue.Stylophone"
Publisher="CN=B2F6FFCA-07C7-479C-AC33-2C75463C7DCE"
Version="1.3.0.0" />
Version="1.4.0.0" />

<mp:PhoneIdentity PhoneProductId="6aab9ef0-77d1-4922-a9da-497e36a34491" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
4 changes: 2 additions & 2 deletions Sources/FluentMPC/Properties/Default.rd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<!--
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" />

-->

<!-- Add your application specific runtime directives here. -->

Expand Down
34 changes: 15 additions & 19 deletions Sources/FluentMPC/Services/AlbumArtService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ public static async Task<bool> IsAlbumArtCachedAsync(IMpdFile f)
/// <param name="albumArtWidth">Width of the final BitmapImage</param>
/// <param name="dispatcher">Dispatcher to use for the UI-bound options. Defaults to MainWindow.CoreWindow.Dispatcher.</param>
/// <returns>An AlbumArt object containing bitmap and color. Returns null if there was no albumart on the MPD server.</returns>
public async static Task<AlbumArt> GetAlbumArtAsync(IMpdFile f, bool calculateDominantColor, int albumArtWidth, CoreDispatcher dispatcher = null)
public async static Task<AlbumArt> GetAlbumArtAsync(IMpdFile f, bool calculateDominantColor, int albumArtWidth, CoreDispatcher dispatcher = null, CancellationToken token = default)
{
if (dispatcher == null)
dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;

var result = new AlbumArt();

var bitmap = await GetAlbumBitmap(f, dispatcher);
var bitmap = await GetAlbumBitmap(f, dispatcher, token);
if (bitmap != null)
{
result.ArtBitmap = await WriteableBitmapToBitmapImageAsync(bitmap, albumArtWidth, dispatcher);
Expand Down Expand Up @@ -140,10 +140,8 @@ private async static Task<WriteableBitmap> GetAlbumBitmap(IMpdFile f, CoreDispat
var fileName = GetFileIdentifier(f);

// Try loading from art cache first
result = await LoadImageFromFile(fileName, dispatcher);

if (result != null)
return result;
if (await IsAlbumArtCachedAsync(f))
return await LoadImageFromFile(fileName, dispatcher);

// Get albumart from MPD
List<byte> data = new List<byte>();
Expand All @@ -170,7 +168,7 @@ private async static Task<WriteableBitmap> GetAlbumBitmap(IMpdFile f, CoreDispat
data.AddRange(response.Data);
foundUsableArt = true;
Debug.WriteLine($"Downloading albumart: {currentSize}/{totalBinarySize}");
} while (currentSize < totalBinarySize);
} while (currentSize < totalBinarySize && !token.IsCancellationRequested);

// Fallback to readpicture if albumart didn't work
if (!foundUsableArt) do
Expand All @@ -186,7 +184,10 @@ private async static Task<WriteableBitmap> GetAlbumBitmap(IMpdFile f, CoreDispat
data.AddRange(response.Data);
foundUsableArt = true;
Debug.WriteLine($"Downloading albumart: {currentSize}/{totalBinarySize}");
} while (currentSize < totalBinarySize);
} while (currentSize < totalBinarySize && !token.IsCancellationRequested);

if (token.IsCancellationRequested)
return null;

// Create the BitmapImage on the UI Thread.
if (foundUsableArt)
Expand Down Expand Up @@ -259,19 +260,14 @@ private static async Task<WriteableBitmap> LoadImageFromFile(string fileName, Co
{
StorageFolder pictureFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("AlbumArt", CreationCollisionOption.OpenIfExists);

if (await pictureFolder.FileExistsAsync(fileName))
{
var file = await pictureFolder.GetFileAsync(fileName);
var readStream = await file.OpenReadAsync();

WriteableBitmap image = null;
await dispatcher.AwaitableRunAsync(async () => image = await BitmapFactory.FromStream(readStream));
var file = await pictureFolder.GetFileAsync(fileName);
var readStream = await file.OpenReadAsync();

readStream.Dispose();
return image;
}
WriteableBitmap image = null;
await dispatcher.AwaitableRunAsync(async () => image = await BitmapFactory.FromStream(readStream));

return null;
readStream.Dispose();
return image;
}
catch (Exception)
{
Expand Down
5 changes: 5 additions & 0 deletions Sources/FluentMPC/Services/MPDConnectionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public static async Task InitializeAsync()
}
}

/// <summary>
/// Get a raw MPD Connection. Please use <see cref="SafelySendCommandAsync{T}(IMpcCommand{T}, CoreDispatcher)"/> instead when possible.
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
public static async Task<PooledObjectWrapper<MpcConnection>> GetConnectionAsync(CancellationToken token = default)
{
return await ConnectionPool.GetObjectAsync(token);
Expand Down
7 changes: 5 additions & 2 deletions Sources/FluentMPC/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
<comment>File name is null or empty to save file in settings storage extensions</comment>
</data>
<data name="Settings_Theme.Text" xml:space="preserve">
<value>Choose Theme</value>
<value>Theme</value>
<comment>Choose theme text for Settings</comment>
</data>
<data name="Settings_Theme_Dark.Content" xml:space="preserve">
Expand Down Expand Up @@ -296,7 +296,7 @@ If you want to clear the album art cache, click this button.</value>
<value>David Bowie is credited with playing the Stylophone on his 1969 debut hit song "Space Oddity" and also for his 2002 album Heathen track titled "Slip Away," as well as on the song "Heathen (The Rays)".</value>
</data>
<data name="Settings_Sizing.Text" xml:space="preserve">
<value>Choose UI Density</value>
<value>UI Density</value>
</data>
<data name="Settings_Sizing_Compact.Content" xml:space="preserve">
<value>Compact</value>
Expand Down Expand Up @@ -448,4 +448,7 @@ If you want to clear the album art cache, click this button.</value>
<data name="UpdateDbDialogTitle" xml:space="preserve">
<value>Update the Server Database?</value>
</data>
<data name="LoadingTreeItem" xml:space="preserve">
<value>Loading...</value>
</data>
</root>
7 changes: 5 additions & 2 deletions Sources/FluentMPC/Strings/fr-fr/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@
<comment>File name is null or empty to save file in settings storage extensions</comment>
</data>
<data name="Settings_Theme.Text" xml:space="preserve">
<value>Theme</value>
<value>Thème</value>
<comment>Choose theme text for Settings</comment>
</data>
<data name="Settings_Theme_Dark.Content" xml:space="preserve">
<value>Sombre</value>
<comment>Dark theme text for Settings</comment>
</data>
<data name="Settings_Theme_Default.Content" xml:space="preserve">
<value>Theme de Windows</value>
<value>Thème de Windows</value>
<comment>Windows default theme text for Settings</comment>
</data>
<data name="Settings_Theme_Light.Content" xml:space="preserve">
Expand Down Expand Up @@ -446,4 +446,7 @@ Pour nettoyer ce cache de pochettes, cliquez sur ce bouton.</value>
<data name="UpdateDbDialogTitle" xml:space="preserve">
<value>Mettre à jour la base de données MPD ?</value>
</data>
<data name="LoadingTreeItem" xml:space="preserve">
<value>Chargement...</value>
</data>
</root>
13 changes: 0 additions & 13 deletions Sources/FluentMPC/ViewModels/FoldersViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,9 @@ namespace FluentMPC.ViewModels
{
public class FoldersViewModel : Observable
{
private ICommand _itemInvokedCommand;
private object _selectedItem;

public object SelectedItem
{
get => _selectedItem;
set => Set(ref _selectedItem, value);
}

public ObservableCollection<FilePathViewModel> SourceData { get; } = new ObservableCollection<FilePathViewModel>();
public bool IsSourceEmpty => SourceData.Count == 0;

public ICommand ItemInvokedCommand => _itemInvokedCommand ?? (_itemInvokedCommand = new RelayCommand<WinUI.TreeViewItemInvokedEventArgs>(OnItemInvoked));

public FoldersViewModel()
{
SourceData.CollectionChanged += (s, e) => OnPropertyChanged(nameof(IsSourceEmpty));
Expand All @@ -49,7 +38,5 @@ public async Task LoadDataAsync()
OnPropertyChanged(nameof(SourceData));
}

private void OnItemInvoked(WinUI.TreeViewItemInvokedEventArgs args)
=> SelectedItem = args.InvokedItem;
}
}
Loading

0 comments on commit 170782c

Please sign in to comment.