Skip to content

Commit

Permalink
Added license to TgDownloaderDesktop
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianMorozov committed Nov 25, 2024
1 parent f7ca9a5 commit 329d0d5
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 13 deletions.
7 changes: 6 additions & 1 deletion Clients/TgDownloaderDesktop/Common/TgPageViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ public string AppTgSession
}
}

public TgAppSettingsHelper TgAppSettings => TgAppSettingsHelper.Instance;
[ObservableProperty]
private TgAppSettingsHelper _appSettings = TgAppSettingsHelper.Instance;
[ObservableProperty]
private TgLicenseManagerHelper _licenseManager = TgLicenseManagerHelper.Instance;
public static TgExceptionModel Exception { get; set; } = new();

[ObservableProperty]
Expand Down Expand Up @@ -71,6 +74,8 @@ public string AppTgSession
public TgPageViewModelBase(ITgSettingsService settingsService)
{
SettingsService = settingsService;
LicenseManager.ActivateLicense(string.Empty, TgResourceExtensions.GetLicenseFreeDescription(),
TgResourceExtensions.GetLicensePaidDescription(), TgResourceExtensions.GetLicensePremiumDescription());
}

#endregion
Expand Down
3 changes: 3 additions & 0 deletions Clients/TgDownloaderDesktop/Helpers/TgResourceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public static class TgResourceExtensions
public static string ClientSettingsAreNotValid() => "ClientSettingsAreNotValid".GetLocalized();
public static string GetAppVersion() => "AppVersion".GetLocalized();
public static string GetCancelButton() => "CancelButton".GetLocalized();
public static string GetLicenseFreeDescription() => "LicenseFreeDescription".GetLocalized();
public static string GetLicensePaidDescription() => "LicensePaidDescription".GetLocalized();
public static string GetLicensePremiumDescription() => "LicensePremiumDescription".GetLocalized();
public static string GetMenuClientIsQuery() => "MenuClientIsQuery".GetLocalized();
public static string GetNoButton() => "NoButton".GetLocalized();
public static string GetSettingsThemeDark() => "SettingsThemeDark".GetLocalized();
Expand Down
15 changes: 12 additions & 3 deletions Clients/TgDownloaderDesktop/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@
<data name="SettingsThemeDefault" xml:space="preserve">
<value>Default</value>
</data>
<data name="Settings_About.Text" xml:space="preserve">
<data name="SettingsAbout.Text" xml:space="preserve">
<value>TgDownloader - Telegram Files Downloader</value>
</data>
<data name="Settings_AboutDescription.Text" xml:space="preserve">
<value>TODO: Replace with your app description.</value>
<data name="SettingsLicense.Text" xml:space="preserve">
<value>License</value>
</data>
<data name="SettingsPage_GitHub_TgDownloader.Content" xml:space="preserve">
<value>TgDownloader repository</value>
Expand Down Expand Up @@ -333,4 +333,13 @@
<data name="ClientSettingsAreNotValid" xml:space="preserve">
<value>Client settings are not valid</value>
</data>
<data name="LicenseFreeDescription" xml:space="preserve">
<value>Free license</value>
</data>
<data name="LicensePaidDescription" xml:space="preserve">
<value>Paid license</value>
</data>
<data name="LicensePremiumDescription" xml:space="preserve">
<value>Premium license</value>
</data>
</root>
17 changes: 13 additions & 4 deletions Clients/TgDownloaderDesktop/Strings/ru-RU/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@
<data name="SettingsThemeDefault" xml:space="preserve">
<value>Default</value>
</data>
<data name="Settings_About.Text" xml:space="preserve">
<value>TgDownloader - Telegram Files Downloader</value>
<data name="SettingsAbout.Text" xml:space="preserve">
<value>TgDownloader - Загрузчик файлов Telegram</value>
</data>
<data name="Settings_AboutDescription.Text" xml:space="preserve">
<value>TODO: Replace with your app description.</value>
<data name="SettingsLicense.Text" xml:space="preserve">
<value>Лицензия</value>
</data>
<data name="SettingsPage_GitHub_TgDownloader.Content" xml:space="preserve">
<value>TgDownloader repository</value>
Expand Down Expand Up @@ -398,4 +398,13 @@
<data name="ClientSettingsAreNotValid" xml:space="preserve">
<value>Настройки клиента не валидны</value>
</data>
<data name="LicenseFreeDescription" xml:space="preserve">
<value>Бесплатная лицензия</value>
</data>
<data name="LicensePaidDescription" xml:space="preserve">
<value>Платная лицензия</value>
</data>
<data name="LicensePremiumDescription" xml:space="preserve">
<value>Премиальная лицензия</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public async Task<string> ConfigClientDesktop(string what)
IsNeedLastName = true;
return LastName;
case "session_pathname":
string sessionPath = Path.Combine(Directory.GetCurrentDirectory(), TgAppSettings.AppXml.XmlFileSession);
string sessionPath = Path.Combine(Directory.GetCurrentDirectory(), AppSettings.AppXml.XmlFileSession);
return sessionPath;
case "verification_code":
if (string.IsNullOrEmpty(VerificationCode))
Expand Down
4 changes: 3 additions & 1 deletion Clients/TgDownloaderDesktop/ViewModels/TgMainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public partial class TgMainViewModel : TgPageViewModelBase
private string _appVersionShort = string.Empty;
[ObservableProperty]
private string _appVersionFull = string.Empty;
[ObservableProperty]
private string _licenseDescription = string.Empty;

