Skip to content

Commit

Permalink
Merge branch 'nift4-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Feb 9, 2024
2 parents ca630b7 + 04a00a6 commit 1fe39d6
Show file tree
Hide file tree
Showing 14 changed files with 348 additions and 199 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/compile-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Compile macOS binaries

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types:
- published
- prereleased
workflow_dispatch:

jobs:
build-x64:
runs-on: macos-14

steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.2'

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.101

- name: Build NativeInterop.xcodeproj
uses: sersoft-gmbh/xcodebuild-action@v3
with:
project: ThePBone.OSX.Native/Native/NativeInterop.xcodeproj
scheme: NativeInterop
destination: platform=macOS,arch=x86_64
build-settings: CONFIGURATION_BUILD_DIR=/Users/runner/work/GalaxyBudsClient/GalaxyBudsClient/ThePBone.OSX.Native/Native/Build/Release CONFIGURATION_TEMP_DIR=/Users/runner/work/GalaxyBudsClient/GalaxyBudsClient/ThePBone.OSX.Native/Native/Build/Intermediates.noindex
action: build

- name: Restore workloads
run: dotnet workload restore
- name: Restore dependencies
run: dotnet restore -r osx-x64 --configfile GalaxyBudsClient/nuget.config GalaxyBudsClient/GalaxyBudsClient.csproj
- name: Build x64
run: dotnet publish -r osx-x64 -o bin_osxx64 -c Release --no-restore GalaxyBudsClient/GalaxyBudsClient.csproj

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: GalaxyBudsClient_osx-x64
path: bin_osxx64/GalaxyBudsClient-*.pkg

build-arm64:
runs-on: macos-14

steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.2'

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.101

- name: Build NativeInterop.xcodeproj
uses: sersoft-gmbh/xcodebuild-action@v3
with:
project: ThePBone.OSX.Native/Native/NativeInterop.xcodeproj
scheme: NativeInterop
destination: platform=macOS,arch=arm64
build-settings: CONFIGURATION_BUILD_DIR=/Users/runner/work/GalaxyBudsClient/GalaxyBudsClient/ThePBone.OSX.Native/Native/Build/Release CONFIGURATION_TEMP_DIR=/Users/runner/work/GalaxyBudsClient/GalaxyBudsClient/ThePBone.OSX.Native/Native/Build/Intermediates.noindex
action: build

- name: Restore workloads
run: dotnet workload restore
- name: Restore dependencies
run: dotnet restore -r osx-arm64 --configfile GalaxyBudsClient/nuget.config GalaxyBudsClient/GalaxyBudsClient.csproj
- name: Build arm64
run: dotnet publish -r osx-arm64 -o bin_osxarm64 -c Release --no-restore GalaxyBudsClient/GalaxyBudsClient.csproj

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: GalaxyBudsClient_osx-arm64
path: bin_osxarm64/GalaxyBudsClient-*.pkg


attach-to-release:
runs-on: ubuntu-latest
needs: [build-x64, build-arm64]
if: github.event_name == 'release'

steps:
- name: Download setup artifact (x64)
uses: actions/download-artifact@v3
with:
name: GalaxyBudsClient_osx-x64

- name: Rename (x64)
run: mv GalaxyBudsClient-*.pkg GalaxyBudsClient_macOS_x64.pkg

- name: Download artifact (arm64)
uses: actions/download-artifact@v3
with:
name: GalaxyBudsClient_osx-arm64

- name: Rename (arm64)
run: mv GalaxyBudsClient-*.pkg GalaxyBudsClient_macOS_arm64.pkg

- uses: AButler/[email protected]
with:
files: '*.pkg'
repo-token: ${{ secrets.GH_TOKEN }}
1 change: 1 addition & 0 deletions GalaxyBudsClient/GalaxyBudsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<RuntimeIdentifiers>osx-x64;osx-arm64</RuntimeIdentifiers>
<_XSAppIconAssets>Assets.xcassets/AppIcon.appiconset</_XSAppIconAssets>
<ApplicationVersion>$(Version)</ApplicationVersion>
<SupportedOSPlatformVersion>12.0</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)'=='true'">
<DefineConstants>Linux</DefineConstants>
Expand Down
10 changes: 10 additions & 0 deletions GalaxyBudsClient/Interface/Dialogs/HotkeyActionBuilder.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
Expand Down Expand Up @@ -224,5 +225,14 @@ private void Action_OnSelectionChanged(object? sender, SelectionChangedEventArgs
{
UpdateKeyCombo();
}

public new async Task ShowDialog(Window owner)
{
await Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(async () =>
{
await Task.Delay(300);
await base.ShowDialog(owner);
});
}
}
}
10 changes: 10 additions & 0 deletions GalaxyBudsClient/Interface/Dialogs/HotkeyRecorder.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
Expand Down Expand Up @@ -75,5 +76,14 @@ protected override void OnClosed(EventArgs e)
}
base.OnClosed(e);
}

