Skip to content

Feature: Display NOTICE.md in the About page #11531

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

Merged
merged 8 commits into from
Mar 7, 2023
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
4 changes: 4 additions & 0 deletions src/Files.App/Files.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<Content Include="7z64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\NOTICE.md">
<Link>NOTICE.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\BingMapsKey.txt" />
<Content Include="Resources\PreviewPanePropertiesInformation.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
12 changes: 12 additions & 0 deletions src/Files.App/ViewModels/Settings/AboutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public class AboutViewModel : ObservableObject
public ICommand OpenGitHubRepoCommand { get; }
public ICommand OpenPrivacyPolicyCommand { get; }

private string _ThirdPartyNotices;
public string ThirdPartyNotices
{
get => _ThirdPartyNotices;
set => SetProperty(ref _ThirdPartyNotices, value);
}

public AboutViewModel()
{
Expand Down Expand Up @@ -104,6 +110,12 @@ public async void SupportUs()
await Launcher.LaunchUriAsync(new Uri(Constants.GitHub.SupportUsUrl));
}

public async void LoadThirdPartyNotices()
{
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///NOTICE.md"));
ThirdPartyNotices = await FileIO.ReadTextAsync(file);
}

public string Version
{
get
Expand Down
22 changes: 10 additions & 12 deletions src/Files.App/Views/Settings/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,20 @@
Text="{helpers:ResourceString Name=OpenSource}" />

<!-- Third Party Licenses -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ThirdPartyLicenses}" HorizontalAlignment="Stretch">
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ThirdPartyLicenses}"
HorizontalAlignment="Stretch"
Click="ThirdPartyLicenses_Click">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xE15E;" />
</local:SettingsBlockControl.Icon>
<local:SettingsBlockControl.ExpandableContent>
<StackPanel Padding="4" Spacing="4">
<HyperlinkButton
AutomationProperties.Name="QuickLook"
Content="QuickLook"
NavigateUri="https://github.com/QL-Win/QuickLook/blob/master/LICENSE-GPL.txt" />

<HyperlinkButton
AutomationProperties.Name="7-Zip (GNU LGPL)"
Content="7-Zip (GNU LGPL)"
NavigateUri="https://7-zip.org" />
</StackPanel>
<ScrollViewer Height="400">
<controls:MarkdownTextBlock
Text="{x:Bind ViewModel.ThirdPartyNotices, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Margin="10"
Background="Transparent"
LinkClicked="MarkdownTextBlock_LinkClicked" />
</ScrollViewer>
</local:SettingsBlockControl.ExpandableContent>
</local:SettingsBlockControl>

Expand Down
15 changes: 15 additions & 0 deletions src/Files.App/Views/Settings/AboutPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using CommunityToolkit.WinUI.UI.Controls;
using Files.App.ViewModels.Settings;
using Microsoft.UI.Xaml.Controls;
using System;
using Windows.System;

namespace Files.App.Settings
{
Expand All @@ -17,5 +20,17 @@ public AboutPage()

ViewModel = new AboutViewModel();
}

private void ThirdPartyLicenses_Click(object sender, bool e)
{
if (e && ViewModel.ThirdPartyNotices is null)
ViewModel.LoadThirdPartyNotices();
}

private async void MarkdownTextBlock_LinkClicked(object sender, LinkClickedEventArgs e)
{
if (Uri.TryCreate(e.Link, UriKind.Absolute, out Uri? link))
await Launcher.LaunchUriAsync(link);
}
}
}