Skip to content

Commit

Permalink
Code Quality: Removed NOTICE.md link from Files.App.csproj (#15542)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5bfa authored Jun 10, 2024
1 parent 6cdfc46 commit 65ee0b1
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 56 deletions.
32 changes: 32 additions & 0 deletions src/Files.App/Data/Items/OpenSourceLibraryItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.Data.Items
{
/// <summary>
/// Represents an item for open source library shown on <see cref="Views.Settings.AboutPage"/>.
/// </summary>
public class OpenSourceLibraryItem
{
/// <summary>
/// Gets the URL that navigates to the open source library.
/// </summary>
public string Url { get; } = "";

/// <summary>
/// Gets the name of the open source library.
/// </summary>
public string Name { get; } = "";

/// <summary>
/// Initializes an instance of <see cref="OpenSourceLibraryItem"/> class.
/// </summary>
/// <param name="url">The URL</param>
/// <param name="name">The name</param>
public OpenSourceLibraryItem(string url, string name)
{
Url = url;
Name = name;
}
}
}
4 changes: 0 additions & 4 deletions src/Files.App/Files.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
<Content Include="7z64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\.github\NOTICE.md">
<Link>NOTICE.md</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="Assets\Resources\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1844,8 +1844,8 @@
<data name="CompatibilityNoReducedColor" xml:space="preserve">
<value>No reduced color</value>
</data>
<data name="ThirdPartyLicenses" xml:space="preserve">
<value>Third party licenses</value>
<data name="ThirdPartyLibraries" xml:space="preserve">
<value>Third party libraries</value>
</data>
<data name="SettingsSetAsDefaultFileManagerDescription" xml:space="preserve">
<value>This option modifies the system registry and can have unexpected side effects on your device. Continue at your own risk.</value>
Expand Down
77 changes: 52 additions & 25 deletions src/Files.App/ViewModels/Settings/AboutViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,25 @@

namespace Files.App.ViewModels.Settings
{
/// <summary>
/// Represents view model of <see cref="Views.Settings.AboutPage"/>.
/// </summary>
public sealed class AboutViewModel : ObservableObject
{
protected readonly IFileTagsSettingsService FileTagsSettingsService = Ioc.Default.GetRequiredService<IFileTagsSettingsService>();
// Properties

public string Version
=> string.Format($"{"SettingsAboutVersionTitle".GetLocalizedResource()} {AppVersion.Major}.{AppVersion.Minor}.{AppVersion.Build}.{AppVersion.Revision}");

public string AppName
=> Package.Current.DisplayName;

public PackageVersion AppVersion
=> Package.Current.Id.Version;

public ObservableCollection<OpenSourceLibraryItem> OpenSourceLibraries { get; }

// Commands

public ICommand CopyAppVersionCommand { get; }
public ICommand CopyWindowsVersionCommand { get; }
Expand All @@ -27,15 +43,42 @@ public sealed class AboutViewModel : ObservableObject
public ICommand OpenPrivacyPolicyCommand { get; }
public ICommand OpenCrowdinCommand { get; }

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

/// <summary>
/// Initializes an instance of <see cref="AboutViewModel"/> class.
/// </summary>
public AboutViewModel()
{
OpenSourceLibraries =
[
new ("https://github.com/omar/ByteSize", "ByteSize"),
new ("https://github.com/CommunityToolkit/dotnet", "CommunityToolkit.Mvvm"),
new ("https://github.com/DiscUtils/DiscUtils", "DiscUtils.Udf"),
new ("https://github.com/robinrodricks/FluentFTP", "FluentFTP"),
new ("https://github.com/rickyah/ini-parser", "INI File Parser"),
new ("https://github.com/libgit2/libgit2sharp", "libgit2sharp"),
new ("https://github.com/mbdavid/LiteDB", "LiteDB"),
new ("https://github.com/beto-rodriguez/LiveCharts2", "LiveCharts2"),
new ("https://github.com/jeffijoe/messageformat.net", "MessageFormat"),
new ("https://github.com/dotnet/efcore", "EF Core for SQLite"),
new ("https://github.com/dotnet/runtime", "Microsoft.Extensions"),
new ("https://github.com/files-community/SevenZipSharp", "SevenZipSharp"),
new ("https://sourceforge.net/projects/sevenzip", "7zip"),
new ("https://github.com/ericsink/SQLitePCL.raw", "PCL for SQLite"),
new ("https://github.com/microsoft/WindowsAppSDK", "WindowsAppSDK"),
new ("https://github.com/microsoft/microsoft-ui-xaml", "WinUI 3"),
new ("https://github.com/microsoft/Win2D", "Win2D"),
new ("https://github.com/CommunityToolkit/WindowsCommunityToolkit", "Windows Community Toolkit 7.x"),
new ("https://github.com/mono/taglib-sharp", "TagLibSharp"),
new ("https://github.com/Tulpep/Active-Directory-Object-Picker", "ActiveDirectoryObjectPicker"),
new ("https://github.com/dotMorten/WinUIEx", "WinUIEx"),
new ("https://github.com/dahall/Vanara", "Vanara"),
new ("https://github.com/PowerShell/MMI", "MMI"),
new ("https://github.com/microsoft/CsWin32", "CsWin32"),
new ("https://github.com/microsoft/CsWinRT", "CsWinRT"),
];

CopyAppVersionCommand = new RelayCommand(CopyAppVersion);
CopyWindowsVersionCommand = new RelayCommand(CopyWindowsVersion);
SupportUsCommand = new AsyncRelayCommand(SupportUs);
Expand All @@ -49,6 +92,8 @@ public AboutViewModel()
OpenCrowdinCommand = new AsyncRelayCommand(DoOpenCrowdin);
}

// Methods

private async Task<bool> OpenLogLocation()
{
await Launcher.LaunchFolderAsync(ApplicationData.Current.LocalFolder).AsTask();
Expand Down Expand Up @@ -95,7 +140,6 @@ public Task DoOpenPrivacyPolicy()
return Launcher.LaunchUriAsync(new Uri(Constants.ExternalUrl.PrivacyPolicyUrl)).AsTask();
}


public Task DoOpenCrowdin()
{
return Launcher.LaunchUriAsync(new Uri(Constants.ExternalUrl.CrowdinUrl)).AsTask();
Expand Down Expand Up @@ -128,12 +172,6 @@ public Task SupportUs()
return Launcher.LaunchUriAsync(new Uri(Constants.ExternalUrl.SupportUsUrl)).AsTask();
}

public async Task LoadThirdPartyNoticesAsync()
{
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(Constants.DocsPath.ThirdPartyNoticePath));
ThirdPartyNotices = await FileIO.ReadTextAsync(file);
}

public string GetAppVersion()
{
return string.Format($"{AppVersion.Major}.{AppVersion.Minor}.{AppVersion.Build}.{AppVersion.Revision}");
Expand All @@ -151,16 +189,5 @@ public string GetVersionsQueryString()
query["windows_version"] = GetWindowsVersion();
return query.ToString() ?? string.Empty;
}

public string Version
{
get
{
return string.Format($"{"SettingsAboutVersionTitle".GetLocalizedResource()} {AppVersion.Major}.{AppVersion.Minor}.{AppVersion.Build}.{AppVersion.Revision}");
}
}

public string AppName => Package.Current.DisplayName;
public PackageVersion AppVersion => Package.Current.Id.Version;
}
}
33 changes: 22 additions & 11 deletions src/Files.App/Views/Settings/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dataitems="using:Files.App.Data.Items"
xmlns:helpers="using:Files.App.Helpers"
xmlns:local="using:Files.App.UserControls.Settings"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand Down Expand Up @@ -181,21 +182,31 @@
</local:SettingsBlockControl>

