Merge pull request #216 from SunboX/update-dialog-workaround

try to fix update dialog
This commit is contained in:
DecaTec 2017-07-02 21:31:51 +02:00 коммит произвёл GitHub
Родитель 3e3c359b32 3d328fb1ae
Коммит d612e9396d
4 изменённых файлов: 112 добавлений и 16 удалений

Просмотреть файл

@ -1,4 +1,4 @@
<controls:ThemeablePage
<controls:ThemeablePage x:Name="themeablePage"
x:Class="NextcloudApp.AppShell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -51,6 +51,90 @@
IsChecked="{Binding IsPaneOpen, ElementName=RootSplitView, Mode=TwoWay}"
Style="{StaticResource SplitViewTogglePaneButtonStyle}"
TabIndex="1" />
<Grid
x:Name="UpdateDialogContainer"
VerticalAlignment="Stretch"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
Padding="20"
Visibility="Collapsed">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="{ThemeResource ContentDialogButtonHeight}" />
</Grid.RowDefinitions>
<ScrollViewer
x:Name="UpdateDialogContentScrollViewer"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
VerticalAlignment="Stretch"
ZoomMode="Disabled"
Margin="{ThemeResource ContentDialogContentScrollViewerMargin}"
IsTabStop="False">
<StackPanel>
<ContentControl
x:Name="UpdateDialogTitle"
Margin="{ThemeResource ContentDialogTitleMargin}"
FontSize="20"
FontFamily="XamlAutoFontFamily"
FontWeight="Normal"
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
IsTabStop="False"
MaxHeight="{ThemeResource ContentDialogTitleMaxHeight}" >
<ContentControl.Template>
<ControlTemplate TargetType="ContentControl">
<ContentPresenter
Content="{TemplateBinding Content}"
MaxLines="2"
TextWrapping="Wrap"
ContentTemplate="{TemplateBinding ContentTemplate}"
Margin="{TemplateBinding Padding}"
ContentTransitions="{TemplateBinding ContentTransitions}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</ControlTemplate>
</ContentControl.Template>
</ContentControl>
<TextBlock
x:Name="UpdateDialogContent"
TextWrapping="WrapWholeWords"
Margin="0,20,0,0"
FontSize="{ThemeResource ControlContentThemeFontSize}"
FontFamily="{ThemeResource ContentControlThemeFontFamily}"
Foreground="{ThemeResource SystemControlPageTextBaseHighBrush}"
Grid.Row="1"/>
</StackPanel>
</ScrollViewer>
<Grid x:Name="UpdateDialogCommandSpace" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border
x:Name="UpdateDialogButton1Host"
Margin="{ThemeResource ContentDialogButton1HostMargin}"
MinWidth="{ThemeResource ContentDialogButtonMinWidth}"
MaxWidth="{ThemeResource ContentDialogButtonMaxWidth}"
Height="{ThemeResource ContentDialogButtonHeight}"
HorizontalAlignment="Stretch">
<Button x:Name="UpdateDialogButton1" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
</Border>
<Border
x:Name="UpdateDialogButton2Host"
Margin="{ThemeResource ContentDialogButton2HostMargin}"
MinWidth="{ThemeResource ContentDialogButtonMinWidth}"
MaxWidth="{ThemeResource ContentDialogButtonMaxWidth}"
Height="{ThemeResource ContentDialogButtonHeight}"
Grid.Column="1"
HorizontalAlignment="Stretch">
<Button x:Name="UpdateDialogButton2" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>
</Border>
</Grid>
</Grid>
</Grid>
</controls:ThemeablePage>

Просмотреть файл

