-
Notifications
You must be signed in to change notification settings - Fork 704
Refactor Application Settings with AppConfig and JSON Storage Support for Packaged/Unpackaged Apps #1924 #2001
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4480a5b
Refactor settings to use AppConfig and JSON storage #1924
ghost1372 605e6ce
Update SettingsHelper.cs
ghost1372 614b57d
Move SettingsHelper.cs to SettingsHelper/SettingsHelper.cs
ghost1372 1552ad7
Mark AppConfg class as partial
ghost1372 e2fbd4d
Merge branch 'main' into Settings
niels9001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| using Microsoft.UI.Xaml; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
|
|
||
| namespace WinUIGallery.Helpers; | ||
|
|
||
| public partial class AppConfig | ||
| { | ||
| internal static readonly string RootDirectoryPath = Path.Combine(GetAppDataFolderPath(), ProcessInfoHelper.ProductNameAndVersion); | ||
| internal static readonly string AppConfigPath = Path.Combine(RootDirectoryPath, "AppConfig.json"); | ||
| private static string GetAppDataFolderPath() | ||
| { | ||
| // This can be replaced with Microsoft.Windows.Storage.ApplicationData.GetForUnPackaged(), once it is available in the WASDK. | ||
| var unpackaged = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); | ||
| return NativeMethods.IsAppPackaged ? Microsoft.Windows.Storage.ApplicationData.GetDefault().LocalFolder.Path : unpackaged; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the currently selected application theme. | ||
| /// </summary> | ||
| public ElementTheme SelectedAppTheme { get; set; } = ElementTheme.Default; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value indicating whether the navigation is in left mode. | ||
| /// </summary> | ||
| public bool IsLeftMode { get; set; } = true; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a value indicating whether the teaching tip for copying links is shown. | ||
| /// </summary> | ||
| public bool IsShowCopyLinkTeachingTip { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the list of favorite items. | ||
| /// </summary> | ||
| public List<string> Favorites { get; set; } = new(); | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the list of recently visited items. | ||
| /// </summary> | ||
| public List<string> RecentlyVisited { get; set; } = new(); | ||
|
|
||
| /// <summary> | ||
| /// Represents the maximum number of recently visited samples to retain. | ||
| /// </summary> | ||
| public int MaxRecentlyVisitedSamples { get; set; } = 7; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the maximum number of favorite samples allowed. | ||
| /// </summary> | ||
| public int MaxFavoriteSamples { get; set; } = 0; | ||
|
Comment on lines
+49
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no maximum for the favorite samples. The old logic assumed that if the maximum was set to |
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace WinUIGallery.Helpers; | ||
|
|
||
| [JsonSourceGenerationOptions(WriteIndented = true)] | ||
| [JsonSerializable(typeof(AppConfig))] | ||
| internal partial class AppConfigJsonContext : JsonSerializerContext | ||
| { | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to be a constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zakariathr22
If we decide to exclude the
maxproperties from the JSON file, we should move those properties out ofAppConfig.csand into theSettingsHelper.csclass.so this suggestion can not be commited here.