Skip to content

Commit 4a337ba

Browse files
authored
Check for updates from Files (#2508)
1 parent 916a853 commit 4a337ba

24 files changed

+427
-4
lines changed

Files.Package/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
xmlns:uap4="http://schemas.microsoft.com/appx/manifest/uap/windows10/4"
1010
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
1111
IgnorableNamespaces="uap uap5 mp rescap desktop4 desktop">
12-
<Identity Name="FilesDev" Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" Version="0.21.3.0" />
12+
<Identity Name="FilesDev" Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" Version="0.22.1.0" />
1313
<Properties>
1414
<DisplayName>Files - Dev</DisplayName>
1515
<PublisherDisplayName>Yair A</PublisherDisplayName>

Files/Files.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
<Compile Include="Converters\StorageDeleteOptionToBooleanConverter.cs" />
165165
<Compile Include="Converters\StringArrayToString.cs" />
166166
<Compile Include="Converters\UInt32ToString.cs" />
167+
<Compile Include="Helpers\AppUpdater.cs" />
167168
<Compile Include="DataModels\DefaultLanguageModel.cs" />
168169
<Compile Include="Enums\FileOperationType.cs" />
169170
<Compile Include="DataModels\SidebarPinnedModel.cs" />

Files/Helpers/AppUpdater.cs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
using Microsoft.Toolkit.Uwp.Extensions;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Windows.Services.Store;
7+
using Windows.UI.Xaml.Controls;
8+
9+
namespace Files.Helpers
10+
{
11+
class AppUpdater
12+
{
13+
private StoreContext context = null;
14+
private IReadOnlyList<StorePackageUpdate> UpdateList = null;
15+
16+
public AppUpdater()
17+
{
18+
context = StoreContext.GetDefault();
19+
}
20+
21+
public async void CheckForUpdatesAsync(bool mandantoryOnly = true)
22+
{
23+
try
24+
{
25+
if (context == null)
26+
{
27+
context = StoreContext.GetDefault();
28+
}
29+
30+
UpdateList = await context.GetAppAndOptionalStorePackageUpdatesAsync();
31+
32+
if (mandantoryOnly)
33+
{
34+
UpdateList = (IReadOnlyList<StorePackageUpdate>)UpdateList.Where(e => e.Mandatory);
35+
}
36+
37+
if (UpdateList.Count > 0)
38+
{
39+
if (await DownloadUpdatesConsent())
40+
{
41+
DownloadUpdates();
42+
}
43+
}
44+
}
45+
catch (Exception)
46+
{
47+
48+
}
49+
}
50+
51+
private async Task<bool> DownloadUpdatesConsent()
52+
{
53+
ContentDialog dialog = new ContentDialog
54+
{
55+
Title = "ConsentDialogTitle".GetLocalized(),
56+
Content = "ConsentDialogContent".GetLocalized(),
57+
CloseButtonText = "ConsentDialogCloseButtonText".GetLocalized(),
58+
PrimaryButtonText = "ConsentDialogPrimaryButtonText".GetLocalized()
59+
};
60+
ContentDialogResult result = await dialog.ShowAsync();
61+
62+
if (result == ContentDialogResult.Primary)
63+
{
64+
return true;
65+
}
66+
return false;
67+
}
68+
69+
private IAsyncResult DownloadUpdates()
70+
{
71+
if (UpdateList == null || UpdateList.Count < 1)
72+
{
73+
return null;
74+
}
75+
76+
if (context == null)
77+
{
78+
context = StoreContext.GetDefault();
79+
}
80+
81+
IAsyncResult downloadOperation = (IAsyncResult)context.RequestDownloadAndInstallStorePackageUpdatesAsync(UpdateList);
82+
return downloadOperation;
83+
}
84+
}
85+
}

Files/MultilingualResources/Files.de-DE.xlf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,22 @@
19231923
<source>Details</source>
19241924
<target state="new">Details</target>
19251925
</trans-unit>
1926+
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
1927+
<source>No</source>
1928+
<target state="new">No</target>
1929+
</trans-unit>
1930+
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
1931+
<source>Do you want to download and install the latest version of Files?</source>
1932+
<target state="new">Do you want to download and install the latest version of Files?</target>
1933+
</trans-unit>
1934+
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
1935+
<source>Yes</source>
1936+
<target state="new">Yes</target>
1937+
</trans-unit>
1938+
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
1939+
<source>Updates Available</source>
1940+
<target state="new">Updates Available</target>
1941+
</trans-unit>
19261942
</group>
19271943
</body>
19281944
</file>

Files/MultilingualResources/Files.es-ES.xlf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,22 @@
19221922
<source>Details</source>
19231923
<target state="translated">Detalles</target>
19241924
</trans-unit>
1925+
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
1926+
<source>No</source>
1927+
<target state="new">No</target>
1928+
</trans-unit>
1929+
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
1930+
<source>Do you want to download and install the latest version of Files?</source>
1931+
<target state="new">Do you want to download and install the latest version of Files?</target>
1932+
</trans-unit>
1933+
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
1934+
<source>Yes</source>
1935+
<target state="new">Yes</target>
1936+
</trans-unit>
1937+
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
1938+
<source>Updates Available</source>
1939+
<target state="new">Updates Available</target>
1940+
</trans-unit>
19251941
</group>
19261942
</body>
19271943
</file>

Files/MultilingualResources/Files.fr-FR.xlf

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<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">
33
<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">
44
<header>
@@ -1922,7 +1922,23 @@
19221922
<source>Details</source>
19231923
<target state="new">Details</target>
19241924
</trans-unit>
1925+
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
1926+
<source>No</source>
1927+
<target state="new">No</target>
1928+
</trans-unit>
1929+
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
1930+
<source>Do you want to download and install the latest version of Files?</source>
1931+
<target state="new">Do you want to download and install the latest version of Files?</target>
1932+
</trans-unit>
1933+
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
1934+
<source>Yes</source>
1935+
<target state="new">Yes</target>
1936+
</trans-unit>
1937+
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
1938+
<source>Updates Available</source>
1939+
<target state="new">Updates Available</target>
1940+
</trans-unit>
19251941
</group>
19261942
</body>
19271943
</file>
1928-
</xliff>
1944+
</xliff>

Files/MultilingualResources/Files.he-IL.xlf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,22 @@
19221922
<source>Details</source>
19231923
<target state="new">Details</target>
19241924
</trans-unit>
1925+
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
1926+
<source>No</source>
1927+
<target state="new">No</target>
1928+
</trans-unit>
1929+
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
1930+
<source>Do you want to download and install the latest version of Files?</source>
1931+
<target state="new">Do you want to download and install the latest version of Files?</target>
1932+
</trans-unit>
1933+
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
1934+
<source>Yes</source>
1935+
<target state="new">Yes</target>
1936+
</trans-unit>
1937+
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
1938+
<source>Updates Available</source>
1939+
<target state="new">Updates Available</target>
1940+
</trans-unit>
19251941
</group>
19261942
</body>
19271943
</file>

Files/MultilingualResources/Files.hi-IN.xlf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,22 @@
19321932
<source>Details</source>
19331933
<target state="new">Details</target>
19341934
</trans-unit>
1935+
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
1936+
<source>No</source>
1937+
<target state="new">No</target>
1938+
</trans-unit>
1939+
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
1940+
<source>Do you want to download and install the latest version of Files?</source>
1941+
<target state="new">Do you want to download and install the latest version of Files?</target>
1942+
</trans-unit>
1943+
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
1944+
<source>Yes</source>
1945+
<target state="new">Yes</target>
1946+
</trans-unit>
1947+
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
1948+
<source>Updates Available</source>
1949+
<target state="new">Updates Available</target>
1950+
</trans-unit>
19351951
</group>
19361952
</body>
19371953
</file>

Files/MultilingualResources/Files.hu-HU.xlf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,22 @@
19221922
<source>Details</source>
19231923
<target state="new">Details</target>
19241924
</trans-unit>
1925+
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
1926+
<source>No</source>
1927+
<target state="new">No</target>
1928+
</trans-unit>
1929+
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
1930+
<source>Do you want to download and install the latest version of Files?</source>
1931+
<target state="new">Do you want to download and install the latest version of Files?</target>
1932+
</trans-unit>
1933+
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
1934+
<source>Yes</source>
1935+
<target state="new">Yes</target>
1936+
</trans-unit>
1937+
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
1938+
<source>Updates Available</source>
1939+
<target state="new">Updates Available</target>
1940+
</trans-unit>
19251941
</group>
19261942
</body>
19271943
</file>

Files/MultilingualResources/Files.it-IT.xlf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,22 @@
19231923
<source>Details</source>
19241924
<target state="translated">Dettagli</target>
19251925
</trans-unit>
1926+
<trans-unit id="UpdateConsentDialogCloseButtonText" translate="yes" xml:space="preserve">
1927+
<source>No</source>
1928+
<target state="new">No</target>
1929+
</trans-unit>
1930+
<trans-unit id="UpdateConsentDialogContent" translate="yes" xml:space="preserve">
1931+
<source>Do you want to download and install the latest version of Files?</source>
1932+
<target state="new">Do you want to download and install the latest version of Files?</target>
1933+
</trans-unit>
1934+
<trans-unit id="UpdateConsentDialogPrimaryButtonText" translate="yes" xml:space="preserve">
1935+
<source>Yes</source>
1936+
<target state="new">Yes</target>
1937+
</trans-unit>
1938+
<trans-unit id="UpdateConsentDialogTitle" translate="yes" xml:space="preserve">
1939+
<source>Updates Available</source>
1940+
<target state="new">Updates Available</target>
1941+
</trans-unit>
19261942
</group>
19271943
</body>
19281944
</file>

0 commit comments

Comments
 (0)