public new async Task ShowDialog(Window owner)
{
await Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(async () =>
{
await Task.Delay(300);
await base.ShowDialog(owner);
});
}
}
}
10 changes: 10 additions & 0 deletions GalaxyBudsClient/Interface/Dialogs/InputDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
Expand All @@ -16,6 +17,15 @@ public InputDialog()

Input = this.FindControl<TextBox>("Input");

Check warning on line 18 in GalaxyBudsClient/Interface/Dialogs/InputDialog.xaml.cs

View workflow job for this annotation

GitHub Actions / build-x64-musl

Possible null reference assignment.
}

public new async Task<TResult> ShowDialog<TResult>(Window owner)
{
return await Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(async () =>
{
await Task.Delay(300);
return await base.ShowDialog<TResult>(owner);
});
}

private void Cancel_OnClick(object? sender, RoutedEventArgs e)
{
Expand Down
10 changes: 10 additions & 0 deletions GalaxyBudsClient/Interface/Dialogs/ManualPairDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
Expand Down Expand Up @@ -41,6 +42,15 @@ public ManualPairDialog()
Init();
}

public new async Task<TResult> ShowDialog<TResult>(Window owner)
{
return await Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(async () =>
{
await Task.Delay(300);
return await base.ShowDialog<TResult>(owner);
});
}

private async void Init()
{
Device.ItemsSource = await BluetoothImpl.Instance.GetDevicesAsync();
Expand Down
12 changes: 11 additions & 1 deletion GalaxyBudsClient/Interface/Dialogs/MessageBox.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
Expand All @@ -21,7 +22,16 @@ public MessageBox()
DataContext = this;
AvaloniaXamlLoader.Load(this);
}


public new Task ShowDialog(Window owner)
{
return Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(async () =>
{
await Task.Delay(300);
await base.ShowDialog(owner);
});
}

private void Apply_OnClick(object? sender, RoutedEventArgs e)
{
Close();
Expand Down
10 changes: 10 additions & 0 deletions GalaxyBudsClient/Interface/Dialogs/QuestionBox.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
Expand All @@ -21,6 +22,15 @@ public QuestionBox()
DataContext = this;
AvaloniaXamlLoader.Load(this);
}

public new async Task<TResult> ShowDialog<TResult>(Window owner)
{
return await Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(async () =>
{
await Task.Delay(300);
return await base.ShowDialog<TResult>(owner);
});
}

private void Apply_OnClick(object? sender, RoutedEventArgs e)
{
Expand Down
22 changes: 8 additions & 14 deletions GalaxyBudsClient/Interface/Pages/DeviceSelectionPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,13 @@ private void ManualPair_OnPointerPressed(object? sender, PointerPressedEventArgs
{
Avalonia.Threading.Dispatcher.UIThread.Post(async () =>
{
await Task.Delay(300);
var dialog = new ManualPairDialog();
var accepted = await dialog.ShowDialog<bool>(MainWindow.Instance);
if (accepted)
{
if (dialog.SelectedModel == Models.NULL || dialog.SelectedDeviceMac == null)
{
ShowErrorDialogSafely();
ShowErrorDialog();
return;
}

Expand All @@ -113,7 +112,7 @@ private void Next_OnPointerPressed(object? sender, PointerPressedEventArgs e)

if (Selection is not { Count: > 0 } || Selection.SelectedItem == null)
{
ShowErrorDialogSafely();
ShowErrorDialog();
return;
}

Expand All @@ -122,25 +121,20 @@ private void Next_OnPointerPressed(object? sender, PointerPressedEventArgs e)

if (spec == null || selection.IsConnected == false || selection.Address == string.Empty)
{
ShowErrorDialogSafely();
ShowErrorDialog();
return;
}

RegisterDevice(spec.Device, selection.Address);
}

// Workaround for Avalonia 11 focusing bug
private static void ShowErrorDialogSafely()
private static void ShowErrorDialog()
{
Avalonia.Threading.Dispatcher.UIThread.Post(async () =>
new MessageBox()
{
await Task.Delay(300);
await new MessageBox()
{
Title = Loc.Resolve("error"),
Description = Loc.Resolve("devsel_invalid_selection")
}.ShowDialog(MainWindow.Instance);
});
Title = Loc.Resolve("error"),
Description = Loc.Resolve("devsel_invalid_selection")
}.ShowDialog(MainWindow.Instance);
}

private async void RegisterDevice(Models model, string mac)
Expand Down
Loading

0 comments on commit 1fe39d6

Please sign in to comment.