Skip to content

Commit c224e81

Browse files
Panda-SharpSergio0694
authored andcommitted
Add PreviousVersionInstalled to sample app
Update doc in app sample Fix XML property comment
1 parent 5ac7f5b commit c224e81

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/SystemInformation/SystemInformationCode.bind

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
// To get the first version installed
3838
public PackageVersion FirstVersionInstalled => SystemInformation.Instance.FirstVersionInstalled;
3939

40+
// To get the previous version installed
41+
public string PreviousVersionInstalled => SystemInformation.Instance.PreviousVersionInstalled.ToFormattedString();
42+
4043
// To get the first time the app was launched
4144
public DateTime FirstUseTime => SystemInformation.Instance.FirstUseTime;
4245

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/SystemInformation/SystemInformationPage.xaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@
170170
<StackPanel x:Name="Stack13"
171171
Margin="10"
172172
Orientation="Horizontal">
173+
<TextBlock FontSize="18"
174+
FontWeight="Bold"
175+
Text="Previous version installed:"
176+
TextWrapping="Wrap" />
177+
<TextBlock Margin="20,0"
178+
FontSize="18"
179+
Text="{x:Bind PreviousVersionInstalled}"
180+
TextWrapping="Wrap" />
181+
</StackPanel>
182+
<StackPanel x:Name="Stack14"
183+
Margin="10"
184+
Orientation="Horizontal">
173185
<TextBlock FontSize="18"
174186
FontWeight="Bold"
175187
Text="First use time:"
@@ -179,7 +191,7 @@
179191
Text="{x:Bind FirstUseTime}"
180192
TextWrapping="Wrap" />
181193
</StackPanel>
182-
<StackPanel x:Name="Stack14"
194+
<StackPanel x:Name="Stack15"
183195
Margin="10"
184196
Orientation="Horizontal">
185197
<TextBlock FontSize="18"
@@ -191,7 +203,7 @@
191203
Text="{x:Bind LaunchTime}"
192204
TextWrapping="Wrap" />
193205
</StackPanel>
194-
<StackPanel x:Name="Stack15"
206+
<StackPanel x:Name="Stack16"
195207
Margin="10"
196208
Orientation="Horizontal">
197209
<TextBlock FontSize="18"
@@ -203,7 +215,7 @@
203215
Text="{x:Bind LastLaunchTime}"
204216
TextWrapping="Wrap" />
205217
</StackPanel>
206-
<StackPanel x:Name="Stack16"
218+
<StackPanel x:Name="Stack17"
207219
Margin="10"
208220
Orientation="Horizontal">
209221
<TextBlock FontSize="18"
@@ -215,7 +227,7 @@
215227
Text="{x:Bind LastResetTime, Mode=OneWay}"
216228
TextWrapping="Wrap" />
217229
</StackPanel>
218-
<StackPanel x:Name="Stack17"
230+
<StackPanel x:Name="Stack18"
219231
Margin="10"
220232
Orientation="Horizontal">
221233
<TextBlock FontSize="18"
@@ -227,7 +239,7 @@
227239
Text="{x:Bind LaunchCount, Mode=OneWay}"
228240
TextWrapping="Wrap" />
229241
</StackPanel>
230-
<StackPanel x:Name="Stack18"
242+
<StackPanel x:Name="Stack19"
231243
Margin="10"
232244
Orientation="Horizontal">
233245
<TextBlock FontSize="18"
@@ -239,7 +251,7 @@
239251
Text="{x:Bind TotalLaunchCount}"
240252
TextWrapping="Wrap" />
241253
</StackPanel>
242-
<StackPanel x:Name="Stack19"
254+
<StackPanel x:Name="Stack20"
243255
Margin="10"
244256
Orientation="Horizontal">
245257
<TextBlock FontSize="18"
@@ -284,6 +296,9 @@
284296
<Setter Target="Stack15.Orientation" Value="Vertical" />
285297
<Setter Target="Stack16.Orientation" Value="Vertical" />
286298
<Setter Target="Stack17.Orientation" Value="Vertical" />
299+
<Setter Target="Stack18.Orientation" Value="Vertical" />
300+
<Setter Target="Stack19.Orientation" Value="Vertical" />
301+
<Setter Target="Stack20.Orientation" Value="Vertical" />
287302
</VisualState.Setters>
288303
</VisualState>
289304
</VisualStateGroup>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/SystemInformation/SystemInformationPage.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public sealed partial class SystemInformationPage : Page
5454
// To get the first version installed
5555
public string FirstVersionInstalled => SystemInformation.Instance.FirstVersionInstalled.ToFormattedString();
5656

57+
// To get the previous version installed
58+
public string PreviousVersionInstalled => SystemInformation.Instance.PreviousVersionInstalled.ToFormattedString();
59+
5760
// To get the first time the app was launched
5861
public string FirstUseTime => SystemInformation.Instance.FirstUseTime.ToString(Culture.DateTimeFormat);
5962

Microsoft.Toolkit.Uwp/Helpers/SystemInformation.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ public static async Task LaunchStoreForReviewAsync()
123123

124124
/// <summary>
125125
/// Gets the previous version of the app that was installed.
126-
/// This will be the current version if a previous version of the app was installed before accessing this property.
126+
/// This will be the current version if a previous version of the app was installed
127+
/// before using SystemInformation or if the app is not updated.
127128
/// </summary>
128129
public PackageVersion PreviousVersionInstalled { get; }
129130

@@ -346,6 +347,7 @@ private bool DetectIfAppUpdated()
346347
var lastVersion = _localObjectStorageHelper.Read<string>(nameof(currentVersion));
347348
if (currentVersion != lastVersion)
348349
{
350+
_localObjectStorageHelper.Save(nameof(PreviousVersionInstalled), lastVersion);
349351
_localObjectStorageHelper.Save(nameof(currentVersion), currentVersion);
350352
return true;
351353
}

0 commit comments

Comments
 (0)