@ -12,19 +12,19 @@ namespace NextcloudApp
ShowUpdateMessage();
}
private async void ShowUpdateMessage()
private void ShowUpdateMessage()
{
if (SettingsService.Instance.LocalSettings.ShowUpdateMessage)
{
await UpdateNotificationService.NotifyUser();
UpdateNotificationService.NotifyUser(UpdateDialogContainer, UpdateDialogTitle, UpdateDialogContent, UpdateDialogButton1, UpdateDialogButton2);
}
else
{
SettingsService.Instance.LocalSettings.PropertyChanged += async (sender, args) =>
SettingsService.Instance.LocalSettings.PropertyChanged += (sender, args) =>
{
if (args.PropertyName.Equals("ShowUpdateMessage") && SettingsService.Instance.LocalSettings.ShowUpdateMessage)
{
await UpdateNotificationService.NotifyUser();
UpdateNotificationService.NotifyUser(UpdateDialogContainer, UpdateDialogTitle, UpdateDialogContent, UpdateDialogButton1, UpdateDialogButton2);
}
};
}

Просмотреть файл

@ -27,6 +27,12 @@
</uap:InitialRotationPreference>
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="nextcloud">
<uap:Logo>Assets\StoreLogo.png</uap:Logo>
<uap:DisplayName>Nextcloud</uap:DisplayName>
</uap:Protocol>
</uap:Extension>
<uap:Extension Category="windows.shareTarget" EntryPoint="NextcloudApp.ShareTarget">
<uap:ShareTarget>
<uap:SupportedFileTypes>
@ -40,12 +46,6 @@
<uap:DataFormat>RTF</uap:DataFormat>
</uap:ShareTarget>
</uap:Extension>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="nextcloud">
<uap:Logo>Assets\StoreLogo.png</uap:Logo>
<uap:DisplayName>Nextcloud</uap:DisplayName>
</uap:Protocol>
</uap:Extension>
</Extensions>
</Application>
</Applications>

Просмотреть файл

@ -1,5 +1,4 @@
using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel;
using Windows.ApplicationModel.DataTransfer;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@ -14,7 +13,7 @@ namespace NextcloudApp.Services
/// <summary>
/// Notifies the user.
/// </summary>
public static async Task NotifyUser()
public static void NotifyUser(Grid updateDialogContainer, ContentControl updateDialogTitle, TextBlock updateDialogContent, Button updateDialogButton1, Button updateDialogButton2)
{
SettingsService.Instance.LocalSettings.ShowUpdateMessage = false;
@ -24,7 +23,7 @@ namespace NextcloudApp.Services
return;
}
var resourceLoader = app.Container.Resolve<IResourceLoader>();
var dialogService = app.Container.Resolve<DialogService>();
//var dialogService = app.Container.Resolve<DialogService>();
var currentVersion =
$"{Package.Current.Id.Version.Major}.{Package.Current.Id.Version.Minor}.{Package.Current.Id.Version.Build}";
@ -41,7 +40,8 @@ namespace NextcloudApp.Services
var line1 = string.Format(resourceLoader.GetString("Changes_Intro_Line_1"), currentVersion);
var line2 = resourceLoader.GetString("Changes_Intro_Line_2");
/*
var dialog = new ContentDialog
{
Title = resourceLoader.GetString("Changes_Title"),
@ -61,6 +61,18 @@ namespace NextcloudApp.Services
SecondaryButtonCommand = new DelegateCommand(RecommendChanges)
};
await dialogService.ShowAsync(dialog);
*/
updateDialogTitle.Content = resourceLoader.GetString("Changes_Title");
updateDialogButton1.Content = resourceLoader.GetString("OK");
updateDialogButton1.Command = new DelegateCommand(() =>
{
updateDialogContainer.Visibility = Visibility.Collapsed;
});
updateDialogButton2.Content = resourceLoader.GetString("Changes_Recommend");
updateDialogButton2.Command = new DelegateCommand(RecommendChanges);
updateDialogContent.Text = string.Format("{0}\n\n{1}\n\n{2}", line1, line2, changelog);
updateDialogContainer.Visibility = Visibility.Visible;
}
private static void RecommendChanges()