metered connection warnings added

This commit is contained in:
2024-03-04 00:28:32 +01:00
Unverified
parent 2edca7e564
commit 3ddb8e73e3
12 changed files with 298 additions and 21 deletions

View File

@@ -7,6 +7,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VDownload.Core.Tasks;
using VDownload.Services.UI.Dialogs;
using VDownload.Services.UI.StringResources;
using VDownload.Services.Utility.Network;
namespace VDownload.Core.ViewModels.Home
{
@@ -16,6 +19,10 @@ namespace VDownload.Core.ViewModels.Home
protected readonly IDownloadTaskManager _tasksManager;
protected readonly INetworkService _networkService;
protected readonly IDialogsService _dialogsService;
protected readonly IStringResourcesService _stringResourcesService;
#endregion
@@ -33,11 +40,15 @@ namespace VDownload.Core.ViewModels.Home
#region CONSTRUCTORS
public HomeDownloadsViewModel(IDownloadTaskManager tasksManager)
public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, INetworkService networkService, IDialogsService dialogsService, IStringResourcesService stringResourcesService)
{
_tasksManager = tasksManager;
_tasksManager.TaskCollectionChanged += Tasks_CollectionChanged;
_networkService = networkService;
_dialogsService = dialogsService;
_stringResourcesService = stringResourcesService;
_taskListIsEmpty = _tasksManager.Tasks.Count == 0;
}
@@ -59,7 +70,19 @@ namespace VDownload.Core.ViewModels.Home
];
if (idleStatuses.Contains(task.Status))
{
task.Enqueue();
bool continueEnqueue = true;
if (_networkService.IsMetered)
{
string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle");
string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage");
DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message);
continueEnqueue = result == DialogResultYesNo.Yes;
}
if (continueEnqueue)
{
task.Enqueue();
}
}
else
{