Skip to content

Commit aee8302

Browse files
authored
Merge branch 'main' into fix-for-issue-#14302
2 parents 4bae29f + ea43865 commit aee8302

File tree

21 files changed

+229
-54
lines changed

21 files changed

+229
-54
lines changed

docs/rich-commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,13 @@ This is the list of all commands defined in `CommandCodes` enum except `None`.
114114
| | GroupByFolderPath | Folder path | Group items by folder path | |
115115
| | GroupByDateModifiedYear | Year | Group items by year of date modified | |
116116
| | GroupByDateModifiedMonth | Month | Group items by month of date modified | |
117+
| | GroupByDateModifiedDay | Day | Group items by day of date modified | |
117118
| | GroupByDateCreatedYear | Year | Group items by year of date created | |
118119
| | GroupByDateCreatedMonth | Month | Group items by month of date created | |
120+
| | GroupByDateCreatedDay | Day | Group items by day of date created | |
119121
| | GroupByDateDeletedYear | Year | Group items by year of date deleted | |
120122
| | GroupByDateDeletedMonth | Month | Group items by month of date deleted | |
123+
| | GroupByDateDeletedDay | Day | Group items by day of date deleted | |
121124
| | GroupAscending | Ascending | Sort groups in ascending order | |
122125
| | GroupDescending | Descending | Sort groups in descending order | |
123126
| | ToggleGroupDirection | Toggle sort direction | Toggle group sort direction | |

src/Files.App/Actions/Display/GroupAction.cs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,21 @@ public override string Description
229229
=> "GroupByDateModifiedMonthDescription".GetLocalizedResource();
230230
}
231231

232+
internal class GroupByDateModifiedDayAction : GroupByDateAction
233+
{
234+
protected override GroupOption GroupOption
235+
=> GroupOption.DateModified;
236+
237+
protected override GroupByDateUnit GroupByDateUnit
238+
=> GroupByDateUnit.Day;
239+
240+
public override string Label
241+
=> "Day".GetLocalizedResource();
242+
243+
public override string Description
244+
=> "GroupByDateModifiedDayDescription".GetLocalizedResource();
245+
}
246+
232247
internal class GroupByDateCreatedYearAction : GroupByDateAction
233248
{
234249
protected override GroupOption GroupOption
@@ -259,6 +274,21 @@ public override string Description
259274
=> "GroupByDateCreatedMonthDescription".GetLocalizedResource();
260275
}
261276

277+
internal class GroupByDateCreatedDayAction : GroupByDateAction
278+
{
279+
protected override GroupOption GroupOption
280+
=> GroupOption.DateCreated;
281+
282+
protected override GroupByDateUnit GroupByDateUnit
283+
=> GroupByDateUnit.Day;
284+
285+
public override string Label
286+
=> "Day".GetLocalizedResource();
287+
288+
public override string Description
289+
=> "GroupByDateCreatedDayDescription".GetLocalizedResource();
290+
}
291+
262292
internal class GroupByDateDeletedYearAction : GroupByDateAction
263293
{
264294
protected override GroupOption GroupOption
@@ -295,6 +325,24 @@ protected override bool GetIsExecutable(ContentPageTypes pageType)
295325
=> pageType is ContentPageTypes.RecycleBin;
296326
}
297327

