Skip to content

Commit 6eaa0a5

Browse files
yaira2hez2010tsvietOK
authored
v0.8.0 (#742)
Co-authored-by: Steve <[email protected]> Co-authored-by: Vladyslav <[email protected]>
1 parent 5322f37 commit 6eaa0a5

13 files changed

+136
-113
lines changed

Files.Package/Package.appxmanifest

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop4="http://schemas.microsoft.com/appx/manifest/desktop/windows10/4" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5" IgnorableNamespaces="uap uap5 mp rescap desktop4 desktop">
3-
<Identity Name="FilesUWPDev" Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" Version="0.7.9.0" />
3+
<Identity Name="FilesUWPDev" Publisher="CN=53EC4384-7F5B-4CF6-8C23-513FFE9D1AB7" Version="0.8.0.0" />
44
<Properties>
55
<DisplayName>Files UWP - Dev</DisplayName>
66
<PublisherDisplayName>Yair A</PublisherDisplayName>
@@ -54,4 +54,4 @@
5454
<uap:Capability Name="removableStorage" />
5555
<Capability Name="internetClient"/>
5656
</Capabilities>
57-
</Package>
57+
</Package>

Files/Files.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -149,7 +149,8 @@
149149
<Compile Include="Dialogs\ConfirmDeleteDialog.xaml.cs">
150150
<DependentUpon>ConfirmDeleteDialog.xaml</DependentUpon>
151151
</Compile>
152-
<Compile Include="Helpers\AppTheme.cs" />
152+
<Compile Include="Helpers\AcrylicTheme.cs" />
153+
<Compile Include="Helpers\DispatcherHelper.cs" />
153154
<Compile Include="Helpers\ItemsDataTemplateSelector.cs" />
154155
<Compile Include="Helpers\NaturalStringComparer.cs" />
155156
<Compile Include="Helpers\StringExtensions.cs" />

Files/Helpers/AppTheme.cs renamed to Files/Helpers/AcrylicTheme.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,12 @@
55

66
namespace Files.Helpers
77
{
8-
public class AppTheme : INotifyPropertyChanged
8+
public class AcrylicTheme : INotifyPropertyChanged
99
{
10-
private double? _TintLuminosityOpacity;
1110
private Color _FallbackColor;
1211
private Color _TintColor;
1312
private double _TintOpacity;
1413

15-
public double? TintLuminosityOpacity
16-
{
17-
get { return _TintLuminosityOpacity; }
18-
set
19-
{
20-
_TintLuminosityOpacity = value;
21-
NotifyPropertyChanged("TintLuminosityOpacity");
22-
}
23-
}
24-
2514
public Color FallbackColor
2615
{
2716
get { return _FallbackColor; }
@@ -59,29 +48,26 @@ private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
5948
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
6049
}
6150

62-
public AppTheme()
51+
public AcrylicTheme()
6352
{
6453
}
6554

6655
public void SetDefaultTheme()
6756
{
68-
TintLuminosityOpacity = 0.9;
6957
FallbackColor = (Color)Application.Current.Resources["SystemChromeMediumLowColor"];
7058
TintColor = (Color)Application.Current.Resources["SystemAltHighColor"];
7159
TintOpacity = 0.9;
7260
}
7361

7462
public void SetLightTheme()
7563
{
76-
TintLuminosityOpacity = 0.9;
7764
FallbackColor = Color.FromArgb(255, 242, 242, 242);
7865
TintColor = Colors.White;
7966
TintOpacity = 0.9;
8067
}
8168

8269
public void SetDarkTheme()
8370
{
84-
TintLuminosityOpacity = 0.9;
8571
FallbackColor = Color.FromArgb(255, 43, 43, 43);
8672
TintColor = Colors.Black;
8773
TintOpacity = 0.7;

Files/Helpers/DispatcherHelper.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System;
2+
using System.Runtime.CompilerServices;
3+
using Windows.UI.Core;
4+
5+
namespace Files.Helpers
6+
{
7+
/// <summary>
8+
/// This class provides static methods helper for executing code in UI thread of the main window.
9+
/// </summary>
10+
static class DispatcherHelper
11+
{ /// <summary>
12+
/// This struct represents an awaitable dispatcher.
13+
/// </summary>
14+
public struct DispatcherPriorityAwaitable
15+
{
16+
private readonly CoreDispatcher dispatcher;
17+
private readonly CoreDispatcherPriority priority;
18+
19+
internal DispatcherPriorityAwaitable(CoreDispatcher dispatcher, CoreDispatcherPriority priority)
20+
{
21+
this.dispatcher = dispatcher;
22+
this.priority = priority;
23+
}
24+
25+
/// <summary>
26+
/// Get awaiter of DispatcherPriorityAwaiter
27+
/// </summary>
28+
/// <returns>Awaiter of DispatcherPriorityAwaiter</returns>
29+
public DispatcherPriorityAwaiter GetAwaiter()
30+
{
31+
return new DispatcherPriorityAwaiter(this.dispatcher, this.priority);
32+
}
33+
}
34+
35+
/// <summary>
36+
/// This struct represents the awaiter of a dispatcher.
37+
/// </summary>
38+
public struct DispatcherPriorityAwaiter : INotifyCompletion
39+
{
40+
private readonly CoreDispatcher dispatcher;
41+
private readonly CoreDispatcherPriority priority;
42+
43+
/// <summary>
44+
/// Gets a value indicating whether task has completed
45+
/// </summary>
46+
public bool IsCompleted => false;
47+
48+
internal DispatcherPriorityAwaiter(CoreDispatcher dispatcher, CoreDispatcherPriority priority)
49+
{
50+
this.dispatcher = dispatcher;
51+
this.priority = priority;
52+
}
53+
54+
/// <summary>
55+
/// Get result for this awaiter
56+
/// </summary>
57+
public void GetResult()
58+
{
59+
}
60+
61+
/// <summary>
62+
/// Fired once task has complated for notify completion
63+
/// </summary>
64+
/// <param name="continuation">Continuation action</param>
65+
public async void OnCompleted(Action continuation)
66+
{
67+
await this.dispatcher.RunAsync(this.priority, new DispatchedHandler(continuation));
68+
}
69+
}
70+
71+
/// <summary>
72+
/// Yield and allow UI update during tasks.
73+
/// </summary>
74+
/// <param name="dispatcher">Dispatcher of a thread to yield</param>
75+
/// <param name="priority">Dispatcher execution priority, default is low</param>
76+
/// <returns>Awaitable dispatcher task</returns>
77+
public static DispatcherPriorityAwaitable YieldAsync(this CoreDispatcher dispatcher, CoreDispatcherPriority priority = CoreDispatcherPriority.Low)
78+
{
79+
return new DispatcherPriorityAwaitable(dispatcher, priority);
80+
}
81+
}
82+
}

Files/Helpers/ThemeHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static ElementTheme RootTheme
6767

6868
public static void Initialize()
6969
{
70-
App.AppSettings.AppTheme = new AppTheme();
70+
App.AppSettings.AcrylicTheme = new AcrylicTheme();
7171

7272
// Set TitleBar background color
7373
_TitleBar = ApplicationView.GetForCurrentView().TitleBar;
@@ -110,19 +110,19 @@ public static void UpdateTheme()
110110
switch (RootTheme)
111111
{
112112
case ElementTheme.Default:
113-
App.AppSettings.AppTheme.SetDefaultTheme();
113+
App.AppSettings.AcrylicTheme.SetDefaultTheme();
114114
_TitleBar.ButtonHoverBackgroundColor = (Color)Application.Current.Resources["SystemBaseLowColor"];
115115
_TitleBar.ButtonForegroundColor = (Color)Application.Current.Resources["SystemBaseHighColor"];
116116
break;
117117

118118
case ElementTheme.Light:
119-
App.AppSettings.AppTheme.SetLightTheme();
119+
App.AppSettings.AcrylicTheme.SetLightTheme();
120120
_TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(51, 0, 0, 0);
121121
_TitleBar.ButtonForegroundColor = Colors.Black;
122122
break;
123123

124124
case ElementTheme.Dark:
125-
App.AppSettings.AppTheme.SetDarkTheme();
125+
App.AppSettings.AcrylicTheme.SetDarkTheme();
126126
_TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(51, 255, 255, 255);
127127
_TitleBar.ButtonForegroundColor = Colors.White;
128128
break;

Files/UserControls/ModernSidebar.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@
228228
OpenPaneLength="{TemplateBinding OpenPaneLength}">
229229
<SplitView.PaneBackground>
230230
<AcrylicBrush
231-
Windows10version1903:TintLuminosityOpacity="{x:Bind local1:App.AppSettings.AppTheme.TintLuminosityOpacity, Mode=OneWay}"
231+
Windows10version1903:TintLuminosityOpacity="0.9"
232232
BackgroundSource="HostBackdrop"
233-
FallbackColor="{x:Bind local1:App.AppSettings.AppTheme.FallbackColor, Mode=OneWay}"
234-
TintColor="{x:Bind local1:App.AppSettings.AppTheme.TintColor, Mode=OneWay}"
235-
TintOpacity="{x:Bind local1:App.AppSettings.AppTheme.TintOpacity, Mode=OneWay}"
233+
FallbackColor="{x:Bind local1:App.AppSettings.AcrylicTheme.FallbackColor, Mode=OneWay}"
234+
TintColor="{x:Bind local1:App.AppSettings.AcrylicTheme.TintColor, Mode=OneWay}"
235+
TintOpacity="{x:Bind local1:App.AppSettings.AcrylicTheme.TintOpacity, Mode=OneWay}"
236236
AlwaysUseFallback="{x:Bind local1:App.AppSettings.AcrylicEnabled, Mode=OneWay}" />
237237
</SplitView.PaneBackground>
238238
<SplitView.Pane>

Files/View Models/ItemViewModel.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
namespace Files.Filesystem
3535
{
36-
public class ItemViewModel : INotifyPropertyChanged
36+
public class ItemViewModel : INotifyPropertyChanged, IDisposable
3737
{
3838
public EmptyFolderTextState EmptyTextState { get; set; } = new EmptyFolderTextState();
3939
public LoadingIndicator LoadIndicator { get; set; } = new LoadingIndicator();
@@ -448,9 +448,16 @@ public void OrderFiles()
448448
ordered = ordered.ThenByDescending(orderByNameFunc, naturalStringComparer);
449449
}
450450
orderedList = ordered.ToList();
451-
_filesAndFolders.Clear();
452-
foreach (ListedItem i in orderedList)
453-
_filesAndFolders.Add(i);
451+
452+
List<ListedItem> originalList = _filesAndFolders.ToList();
453+
for (var i = 0; i < originalList.Count; i++)
454+
{
455+
if (originalList[i] != orderedList[i])
456+
{
457+
_filesAndFolders.RemoveAt(i);
458+
_filesAndFolders.Insert(i, orderedList[i]);
459+
}
460+
}
454461
}
455462

456463
public static T GetCurrentSelectedTabInstance<T>()
@@ -742,6 +749,15 @@ public async Task RapidAddItemsToCollectionAsync(string path)
742749
}
743750
}
744751
}
752+
if (_cancellationTokenSource.IsCancellationRequested)
753+
{
754+
break;
755+
}
756+
757+
if (count % 64 == 0)
758+
{
759+
await CoreApplication.MainView.CoreWindow.Dispatcher.YieldAsync();
760+
}
745761
} while (FindNextFile(hFile, out findData));
746762

747763
FindClose(hFile);
@@ -751,6 +767,7 @@ public async Task RapidAddItemsToCollectionAsync(string path)
751767
{
752768
if (_cancellationTokenSource.IsCancellationRequested)
753769
{
770+
_cancellationTokenSource.Dispose();
754771
_cancellationTokenSource = new CancellationTokenSource();
755772
IsLoadingItems = false;
756773
return;
@@ -1139,5 +1156,10 @@ private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
11391156
}
11401157
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
11411158
}
1159+
1160+
public void Dispose()
1161+
{
1162+
_cancellationTokenSource?.Dispose();
1163+
}
11421164
}
11431165
}

