Skip to content

Commit

Permalink
0.0.2 - Implemented In-App Updater
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicPredator committed Feb 8, 2024
1 parent 55291f1 commit f48b368
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 73 deletions.
8 changes: 6 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
## AniMoe Version 0.0.2

### Fixes:
- Fixed the Navigation Pane where it breaks the ui when the window is maximized.

### What's new?
- 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.
- Added a new In-App updater feature.
- Both AniMoe.msix and animoe_setup.exe are now signed with a proper certificate.
- Bumped some packages to latest version.

[GitHub](https://github.com/CosmicPredator/AniMoe) | [Download](https://github.com/CosmicPredator/AniMoe/releases/latest/)
4 changes: 3 additions & 1 deletion src/AniMoe.App/AniMoe.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<ApplicationIcon>Window-Icon.ico</ApplicationIcon>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningEnabled>False</AppxPackageSigningEnabled>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxPackageDir>E:\Notes\</AppxPackageDir>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
Expand All @@ -25,6 +25,8 @@
<AppInstallerUri>E:\fonts</AppInstallerUri>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
<AppxBundlePlatforms>x64</AppxBundlePlatforms>
<PackageCertificateThumbprint>34FD2A46959D50DE9A7A7899E5DDF7A3C6F7CC79</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Constants\**" />
Expand Down
102 changes: 53 additions & 49 deletions src/AniMoe.App/Controls/SettingsViewControls/UpdateDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,62 +21,66 @@
</Style>
</ContentDialog.CloseButtonStyle>

<Grid
Width="400"
Margin="0"
RowSpacing="5">
<ScrollViewer>
<Grid
Width="400"
MaxHeight="600"
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>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<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}" />
Style="{ThemeResource TitleTextBlockStyle}"
Text="Update Available!" />

<StackPanel
x:Name="LoaderStackPanel"
Margin="0,10,0,0"
Orientation="Horizontal"
Spacing="10"
Visibility="Collapsed">
<ProgressRing IsIndeterminate="True" />
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
VerticalAlignment="Center"
FontSize="16"
FontWeight="SemiBold"
Text="Updating..." />
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 AniMoe. This may take a minute..."
TextWrapping="WrapWholeWords" />
</StackPanel>
</StackPanel>
</StackPanel>

</Grid>
</Grid>
</ScrollViewer>
</ContentDialog>
19 changes: 8 additions & 11 deletions src/AniMoe.App/Controls/SettingsViewControls/UpdateDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,28 @@ namespace AniMoe.App.Controls.SettingsViewControls
public sealed partial class UpdateDialog : ContentDialog
{
public GithubModel Model;
public Uri AssetUrl;
public UpdateDialog(GithubModel model)
{
this.InitializeComponent();
Model = model;
DataContext = this;
}

private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
private async 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);
}
}
LoaderStackPanel.Visibility = Visibility.Visible;
await new UpdateService().UpdateAniMoe(AssetUrl);
LoaderStackPanel.Visibility = Visibility.Collapsed;
}

private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
{
var selectedMsix = Model.Assets.First(x => x.Name.Contains(".msix"));
AssetUrl = selectedMsix.BrowserDownloadUrl;
double assetSize = Math.Round(
(Model.Assets.First(x => x.Name.Contains(".msix")).Size * 0.000001), 2);
(selectedMsix.Size * 0.000001), 2);
SizeTextBlock.Text = $"{assetSize}MB";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@
<Grid
x:Name="GenreDataPanel"
Grid.Row="3"
x:Load="{x:Bind _loadGenreTable, Mode=OneWay}"
RowSpacing="15">
<!-- x:Load="{x:Bind _loadGenreTable, Mode=OneWay}" -->

<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand Down
2 changes: 1 addition & 1 deletion src/AniMoe.App/ViewModels/UpdateViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private async Task runRequest()
LoaderState = true;
Model = await handler.CheckLatestRelease();
LoaderState = false;
if (Model.TagName.CompareTo(CurrentAppVersion) < 0)
if (Model.TagName.CompareTo(CurrentAppVersion) > 0)
{
_dispatcherQueue.TryEnqueue(async () =>
{
Expand Down
2 changes: 1 addition & 1 deletion src/AniMoe.App/Views/MasterView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private void RepositionTitleBar()
}
else
{
MasterNavView.PaneDisplayMode = NavigationViewPaneDisplayMode.Left;
MasterNavView.PaneDisplayMode = NavigationViewPaneDisplayMode.LeftCompact;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/AniMoe.Updater/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

namespace AniMoe.Updater
{
public class Entry
public class UpdateService
{
public async Task UpdateAniMoe()
public async Task UpdateAniMoe(Uri assetUrl)
{
uint res = ReopenHandler.RegisterApplicationRestart(null, ReopenHandler.RestartFlags.NONE);

PackageManager pm = new();
var data = await pm.UpdatePackageAsync(
new Uri("https://i-will-do.with-your.mom/r/AniMoe.App_0.0.2.102_x64.msix"),
assetUrl,
null,
DeploymentOptions.ForceApplicationShutdown
);
Expand Down
4 changes: 0 additions & 4 deletions src/AniMoe.Updater/UpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ public UpdateHandler(HttpClient httpClient)
Package.Current.Id.Version.Minor,
Package.Current.Id.Version.Build);

// It's a read-only access token. So, You can't do anything but reading public repos
_accessToken =
"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";
_baseUrl = @"https://api.github.com/repos/CosmicPredator/AniMoe/releases/latest";

_httpClient.DefaultRequestHeaders.Add("Accept", "application/vnd.github+json");
_httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {_accessToken}");
_httpClient.DefaultRequestHeaders.Add("X-GitHub-Api-Version", "2022-11-28");
_httpClient.DefaultRequestHeaders.Add("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0");
Expand Down

0 comments on commit f48b368

Please sign in to comment.