328+
internal class GroupByDateDeletedDayAction : GroupByDateAction
329+
{
330+
protected override GroupOption GroupOption
331+
=> GroupOption.DateDeleted;
332+
333+
protected override GroupByDateUnit GroupByDateUnit
334+
=> GroupByDateUnit.Day;
335+
336+
public override string Label
337+
=> "Day".GetLocalizedResource();
338+
339+
public override string Description
340+
=> "GroupByDateDeletedDayDescription".GetLocalizedResource();
341+
342+
protected override bool GetIsExecutable(ContentPageTypes pageType)
343+
=> pageType is ContentPageTypes.RecycleBin;
344+
}
345+
298346
internal abstract class GroupByDateAction : ObservableObject, IToggleAction
299347
{
300348
protected IContentPageContext ContentContext;
@@ -567,7 +615,12 @@ public ToggleGroupByDateUnitAction()
567615

568616
public Task ExecuteAsync()
569617
{
570-
context.GroupByDateUnit = context.GroupByDateUnit is GroupByDateUnit.Month ? GroupByDateUnit.Year : GroupByDateUnit.Month;
618+
context.GroupByDateUnit = context.GroupByDateUnit switch
619+
{
620+
GroupByDateUnit.Year => GroupByDateUnit.Month,
621+
GroupByDateUnit.Month => GroupByDateUnit.Day,
622+
_ => GroupByDateUnit.Year
623+
};
571624

572625
return Task.CompletedTask;
573626
}

src/Files.App/App.xaml.cs

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,21 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
6565

6666
async Task ActivateAsync()
6767
{
68-
// Initialize and activate MainWindow
69-
MainWindow.Instance.Activate();
68+
// Get AppActivationArguments
69+
var appActivationArguments = Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent().GetActivatedEventArgs();
70+
var isStartupTask = appActivationArguments.Data is Windows.ApplicationModel.Activation.IStartupTaskActivatedEventArgs;
7071

71-
// Wait for the Window to initialize
72-
await Task.Delay(10);
72+
if (!isStartupTask)
73+
{
74+
// Initialize and activate MainWindow
75+
MainWindow.Instance.Activate();
7376

74-
SplashScreenLoadingTCS = new TaskCompletionSource();
75-
MainWindow.Instance.ShowSplashScreen();
77+
// Wait for the Window to initialize
78+
await Task.Delay(10);
7679

77-
// Get AppActivationArguments
78-
var appActivationArguments = Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent().GetActivatedEventArgs();
80+
SplashScreenLoadingTCS = new TaskCompletionSource();
81+
MainWindow.Instance.ShowSplashScreen();
82+
}
7983

8084
// Start tracking app usage
8185
if (appActivationArguments.Data is Windows.ApplicationModel.Activation.IActivatedEventArgs activationEventArgs)
@@ -90,6 +94,21 @@ async Task ActivateAsync()
9094
AppLifecycleHelper.ConfigureAppCenter();
9195
#endif
9296

97+
var userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
98+
var isLeaveAppRunning = userSettingsService.GeneralSettingsService.LeaveAppRunning;
99+
100+
if (isStartupTask && !isLeaveAppRunning)
101+
{
102+
// Initialize and activate MainWindow
103+
MainWindow.Instance.Activate();
104+
105+
// Wait for the Window to initialize
106+
await Task.Delay(10);
107+
108+
SplashScreenLoadingTCS = new TaskCompletionSource();
109+
MainWindow.Instance.ShowSplashScreen();
110+
}
111+
93112
// TODO: Replace with DI
94113
QuickAccessManager = Ioc.Default.GetRequiredService<QuickAccessManager>();
95114
HistoryWrapper = Ioc.Default.GetRequiredService<StorageHistoryWrapper>();
@@ -105,15 +124,28 @@ async Task ActivateAsync()
105124

106125
Logger.LogInformation($"App launched. Launch args type: {appActivationArguments.Data.GetType().Name}");
107126

108-
// Wait for the UI to update
109-
await SplashScreenLoadingTCS!.Task.WithTimeoutAsync(TimeSpan.FromMilliseconds(500));
110-
SplashScreenLoadingTCS = null;
127+
if (!(isStartupTask && isLeaveAppRunning))
128+
{
129+
// Wait for the UI to update
130+
await SplashScreenLoadingTCS!.Task.WithTimeoutAsync(TimeSpan.FromMilliseconds(500));
131+
SplashScreenLoadingTCS = null;
111132

112-
// Create a system tray icon
113-
SystemTrayIcon = new SystemTrayIcon().Show();
133+
// Create a system tray icon
134+
SystemTrayIcon = new SystemTrayIcon().Show();
114135

115-
_ = AppLifecycleHelper.InitializeAppComponentsAsync();
116-
_ = MainWindow.Instance.InitializeApplicationAsync(appActivationArguments.Data);
136+
_ = MainWindow.Instance.InitializeApplicationAsync(appActivationArguments.Data);
137+
}
138+
139+
await AppLifecycleHelper.InitializeAppComponentsAsync();
140+
141+
if (isStartupTask && isLeaveAppRunning)
142+
{
143+
// Create a system tray icon when initialization is done
144+
SystemTrayIcon = new SystemTrayIcon().Show();
145+
App.Current.Exit();
146+
}
147+
else
148+
await AppLifecycleHelper.CheckAppUpdate();
117149
}
118150
}
119151

