Skip to content

Commit

Permalink
v1.5.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Guerra24 committed Jan 22, 2021
1 parent dc4296e commit 438e0fb
Show file tree
Hide file tree
Showing 12 changed files with 157 additions and 12 deletions.
5 changes: 5 additions & 0 deletions LRReader.UWP/Internal/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public static Version GetAppVersion()
return new Version(version.Major, version.Minor, version.Build, version.Revision);
}

public static string GetPackageFamilyName()
{
return AppInfo.Current.PackageFamilyName;
}

public static async Task<bool> OpenInBrowser(Uri uri)
{
return await Launcher.LaunchUriAsync(uri);
Expand Down
2 changes: 1 addition & 1 deletion LRReader.UWP/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity
Name="63705Guerra24.LRReader"
Publisher="CN=690E488B-1B49-4006-8D8D-14F81EFE17C5"
Version="1.5.5.0" />
Version="1.5.6.0" />

<mp:PhoneIdentity PhoneProductId="eccfefd4-5961-4ad1-894e-3000dc4fe01a" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
6 changes: 6 additions & 0 deletions LRReader.UWP/Strings/en/Dialogs.resw
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ServerProfile.Copy.ToolTipService.ToolTip" xml:space="preserve">
<value>Copy</value>
</data>
<data name="ServerProfile.Dialog.CloseButtonText" xml:space="preserve">
<value>Cancel</value>
</data>
Expand All @@ -129,6 +132,9 @@
<data name="ServerProfile.ErrorInvalidAddress" xml:space="preserve">
<value>Invalid Server Address</value>
</data>
<data name="ServerProfile.ErrorLocalHost" xml:space="preserve">
<value>You might need to run this command to allow localhost access{0}Restart the app afterwards</value>
</data>
<data name="ServerProfile.ErrorNoAddress" xml:space="preserve">
<value>Empty Server Address</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions LRReader.UWP/Strings/en/Pages.resw
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,10 @@
<data name="LoadingPage.NoConnection" xml:space="preserve">
<value>Unable to connect... Please select another profile</value>
</data>
<data name="LoadingPage.NoConnectionLocalHost" xml:space="preserve">
<value>Unable to connect... Make sure the app has localhost access</value>
</data>
<data name="LoadingPage.NoConnectionLocalHostSub" xml:space="preserve">
<value>Check Profile-&gt;Edit for more information</value>
</data>
</root>
6 changes: 6 additions & 0 deletions LRReader.UWP/Strings/es/Dialogs.resw
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ServerProfile.Copy.ToolTipService.ToolTip" xml:space="preserve">
<value>Copiar</value>
</data>
<data name="ServerProfile.Dialog.CloseButtonText" xml:space="preserve">
<value>Cancelar</value>
</data>
Expand All @@ -129,6 +132,9 @@
<data name="ServerProfile.ErrorInvalidAddress" xml:space="preserve">
<value>Direccion Invalida</value>
</data>
<data name="ServerProfile.ErrorLocalHost" xml:space="preserve">
<value>Puede que necesites ejecutar este comando para permitir el acceso local{0}Reiniciar la aplicación después</value>
</data>
<data name="ServerProfile.ErrorNoAddress" xml:space="preserve">
<value>Direccion en blanco</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions LRReader.UWP/Strings/es/Pages.resw
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,10 @@
<data name="LoadingPage.NoConnection" xml:space="preserve">
<value>No se pudo conectar... Selecciona otro perfil</value>
</data>
<data name="LoadingPage.NoConnectionLocalHost" xml:space="preserve">
<value>No se pudo conectar... Asegurate de que la aplicación tiene acceso a localhost</value>
</data>
<data name="LoadingPage.NoConnectionLocalHostSub" xml:space="preserve">
<value>Revisa Perfil-&gt;Editar para más información</value>
</data>
</root>
25 changes: 20 additions & 5 deletions LRReader.UWP/ViewModels/LoadingPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LRReader.UWP.ViewModels
{
Expand Down Expand Up @@ -39,5 +34,25 @@ public bool Active
RaisePropertyChanged("Active");
}
}
private bool _updating;
public bool Updating
{
get => _updating;
set
{
_updating = value;
RaisePropertyChanged("Updating");
}
}
private double _progress;
public double Progress
{
get => _progress;
set
{
_progress = value;
RaisePropertyChanged("Progress");
}
}
}
}
12 changes: 11 additions & 1 deletion LRReader.UWP/Views/Dialogs/ServerProfileDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
<PasswordBox
x:Name="ProfileServerApiKey" x:Uid="/Dialogs/ServerProfile/ProfileApiKey" Margin="0,0,0,10"
x:FieldModifier="public" />
<TextBlock Name="ProfileError" Foreground="#FF4141" />
<TextBlock x:Name="ProfileError" Foreground="#FF4141" IsTextSelectionEnabled="True" />
<StackPanel
x:Name="Command" Margin="0,10,0,0" Orientation="Horizontal"
Visibility="Collapsed">
<TextBox
x:Name="CommandBox" MaxWidth="350" Margin="0,0,10,0"
IsReadOnly="True" />
<Button x:Uid="/Dialogs/ServerProfile/Copy" Click="Button_Click">
<SymbolIcon Symbol="Copy" />
</Button>
</StackPanel>
</StackPanel>
</ContentDialog>
22 changes: 21 additions & 1 deletion LRReader.UWP/Views/Dialogs/ServerProfileDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System;
using LRReader.UWP.Internal;
using Microsoft.Toolkit.Extensions;
using System;
using Windows.ApplicationModel.DataTransfer;
using Windows.ApplicationModel.Resources;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace LRReader.UWP.Views.Dialogs
Expand All @@ -19,6 +23,7 @@ public ServerProfileDialog(bool edit)
private void ProfileName_TextChanging(TextBox sender, TextBoxTextChangingEventArgs args)
{
bool allow = true;
Command.Visibility = Visibility.Collapsed;
ProfileError.Text = "";
if (string.IsNullOrEmpty(ProfileName.Text))
{
Expand All @@ -31,6 +36,7 @@ private void ProfileName_TextChanging(TextBox sender, TextBoxTextChangingEventAr
private void ProfileServerAddress_TextChanging(TextBox sender, TextBoxTextChangingEventArgs args)
{
bool allow = true;
Command.Visibility = Visibility.Collapsed;
ProfileError.Text = "";
if (string.IsNullOrEmpty(ProfileServerAddress.Text))
{
Expand All @@ -42,6 +48,12 @@ private void ProfileServerAddress_TextChanging(TextBox sender, TextBoxTextChangi
ProfileError.Text = lang.GetString("ServerProfile/ErrorInvalidAddress");
allow = false;
}
else if (ProfileServerAddress.Text.Contains("127.0.0.") || ProfileServerAddress.Text.Contains("localhost"))
{
ProfileError.Text = lang.GetString("ServerProfile/ErrorLocalHost").AsFormat("\n");
Command.Visibility = Visibility.Visible;
CommandBox.Text = $"CheckNetIsolation loopbackexempt -a -n={Util.GetPackageFamilyName()}";
}
IsPrimaryButtonEnabled = allow && ValidateProfileName();
}

Expand All @@ -54,5 +66,13 @@ private bool ValidateServerAddress()
{
return !string.IsNullOrEmpty(ProfileServerAddress.Text) && Uri.IsWellFormedUriString(ProfileServerAddress.Text, UriKind.Absolute);
}

private void Button_Click(object sender, RoutedEventArgs e)
{
var dataPackage = new DataPackage();
dataPackage.RequestedOperation = DataPackageOperation.Copy;
dataPackage.SetText($"CheckNetIsolation loopbackexempt -a -n={Util.GetPackageFamilyName()}");
Clipboard.SetContent(dataPackage);
}
}
}
5 changes: 5 additions & 0 deletions LRReader.UWP/Views/Main/LoadingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
Width="40" Height="40" HorizontalAlignment="Center"
VerticalAlignment="Top"
IsActive="{x:Bind ViewModel.Active, Mode=OneWay}" />
<muxc:ProgressBar
Width="200" Margin="0,18,0,0" VerticalAlignment="Top"
Maximum="1"
Visibility="{x:Bind ViewModel.Updating, Mode=OneWay}"
Value="{x:Bind ViewModel.Progress, Mode=OneWay}" />
<StackPanel VerticalAlignment="Top">
<TextBlock
Margin="0,30,0,0" HorizontalAlignment="Center" FontSize="18"
Expand Down
68 changes: 67 additions & 1 deletion LRReader.UWP/Views/Main/LoadingPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
using Windows.ApplicationModel.Resources;
using Microsoft.Toolkit.Extensions;
using LRReader.UWP.Internal;
using Windows.Services.Store;
using GalaSoft.MvvmLight.Threading;

namespace LRReader.UWP.Views.Main
{
Expand Down Expand Up @@ -64,14 +66,24 @@ private void TitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar coreTitle

private async void Page_Loaded(object sender, RoutedEventArgs e)
{
#if !SIDELOAD
await DownloadUpdate();
#endif
ViewModel.Active = true;
await SharedGlobal.UpdatesManager.UpdateSupportedRange(Util.GetAppVersion());

SharedGlobal.LRRApi.RefreshSettings(SharedGlobal.SettingsManager.Profile);
var serverInfo = await ServerProvider.GetServerInfo();
if (serverInfo == null)
{
ViewModel.Status = lang.GetString("LoadingPage/NoConnection");
var address = SharedGlobal.SettingsManager.Profile.ServerAddress;
if (address.Contains("127.0.0.") || address.Contains("localhost"))
{
ViewModel.Status = lang.GetString("LoadingPage/NoConnectionLocalHost");
ViewModel.StatusSub = lang.GetString("LoadingPage/NoConnectionLocalHostSub");
}
else
ViewModel.Status = lang.GetString("LoadingPage/NoConnection");
await Reload();
return;
}
Expand Down Expand Up @@ -115,5 +127,59 @@ private async Task Reload()
ViewModel.StatusSub = "";
(Window.Current.Content as Frame).Navigate(typeof(FirstRunPage), null, new DrillInNavigationTransitionInfo());
}

private async Task DownloadUpdate()
{
ViewModel.Active = true;
var context = StoreContext.GetDefault();

var packageUpdates = await context.GetAppAndOptionalStorePackageUpdatesAsync();
if (packageUpdates.Count == 0)
return;

if (!context.CanSilentlyDownloadStorePackageUpdates)
return;
ViewModel.Active = false;
await Task.Delay(TimeSpan.FromMilliseconds(500));
ViewModel.Updating = true;

var downloadTask = context.TrySilentDownloadStorePackageUpdatesAsync(packageUpdates);

downloadTask.Progress = async (info, progress) =>
{
await DispatcherHelper.RunAsync(() => ViewModel.Progress = progress.TotalDownloadProgress);
};

var result = await downloadTask.AsTask();

ViewModel.Updating = false;

await Task.Delay(TimeSpan.FromMilliseconds(500));

switch (result.OverallState)
{
case StorePackageUpdateState.Completed:
await InstallUpdate(packageUpdates, context);
break;
default:
break;
}
}

private async Task InstallUpdate(IReadOnlyList<StorePackageUpdate> packages, StoreContext context)
{
ViewModel.Progress = 0;
ViewModel.Updating = true;

var installTask = context.TrySilentDownloadAndInstallStorePackageUpdatesAsync(packages);

installTask.Progress = async (info, progress) =>
{
await DispatcherHelper.RunAsync(() => ViewModel.Progress = progress.TotalDownloadProgress);
};

var result = await installTask.AsTask();
ViewModel.Updating = false;
}
}
}
6 changes: 3 additions & 3 deletions Util/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<Identity
Name="Guerra24.LRReader"
Publisher="CN=Guerra24, O=Guerra24, C=GT"
Version="1.5.5.0" />
Version="1.5.6.0" />

<mp:PhoneIdentity PhoneProductId="97639259-a9d5-4784-8ec1-a88609560ca7" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

<Properties>
<DisplayName>LRReader Sideload</DisplayName>
<DisplayName>LRReader</DisplayName>
<PublisherDisplayName>Guerra24</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
Expand All @@ -32,7 +32,7 @@
Executable="$targetnametoken$.exe"
EntryPoint="LRReader.UWP.App">
<uap:VisualElements
DisplayName="LRReader Sideload"
DisplayName="LRReader"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png"
Description="UWP Client for LANraragi"
Expand Down

0 comments on commit 438e0fb

Please sign in to comment.