Files/View Models/SettingsViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ private async void LoadTerminalApps()
314314
// await FileIO.WriteTextAsync(file, JsonConvert.SerializeObject(terminalsFileModel, Formatting.Indented));
315315
// }
316316
//}
317-
Terminals = terminalsFileModel.Terminals;
317+
Terminals = terminalsFileModel?.Terminals ?? new List<TerminalModel>();
318318
}
319319

320320
private IList<TerminalModel> _Terminals = null;
@@ -493,7 +493,7 @@ public bool AcrylicEnabled
493493
ThemeModeChanged?.Invoke(this, EventArgs.Empty);
494494
});
495495

496-
public AppTheme AppTheme { get; set; }
496+
public AcrylicTheme AcrylicTheme { get; set; }
497497

498498
public Int32 LayoutMode
499499
{

Files/Views/InstanceTabsView.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
mc:Ignorable="d">
1313
<Page.Background>
1414
<AcrylicBrush
15-
Windows10version1903:TintLuminosityOpacity="{x:Bind local:App.AppSettings.AppTheme.TintLuminosityOpacity, Mode=OneWay}"
15+
Windows10version1903:TintLuminosityOpacity="0.9"
1616
BackgroundSource="HostBackdrop"
17-
FallbackColor="{x:Bind local:App.AppSettings.AppTheme.FallbackColor, Mode=OneWay}"
18-
TintColor="{x:Bind local:App.AppSettings.AppTheme.TintColor, Mode=OneWay}"
19-
TintOpacity="{x:Bind local:App.AppSettings.AppTheme.TintOpacity, Mode=OneWay}"
17+
FallbackColor="{x:Bind local:App.AppSettings.AcrylicTheme.FallbackColor, Mode=OneWay}"
18+
TintColor="{x:Bind local:App.AppSettings.AcrylicTheme.TintColor, Mode=OneWay}"
19+
TintOpacity="{x:Bind local:App.AppSettings.AcrylicTheme.TintOpacity, Mode=OneWay}"
2020
AlwaysUseFallback="{x:Bind local:App.AppSettings.AcrylicEnabled, Mode=OneWay}" />
2121
</Page.Background>
2222

Files/Views/Pages/Properties.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
RequestedTheme="{x:Bind local1:ThemeHelper.RootTheme}">
1515
<Page.Background>
1616
<AcrylicBrush
17-
Windows10version1903:TintLuminosityOpacity="{x:Bind local:App.AppSettings.AppTheme.TintLuminosityOpacity, Mode=OneWay}"
17+
Windows10version1903:TintLuminosityOpacity="0.9"
1818
BackgroundSource="HostBackdrop"
19-
FallbackColor="{x:Bind local:App.AppSettings.AppTheme.FallbackColor, Mode=OneWay}"
20-
TintColor="{x:Bind local:App.AppSettings.AppTheme.TintColor, Mode=OneWay}"
21-
TintOpacity="{x:Bind local:App.AppSettings.AppTheme.TintOpacity, Mode=OneWay}"
19+
FallbackColor="{x:Bind local:App.AppSettings.AcrylicTheme.FallbackColor, Mode=OneWay}"
20+
TintColor="{x:Bind local:App.AppSettings.AcrylicTheme.TintColor, Mode=OneWay}"
21+
TintOpacity="{x:Bind local:App.AppSettings.AcrylicTheme.TintOpacity, Mode=OneWay}"
2222
AlwaysUseFallback="{x:Bind local:App.AppSettings.AcrylicEnabled, Mode=OneWay}" />
2323
</Page.Background>
2424
<Grid>

0 commit comments

Comments
 (0)