Skip to content
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

Install updates from Files #2508

Merged
merged 13 commits into from
Dec 17, 2020
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
2 changes: 1 addition & 1 deletion Files.Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
IgnorableNamespaces="uap uap5 mp rescap desktop4 desktop">
<Identity Name="FilesDev" Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" Version="0.21.3.0" />
<Identity Name="FilesDev" Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" Version="0.22.1.0" />
<Properties>
<DisplayName>Files - Dev</DisplayName>
<PublisherDisplayName>Yair A</PublisherDisplayName>
Expand Down
1 change: 1 addition & 0 deletions Files/Files.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<Compile Include="Converters\StorageDeleteOptionToBooleanConverter.cs" />
<Compile Include="Converters\StringArrayToString.cs" />
<Compile Include="Converters\UInt32ToString.cs" />
<Compile Include="Helpers\AppUpdater.cs" />
<Compile Include="DataModels\DefaultLanguageModel.cs" />
<Compile Include="Enums\FileOperationType.cs" />
<Compile Include="DataModels\SidebarPinnedModel.cs" />
Expand Down
85 changes: 85 additions & 0 deletions Files/Helpers/AppUpdater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using Microsoft.Toolkit.Uwp.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Windows.Services.Store;
using Windows.UI.Xaml.Controls;

namespace Files.Helpers
{
class AppUpdater
{
private StoreContext context = null;
private IReadOnlyList<StorePackageUpdate> UpdateList = null;

public AppUpdater()
{
context = StoreContext.GetDefault();
}

public async void CheckForUpdatesAsync(bool mandantoryOnly = true)
{
try
{
if (context == null)
{
context = StoreContext.GetDefault();
}

UpdateList = await context.GetAppAndOptionalStorePackageUpdatesAsync();

if (mandantoryOnly)
{
UpdateList = (IReadOnlyList<StorePackageUpdate>)UpdateList.Where(e => e.Mandatory);
}

if (UpdateList.Count > 0)
{
if (await DownloadUpdatesConsent())
{
DownloadUpdates();
}
}
}
catch (Exception)
{

}
}

private async Task<bool> DownloadUpdatesConsent()
{
ContentDialog dialog = new ContentDialog
{
Title = "ConsentDialogTitle".GetLocalized(),
Content = "ConsentDialogContent".GetLocalized(),
CloseButtonText = "ConsentDialogCloseButtonText".GetLocalized(),
PrimaryButtonText = "ConsentDialogPrimaryButtonText".GetLocalized()
};
ContentDialogResult result = await dialog.ShowAsync();

if (result == ContentDialogResult.Primary)
{
return true;
}
return false;
}

private IAsyncResult DownloadUpdates()
{
if (UpdateList == null || UpdateList.Count < 1)
{
return null;
}

if (context == null)
{
context = StoreContext.GetDefault();
}

IAsyncResult downloadOperation = (IAsyncResult)context.RequestDownloadAndInstallStorePackageUpdatesAsync(UpdateList);
return downloadOperation;
}
}
}
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.de-DE.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,22 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.es-ES.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,22 @@
<source>Details</source>
<target state="translated">Detalles</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
20 changes: 18 additions & 2 deletions Files/MultilingualResources/Files.fr-FR.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en-US" target-language="fr-FR" original="FILES/STRINGS/EN-US/RESOURCES.RESW" tool-id="MultilingualAppToolkit" product-name="n/a" product-version="n/a" build-num="n/a">
<header>
Expand Down Expand Up @@ -1922,7 +1922,23 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
</xliff>
</xliff>
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.he-IL.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,22 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.hi-IN.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,22 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.hu-HU.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,22 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.it-IT.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,22 @@
<source>Details</source>
<target state="translated">Dettagli</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.ja-JP.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,22 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.nl-NL.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,22 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.or-IN.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,22 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.pl-PL.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,22 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
16 changes: 16 additions & 0 deletions Files/MultilingualResources/Files.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,22 @@
<source>Details</source>
<target state="new">Details</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
<source>No</source>
<target state="new">No</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
<source>Do you want to download and install the latest version of Files?</source>
<target state="new">Do you want to download and install the latest version of Files?</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
<source>Yes</source>
<target state="new">Yes</target>
</trans-unit>
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
<source>Updates Available</source>
<target state="new">Updates Available</target>
</trans-unit>
</group>
</body>
</file>
Expand Down
Loading