-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Code Quality: Sync the jump list with Explorer #17564
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
base: main
Are you sure you want to change the base?
Changes from all commits
a3e662e
cda9bb6
bb62597
53713da
ea72a8e
cced46b
3674293
49bfc78
1a07680
1bddc4b
1e64430
954b1fc
cd92aa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| // Copyright (c) Files Community | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Files.App.Storage; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Windows.ApplicationModel.Background; | ||
| using Windows.Storage; | ||
| using Windows.UI.StartScreen; | ||
|
|
||
| namespace Files.App.BackgroundTasks | ||
| { | ||
|
|
@@ -19,8 +17,8 @@ private async Task RunAsync(IBackgroundTaskInstance taskInstance) | |
| { | ||
| var deferral = taskInstance.GetDeferral(); | ||
|
|
||
| // Refresh jump list to update string resources | ||
| try { await RefreshJumpListAsync(); } catch { } | ||
| // Sync the jump list with Explorer | ||
| try { RefreshJumpList(); } catch { } | ||
|
|
||
| // Delete previous version log files | ||
| try { DeleteLogFiles(); } catch { } | ||
|
|
@@ -34,30 +32,18 @@ private void DeleteLogFiles() | |
| File.Delete(Path.Combine(ApplicationData.Current.LocalFolder.Path, "debug_fulltrust.log")); | ||
| } | ||
|
|
||
| private async Task RefreshJumpListAsync() | ||
| private void RefreshJumpList() | ||
| { | ||
| if (JumpList.IsSupported()) | ||
| { | ||
| var instance = await JumpList.LoadCurrentAsync(); | ||
| // Disable automatic jumplist. It doesn't work with Files UWP. | ||
| instance.SystemGroupKind = JumpListSystemGroupKind.None; | ||
|
|
||
| var jumpListItems = instance.Items.ToList(); | ||
|
|
||
| // Clear all items to avoid localization issues | ||
| instance.Items.Clear(); | ||
|
|
||
| foreach (var temp in jumpListItems) | ||
| { | ||
| var jumplistItem = JumpListItem.CreateWithArguments(temp.Arguments, temp.DisplayName); | ||
| jumplistItem.Description = jumplistItem.Arguments; | ||
| jumplistItem.GroupName = "ms-resource:///Resources/JumpListRecentGroupHeader"; | ||
| jumplistItem.Logo = new Uri("ms-appx:///Assets/FolderIcon.png"); | ||
| instance.Items.Add(jumplistItem); | ||
| } | ||
|
|
||
| await instance.SaveAsync(); | ||
| } | ||
| // Make sure to delete the Files' custom destinations binary files | ||
| var recentFolder = WindowsStorableHelpers.GetRecentFolderPath(); | ||
| File.Delete($"{recentFolder}\\CustomDestinations\\3b19d860a346d7da.customDestinations-ms"); | ||
| File.Delete($"{recentFolder}\\CustomDestinations\\1265066178db259d.customDestinations-ms"); | ||
| File.Delete($"{recentFolder}\\CustomDestinations\\8e2322986488aba5.customDestinations-ms"); | ||
| File.Delete($"{recentFolder}\\CustomDestinations\\6b0bf5ca007c8bea.customDestinations-ms"); | ||
| File.Delete($"{recentFolder}\\AutomaticDestinations\\3b19d860a346d7da.automaticDestinations-ms"); | ||
| File.Delete($"{recentFolder}\\AutomaticDestinations\\1265066178db259d.automaticDestinations-ms"); | ||
| File.Delete($"{recentFolder}\\AutomaticDestinations\\8e2322986488aba5.automaticDestinations-ms"); | ||
| File.Delete($"{recentFolder}\\AutomaticDestinations\\6b0bf5ca007c8bea.automaticDestinations-ms"); | ||
|
Comment on lines
+35
to
+46
|
||
| } | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // Copyright (c) Files Community | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace Windows.Win32 | ||
| { | ||
| /// <summary> | ||
| /// Contains a heap pointer allocated via <see cref="NativeMemory.Alloc"/> and a set of methods to work with the pointer safely. | ||
| /// </summary> | ||
| public unsafe struct HeapPtr<T> : IDisposable where T : unmanaged | ||
| { | ||
| private T* _ptr; | ||
|
|
||
| public readonly bool IsNull | ||
| { | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| get => _ptr is null; | ||
| } | ||
|
|
||
| public HeapPtr(T* ptr) | ||
| { | ||
| _ptr = ptr; | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public readonly T* Get() | ||
| { | ||
| return _ptr; | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public readonly T** GetAddressOf() | ||
| { | ||
| return (T**)Unsafe.AsPointer(ref Unsafe.AsRef(in this)); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public void Attach(T* ptr) | ||
| { | ||
| Dispose(); | ||
| _ptr = ptr; | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public T* Detach() | ||
| { | ||
| T* ptr = _ptr; | ||
| _ptr = null; | ||
| return ptr; | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public bool Allocate(nuint cch) | ||
| { | ||
| _ptr = (T*)NativeMemory.Alloc(cch * (nuint)sizeof(T)); // malloc() | ||
| return _ptr is not null; | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public bool Reallocate(nuint cch) | ||
| { | ||
| T* ptr = (T*)NativeMemory.Realloc(_ptr, cch * (nuint)sizeof(T)); // realloc() | ||
| if (ptr is null) return false; | ||
| _ptr = ptr; | ||
| return true; | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| public void Dispose() | ||
| { | ||
| T* ptr = _ptr; | ||
| if (ptr is null) return; | ||
| _ptr = null; | ||
| NativeMemory.Free(ptr); // free() | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.