Skip to content

Code quality: Improved code readability #10116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 3, 2022
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
25 changes: 12 additions & 13 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ public string JumpString
IEnumerable<ListedItem> candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders
.SkipWhile(x => x != previouslySelectedItem)
.Skip(value.Length == 1 ? 1 : 0) // User is trying to cycle through items starting with the same letter
.Where(f => f.ItemName.Length >= value.Length && string.Equals(f.ItemName.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
.Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
jumpedToItem = candidateItems.FirstOrDefault();
}

if (jumpedToItem == null)
{
// Use FilesAndFolders because only displayed entries should be jumped to
IEnumerable<ListedItem> candidateItems = ParentShellPageInstance!.FilesystemViewModel.FilesAndFolders
.Where(f => f.ItemName.Length >= value.Length && string.Equals(f.ItemName.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
.Where(f => f.Name.Length >= value.Length && string.Equals(f.Name.Substring(0, value.Length), value, StringComparison.OrdinalIgnoreCase));
jumpedToItem = candidateItems.FirstOrDefault();
}

Expand Down Expand Up @@ -761,7 +761,7 @@ protected void FileList_DragItemsStarting(object sender, DragItemsStartingEventA
try
{
// Only support IStorageItem capable paths
var itemList = e.Items.OfType<ListedItem>().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcutItem)).Select(x => VirtualStorageItem.FromListedItem(x));
var itemList = e.Items.OfType<ListedItem>().Where(x => !(x.IsHiddenItem && x.IsLinkItem && x.IsRecycleBinItem && x.IsShortcut)).Select(x => VirtualStorageItem.FromListedItem(x));
e.Data.SetStorageItems(itemList, false);
}
catch (Exception)
Expand Down Expand Up @@ -820,7 +820,7 @@ protected async void Item_DragOver(object sender, DragEventArgs e)
else if (handledByFtp)
{
e.DragUIOverride.IsCaptionVisible = true;
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.ItemName);
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Copy;
}
else if (!draggedItems.Any())
Expand All @@ -832,38 +832,38 @@ protected async void Item_DragOver(object sender, DragEventArgs e)
e.DragUIOverride.IsCaptionVisible = true;
if (item.IsExecutable)
{
e.DragUIOverride.Caption = $"{"OpenItemsWithCaptionText".GetLocalizedResource()} {item.ItemName}";
e.DragUIOverride.Caption = $"{"OpenItemsWithCaptionText".GetLocalizedResource()} {item.Name}";
e.AcceptedOperation = DataPackageOperation.Link;
} // Items from the same drive as this folder are dragged into this folder, so we move the items instead of copy
else if (e.Modifiers.HasFlag(DragDropModifiers.Alt) || e.Modifiers.HasFlag(DragDropModifiers.Control | DragDropModifiers.Shift))
{
e.DragUIOverride.Caption = string.Format("LinkToFolderCaptionText".GetLocalizedResource(), item.ItemName);
e.DragUIOverride.Caption = string.Format("LinkToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Link;
}
else if (e.Modifiers.HasFlag(DragDropModifiers.Control))
{
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.ItemName);
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Copy;
}
else if (e.Modifiers.HasFlag(DragDropModifiers.Shift))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.ItemName);
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Move;
}
else if (draggedItems.Any(x => x.Item is ZipStorageFile || x.Item is ZipStorageFolder)
|| ZipStorageFolder.IsZipPath(item.ItemPath))
{
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.ItemName);
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Copy;
}
else if (draggedItems.AreItemsInSameDrive(item.ItemPath))
{
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.ItemName);
e.DragUIOverride.Caption = string.Format("MoveToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Move;
}
else
{
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.ItemName);
e.DragUIOverride.Caption = string.Format("CopyToFolderCaptionText".GetLocalizedResource(), item.Name);
e.AcceptedOperation = DataPackageOperation.Copy;
}
}
Expand Down Expand Up @@ -1016,10 +1016,9 @@ protected internal void FileListItem_PointerExited(object sender, PointerRoutedE
protected void FileListItem_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
var rightClickedItem = GetItemFromElement(sender);

if (rightClickedItem != null && !((SelectorItem)sender).IsSelected)
{
ItemManipulationModel.SetSelectedItem(rightClickedItem);
}
}

private readonly RecycleBinHelpers recycleBinHelpers = new();
Expand Down
Loading