Skip to content
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
2 changes: 1 addition & 1 deletion src/Files.App/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static class ExternalUrl
public const string FeatureRequestUrl = @"https://github.com/files-community/Files/issues/new?labels=feature+request&template=feature_request.yml";
public const string BugReportUrl = @"https://github.com/files-community/Files/issues/new?labels=bug&template=bug_report.yml";
public const string PrivacyPolicyUrl = @"https://files.community/privacy";
public const string SupportUsUrl = @"https://github.com/sponsors/yaira2";
public const string SupportUsUrl = @"https://github.com/files-community/Files?sponsor";
public const string CrowdinUrl = @"https://crowdin.com/project/files-app";
public static readonly string ReleaseNotesUrl= $"https://files.community/blog/posts/v{Package.Current.Id.Version.Major}-{Package.Current.Id.Version.Minor}-{Package.Current.Id.Version.Build}?minimal";
}
Expand Down
9 changes: 7 additions & 2 deletions src/Files.App/Data/Contracts/IApplicationSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ namespace Files.App.Data.Contracts
public interface IApplicationSettingsService : IBaseSettingsService
{
/// <summary>
/// Gets or sets a value indicating whether or not the user clicked to review the app.
/// Gets or sets a value indicating whether or not the user clicked the 'review' prompt.
/// </summary>
bool ClickedToReviewApp { get; set; }
bool HasClickedReviewPrompt { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not the user clicked the 'sponsor' prompt.
/// </summary>
bool HasClickedSponsorPrompt { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to display a prompt when running the app as administrator.
Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/Helpers/Application/AppLifecycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ static AppLifecycleHelper()
{
IsAppUpdated = version.ToString() != AppVersion.ToString();
}
TotalLaunchCount = launchCount is long l ? l + 1 : 1;

TotalLaunchCount = long.TryParse(launchCount?.ToString(), out var v) ? v + 1 : 1;
infoKey.SetValue("LastLaunchVersion", AppVersion.ToString());
infoKey.SetValue("TotalLaunchCount", TotalLaunchCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ namespace Files.App.Services.Settings
{
internal sealed partial class ApplicationSettingsService : BaseObservableJsonSettings, IApplicationSettingsService
{
public bool ClickedToReviewApp
public bool HasClickedReviewPrompt
{
get => Get(false);
set => Set(value);
}

public bool HasClickedSponsorPrompt
{
get => Get(false);
set => Set(value);
Expand Down
8 changes: 7 additions & 1 deletion src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -2012,11 +2012,17 @@
<data name="Behaviors" xml:space="preserve">
<value>Behaviors</value>
</data>
<data name="ReviewFilesTitle" xml:space="preserve">
<data name="Hello" xml:space="preserve">
<value>Hello!</value>
</data>
<data name="ReviewFilesSubtitle" xml:space="preserve">
<value>Enjoying Files? Please consider reviewing in the Microsoft Store.</value>
</data>
<data name="SponsorSubtitle" xml:space="preserve">
<value>Enjoying Files? Please consider supporting the project on GitHub.</value>
</data>
<data name="Sponsor" xml:space="preserve">
<value>Sponsor</value>
</data>
<data name="RateUs" xml:space="preserve">
<value>Rate us</value>
Expand Down
39 changes: 33 additions & 6 deletions src/Files.App/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.UI.Xaml.Media.Imaging;
using Microsoft.UI.Xaml.Navigation;
using System.Windows.Input;
using Windows.ApplicationModel;
using Windows.Services.Store;
using Windows.System;
using WinRT.Interop;
Expand Down Expand Up @@ -134,11 +133,23 @@ public bool ShowReviewPrompt
{
get
{
var isTargetPackage = Package.Current.Id.Name == "49306atecsolution.FilesUWP" || Package.Current.Id.Name == "49306atecsolution.FilesPreview";
var hasNotClickedReview = !UserSettingsService.ApplicationSettingsService.ClickedToReviewApp;
var isTargetEnvironment = AppLifecycleHelper.AppEnvironment is AppEnvironment.StoreStable or AppEnvironment.StorePreview;
var hasClickedReviewPrompt = UserSettingsService.ApplicationSettingsService.HasClickedReviewPrompt;
var launchCountReached = AppLifecycleHelper.TotalLaunchCount == 30;

return isTargetPackage && hasNotClickedReview && launchCountReached;
return isTargetEnvironment && !hasClickedReviewPrompt && launchCountReached;
}
}

public bool ShowSponsorPrompt
{
get
{
var isTargetEnvironment = AppLifecycleHelper.AppEnvironment is AppEnvironment.Dev or AppEnvironment.SideloadStable or AppEnvironment.SideloadPreview;
var hasClickedSponsorPrompt = UserSettingsService.ApplicationSettingsService.HasClickedSponsorPrompt;
var launchCountReached = AppLifecycleHelper.TotalLaunchCount == 30;

return isTargetEnvironment && !hasClickedSponsorPrompt && launchCountReached;
}
}

Expand All @@ -147,6 +158,8 @@ public bool ShowReviewPrompt
public ICommand NavigateToNumberedTabKeyboardAcceleratorCommand { get; }
public ICommand ReviewAppCommand { get; }
public ICommand DismissReviewPromptCommand { get; }
public ICommand SponsorCommand { get; }
public ICommand DismissSponsorPromptCommand { get; }

// Constructor

Expand All @@ -155,6 +168,8 @@ public MainPageViewModel()
NavigateToNumberedTabKeyboardAcceleratorCommand = new RelayCommand<KeyboardAcceleratorInvokedEventArgs>(ExecuteNavigateToNumberedTabKeyboardAcceleratorCommand);
ReviewAppCommand = new RelayCommand(ExecuteReviewAppCommand);
DismissReviewPromptCommand = new RelayCommand(ExecuteDismissReviewPromptCommand);
SponsorCommand = new RelayCommand(ExecuteSponsorCommand);
DismissSponsorPromptCommand = new RelayCommand(ExecuteDismissSponsorPromptCommand);

AppearanceSettingsService.PropertyChanged += (s, e) =>
{
Expand Down Expand Up @@ -322,7 +337,7 @@ await Task.WhenAll(

private async void ExecuteReviewAppCommand()
{
UserSettingsService.ApplicationSettingsService.ClickedToReviewApp = true;
UserSettingsService.ApplicationSettingsService.HasClickedReviewPrompt = true;
OnPropertyChanged(nameof(ShowReviewPrompt));

try
Expand All @@ -336,7 +351,19 @@ private async void ExecuteReviewAppCommand()

private void ExecuteDismissReviewPromptCommand()
{
UserSettingsService.ApplicationSettingsService.ClickedToReviewApp = true;
UserSettingsService.ApplicationSettingsService.HasClickedReviewPrompt = true;
}

private async void ExecuteSponsorCommand()
{
UserSettingsService.ApplicationSettingsService.HasClickedSponsorPrompt = true;
OnPropertyChanged(nameof(ShowSponsorPrompt));
await Launcher.LaunchUriAsync(new Uri(Constants.ExternalUrl.SupportUsUrl)).AsTask();
}

private void ExecuteDismissSponsorPromptCommand()
{
UserSettingsService.ApplicationSettingsService.HasClickedSponsorPrompt = true;
}

private async void ExecuteNavigateToNumberedTabKeyboardAcceleratorCommand(KeyboardAcceleratorInvokedEventArgs? e)
Expand Down
15 changes: 14 additions & 1 deletion src/Files.App/Views/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@

<!-- Review Files Prompt -->
<TeachingTip
Title="{helpers:ResourceString Name=ReviewFilesTitle}"
Title="{helpers:ResourceString Name=Hello}"
Grid.RowSpan="3"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Expand All @@ -379,6 +379,19 @@
IsOpen="{x:Bind ViewModel.ShowReviewPrompt, Mode=OneWay}"
Subtitle="{helpers:ResourceString Name=ReviewFilesSubtitle}" />

<!-- Sponsor Prompt -->
<TeachingTip
Title="{helpers:ResourceString Name=Hello}"
Grid.RowSpan="3"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
ActionButtonCommand="{x:Bind ViewModel.SponsorCommand}"
ActionButtonContent="{helpers:ResourceString Name=Sponsor}"
CloseButtonCommand="{x:Bind ViewModel.DismissSponsorPromptCommand}"
CloseButtonContent="{helpers:ResourceString Name=Dismiss}"
IsOpen="{x:Bind ViewModel.ShowSponsorPrompt, Mode=OneWay}"
Subtitle="{helpers:ResourceString Name=SponsorSubtitle}" />

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SidebarWidthStates">
<VisualState x:Name="SmallSidebarWidthState">
Expand Down
Loading