Skip to content

Feature: Added progress ring when updating app #10970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Files.App/ServicesImplementation/SideloadUpdateService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.WinUI.Helpers;
using Files.Backend.Services;
using Files.Shared;
using System;
Expand Down Expand Up @@ -54,6 +55,13 @@ public bool IsUpdating
private set => SetProperty(ref _isUpdating, value);
}

private bool _isAppUpdated;
public bool IsAppUpdated
{
get => _isAppUpdated;
private set => SetProperty(ref _isAppUpdated, value);
}

public async Task DownloadUpdates()
{
await ApplyPackageUpdate();
Expand All @@ -64,6 +72,11 @@ public Task DownloadMandatoryUpdates()
return Task.CompletedTask;
}

public SideloadUpdateService()
{
IsAppUpdated = SystemInformation.Instance.IsAppUpdated;
}

public async Task CheckForUpdates()
{
try
Expand Down
12 changes: 10 additions & 2 deletions src/Files.App/ServicesImplementation/UpdateService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.WinUI.Helpers;
using Files.App.Extensions;
using Files.Backend.Services;
using Microsoft.UI.Xaml.Controls;
Expand All @@ -20,24 +21,31 @@ internal sealed class UpdateService : ObservableObject, IUpdateService
private bool IsMandatory => _updatePackages?.Where(e => e.Mandatory).ToList().Count >= 1;

private bool _isUpdateAvailable;

public bool IsUpdateAvailable
{
get => _isUpdateAvailable;
set => SetProperty(ref _isUpdateAvailable, value);
}

private bool _isUpdating;

public bool IsUpdating
{
get => _isUpdating;
private set => SetProperty(ref _isUpdating, value);
}

private bool _isAppUpdated;
public bool IsAppUpdated
{
get => _isAppUpdated;
private set => SetProperty(ref _isAppUpdated, value);
}

public UpdateService()
{
_updatePackages = new List<StorePackageUpdate>();

IsAppUpdated = SystemInformation.Instance.IsAppUpdated;
}

public async Task DownloadUpdates()
Expand Down
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2874,4 +2874,7 @@
<data name="EditSettingsFile" xml:space="preserve">
<value>Edit Settings File</value>
</data>
<data name="ReleaseNotes" xml:space="preserve">
<value>Release Notes</value>
</data>
</root>
32 changes: 31 additions & 1 deletion src/Files.App/UserControls/AddressToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
Value="{x:Bind OngoingTasksViewModel.InfoBadgeValue, Mode=OneWay}" />
</Grid>

<!-- Install Update Notification -->
<Button
x:Name="UpdateButton"
HorizontalContentAlignment="Stretch"
Expand All @@ -270,10 +271,39 @@
IsEnabled="{x:Bind ViewModel.UpdateService.IsUpdating, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
Style="{StaticResource AddressToolbarButtonStyle}"
ToolTipService.ToolTip="{helpers:ResourceString Name=UpdateFiles}">
<Grid>
<!-- Icon -->
<FontIcon
x:Name="UpdateIcon"
x:Load="{x:Bind ViewModel.UpdateService.IsUpdating, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
FontSize="14"
Foreground="{ThemeResource SystemAccentColor}"
Glyph="&#xE896;" />

<!-- Progress -->
<ProgressRing
x:Name="UpdateProgressRing"
Width="20"
Height="20"
x:Load="{x:Bind ViewModel.UpdateService.IsUpdating, Mode=OneWay}"
IsIndeterminate="True" />
</Grid>
</Button>

<!-- Update Release Notes -->
<Button
x:Name="ViewReleaseNotesButton"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
x:Load="{x:Bind ViewModel.UpdateService.IsAppUpdated, Mode=OneWay}"
AccessKey="2"
AutomationProperties.Name="{helpers:ResourceString Name=ReleaseNotes}"
Style="{StaticResource AddressToolbarButtonStyle}"
ToolTipService.ToolTip="{helpers:ResourceString Name=ReleaseNotes}">
<FontIcon
FontSize="14"
Foreground="{ThemeResource SystemAccentColor}"
Glyph="&#xE896;" />
Glyph="&#xF133;" />
</Button>

<Button
Expand Down
5 changes: 5 additions & 0 deletions src/Files.Backend/Services/IUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public interface IUpdateService : INotifyPropertyChanged
/// </summary>
bool IsUpdating { get; }

/// <summary>
/// Gets a value indicating if the apps being used the first time after an update.
/// </summary>
bool IsAppUpdated { get; }

Task DownloadUpdates();

Task DownloadMandatoryUpdates();
Expand Down