diff --git a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SettingsViewResources.resw b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SettingsViewResources.resw index afeb536..f72871d 100644 --- a/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SettingsViewResources.resw +++ b/VDownload.Core/VDownload.Core.Strings/Strings/en-US/SettingsViewResources.resw @@ -180,6 +180,15 @@ Media type + + Show warning before downloading on a metered connection + + + If file with same name as output file, already exists, it will be replaced. Otherwise new file with unique name will be created. + + + Replace output file if exists + Maximum number of tasks running in parallel diff --git a/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs b/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs index f19fd9b..2503af5 100644 --- a/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs +++ b/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs @@ -250,7 +250,12 @@ namespace VDownload.Core.Tasks StorageFolder destination = await StorageFolder.GetFolderFromPathAsync(DownloadOptions.Directory); string filename = $"{DownloadOptions.Filename}.{DownloadOptions.Extension}"; - await outputFile.CopyAsync(destination, filename, NameCollisionOption.ReplaceExisting); + + NameCollisionOption nameCollisionOption = _settingsService.Data.Common.Tasks.ReplaceOutputFileIfExists + ? NameCollisionOption.ReplaceExisting + : NameCollisionOption.GenerateUniqueName; + + await outputFile.CopyAsync(destination, filename, nameCollisionOption); } protected void UpdateStatusWithDispatcher(DownloadTaskStatus status) => _dispatcherQueue.TryEnqueue(() => Status = status); diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeDownloadsViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeDownloadsViewModel.cs index 7d03e7f..47e53a5 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeDownloadsViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeDownloadsViewModel.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using VDownload.Core.Tasks; +using VDownload.Services.Data.Settings; using VDownload.Services.UI.Dialogs; using VDownload.Services.UI.StringResources; @@ -21,6 +22,7 @@ namespace VDownload.Core.ViewModels.Home protected readonly IDialogsService _dialogsService; protected readonly IStringResourcesService _stringResourcesService; + protected readonly ISettingsService _settingsService; #endregion @@ -39,13 +41,14 @@ namespace VDownload.Core.ViewModels.Home #region CONSTRUCTORS - public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, IDialogsService dialogsService, IStringResourcesService stringResourcesService) + public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, IDialogsService dialogsService, IStringResourcesService stringResourcesService, ISettingsService settingsService) { _tasksManager = tasksManager; _tasksManager.TaskCollectionChanged += Tasks_CollectionChanged; _dialogsService = dialogsService; _stringResourcesService = stringResourcesService; + _settingsService = settingsService; _taskListIsEmpty = _tasksManager.Tasks.Count == 0; } @@ -77,7 +80,12 @@ namespace VDownload.Core.ViewModels.Home } bool continueEnqueue = true; - if (NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection) + if + ( + _settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings + && + NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection + ) { string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoCollectionViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoCollectionViewModel.cs index 49ec442..ca3fe15 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoCollectionViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoCollectionViewModel.cs @@ -297,7 +297,14 @@ namespace VDownload.Core.ViewModels.Home protected async Task CreateTasks(bool download) { - if (download && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection) + if + ( + download + && + _settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings + && + NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection + ) { string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs index 9dcdf25..4c4e483 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs @@ -175,7 +175,14 @@ namespace VDownload.Core.ViewModels.Home protected async Task CreateTask(bool download) { - if (download && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection) + if + ( + download + && + _settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings + && + NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection + ) { string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs index 1841391..9319f71 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs @@ -342,26 +342,34 @@ namespace VDownload.Core.ViewModels.Home [RelayCommand] public async Task Download() { - if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) + if (_downloadTaskManager.Tasks.Count > 0) { - ShowError(ErrorNoInternetConnection()); - return; - } - - if (_downloadTaskManager.Tasks.Count > 0 && NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection) - { - string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); - string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); - DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message); - if (result == DialogResultYesNo.No) + if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { + ShowError(ErrorNoInternetConnection()); return; } - } - foreach (DownloadTask task in _downloadTaskManager.Tasks) - { - task.Enqueue(); + if + ( + _settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings + && + NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection + ) + { + string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); + string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); + DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message); + if (result == DialogResultYesNo.No) + { + return; + } + } + + foreach (DownloadTask task in _downloadTaskManager.Tasks) + { + task.Enqueue(); + } } } diff --git a/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs index 9ea848e..cfa9784 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs @@ -65,6 +65,12 @@ namespace VDownload.Core.ViewModels.Settings set => SetProperty(_settingsService.Data.Common.Tasks.FilenameTemplate, value, _settingsService.Data.Common.Tasks, (u, n) => u.FilenameTemplate = n); } + public bool TasksMeteredConnectionWarning + { + get => _settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings; + set => SetProperty(_settingsService.Data.Common.Tasks.ShowMeteredConnectionWarnings, value, _settingsService.Data.Common.Tasks, (u, n) => u.ShowMeteredConnectionWarnings = n); + } + public bool TasksSaveLastOutputDirectory { get => _settingsService.Data.Common.Tasks.SaveLastOutputDirectory; @@ -77,6 +83,12 @@ namespace VDownload.Core.ViewModels.Settings set => SetProperty(_settingsService.Data.Common.Tasks.DefaultOutputDirectory, value, _settingsService.Data.Common.Tasks, (u, n) => u.DefaultOutputDirectory = n); } + public bool TasksReplaceOutputFile + { + get => _settingsService.Data.Common.Tasks.ReplaceOutputFileIfExists; + set => SetProperty(_settingsService.Data.Common.Tasks.ReplaceOutputFileIfExists, value, _settingsService.Data.Common.Tasks, (u, n) => u.ReplaceOutputFileIfExists = n); + } + public string ProcessingFFmpegLocation { get => _settingsService.Data.Common.Processing.FFmpegLocation; diff --git a/VDownload.Core/VDownload.Core.Views/Settings/SettingsView.xaml b/VDownload.Core/VDownload.Core.Views/Settings/SettingsView.xaml index 8fcb718..96e06c9 100644 --- a/VDownload.Core/VDownload.Core.Views/Settings/SettingsView.xaml +++ b/VDownload.Core/VDownload.Core.Views/Settings/SettingsView.xaml @@ -105,6 +105,13 @@ + + + + + + + + + + + + diff --git a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/Models/Tasks.cs b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/Models/Tasks.cs index dd46c0e..70bed9d 100644 --- a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/Models/Tasks.cs +++ b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/Models/Tasks.cs @@ -30,5 +30,11 @@ namespace VDownload.Services.Data.Settings.Models [JsonProperty("max_number_of_running_tasks")] public int MaxNumberOfRunningTasks { get; set; } = 5; + + [JsonProperty("show_metered_connection_warnings")] + public bool ShowMeteredConnectionWarnings { get; set; } = true; + + [JsonProperty("replace_output_file_if_exists")] + public bool ReplaceOutputFileIfExists { get; set; } = false; } } diff --git a/VDownload/Assets/SettingsView/TasksMeteredConnectionWarningDark.png b/VDownload/Assets/SettingsView/TasksMeteredConnectionWarningDark.png new file mode 100644 index 0000000..34cb119 Binary files /dev/null and b/VDownload/Assets/SettingsView/TasksMeteredConnectionWarningDark.png differ diff --git a/VDownload/Assets/SettingsView/TasksMeteredConnectionWarningLight.png b/VDownload/Assets/SettingsView/TasksMeteredConnectionWarningLight.png new file mode 100644 index 0000000..14763bf Binary files /dev/null and b/VDownload/Assets/SettingsView/TasksMeteredConnectionWarningLight.png differ diff --git a/VDownload/Assets/SettingsView/TasksReplaceOutputFileDark.png b/VDownload/Assets/SettingsView/TasksReplaceOutputFileDark.png new file mode 100644 index 0000000..c9e398c Binary files /dev/null and b/VDownload/Assets/SettingsView/TasksReplaceOutputFileDark.png differ diff --git a/VDownload/Assets/SettingsView/TasksReplaceOutputFileLight.png b/VDownload/Assets/SettingsView/TasksReplaceOutputFileLight.png new file mode 100644 index 0000000..451e87a Binary files /dev/null and b/VDownload/Assets/SettingsView/TasksReplaceOutputFileLight.png differ diff --git a/VDownload/Dictionaries/Images/ImagesSettingsView.xaml b/VDownload/Dictionaries/Images/ImagesSettingsView.xaml index fd1967a..952de6b 100644 --- a/VDownload/Dictionaries/Images/ImagesSettingsView.xaml +++ b/VDownload/Dictionaries/Images/ImagesSettingsView.xaml @@ -8,7 +8,9 @@ /Assets/SettingsView/TasksDefaultMediaOptionsLight.png /Assets/SettingsView/TasksRunningTasksLight.png /Assets/SettingsView/TasksFilenameTemplateLight.png + /Assets/SettingsView/TasksMeteredConnectionWarningLight.png /Assets/SettingsView/TasksOutputDirectoryLight.png + /Assets/SettingsView/TasksReplaceOutputFileLight.png /Assets/SettingsView/TempDirectoryLight.png /Assets/SettingsView/TempDeleteOnFailLight.png /Assets/SettingsView/NotificationOnSuccessfulLight.png @@ -23,7 +25,9 @@ /Assets/SettingsView/TasksDefaultMediaOptionsDark.png /Assets/SettingsView/TasksRunningTasksDark.png /Assets/SettingsView/TasksFilenameTemplateDark.png + /Assets/SettingsView/TasksMeteredConnectionWarningDark.png /Assets/SettingsView/TasksOutputDirectoryDark.png + /Assets/SettingsView/TasksReplaceOutputFileDark.png /Assets/SettingsView/TempDirectoryDark.png /Assets/SettingsView/TempDeleteOnFailDark.png /Assets/SettingsView/NotificationOnSuccessfulDark.png diff --git a/VDownload/VDownload.csproj b/VDownload/VDownload.csproj index 31c3e2f..589ff2a 100644 --- a/VDownload/VDownload.csproj +++ b/VDownload/VDownload.csproj @@ -266,6 +266,18 @@ Always + + Always + + + Always + + + Always + + + Always + Always