-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partially Added in-app updater functionality
- Loading branch information
1 parent
cd7431f
commit 55291f1
Showing
25 changed files
with
412 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ jobs: | |
|
||
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild | ||
- name: Setup MSBuild.exe | ||
uses: microsoft/setup-msbuild@v1.1 | ||
uses: microsoft/setup-msbuild@v2 | ||
|
||
# Add Community Toolkit Labs Repository for some Packages to get Installed | ||
- name: Add CommunityToolkit Labs Package Repository | ||
|
@@ -82,11 +82,3 @@ jobs: | |
retention-days: 10 | ||
path: ${{ github.workspace }}\\src\AniMoe.App\Packages\AniMoe.App.msix | ||
|
||
- name: Send discord announcement | ||
uses: snorrwe/[email protected] | ||
with: | ||
discord_message: new | ||
discord_token: ${{ secrets.DISCORD_BOT_TOKEN }} | ||
post_file: changelog.md | ||
discord_channel: '1122748057696604163' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,3 +113,11 @@ jobs: | |
tag_name: ${{ env.APP_VERSION }} | ||
generate_release_notes: true | ||
|
||
# Sends a message to the #updates channel on AniMoe's Cafe discord server. | ||
- name: Send discord announcement | ||
uses: snorrwe/[email protected] | ||
with: | ||
discord_message: new | ||
discord_token: ${{ secrets.DISCORD_BOT_TOKEN }} | ||
post_file: changelog.md | ||
discord_channel: '1170356953785061517' |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
## AniMoe Version 0.0.2 | ||
|
||
### What's new? | ||
- Added a new installer where you can install AniMoe without using any scripts. | ||
- Testing out the automatic updator fucntion. | ||
- Some pakcages bump | ||
- Added a new installer (animoe_setup.exe) where you can install AniMoe without using any scripts. | ||
- Testing out the automatic updator function. | ||
- Some packages bumped. | ||
|
||
[GitHub](https://github.com/CosmicPredator/AniMoe) | [Download](https://github.com/CosmicPredator/AniMoe/releases/latest/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/AniMoe.App/Controls/SettingsViewControls/UpdateDialog.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentDialog | ||
x:Class="AniMoe.App.Controls.SettingsViewControls.UpdateDialog" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="using:AniMoe.App.Controls.SettingsViewControls" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls" | ||
CloseButtonText="Not now" | ||
CornerRadius="10" | ||
Loaded="ContentDialog_Loaded" | ||
PrimaryButtonClick="ContentDialog_PrimaryButtonClick" | ||
PrimaryButtonStyle="{ThemeResource AccentButtonStyle}" | ||
PrimaryButtonText="Update & Restart" | ||
mc:Ignorable="d"> | ||
|
||
<ContentDialog.CloseButtonStyle> | ||
<Style TargetType="Button"> | ||
<Setter Property="CornerRadius" Value="4" /> | ||
</Style> | ||
</ContentDialog.CloseButtonStyle> | ||
|
||
<Grid | ||
Width="400" | ||
Margin="0" | ||
RowSpacing="5"> | ||
|
||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
</Grid.RowDefinitions> | ||
|
||
<TextBlock | ||
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" | ||
Style="{ThemeResource TitleTextBlockStyle}" | ||
Text="Update Available!" /> | ||
|
||
<StackPanel | ||
Grid.Row="1" | ||
Orientation="Vertical" | ||
Spacing="5"> | ||
<TextBlock VerticalAlignment="Center"> | ||
<Run FontWeight="SemiBold" Text="Version:" /> | ||
<Run Text="{x:Bind Model.TagName, Mode=OneWay}" /> | ||
</TextBlock> | ||
|
||
<TextBlock VerticalAlignment="Center"> | ||
<Run FontWeight="SemiBold" Text="Size:" /> | ||
<Run x:Name="SizeTextBlock" /> | ||
</TextBlock> | ||
|
||
<TextBlock | ||
Margin="0,10,0,0" | ||
FontSize="17" | ||
FontWeight="Medium" | ||
Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" | ||
Text="Changelog:" /> | ||
|
||
<toolkit:MarkdownTextBlock | ||
x:Name="MdTextBlock" | ||
Background="Transparent" | ||
LinkClicked="MdTextBlock_LinkClicked" | ||
Text="{x:Bind Model.Body}" /> | ||
|
||
<StackPanel | ||
x:Name="LoaderStackPanel" | ||
Margin="0,10,0,0" | ||
Orientation="Horizontal" | ||
Spacing="10" | ||
Visibility="Collapsed"> | ||
<ProgressRing IsIndeterminate="True" /> | ||
<TextBlock | ||
VerticalAlignment="Center" | ||
FontSize="16" | ||
FontWeight="SemiBold" | ||
Text="Updating..." /> | ||
</StackPanel> | ||
</StackPanel> | ||
|
||
</Grid> | ||
</ContentDialog> |
56 changes: 56 additions & 0 deletions
56
src/AniMoe.App/Controls/SettingsViewControls/UpdateDialog.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using AniMoe.Updater; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using Microsoft.UI.Xaml.Data; | ||
using Microsoft.UI.Xaml.Input; | ||
using Microsoft.UI.Xaml.Media; | ||
using Microsoft.UI.Xaml.Navigation; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.WindowsRuntime; | ||
using Windows.Foundation; | ||
using Windows.Foundation.Collections; | ||
|
||
namespace AniMoe.App.Controls.SettingsViewControls | ||
{ | ||
public sealed partial class UpdateDialog : ContentDialog | ||
{ | ||
public GithubModel Model; | ||
public UpdateDialog(GithubModel model) | ||
{ | ||
this.InitializeComponent(); | ||
Model = model; | ||
DataContext = this; | ||
} | ||
|
||
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) | ||
{ | ||
args.Cancel = true; | ||
foreach(var i in Model.Assets) | ||
{ | ||
if (i.Name.Contains(".msix")) | ||
{ | ||
Debug.WriteLine(i.Name); | ||
Debug.WriteLine(i.Size); | ||
Debug.WriteLine(i.BrowserDownloadUrl); | ||
} | ||
} | ||
} | ||
|
||
private void ContentDialog_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
double assetSize = Math.Round( | ||
(Model.Assets.First(x => x.Name.Contains(".msix")).Size * 0.000001), 2); | ||
SizeTextBlock.Text = $"{assetSize}MB"; | ||
} | ||
|
||
private async void MdTextBlock_LinkClicked(object sender, CommunityToolkit.WinUI.UI.Controls.LinkClickedEventArgs e) | ||
{ | ||
await Windows.System.Launcher.LaunchUriAsync(new Uri(e.Link)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using AniMoe.App.Controls.SettingsViewControls; | ||
using AniMoe.Updater; | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.UI.Dispatching; | ||
using Microsoft.UI.Xaml; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.ApplicationModel; | ||
|
||
namespace AniMoe.App.ViewModels | ||
{ | ||
public partial class UpdateViewModel : ObservableObject | ||
{ | ||
|
||
private UpdateHandler handler = App.Current.Services.GetRequiredService<UpdateHandler>(); | ||
private XamlRoot _currentXamlRoot; | ||
private DispatcherQueue _dispatcherQueue; | ||
|
||
[ObservableProperty] | ||
private string _currentAppVersion; | ||
|
||
[ObservableProperty] | ||
private GithubModel _model; | ||
|
||
[ObservableProperty] | ||
private string _buttonStatus = "Check for Update"; | ||
|
||
[ObservableProperty] | ||
private bool _loaderState; | ||
|
||
[ObservableProperty] | ||
private bool _updateButtonEnable = true; | ||
|
||
[RelayCommand] | ||
private async Task runRequest() | ||
{ | ||
LoaderState = true; | ||
Model = await handler.CheckLatestRelease(); | ||
LoaderState = false; | ||
if (Model.TagName.CompareTo(CurrentAppVersion) < 0) | ||
{ | ||
_dispatcherQueue.TryEnqueue(async () => | ||
{ | ||
UpdateDialog dialog = new(Model); | ||
dialog.XamlRoot = null; | ||
dialog.XamlRoot = _currentXamlRoot; | ||
await dialog.ShowAsync(); | ||
}); | ||
} else | ||
{ | ||
ButtonStatus = "No Updates Available"; | ||
UpdateButtonEnable = false; | ||
} | ||
} | ||
|
||
public UpdateViewModel(XamlRoot xamlRoot, DispatcherQueue dispatcherQueue) | ||
{ | ||
CurrentAppVersion = string.Format("Version: {0}.{1}.{2}", | ||
Package.Current.Id.Version.Major, | ||
Package.Current.Id.Version.Minor, | ||
Package.Current.Id.Version.Build); | ||
_currentXamlRoot = xamlRoot; | ||
_dispatcherQueue = dispatcherQueue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.