@@ -122,11 +154,12 @@ async Task ActivateAsync()
122154
/// </summary>
123155
public async Task OnActivatedAsync(AppActivationArguments activatedEventArgs)
124156
{
125-
Logger.LogInformation($"The app is being activated. Activation type: {activatedEventArgs.Data.GetType().Name}");
157+
var activatedEventArgsData = activatedEventArgs.Data;
158+
Logger.LogInformation($"The app is being activated. Activation type: {activatedEventArgsData.GetType().Name}");
126159

127160
// InitializeApplication accesses UI, needs to be called on UI thread
128161
await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(()
129-
=> MainWindow.Instance.InitializeApplicationAsync(activatedEventArgs.Data));
162+
=> MainWindow.Instance.InitializeApplicationAsync(activatedEventArgsData));
130163
}
131164

132165
/// <summary>

src/Files.App/Data/Commands/CommandCodes.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,13 @@ public enum CommandCodes
151151
GroupByFolderPath,
152152
GroupByDateModifiedYear,
153153
GroupByDateModifiedMonth,
154+
GroupByDateModifiedDay,
154155
GroupByDateCreatedYear,
155156
GroupByDateCreatedMonth,
157+
GroupByDateCreatedDay,
156158
GroupByDateDeletedYear,
157159
GroupByDateDeletedMonth,
160+
GroupByDateDeletedDay,
158161
GroupAscending,
159162
GroupDescending,
160163
ToggleGroupDirection,

src/Files.App/Data/Commands/Manager/CommandManager.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,13 @@ public IRichCommand this[HotKey hotKey]
147147
public IRichCommand GroupByFolderPath => commands[CommandCodes.GroupByFolderPath];
148148
public IRichCommand GroupByDateModifiedYear => commands[CommandCodes.GroupByDateModifiedYear];
149149
public IRichCommand GroupByDateModifiedMonth => commands[CommandCodes.GroupByDateModifiedMonth];
150+
public IRichCommand GroupByDateModifiedDay => commands[CommandCodes.GroupByDateModifiedDay];
150151
public IRichCommand GroupByDateCreatedYear => commands[CommandCodes.GroupByDateCreatedYear];
151152
public IRichCommand GroupByDateCreatedMonth => commands[CommandCodes.GroupByDateCreatedMonth];
153+
public IRichCommand GroupByDateCreatedDay => commands[CommandCodes.GroupByDateCreatedDay];
152154
public IRichCommand GroupByDateDeletedYear => commands[CommandCodes.GroupByDateDeletedYear];
153155
public IRichCommand GroupByDateDeletedMonth => commands[CommandCodes.GroupByDateDeletedMonth];
156+
public IRichCommand GroupByDateDeletedDay => commands[CommandCodes.GroupByDateDeletedDay];
154157
public IRichCommand GroupAscending => commands[CommandCodes.GroupAscending];
155158
public IRichCommand GroupDescending => commands[CommandCodes.GroupDescending];
156159
public IRichCommand ToggleGroupDirection => commands[CommandCodes.ToggleGroupDirection];
@@ -314,10 +317,13 @@ public CommandManager()
314317
[CommandCodes.GroupByFolderPath] = new GroupByFolderPathAction(),
315318
[CommandCodes.GroupByDateModifiedYear] = new GroupByDateModifiedYearAction(),
316319
[CommandCodes.GroupByDateModifiedMonth] = new GroupByDateModifiedMonthAction(),
320+
[CommandCodes.GroupByDateModifiedDay] = new GroupByDateModifiedDayAction(),
317321
[CommandCodes.GroupByDateCreatedYear] = new GroupByDateCreatedYearAction(),
318322
[CommandCodes.GroupByDateCreatedMonth] = new GroupByDateCreatedMonthAction(),
323+
[CommandCodes.GroupByDateCreatedDay] = new GroupByDateCreatedDayAction(),
319324
[CommandCodes.GroupByDateDeletedYear] = new GroupByDateDeletedYearAction(),
320325
[CommandCodes.GroupByDateDeletedMonth] = new GroupByDateDeletedMonthAction(),
326+
[CommandCodes.GroupByDateDeletedDay] = new GroupByDateDeletedDayAction(),
321327
[CommandCodes.GroupAscending] = new GroupAscendingAction(),
322328
[CommandCodes.GroupDescending] = new GroupDescendingAction(),
323329
[CommandCodes.ToggleGroupDirection] = new ToggleGroupDirectionAction(),

