Skip to content

Commit

Permalink
Merge pull request #17 from AzureAms/dev/trungnt2910
Browse files Browse the repository at this point in the history
chore: Merge dev to master branch
  • Loading branch information
trungnt2910 authored Aug 26, 2022
2 parents b655b7e + d6f55b5 commit e985668
Show file tree
Hide file tree
Showing 26 changed files with 176 additions and 323 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

env:
BUILD_CONFIG: 'Release'
PACKAGE_NAME: com.azureams.TimetableApp
PACKAGE_NAME: org.azureams.TimetableApp

name: Build app (Android)
# Also need to run on Windows Server 2022
Expand All @@ -48,7 +48,7 @@ jobs:
run: nuget restore TimetableApp.Uno.sln

- name: Build
run: msbuild TimetableApp/TimetableApp.Droid/TimetableApp.Droid.csproj /t:PackageForAndroid /p:Configuration=Release
run: msbuild TimetableApp/TimetableApp.Droid/TimetableApp.Droid.csproj /p:Configuration=Release /p:AndroidBuildApplicationPackage=true

- name: Publish arm64 APK
uses: actions/upload-artifact@v2
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci_uwp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
steps:
# Checkout the code
- uses: actions/checkout@v2
with:
# For the DataGrid
fetch-depth: 0
submodules: 'recursive'

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.0.2
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Timetable
Copyright (C) 2021 Trung Nguyen
Copyright (C) 2021 AzureAms Open Source Community
Copyright (C) 2022 AzureAms Programming Club

## The MIT license

Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ git