<!-- Third Party Licenses -->
<local:SettingsBlockControl
Title="{helpers:ResourceString Name=ThirdPartyLicenses}"
HorizontalAlignment="Stretch"
Click="ThirdPartyLicenses_Click">
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ThirdPartyLibraries}">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xE90F;" />
</local:SettingsBlockControl.Icon>
<local:SettingsBlockControl.ExpandableContent>
<ScrollViewer Height="400">
<controls:MarkdownTextBlock
Margin="10"
Background="Transparent"
LinkClicked="MarkdownTextBlock_LinkClicked"
Text="{x:Bind ViewModel.ThirdPartyNotices, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</ScrollViewer>
<ItemsRepeater Margin="54,12,12,12" ItemsSource="{x:Bind ViewModel.OpenSourceLibraries, Mode=OneWay}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="dataitems:OpenSourceLibraryItem">
<TextBlock Margin="4,0" VerticalAlignment="Center">
<Hyperlink NavigateUri="{x:Bind Url}" UnderlineStyle="None">
<Run Text="{x:Bind Name}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
<ItemsRepeater.Layout>
<UniformGridLayout
ItemsStretch="Fill"
MaximumRowsOrColumns="6"
MinColumnSpacing="8"
MinItemWidth="200"
MinRowSpacing="8"
Orientation="Horizontal" />
</ItemsRepeater.Layout>
</ItemsRepeater>
</local:SettingsBlockControl.ExpandableContent>
</local:SettingsBlockControl>

Expand Down
14 changes: 0 additions & 14 deletions src/Files.App/Views/Settings/AboutPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.WinUI.UI.Controls;
using Microsoft.UI.Xaml.Controls;
using Windows.System;

namespace Files.App.Views.Settings
{
Expand All @@ -13,17 +11,5 @@ public AboutPage()
{
InitializeComponent();
}

private async void ThirdPartyLicenses_Click(object sender, bool e)
{
if (e && string.IsNullOrEmpty(ViewModel.ThirdPartyNotices))
await ViewModel.LoadThirdPartyNoticesAsync();
}

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

0 comments on commit 65ee0b1

Please sign in to comment.