public TgMainViewModel(ITgSettingsService settingsService) : base(settingsService)
{
Expand All @@ -24,7 +26,7 @@ public TgMainViewModel(ITgSettingsService settingsService) : base(settingsServic
$"v{TgCommonUtils.GetTrimVersion(Assembly.GetExecutingAssembly().GetName().Version)}";
AppVersionShort = $"v{TgCommonUtils.GetTrimVersion(Assembly.GetExecutingAssembly().GetName().Version)}";
AppVersionFull = $"{TgResourceExtensions.GetAppVersion()}: {AppVersionShort}";

LicenseDescription = LicenseManager.CurrentLicense.Description;
}

#endregion
Expand Down
12 changes: 9 additions & 3 deletions Clients/TgDownloaderDesktop/Views/TgMainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,28 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- About -->
<StackPanel Grid.Row="0" Margin="{StaticResource MediumTopMargin}">
<TextBlock x:Uid="Settings_About" Style="{ThemeResource BodyStrongTextBlockStyle}" />
<TextBlock x:Uid="SettingsAbout" Style="{ThemeResource BodyStrongTextBlockStyle}" />
<TextBlock Style="{ThemeResource BodyStrongTextBlockStyle}" Text="{x:Bind ViewModel.AppVersionFull, Mode=OneWay}" />
</StackPanel>
<!-- GitHub links -->
<!-- License -->
<StackPanel Grid.Row="1" Margin="{StaticResource MediumTopMargin}">
<TextBlock x:Uid="SettingsLicense" Style="{ThemeResource SubtitleTextBlockStyle}" />
<TextBlock Style="{ThemeResource BodyStrongTextBlockStyle}" Text="{x:Bind ViewModel.LicenseDescription, Mode=OneWay}" />
</StackPanel>
<!-- GitHub links -->
<StackPanel Grid.Row="2" Margin="{StaticResource MediumTopMargin}">
<TextBlock x:Uid="SettingsPage_GitHub" Style="{ThemeResource SubtitleTextBlockStyle}" />
<HyperlinkButton x:Uid="SettingsPage_GitHub_TgDownloader" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
<HyperlinkButton x:Uid="SettingsPage_GitHub_ReportBug" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
<HyperlinkButton x:Uid="SettingsPage_GitHub_Discussions" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
<HyperlinkButton x:Uid="SettingsPage_GitHub_Ideas" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
</StackPanel>
<!-- Support -->
<StackPanel Grid.Row="2" Margin="{StaticResource MediumTopMargin}">
<StackPanel Grid.Row="3" Margin="{StaticResource MediumTopMargin}">
<TextBlock x:Uid="SettingsPage_GitHub_Support" Style="{ThemeResource SubtitleTextBlockStyle}" />
<HyperlinkButton x:Uid="SettingsPage_GitHub_TgDownloaderNews" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
<HyperlinkButton x:Uid="SettingsPage_GitHub_TgDownloaderGlobalChat" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
Expand Down

0 comments on commit 329d0d5

Please sign in to comment.