## Related issues:
### Uno Platform's macOS specific issues:
- [#7312](https://github.com/unoplatform/uno/issues/7312) \[MacOS\] NavigationView Items not working. (Scheduled for Uno Platform 3.11 release but still not fixed now.)
- [#7319](https://github.com/unoplatform/uno/issues/7319) \[macOS\] Application freezes when DataGrid contains data.
- [#7319](https://github.com/unoplatform/uno/issues/7319) \[macOS\] Application freezes when DataGrid contains data. (Not fixed but closed by the Uno Platform maintainers).
- [#8110](https://github.com/unoplatform/uno/issues/8110) \[macOS\] DataGrid on a TabView not appearing in macOS (Similar issue, TimetableApp also uses a DataGrid on a TabView).

These two issues are making _any_ support for macOS impossible.
This issue is making _any_ support for macOS impossible.

### Uno Platform's theming issues:
- [#7210](https://github.com/unoplatform/uno/issues/7210) Weird dark mode NavigationView colors.
### Uno Platform's Linux specific issues:
- [#7212](https://github.com/unoplatform/uno/issues/7212) \[Skia.GTK\] Applications do not respond to Dark mode themes. The method Uno Platform uses to detect Dark/Light mode for Skia.GTK is currently faulty.

Because of these two issues, for platforms other than UWP (Windows), we are locking TimetableApp in Light mode.
- [#8643](https://github.com/unoplatform/uno/issues/8643) \[Skia\] OpenGL render surface fails with a null reference on WSL. TimetableApp is still forced to use software rendering.
- [#8661](https://github.com/unoplatform/uno/issues/8661) MessageDialog does not show Close button on Skia.GTK (Linux, WSL). Currently, TimetableApp.Skia.GTK still uses the [native MessageDialog hack](https://github.com/AzureAms/TimetableApp.Uno/blob/master/TimetableApp/TimetableApp.Skia.Gtk/MessageDialog.cs).
10 changes: 8 additions & 2 deletions TimetableApp/TimetableApp.Droid/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.AzureAms.TimetableApp" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="31" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.azureams.TimetableApp" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="TimetableApp"></application>
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="*" />
</intent>
</queries>
</manifest>
17 changes: 6 additions & 11 deletions TimetableApp/TimetableApp.Droid/TimetableApp.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ToastNotification.Uno">
<Version>0.1.5</Version>
</PackageReference>
<PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.DataGrid">
<Version>7.1.11</Version>
</PackageReference>
<PackageReference Include="Uno.UI" Version="4.0.13" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging">
<Version>4.0.13</Version>
</PackageReference>
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.13" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="ToastNotification.Uno" Version="0.1.7" />
<PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.DataGrid" Version="7.1.11" />
<PackageReference Include="Uno.SourceGenerationTasks" Version="4.1.0" />
<PackageReference Include="Uno.UI" Version="4.2.6" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.2.6" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.2.6" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UniversalImageLoader" Version="1.9.35" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
Expand Down
6 changes: 0 additions & 6 deletions TimetableApp/TimetableApp.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ public App()
#if HAS_UNO || NETFX_CORE
this.Suspending += OnSuspending;
#endif

// Hack until issue:
// https://github.com/unoplatform/uno/issues/7210 is resolved.
#if HAS_UNO
RequestedTheme = ApplicationTheme.Light;
#endif
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions TimetableApp/TimetableApp.Shared/Dialogs/AboutDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<StackPanel>
<TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="Timetable"/>
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="Copyright (C) 2021 Trung Nguyen"/>
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="Copyright (C) 2022 AzureAms Programming Club"/>
<TextBlock Style="{StaticResource BodyTextBlockStyle}">
<Span xml:space="preserve"><Run>This program is free software, covered by the terms of the </Run><Hyperlink NavigateUri="https://github.com/trungnt2910/RootLicense/blob/master/LICENSE.md">Root License</Hyperlink><Run>.</Run></Span>
<Span xml:space="preserve"><Run>This program is licensed under the </Run><Hyperlink NavigateUri="https://github.com/AzureAms/TimetableApp.Uno/blob/master/LICENSE.md">MIT License</Hyperlink><Run>.</Run></Span>
</TextBlock>
<TextBlock Style="{StaticResource BodyTextBlockStyle}" FontWeight="Bold" Text="This program is provided &quot;AS-IS&quot;, without warranties of any kind, expressed or implied. You use this program AT YOUR OWN RISK."/>
</StackPanel>
</ContentDialog>
3 changes: 2 additions & 1 deletion TimetableApp/TimetableApp.Shared/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:toolkit="using:Uno.UI.Toolkit"
mc:Ignorable="d">
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid toolkit:VisibleBoundsPadding.PaddingMask="All">
<muxc:NavigationView x:Name="NavView"
Expand Down
198 changes: 102 additions & 96 deletions TimetableApp/TimetableApp.Skia.Gtk/MessageDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
// This file contains code that is not suitable for children or those who are easily disturbed.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
Expand All @@ -16,104 +17,109 @@

namespace Windows.UI.Popups
{
public sealed partial class MessageDialog
{
private static readonly MethodInfo FromTaskFunction = typeof(IAsyncOperation<IUICommand>).Assembly.GetTypes()
.FirstOrDefault(type => !type.IsGenericType && type.FullName == "Windows.Foundation.AsyncOperation")
.GetMethod("FromTask", BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(typeof(IUICommand));

/// <summary>
/// Creates a new instance of the MessageDialog class, using the specified message content and no title.
/// </summary>
/// <param name="content"></param>
public MessageDialog(string content)
: this(content, "")
{
}

/// <summary>
/// Creates a new instance of the MessageDialog class, using the specified message content and title.
/// </summary>
/// <param name="content"></param>
/// <param name="title"></param>
public MessageDialog(string content, string title)
{
if (content == null)
{
throw new ArgumentNullException(nameof(content));
}

if (title == null)
{
throw new ArgumentNullException(nameof(title));
}

// They can both be empty.
Content = content;
Title = title;

var collection = new ObservableCollection<IUICommand>();
collection.CollectionChanged += (s, e) => this.ValidateCommands();

Commands = collection;
}

public uint CancelCommandIndex { get; set; } = uint.MaxValue;
public IList<IUICommand> Commands { get; }
public string Content { get; set; }
public uint DefaultCommandIndex { get; set; } = 0;
public MessageDialogOptions Options { get; set; }
public string Title { get; set; }

public IAsyncOperation<IUICommand> ShowAsync()
/// <summary>
/// A hack class, originally written to fix the lack of MessageDialog support on Uno Platform for Skia targets.
/// While MessageDialog has been officially added since 4.2.6, unoplatform/uno#8661 is preventing
/// the dialog from working correctly (no Close button, hanging the app).
/// </summary>
public sealed partial class MessageDialog
{
private static readonly MethodInfo FromTaskFunction = typeof(IAsyncOperation<IUICommand>).Assembly.GetTypes()
.FirstOrDefault(type => !type.IsGenericType && type.FullName == "Windows.Foundation.AsyncOperation")
.GetMethod("FromTask", BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(typeof(IUICommand));

/// <summary>
/// Creates a new instance of the MessageDialog class, using the specified message content and no title.
/// </summary>
/// <param name="content"></param>
public MessageDialog(string content)
: this(content, "")
{
Func<CancellationToken, Task<IUICommand>> func = async (ct) =>
{
return await Task.Run(() =>
{
var waitHandle = new ManualResetEventSlim();
int result = -1;
Gtk.Application.Invoke((s, a) =>
{
var dialog = new Gtk.Dialog(Title, GtkHost.Window, Gtk.DialogFlags.Modal);
dialog.SkipTaskbarHint = true;
}

/// <summary>
/// Creates a new instance of the MessageDialog class, using the specified message content and title.
/// </summary>
/// <param name="content"></param>
/// <param name="title"></param>
public MessageDialog(string content, string title)
{
if (content == null)
{
throw new ArgumentNullException(nameof(content));
}

if (title == null)
{
throw new ArgumentNullException(nameof(title));
}

// They can both be empty.
Content = content;
Title = title;

var collection = new ObservableCollection<IUICommand>();
collection.CollectionChanged += (s, e) => this.ValidateCommands();

Commands = collection;
}

public uint CancelCommandIndex { get; set; } = uint.MaxValue;
public IList<IUICommand> Commands { get; }
public string Content { get; set; }
public uint DefaultCommandIndex { get; set; } = 0;
public MessageDialogOptions Options { get; set; }
public string Title { get; set; }

public IAsyncOperation<IUICommand> ShowAsync()
{
Func<CancellationToken, Task<IUICommand>> func = async (ct) =>
{
return await Task.Run(() =>
{
var waitHandle = new ManualResetEventSlim();
int result = -1;
Gtk.Application.Invoke((s, a) =>
{
var dialog = new Gtk.Dialog(Title, GtkHost.Window, Gtk.DialogFlags.Modal);
dialog.SkipTaskbarHint = true;

Gtk.Label label = new Gtk.Label(Content);
label.Halign = Gtk.Align.Fill;
dialog.ContentArea.Add(label);
label.Show();

if (Commands.Count == 0)
{
Commands.Add(new UICommand("Close"));
}
for (int i = 0; i < Commands.Count; ++i)
{
dialog.AddButton(Commands[i].Label, i);
}

dialog.DefaultResponse = (Gtk.ResponseType)DefaultCommandIndex;

result = dialog.Run();

dialog.Hide();
// dialog.Destroy();
dialog.Dispose();

waitHandle.Set();
});
waitHandle.Wait();

if (result < 0) result = unchecked((int)CancelCommandIndex);
// CancelCommandIndex still not set.
if (result < 0) result = (int)DefaultCommandIndex;
return Commands[result];
}, ct);
};
return FromTaskFunction.Invoke(null, new object[] { func }) as IAsyncOperation<IUICommand>;
label.Halign = Gtk.Align.Fill;
dialog.ContentArea.Add(label);
label.Show();

if (Commands.Count == 0)
{
Commands.Add(new UICommand("Close"));
}
for (int i = 0; i < Commands.Count; ++i)
{
dialog.AddButton(Commands[i].Label, i);
}

dialog.DefaultResponse = (Gtk.ResponseType)DefaultCommandIndex;

result = dialog.Run();

dialog.Hide();
// dialog.Destroy();
dialog.Dispose();

waitHandle.Set();
});
waitHandle.Wait();

if (result < 0) result = unchecked((int)CancelCommandIndex);
// CancelCommandIndex still not set.
if (result < 0) result = (int)DefaultCommandIndex;

return Commands[result];
}, ct);
};
return FromTaskFunction.Invoke(null, new object[] { func }) as IAsyncOperation<IUICommand>;
}

partial void ValidateCommands();
}
partial void ValidateCommands();
}
}
4 changes: 4 additions & 0 deletions TimetableApp/TimetableApp.Skia.Gtk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ static void Main(string[] args)

var host = new GtkHost(() => new App(), args);

// OpenGL render does not work on some environments,
// such as WSL. See unoplatform/uno#8643
host.RenderSurfaceType = RenderSurfaceType.Software;

host.Run();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="ToastNotification.Uno.Gtk" Version="0.1.5" />
<PackageReference Include="Uno.UI.Skia.Gtk" Version="4.2.0-dev.35" />
<PackageReference Include="ToastNotification.Uno.Gtk" Version="0.1.7" />
<PackageReference Include="Uno.UI.Skia.Gtk" Version="4.2.6"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.DataGrid" Version="7.1.11" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.13" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.0.13" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.2.6" />
<PackageReference Include="Uno.UI.RemoteControl" Version="4.2.6" Condition="'$(Configuration)'=='Debug'" />
</ItemGroup>
<Import Project="..\TimetableApp.Shared\TimetableApp.Shared.projitems" Label="Shared" />
</Project>
2 changes: 1 addition & 1 deletion TimetableApp/TimetableApp.Skia.Wpf.Host/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
xmlns:local="clr-namespace:TimetableApp.WPF.Host"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="WpfHost.xaml" />

</Application.Resources>
</Application>
4 changes: 0 additions & 4 deletions TimetableApp/TimetableApp.Skia.Wpf.Host/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@ namespace TimetableApp.WPF.Host
/// </summary>
public partial class App : Application
{
static App()
{
Skia.Wpf.MessageBox.Show = (Content, Title) => MessageBox.Show(Content, Title, MessageBoxButton.OK);
}
}
}
Loading

0 comments on commit e985668

Please sign in to comment.