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
15 changes: 15 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3487,6 +3487,9 @@
<data name="ProcessingItems" xml:space="preserve">
<value>Processing items...</value>
</data>
<data name="DiscoveringItems" xml:space="preserve">
<value>Discovery in progress...</value>
</data>
<data name="SpeedWithColon" xml:space="preserve">
<value>Speed:</value>
</data>
Expand Down Expand Up @@ -3618,6 +3621,10 @@
<value>Copying {0, plural, one {# item} other {# items}} from "{1}" to "{2}"</value>
<comment>Shown in a StatusCenter card.</comment>
</data>
<data name="StatusCenter_CopyDiscovery_Header" xml:space="preserve">
<value>Discovered {0, plural, one {# item} other {# items}}</value>
<comment>Shown in a StatusCenter card during file discovery phase.</comment>
</data>
<data name="StatusCenter_DecompressCanceled_Header" xml:space="preserve">
<value>Canceled extracting "{0}" to "{1}"</value>
<comment>Shown in a StatusCenter card.</comment>
Expand Down Expand Up @@ -3670,6 +3677,10 @@
<value>Deleting {0, plural, one {# item} other {# items}} from "{1}"</value>
<comment>Shown in a StatusCenter card.</comment>
</data>
<data name="StatusCenter_DeleteDiscovery_Header" xml:space="preserve">
<value>Discovered {0, plural, one {# item} other {# items}}</value>
<comment>Shown in a StatusCenter card during file discovery phase.</comment>
</data>
<data name="StatusCenter_MoveCanceled_Header" xml:space="preserve">
<value>Canceled moving {0, plural, one {# item} other {# items}} to "{1}"</value>
<comment>Shown in a StatusCenter card.</comment>
Expand All @@ -3694,6 +3705,10 @@
<value>Moving {0, plural, one {# item} other {# items}} from "{1}" to "{2}"</value>
<comment>Shown in a StatusCenter card.</comment>
</data>
<data name="StatusCenter_MoveDiscovery_Header" xml:space="preserve">
<value>Discovered {0, plural, one {# item} other {# items}}</value>
<comment>Shown in a StatusCenter card during file discovery phase.</comment>
</data>
<data name="StatusCenter_MoveFailed_Header" xml:space="preserve">
<value>Error moving {0, plural, one {# item} other {# items}} to "{1}"</value>
<comment>Shown in a StatusCenter card.</comment>
Expand Down
44 changes: 34 additions & 10 deletions src/Files.App/Utils/StatusCenter/StatusCenterHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public static StatusCenterItem AddCard_Prepare()
false);
}

public static void UpdateCardStrings(StatusCenterItem card)
public static void UpdateCardStrings(StatusCenterItem card, StatusCenterItemProgressModel? progressValue = null)
{
// Aren't used for now
string sourcePath = string.Empty;
Expand Down Expand Up @@ -645,9 +645,17 @@ public static void UpdateCardStrings(StatusCenterItem card)
{
case FileOperationType.Copy:
{
string headerString = string.IsNullOrWhiteSpace(card.HeaderStringResource) ? string.Empty
: card.HeaderStringResource.GetLocalizedFormatResource(card.TotalItemsCount, destinationDirName);
card.Header = headerString;
string headerResource = card.HeaderStringResource;

if (card.IsDiscovering && card.TotalItemsCount > 0 && card.IsInProgress)
headerResource = "StatusCenter_CopyDiscovery_Header";

if (string.IsNullOrWhiteSpace(headerResource))
card.Header = string.Empty;
else if (headerResource == "StatusCenter_CopyDiscovery_Header")
card.Header = headerResource.GetLocalizedFormatResource(card.TotalItemsCount);
else
card.Header = headerResource.GetLocalizedFormatResource(card.TotalItemsCount, destinationDirName);

string subHeaderString = string.IsNullOrWhiteSpace(card.SubHeaderStringResource) ? string.Empty
: card.SubHeaderStringResource.GetLocalizedFormatResource(card.TotalItemsCount, sourcePath, destinationPath);
Expand All @@ -656,9 +664,17 @@ public static void UpdateCardStrings(StatusCenterItem card)
}
case FileOperationType.Move:
{
string headerString = string.IsNullOrWhiteSpace(card.HeaderStringResource) ? string.Empty
: card.HeaderStringResource.GetLocalizedFormatResource(card.TotalItemsCount, destinationDirName);
card.Header = headerString;
string headerResource = card.HeaderStringResource;

if (card.IsDiscovering && card.TotalItemsCount > 0 && card.IsInProgress)
headerResource = "StatusCenter_MoveDiscovery_Header";

if (string.IsNullOrWhiteSpace(headerResource))
card.Header = string.Empty;
else if (headerResource == "StatusCenter_MoveDiscovery_Header")
card.Header = headerResource.GetLocalizedFormatResource(card.TotalItemsCount);
else
card.Header = headerResource.GetLocalizedFormatResource(card.TotalItemsCount, destinationDirName);

string subHeaderString = string.IsNullOrWhiteSpace(card.SubHeaderStringResource) ? string.Empty
: card.SubHeaderStringResource.GetLocalizedFormatResource(card.TotalItemsCount, sourcePath, destinationPath);
Expand All @@ -667,9 +683,17 @@ public static void UpdateCardStrings(StatusCenterItem card)
}
case FileOperationType.Delete:
{
string headerString = string.IsNullOrWhiteSpace(card.HeaderStringResource) ? string.Empty
: card.HeaderStringResource.GetLocalizedFormatResource(card.TotalItemsCount, sourceDirName);
card.Header = headerString;
string headerResource = card.HeaderStringResource;

if (card.IsDiscovering && card.TotalItemsCount > 0 && card.IsInProgress)
headerResource = "StatusCenter_DeleteDiscovery_Header";

if (string.IsNullOrWhiteSpace(headerResource))
card.Header = string.Empty;
else if (headerResource == "StatusCenter_DeleteDiscovery_Header")
card.Header = headerResource.GetLocalizedFormatResource(card.TotalItemsCount);
else
card.Header = headerResource.GetLocalizedFormatResource(card.TotalItemsCount, sourceDirName);

string subHeaderString = string.IsNullOrWhiteSpace(card.SubHeaderStringResource) ? string.Empty
: card.SubHeaderStringResource.GetLocalizedFormatResource(card.TotalItemsCount, sourcePath);
Expand Down
14 changes: 11 additions & 3 deletions src/Files.App/Utils/StatusCenter/StatusCenterItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public StatusCenterItemProgressModel Progress

public bool IsInProgress { get; private set; }

public bool IsDiscovering { get; private set; } = true;

public IEnumerable<string>? Source { get; private set; }

public IEnumerable<string>? Destination { get; private set; }
Expand Down Expand Up @@ -199,7 +201,7 @@ public StatusCenterItem(
AnimatedIconState = "NormalOff";
SpeedGraphValues = [];
CancelCommand = new RelayCommand(ExecuteCancelCommand);
Message = Strings.ProcessingItems.GetLocalizedResource();
Message = Strings.DiscoveringItems.GetLocalizedResource();
Source = source;
Destination = destination;

Expand Down Expand Up @@ -327,8 +329,14 @@ private void ReportProgress(StatusCenterItemProgressModel value)
if (TotalSize < value.TotalSize)
TotalSize = value.TotalSize;

if (value.EnumerationCompleted && IsDiscovering)
{
IsDiscovering = false;
Message = Strings.ProcessingItems.GetLocalizedResource();
}

// Update UI for strings
StatusCenterHelper.UpdateCardStrings(this);
StatusCenterHelper.UpdateCardStrings(this, value);
OnPropertyChanged(nameof(HeaderTooltip));

// Graph item point
Expand Down Expand Up @@ -382,7 +390,7 @@ private void ReportProgress(StatusCenterItemProgressModel value)
SpeedGraphValues?.Add(point);

// Add percentage to the header
if (!IsIndeterminateProgress)
if (!IsIndeterminateProgress && value.EnumerationCompleted)
Header = $"{Header} ({ProgressPercentage}%)";

// Update UI of the address bar
Expand Down
24 changes: 24 additions & 0 deletions src/Files.App/Utils/Storage/Operations/FileOperationsHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera

var cts = new CancellationTokenSource();
var sizeCalculator = new FileSizeCalculator(fileToDeletePath);

// Track the count and update the progress
sizeCalculator.ItemsCountChanged += (newCount) =>
{
fsProgress.ItemsCount = newCount;
fsProgress.Report();
};

var sizeTask = sizeCalculator.ComputeSizeAsync(cts.Token);
sizeTask.ContinueWith(_ =>
{
Expand Down Expand Up @@ -405,6 +413,14 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera

var cts = new CancellationTokenSource();
var sizeCalculator = new FileSizeCalculator(fileToMovePath);

// Track the count and update the progress
sizeCalculator.ItemsCountChanged += (newCount) =>
{
fsProgress.ItemsCount = newCount;
fsProgress.Report();
};

var sizeTask = sizeCalculator.ComputeSizeAsync(cts.Token);
sizeTask.ContinueWith(_ =>
{
Expand Down Expand Up @@ -533,6 +549,14 @@ public static Task SetClipboard(string[] filesToCopy, DataPackageOperation opera

var cts = new CancellationTokenSource();
var sizeCalculator = new FileSizeCalculator(fileToCopyPath);

// Track the count and update the progress
sizeCalculator.ItemsCountChanged += (newCount) =>
{
fsProgress.ItemsCount = newCount;
fsProgress.Report();
};

var sizeTask = sizeCalculator.ComputeSizeAsync(cts.Token);
sizeTask.ContinueWith(_ =>
{
Expand Down
5 changes: 5 additions & 0 deletions src/Files.App/Utils/Storage/Operations/FileSizeCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal sealed class FileSizeCalculator
public int ItemsCount => _computedFiles.Count;
public bool Completed { get; private set; }

public event Action<int>? ItemsCountChanged;

public FileSizeCalculator(params string[] paths)
{
_paths = paths;
Expand Down Expand Up @@ -118,7 +120,10 @@ private long ComputeFileSize(string path)
null);

if (!hFile.IsInvalid && PInvoke.GetFileSizeEx(hFile, out size) && _computedFiles.TryAdd(path, size))
{
Interlocked.Add(ref _size, size);
ItemsCountChanged?.Invoke(ItemsCount);
}

return size;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task<IStorageHistory> CopyItemsAsync(IList<IStorageItemWithPath> so

StatusCenterItemProgressModel fsProgress = new(
progress,
true,
false,
FileSystemStatusCode.InProgress,
source.Count);

Expand Down
Loading