Skip to content

Commit dd05522

Browse files
authored
Show OneDrive sync status (#1356)
1 parent fb27f40 commit dd05522

28 files changed

+423
-170
lines changed

Files.Launcher/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private static void UnhandledExceptionTrapper(object sender, UnhandledExceptionE
102102

103103
private static async void Watcher_Changed(object sender, FileSystemEventArgs e)
104104
{
105-
Debug.WriteLine($"Reycle bin event: {e.ChangeType}, {e.FullPath}");
105+
Debug.WriteLine($"Recycle bin event: {e.ChangeType}, {e.FullPath}");
106106
if (connection != null)
107107
{
108108
// Send message to UWP app to refresh items

Files/App.xaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@
99
<ResourceDictionary>
1010
<ResourceDictionary.ThemeDictionaries>
1111
<ResourceDictionary x:Key="Light">
12+
<SolidColorBrush x:Key="CloudDriveSyncStatusOnlineColor" Color="#0078D7" />
13+
<SolidColorBrush x:Key="CloudDriveSyncStatusOfflineColor" Color="#30BB03" />
14+
<SolidColorBrush x:Key="CloudDriveSyncStatusExcludedColor" Color="#AAAAAA" />
1215
<SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#99000000" />
1316
</ResourceDictionary>
1417
<ResourceDictionary x:Key="Dark">
18+
<SolidColorBrush x:Key="CloudDriveSyncStatusOnlineColor" Color="#0078D7" />
19+
<SolidColorBrush x:Key="CloudDriveSyncStatusOfflineColor" Color="#30BB03" />
20+
<SolidColorBrush x:Key="CloudDriveSyncStatusExcludedColor" Color="#AAAAAA" />
1521
<SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="#191919" />
1622
<SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#99000000" />
1723
</ResourceDictionary>
1824
<ResourceDictionary x:Key="HighContrast">
25+
<SolidColorBrush x:Key="CloudDriveSyncStatusOnlineColor" Color="#0078D7" />
26+
<SolidColorBrush x:Key="CloudDriveSyncStatusOfflineColor" Color="#30BB03" />
27+
<SolidColorBrush x:Key="CloudDriveSyncStatusExcludedColor" Color="#AAAAAA" />
1928
<SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="#191919" />
2029
<SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#99000000" />
2130
</ResourceDictionary>

Files/BaseLayout.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public abstract class BaseLayout : Page, INotifyPropertyChanged
2828
{
2929
public SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; }
3030
public SettingsViewModel AppSettings => App.AppSettings;
31+
public CurrentInstanceViewModel InstanceViewModel => App.CurrentInstance.InstanceViewModel;
3132
public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }
3233
public bool IsQuickLookEnabled { get; set; } = false;
3334
public MenuFlyout BaseLayoutItemContextFlyout { get; set; }

Files/Files.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
<Compile Include="Dialogs\ConfirmDeleteDialog.xaml.cs">
167167
<DependentUpon>ConfirmDeleteDialog.xaml</DependentUpon>
168168
</Compile>
169+
<Compile Include="Filesystem\CloudDriveSyncStatus.cs" />
169170
<Compile Include="Filesystem\StorageFileHelpers\StorageFileExtensions.cs" />
170171
<Compile Include="Filesystem\StorageFileHelpers\IStorageItemWithPath.cs" />
171172
<Compile Include="Filesystem\StorageFileHelpers\StorageFileWithPath.cs" />
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
using GalaSoft.MvvmLight;
2+
using Windows.UI.Xaml.Media;
3+
4+
namespace Files.Filesystem
5+
{
6+
public enum CloudDriveSyncStatus
7+
{
8+
Unknown = -1,
9+
Folder_Online = 0,
10+
Folder_Offline_Partial = 1,
11+
Folder_Offline_Full = 2,
12+
Folder_Offline_Pinned = 3,
13+
Folder_Excluded = 4,
14+
Folder_Empty = 5,
15+
NotSynced = 6,
16+
File_Online = 8,
17+
File_Sync = 9,
18+
File_Offline = 14,
19+
File_Offline_Pinned = 15,
20+
}
21+
22+
public class CloudDriveSyncStatusUI : ObservableObject
23+
{
24+
private bool _LoadSyncStatus;
25+
public bool LoadSyncStatus { get => _LoadSyncStatus; set => Set(ref _LoadSyncStatus, value); }
26+
private string _Glyph;
27+
public string Glyph { get => _Glyph; set => Set(ref _Glyph, value); }
28+
private SolidColorBrush _Foreground;
29+
public SolidColorBrush Foreground { get => _Foreground; set => Set(ref _Foreground, value); }
30+
31+
public static CloudDriveSyncStatusUI FromCloudDriveSyncStatus(CloudDriveSyncStatus syncStatus)
32+
{
33+
var statusUI = new CloudDriveSyncStatusUI();
34+
35+
switch (syncStatus)
36+
{
37+
// File
38+
case CloudDriveSyncStatus.File_Online:
39+
statusUI.LoadSyncStatus = true;
40+
statusUI.Glyph = "\uE753";
41+
statusUI.Foreground = (SolidColorBrush)App.Current.Resources["CloudDriveSyncStatusOnlineColor"];
42+
break;
43+
case CloudDriveSyncStatus.File_Offline:
44+
case CloudDriveSyncStatus.File_Offline_Pinned:
45+
statusUI.LoadSyncStatus = true;
46+
statusUI.Glyph = "\uE73E";
47+
statusUI.Foreground = (SolidColorBrush)App.Current.Resources["CloudDriveSyncStatusOfflineColor"];
48+
break;
49+
case CloudDriveSyncStatus.File_Sync:
50+
statusUI.LoadSyncStatus = true;
51+
statusUI.Glyph = "\uE895";
52+
statusUI.Foreground = (SolidColorBrush)App.Current.Resources["CloudDriveSyncStatusOnlineColor"];
53+
break;
54+
55+
// Folder
56+
case CloudDriveSyncStatus.Folder_Online:
57+
case CloudDriveSyncStatus.Folder_Offline_Partial:
58+
statusUI.LoadSyncStatus = true;
59+
statusUI.Glyph = "\uE753";
60+
statusUI.Foreground = (SolidColorBrush)App.Current.Resources["CloudDriveSyncStatusOnlineColor"];
61+
break;
62+
case CloudDriveSyncStatus.Folder_Offline_Full:
63+
case CloudDriveSyncStatus.Folder_Offline_Pinned:
64+
case CloudDriveSyncStatus.Folder_Empty:
65+
statusUI.LoadSyncStatus = true;
66+
statusUI.Glyph = "\uE73E";
67+
statusUI.Foreground = (SolidColorBrush)App.Current.Resources["CloudDriveSyncStatusOfflineColor"];
68+
break;
69+
case CloudDriveSyncStatus.Folder_Excluded:
70+
statusUI.LoadSyncStatus = true;
71+
statusUI.Glyph = "\uF140";
72+
statusUI.Foreground = (SolidColorBrush)App.Current.Resources["CloudDriveSyncStatusExcludedColor"];
73+
break;
74+
75+
// Unknown
76+
case CloudDriveSyncStatus.NotSynced:
77+
case CloudDriveSyncStatus.Unknown:
78+
default:
79+
statusUI.LoadSyncStatus = false;
80+
break;
81+
}
82+
83+
return statusUI;
84+
}
85+
}
86+
}

Files/Filesystem/ListedItem.cs

Lines changed: 22 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Files.Enums;
2+
using GalaSoft.MvvmLight;
23
using System;
3-
using System.ComponentModel;
44
using Windows.Storage;
55
using Windows.UI.Xaml.Media.Imaging;
66

77
namespace Files.Filesystem
88
{
9-
public class ListedItem : INotifyPropertyChanged
9+
public class ListedItem : ObservableObject
1010
{
1111
public StorageItemTypes PrimaryItemAttribute { get; set; }
1212
public bool ItemPropertiesInitialized { get; set; } = false;
@@ -17,52 +17,36 @@ public class ListedItem : INotifyPropertyChanged
1717

1818
public bool LoadFileIcon
1919
{
20-
get
21-
{
22-
return _LoadFileIcon;
23-
}
24-
set
25-
{
26-
if (_LoadFileIcon != value)
27-
{
28-
_LoadFileIcon = value;
29-
NotifyPropertyChanged("LoadFileIcon");
30-
}
31-
}
20+
get => _LoadFileIcon;
21+
set => Set(ref _LoadFileIcon, value);
3222
}
3323

3424
private bool _LoadUnknownTypeGlyph;
3525

3626
public bool LoadUnknownTypeGlyph
3727
{
38-
get
39-
{
40-
return _LoadUnknownTypeGlyph;
41-
}
42-
set
43-
{
44-
if (_LoadUnknownTypeGlyph != value)
45-
{
46-
_LoadUnknownTypeGlyph = value;
47-
NotifyPropertyChanged("LoadUnknownTypeGlyph");
48-
}
49-
}
28+
get => _LoadUnknownTypeGlyph;
29+
set => Set(ref _LoadUnknownTypeGlyph, value);
30+
}
31+
32+
private CloudDriveSyncStatusUI _SyncStatusUI;
33+
34+
public CloudDriveSyncStatusUI SyncStatusUI
35+
{
36+
get => _SyncStatusUI;
37+
set => Set(ref _SyncStatusUI, value);
5038
}
5139

5240
private BitmapImage _FileImage;
5341

5442
public BitmapImage FileImage
5543
{
56-
get
57-
{
58-
return _FileImage;
59-
}
44+
get => _FileImage;
6045
set
6146
{
62-
if (_FileImage != value && value != null)
47+
if (value != null)
6348
{
64-
_FileImage = value;
65-
NotifyPropertyChanged("FileImage");
49+
Set(ref _FileImage, value);
6650
}
6751
}
6852
}
@@ -73,16 +57,12 @@ public BitmapImage FileImage
7357

7458
public string ItemType
7559
{
76-
get
77-
{
78-
return _ItemType;
79-
}
60+
get => _ItemType;
8061
set
8162
{
82-
if (_ItemType != value && value != null)
63+
if (value != null)
8364
{
84-
_ItemType = value;
85-
NotifyPropertyChanged("ItemType");
65+
Set(ref _ItemType, value);
8666
}
8767
}
8868
}
@@ -97,7 +77,7 @@ public string ItemType
9777

9878
public DateTimeOffset ItemDateModifiedReal
9979
{
100-
get { return _itemDateModifiedReal; }
80+
get => _itemDateModifiedReal;
10181
set
10282
{
10383
ItemDateModified = GetFriendlyDate(value);
@@ -107,21 +87,14 @@ public DateTimeOffset ItemDateModifiedReal
10787

10888
private DateTimeOffset _itemDateModifiedReal;
10989

110-
public event PropertyChangedEventHandler PropertyChanged;
111-
112-
private void NotifyPropertyChanged(string info)
113-
{
114-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info));
115-
}
116-
11790
public ListedItem(string folderRelativeId)
11891
{
11992
FolderRelativeId = folderRelativeId;
12093
}
12194

12295
public static string GetFriendlyDate(DateTimeOffset d)
12396
{
124-
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
97+
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
12598
var elapsed = DateTimeOffset.Now - d;
12699

127100
string returnformat = Enum.Parse<TimeStyle>(localSettings.Values[LocalSettings.DateTimeFormat].ToString()) == TimeStyle.Application ? "D" : "g";

Files/Helpers/NativeDirectoryChangesHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public struct OffsetPair { public uint Offset; public uint OffsetHigh; }
108108

109109
public const int FILE_NOTIFY_CHANGE_FILE_NAME = 1;
110110
public const int FILE_NOTIFY_CHANGE_DIR_NAME = 2;
111+
public const int FILE_NOTIFY_CHANGE_ATTRIBUTES = 4;
111112

112113
public unsafe struct FILE_NOTIFY_INFORMATION
113114
{

Files/MultilingualResources/Files.de-DE.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,10 @@
969969
<source>Restart required</source>
970970
<target state="new">Restart required</target>
971971
</trans-unit>
972+
<trans-unit id="syncStatusColumn.Header" translate="yes" xml:space="preserve">
973+
<source>Status</source>
974+
<target state="new">Status</target>
975+
</trans-unit>
972976
</group>
973977
</body>
974978
</file>

Files/MultilingualResources/Files.es-ES.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,10 @@
962962
<source>Restart required</source>
963963
<target state="new">Restart required</target>
964964
</trans-unit>
965+
<trans-unit id="syncStatusColumn.Header" translate="yes" xml:space="preserve">
966+
<source>Status</source>
967+
<target state="new">Status</target>
968+
</trans-unit>
965969
</group>
966970
</body>
967971
</file>

Files/MultilingualResources/Files.fr-FR.xlf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,10 @@
965965
<source>Restart required</source>
966966
<target state="new">Restart required</target>
967967
</trans-unit>
968+
<trans-unit id="syncStatusColumn.Header" translate="yes" xml:space="preserve">
969+
<source>Status</source>
970+
<target state="new">Status</target>
971+
</trans-unit>
968972
</group>
969973
</body>
970974
</file>

0 commit comments

Comments
 (0)