src/Files.App/Data/Commands/Manager/ICommandManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ public interface ICommandManager : IEnumerable<IRichCommand>
135135
IRichCommand GroupByFolderPath { get; }
136136
IRichCommand GroupByDateModifiedYear { get; }
137137
IRichCommand GroupByDateModifiedMonth { get; }
138+
IRichCommand GroupByDateModifiedDay { get; }
138139
IRichCommand GroupByDateCreatedYear { get; }
139140
IRichCommand GroupByDateCreatedMonth { get; }
141+
IRichCommand GroupByDateCreatedDay { get; }
140142
IRichCommand GroupByDateDeletedYear { get; }
141143
IRichCommand GroupByDateDeletedMonth { get; }
144+
IRichCommand GroupByDateDeletedDay { get; }
142145
IRichCommand GroupAscending { get; }
143146
IRichCommand GroupDescending { get; }
144147
IRichCommand ToggleGroupDirection { get; }

src/Files.App/Data/Factories/SecurityAdvancedAccessControlItemFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static ObservableCollection<AccessMaskItem> Initialize(AccessControlEntry
166166
new(current)
167167
{
168168
AccessMask = AccessMaskFlags.Modify,
169-
AccessMaskName = "SecurityModifyLabel/Text".GetLocalizedResource(),
169+
AccessMaskName = "Modify".GetLocalizedResource(),
170170
IsEditable = !isInherited
171171
},
172172
new(current)

src/Files.App/Helpers/Application/AppLifecycleHelper.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ await Task.WhenAll(
5252

5353
FileTagsHelper.UpdateTagsDb();
5454

55-
await CheckAppUpdate();
56-
5755
static Task OptionalTaskAsync(Task task, bool condition)
5856
{
5957
if (condition)

src/Files.App/Helpers/MenuFlyout/ContextFlyoutItemHelper.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
245245
{
246246
IsToggle = true
247247
}.Build(),
248+
new ContextMenuFlyoutItemViewModelBuilder(commands.GroupByDateModifiedDay)
249+
{
250+
IsToggle = true
251+
}.Build(),
248252
},
249253
},
250254
new ContextMenuFlyoutItemViewModel()
@@ -264,6 +268,10 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
264268
{
265269
IsToggle = true
266270
}.Build(),
271+
new ContextMenuFlyoutItemViewModelBuilder(commands.GroupByDateCreatedDay)
272+
{
273+
IsToggle = true
274+
}.Build(),
267275
},
268276
},
269277
new ContextMenuFlyoutItemViewModelBuilder(commands.GroupByType)
@@ -301,6 +309,10 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
301309
{
302310
IsToggle = true
303311
}.Build(),
312+
new ContextMenuFlyoutItemViewModelBuilder(commands.GroupByDateDeletedDay)
313+
{
314+
IsToggle = true
315+
}.Build(),
304316
},
305317
},
306318
new ContextMenuFlyoutItemViewModelBuilder(commands.GroupByFolderPath)
@@ -503,7 +515,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
503515
new ContextMenuFlyoutItemViewModelBuilder(commands.CompressIntoZip).Build(),
504516
new ContextMenuFlyoutItemViewModelBuilder(commands.CompressIntoSevenZip).Build(),
505517
},
506-
ShowItem = itemsSelected && CompressHelper.CanCompress(selectedItems)
518+
ShowItem = userSettingsService.GeneralSettingsService.ShowCompressionOptions && itemsSelected && CompressHelper.CanCompress(selectedItems)
507519
},
508520
new ContextMenuFlyoutItemViewModel
509521
{
@@ -520,7 +532,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseItemMenuItems(
520532
new ContextMenuFlyoutItemViewModelBuilder(commands.DecompressArchiveHere).Build(),
521533
new ContextMenuFlyoutItemViewModelBuilder(commands.DecompressArchiveToChildFolder).Build(),
522534
},
523-
ShowItem = CompressHelper.CanDecompress(selectedItems)
535+
ShowItem = userSettingsService.GeneralSettingsService.ShowCompressionOptions && CompressHelper.CanDecompress(selectedItems)
524536
},
525537
new ContextMenuFlyoutItemViewModel()
526538
{

src/Files.App/Services/DateTimeFormatter/AbstractDateTimeFormatter.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,34 @@ public ITimeSpanLabel ToTimeSpanLabel(DateTimeOffset offset, GroupByDateUnit uni
2828
return 0 switch
2929
{
3030
_ when now.Date < time.Date
31-
=> new Label("Future".GetLocalizedResource(), "\uED28", 1000006),
31+
=> new Label("Future".GetLocalizedResource(), "\uED28", 1000000006),
3232
_ when now.Date == time.Date
33-
=> new Label("Today".GetLocalizedResource(), "\uE8D1", 1000005),
33+
=> new Label("Today".GetLocalizedResource(), "\uE8D1", 1000000005),
3434
_ when now.AddDays(-1).Date == time.Date
35-
=> new Label("Yesterday".GetLocalizedResource(), "\uE8BF", 1000004),
35+
=> new Label("Yesterday".GetLocalizedResource(), "\uE8BF", 1000000004),
36+
37+
// Group by day
38+
_ when unit == GroupByDateUnit.Day
39+
=> new Label(ToString(time, "D"), "\uE8BF", time.Year * 10000 + time.Month * 100 + time.Day),
40+
3641
_ when diff.Days <= 7 && GetWeekOfYear(now) == GetWeekOfYear(time)
37-
=> new Label("EarlierThisWeek".GetLocalizedResource(), "\uE8C0", 1000003),
42+
=> new Label("EarlierThisWeek".GetLocalizedResource(), "\uE8C0", 1000000003),
3843
_ when diff.Days <= 14 && GetWeekOfYear(now.AddDays(-7)) == GetWeekOfYear(time)
39-
=> new Label("LastWeek".GetLocalizedResource(), "\uE8C0", 1000002),
44+
=> new Label("LastWeek".GetLocalizedResource(), "\uE8C0", 1000000002),
4045
_ when now.Year == time.Year && now.Month == time.Month
41-
=> new Label("EarlierThisMonth".GetLocalizedResource(), "\uE787", 1000001),
46+
=> new Label("EarlierThisMonth".GetLocalizedResource(), "\uE787", 1000000001),
4247
_ when now.AddMonths(-1).Year == time.Year && now.AddMonths(-1).Month == time.Month
43-
=> new Label("LastMonth".GetLocalizedResource(), "\uE787", 1000000),
48+
=> new Label("LastMonth".GetLocalizedResource(), "\uE787", 1000000000),
4449

4550
// Group by month
4651
_ when unit == GroupByDateUnit.Month
47-
=> new Label(ToString(time, "Y"), "\uE787", time.Year * 100 + time.Month),
52+
=> new Label(ToString(time, "Y"), "\uE787", time.Year * 10000 + time.Month * 100),
4853

4954
// Group by year
5055
_ when now.Year == time.Year
51-
=> new Label("EarlierThisYear".GetLocalizedResource(), "\uEC92", 10001),
56+
=> new Label("EarlierThisYear".GetLocalizedResource(), "\uEC92", 10000001),
5257
_ when now.AddYears(-1).Year == time.Year
53-
=> new Label("LastYear".GetLocalizedResource(), "\uEC92", 10000),
58+
=> new Label("LastYear".GetLocalizedResource(), "\uEC92", 10000000),
5459
_
5560
=> new Label(string.Format("YearN".GetLocalizedResource(), time.Year), "\uEC92", time.Year),
5661
};

0 commit comments

Comments
 (0)