From eeb38d84b3d5719adf551f5cef3b4379088a0282 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Fri, 2 Jul 2021 11:38:07 +0800 Subject: [PATCH 01/13] Fix up Actionkeyword for folder result --- Plugins/Flow.Launcher.Plugin.Explorer/Main.cs | 2 +- .../Search/ResultManager.cs | 41 +++++++++++++++---- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs index 92b7c95a0..60208759e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs @@ -46,7 +46,7 @@ namespace Flow.Launcher.Plugin.Explorer contextMenu = new ContextMenu(Context, Settings, viewModel); searchManager = new SearchManager(Settings, Context); - ResultManager.Init(Context); + ResultManager.Init(Context, Settings); return Task.CompletedTask; } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index f756f8a0a..004e57cfb 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -10,10 +10,12 @@ namespace Flow.Launcher.Plugin.Explorer.Search public static class ResultManager { private static PluginInitContext Context; + private static Settings Settings { get; set; } - public static void Init(PluginInitContext context) + public static void Init(PluginInitContext context, Settings settings) { Context = context; + Settings = settings; } internal static Result CreateFolderResult(string title, string subtitle, string path, Query query, int score = 0, bool showIndexState = false, bool windowsIndexed = false) @@ -41,15 +43,21 @@ namespace Flow.Launcher.Plugin.Explorer.Search } string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator; - Context.API.ChangeQuery(string.IsNullOrEmpty(query.ActionKeyword) ? + Context.API.ChangeQuery(Settings.PathSearchActionKeyword == "*" ? changeTo : - query.ActionKeyword + " " + changeTo); + $"{Settings.PathSearchActionKeyword} {changeTo}"); return false; }, Score = score, TitleToolTip = Constants.ToolTipOpenDirectory, SubTitleToolTip = Constants.ToolTipOpenDirectory, - ContextData = new SearchResult { Type = ResultType.Folder, FullPath = path, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed } + ContextData = new SearchResult + { + Type = ResultType.Folder, + FullPath = path, + ShowIndexState = showIndexState, + WindowsIndexed = windowsIndexed + } }; } @@ -57,7 +65,10 @@ namespace Flow.Launcher.Plugin.Explorer.Search { var retrievedDirectoryPath = FilesFolders.ReturnPreviousDirectoryIfIncompleteString(path); - var folderName = retrievedDirectoryPath.TrimEnd(Constants.DirectorySeperator).Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None).Last(); + var folderName = retrievedDirectoryPath.TrimEnd(Constants.DirectorySeperator).Split(new[] + { + Path.DirectorySeparatorChar + }, StringSplitOptions.None).Last(); if (retrievedDirectoryPath.EndsWith(":\\")) { @@ -81,7 +92,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search { Title = title, SubTitle = $"Use > to search within {subtitleFolderName}, " + - $"* to search for file extensions or >* to combine both searches.", + $"* to search for file extensions or >* to combine both searches.", IcoPath = retrievedDirectoryPath, Score = 500, Action = c => @@ -91,7 +102,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search }, TitleToolTip = retrievedDirectoryPath, SubTitleToolTip = retrievedDirectoryPath, - ContextData = new SearchResult { Type = ResultType.Folder, FullPath = retrievedDirectoryPath, ShowIndexState = true, WindowsIndexed = windowsIndexed } + ContextData = new SearchResult + { + Type = ResultType.Folder, + FullPath = retrievedDirectoryPath, + ShowIndexState = true, + WindowsIndexed = windowsIndexed + } }; } @@ -126,7 +143,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search }, TitleToolTip = Constants.ToolTipOpenContainingFolder, SubTitleToolTip = Constants.ToolTipOpenContainingFolder, - ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath, ShowIndexState = showIndexState, WindowsIndexed = windowsIndexed } + ContextData = new SearchResult + { + Type = ResultType.File, + FullPath = filePath, + ShowIndexState = showIndexState, + WindowsIndexed = windowsIndexed + } }; return result; } @@ -148,4 +171,4 @@ namespace Flow.Launcher.Plugin.Explorer.Search Folder, File } -} +} \ No newline at end of file From e8a9377ec48a6246563f3a8925fd8b1504c18188 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Fri, 2 Jul 2021 11:46:10 +0800 Subject: [PATCH 02/13] fix up logic --- .../Search/ResultManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 004e57cfb..76736466f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, Action = c => { - if (c.SpecialKeyState.CtrlPressed) + if (c.SpecialKeyState.CtrlPressed || !(Settings.EnabledPathSearchKeyword || Settings.EnableSearchActionKeyword)) { try { @@ -41,11 +41,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search return false; } } + // one of it is enabled + var keyword = Settings.EnableSearchActionKeyword ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword; + + keyword = keyword == "*" ? "" : $"{keyword} "; string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator; - Context.API.ChangeQuery(Settings.PathSearchActionKeyword == "*" ? - changeTo : - $"{Settings.PathSearchActionKeyword} {changeTo}"); + Context.API.ChangeQuery($"{keyword}{changeTo}"); return false; }, Score = score, From 192d64bb2a72d259919a0e0df4eb660d6cecf68c Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sat, 3 Jul 2021 00:20:33 +0800 Subject: [PATCH 03/13] Use Constant Name --- .../Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs | 6 +++--- .../Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs | 2 +- Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 76736466f..8af757da9 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, Action = c => { - if (c.SpecialKeyState.CtrlPressed || !(Settings.EnabledPathSearchKeyword || Settings.EnableSearchActionKeyword)) + if (c.SpecialKeyState.CtrlPressed || !(Settings.EnabledPathSearchKeyword || Settings.EnabledSearchActionKeyword)) { try { @@ -42,9 +42,9 @@ namespace Flow.Launcher.Plugin.Explorer.Search } } // one of it is enabled - var keyword = Settings.EnableSearchActionKeyword ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword; + var keyword = Settings.EnabledSearchActionKeyword ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword; - keyword = keyword == "*" ? "" : $"{keyword} "; + keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + ""; string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator; Context.API.ChangeQuery($"{keyword}{changeTo}"); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index 6f3996b0d..d98c5400a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -71,7 +71,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search return allowedActionKeyword switch { - Settings.ActionKeyword.SearchActionKeyword => settings.EnableSearchActionKeyword && + Settings.ActionKeyword.SearchActionKeyword => settings.EnabledSearchActionKeyword && keyword == settings.SearchActionKeyword, Settings.ActionKeyword.PathSearchActionKeyword => settings.EnabledPathSearchKeyword && keyword == settings.PathSearchActionKeyword, diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index bd6fe7e20..26204616a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -21,7 +21,7 @@ namespace Flow.Launcher.Plugin.Explorer public List IndexSearchExcludedSubdirectoryPaths { get; set; } = new List(); public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; - public bool EnableSearchActionKeyword { get; set; } = true; + public bool EnabledSearchActionKeyword { get; set; } = true; public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword; @@ -60,7 +60,7 @@ namespace Flow.Launcher.Plugin.Explorer internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch { - ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword, + ActionKeyword.SearchActionKeyword => EnabledSearchActionKeyword, ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword, ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword, _ => null @@ -68,7 +68,7 @@ namespace Flow.Launcher.Plugin.Explorer internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch { - ActionKeyword.SearchActionKeyword => EnableSearchActionKeyword = enable, + ActionKeyword.SearchActionKeyword => EnabledSearchActionKeyword = enable, ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword = enable, ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword = enable, _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property") From 0c3a37eb706090b9016b2c4bd59a4d69dfbc9c7b Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sat, 3 Jul 2021 00:23:23 +0800 Subject: [PATCH 04/13] change logic --- Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 8af757da9..f2d1cbe2a 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, Action = c => { - if (c.SpecialKeyState.CtrlPressed || !(Settings.EnabledPathSearchKeyword || Settings.EnabledSearchActionKeyword)) + if (c.SpecialKeyState.CtrlPressed || (!Settings.EnabledPathSearchKeyword && !Settings.EnabledSearchActionKeyword)) { try { From 020ced45d084e96fd5feb431fce5a1d95f328738 Mon Sep 17 00:00:00 2001 From: pc223 <10551242+pc223@users.noreply.github.com> Date: Sat, 3 Jul 2021 00:40:20 +0700 Subject: [PATCH 05/13] Fix (workaround) for the window freezes after lock screen (Win+L) Co-authored-by: taooceros --- Flow.Launcher/SettingWindow.xaml | 1 + Flow.Launcher/SettingWindow.xaml.cs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 566ecd61a..9513cf41c 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -18,6 +18,7 @@ Height="600" Width="900" MinWidth="850" MinHeight="500" + Loaded="OnLoaded" Closed="OnClosed" d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}"> diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index a922b4d67..2823e4ddd 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Windows; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Navigation; using Microsoft.Win32; using NHotkey; @@ -35,6 +36,14 @@ namespace Flow.Launcher } #region General + private void OnLoaded(object sender, RoutedEventArgs e) + { + // Fix (workaround) for the window freezes after lock screen (Win+L) + // https://stackoverflow.com/questions/4951058/software-rendering-mode-wpf + HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource; + HwndTarget hwndTarget = hwndSource.CompositionTarget; + hwndTarget.RenderMode = RenderMode.SoftwareOnly; + } private void OnAutoStartupChecked(object sender, RoutedEventArgs e) { From 428efb1cd0f5c6a29013660e49e7e587e2b45fca Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sat, 3 Jul 2021 12:43:38 +0800 Subject: [PATCH 06/13] fix unexpected empty string --- Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index f2d1cbe2a..47a5a006c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -44,7 +44,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search // one of it is enabled var keyword = Settings.EnabledSearchActionKeyword ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword; - keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + ""; + keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " "; string changeTo = path.EndsWith(Constants.DirectorySeperator) ? path : path + Constants.DirectorySeperator; Context.API.ChangeQuery($"{keyword}{changeTo}"); From 0df9f373ce8a06bc3211f8bc94bc996691c65523 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sat, 3 Jul 2021 12:45:00 +0800 Subject: [PATCH 07/13] Rename variables --- .../Search/ResultManager.cs | 4 ++-- .../Search/SearchManager.cs | 6 +++--- .../Flow.Launcher.Plugin.Explorer/Settings.cs | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs index 47a5a006c..d0f78e14d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs @@ -28,7 +28,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search TitleHighlightData = StringMatcher.FuzzySearch(query.Search, title).MatchData, Action = c => { - if (c.SpecialKeyState.CtrlPressed || (!Settings.EnabledPathSearchKeyword && !Settings.EnabledSearchActionKeyword)) + if (c.SpecialKeyState.CtrlPressed || (!Settings.PathSearchKeywordEnabled && !Settings.SearchActionKeywordEnabled)) { try { @@ -42,7 +42,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search } } // one of it is enabled - var keyword = Settings.EnabledSearchActionKeyword ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword; + var keyword = Settings.SearchActionKeywordEnabled ? Settings.SearchActionKeyword : Settings.PathSearchActionKeyword; keyword = keyword == Query.GlobalPluginWildcardSign ? string.Empty : keyword + " "; diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs index d98c5400a..2aa389f89 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/SearchManager.cs @@ -71,13 +71,13 @@ namespace Flow.Launcher.Plugin.Explorer.Search return allowedActionKeyword switch { - Settings.ActionKeyword.SearchActionKeyword => settings.EnabledSearchActionKeyword && + Settings.ActionKeyword.SearchActionKeyword => settings.SearchActionKeywordEnabled && keyword == settings.SearchActionKeyword, - Settings.ActionKeyword.PathSearchActionKeyword => settings.EnabledPathSearchKeyword && + Settings.ActionKeyword.PathSearchActionKeyword => settings.PathSearchKeywordEnabled && keyword == settings.PathSearchActionKeyword, Settings.ActionKeyword.FileContentSearchActionKeyword => keyword == settings.FileContentSearchActionKeyword, - Settings.ActionKeyword.IndexSearchActionKeyword => settings.EnabledIndexOnlySearchKeyword && + Settings.ActionKeyword.IndexSearchActionKeyword => settings.IndexOnlySearchKeywordEnabled && keyword == settings.IndexSearchActionKeyword }; } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 26204616a..985cb2fd9 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -21,17 +21,17 @@ namespace Flow.Launcher.Plugin.Explorer public List IndexSearchExcludedSubdirectoryPaths { get; set; } = new List(); public string SearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; - public bool EnabledSearchActionKeyword { get; set; } = true; + public bool SearchActionKeywordEnabled { get; set; } = true; public string FileContentSearchActionKeyword { get; set; } = Constants.DefaultContentSearchActionKeyword; public string PathSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; - public bool EnabledPathSearchKeyword { get; set; } + public bool PathSearchKeywordEnabled { get; set; } public string IndexSearchActionKeyword { get; set; } = Query.GlobalPluginWildcardSign; - public bool EnabledIndexOnlySearchKeyword { get; set; } + public bool IndexOnlySearchKeywordEnabled { get; set; } internal enum ActionKeyword { @@ -60,17 +60,17 @@ namespace Flow.Launcher.Plugin.Explorer internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch { - ActionKeyword.SearchActionKeyword => EnabledSearchActionKeyword, - ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword, - ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword, + ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled, + ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled, + ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled, _ => null }; internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch { - ActionKeyword.SearchActionKeyword => EnabledSearchActionKeyword = enable, - ActionKeyword.PathSearchActionKeyword => EnabledPathSearchKeyword = enable, - ActionKeyword.IndexSearchActionKeyword => EnabledIndexOnlySearchKeyword = enable, + ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable, + ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable, + ActionKeyword.IndexSearchActionKeyword => IndexOnlySearchKeywordEnabled = enable, _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property") }; } From 2d32bc981450708838f5c7e84d1c5e9d1e262b42 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 3 Jul 2021 16:33:29 +1000 Subject: [PATCH 08/13] fix method typo --- Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs | 4 ++-- .../Views/ExplorerSettings.xaml.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs index 985cb2fd9..13f938dea 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Settings.cs @@ -58,7 +58,7 @@ namespace Flow.Launcher.Plugin.Explorer _ => throw new ArgumentOutOfRangeException(nameof(actionKeyword), actionKeyword, "Unexpected property") }; - internal bool? GetActionKeywordEnable(ActionKeyword actionKeyword) => actionKeyword switch + internal bool? GetActionKeywordEnabled(ActionKeyword actionKeyword) => actionKeyword switch { ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled, ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled, @@ -66,7 +66,7 @@ namespace Flow.Launcher.Plugin.Explorer _ => null }; - internal void SetActionKeywordEnable(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch + internal void SetActionKeywordEnabled(ActionKeyword actionKeyword, bool enable) => _ = actionKeyword switch { ActionKeyword.SearchActionKeyword => SearchActionKeywordEnabled = enable, ActionKeyword.PathSearchActionKeyword => PathSearchKeywordEnabled = enable, diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs index ffd5b618a..0c3799cee 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs @@ -337,8 +337,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views public bool? Enabled { - get => _settings.GetActionKeywordEnable(KeywordProperty); - set => _settings.SetActionKeywordEnable(KeywordProperty, + get => _settings.GetActionKeywordEnabled(KeywordProperty); + set => _settings.SetActionKeywordEnabled(KeywordProperty, value ?? throw new ArgumentException("Unexpected null value")); } } From 12b2d653f6292f12998f2587463b34d0358650ff Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sat, 3 Jul 2021 20:35:22 +0800 Subject: [PATCH 09/13] Check Empty image path to avoid exception --- Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index e53fb7a52..869172de7 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -565,7 +565,7 @@ namespace Flow.Launcher.Plugin.Program.Programs } else { - ProgramLogger.LogException($"|UWP|ImageFromPath|{path}" + + ProgramLogger.LogException($"|UWP|ImageFromPath|{(string.IsNullOrEmpty(path) ? "Not Avaliable" : path)}" + $"|Unable to get logo for {UserModelId} from {path} and" + $" located in {Package.Location}", new FileNotFoundException()); return new BitmapImage(new Uri(Constant.MissingImgIcon)); From 2405af88a696267b6593295c20633c8f594cf507 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sun, 4 Jul 2021 18:35:00 +0800 Subject: [PATCH 10/13] fix unexpected Task Status --- .../PluginsManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index ebb76a838..ac40b53bc 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -59,11 +59,13 @@ namespace Flow.Launcher.Plugin.PluginsManager } else { - return _downloadManifestTask = pluginsManifest.DownloadManifest().ContinueWith(t => - Context.API.ShowMsg("Plugin Manifest Download Fail.", - "Please check if you can connect to github.com. " + - "This error means you may not be able to Install and Update Plugin.", icoPath, false), + _downloadManifestTask = pluginsManifest.DownloadManifest(); + _downloadManifestTask.ContinueWith(_ => + Context.API.ShowMsg("Plugin Manifest Download Fail.", + "Please check if you can connect to github.com. " + + "This error means you may not be able to Install and Update Plugin.", icoPath, false), TaskContinuationOptions.OnlyOnFaulted); + return _downloadManifestTask; } } From 47cb7a4ebc31a4ce2f15af88fe02fa2e537d2fc1 Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Sun, 4 Jul 2021 18:53:40 +0800 Subject: [PATCH 11/13] another check to avoid re-update lastUpdateTime --- Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs index f0ef89c82..5f200aa21 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs @@ -38,7 +38,7 @@ namespace Flow.Launcher.Plugin.PluginsManager viewModel = new SettingsViewModel(context, Settings); contextMenu = new ContextMenu(Context); pluginManager = new PluginsManager(Context, Settings); - _ = pluginManager.UpdateManifest().ContinueWith(_ => + _manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(_ => { lastUpdateTime = DateTime.Now; }, TaskContinuationOptions.OnlyOnRanToCompletion); @@ -50,6 +50,8 @@ namespace Flow.Launcher.Plugin.PluginsManager { return contextMenu.LoadContextMenus(selectedResult); } + + private Task _manifestUpdateTask = Task.CompletedTask; public async Task> QueryAsync(Query query, CancellationToken token) { @@ -58,9 +60,9 @@ namespace Flow.Launcher.Plugin.PluginsManager if (string.IsNullOrWhiteSpace(search)) return pluginManager.GetDefaultHotKeys(); - if ((DateTime.Now - lastUpdateTime).TotalHours > 12) // 12 hours + if ((DateTime.Now - lastUpdateTime).TotalHours > 12 && _manifestUpdateTask.IsCompleted) // 12 hours { - _ = pluginManager.UpdateManifest().ContinueWith(t => + _manifestUpdateTask = pluginManager.UpdateManifest().ContinueWith(t => { lastUpdateTime = DateTime.Now; }, TaskContinuationOptions.OnlyOnRanToCompletion); From 262cf90aeea8f51b0aeb05a3cb93c1201c8b9f96 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 4 Jul 2021 21:11:28 +1000 Subject: [PATCH 12/13] version bump --- Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json b/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json index 0a28d8acd..a0b84ac9a 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json @@ -6,7 +6,7 @@ "Name": "Plugins Manager", "Description": "Management of installing, uninstalling or updating Flow Launcher plugins", "Author": "Jeremy Wu", - "Version": "1.8.1", + "Version": "1.8.2", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll", From e7b90b818e4773849736d7e227d764c37005b564 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 4 Jul 2021 21:12:22 +1000 Subject: [PATCH 13/13] add translation for download failed error msg --- .../Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml | 2 ++ .../Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml index 3017f39c3..c36a1dcaa 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/en.xaml @@ -19,6 +19,8 @@ Plugin Update This plugin has an update, would you like to see it? This plugin is already installed + Plugin Manifest Download Failed + Please check if you can connect to github.com. This error means you may not be able to install or update plugins. diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index ac40b53bc..1aa39469b 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -61,9 +61,8 @@ namespace Flow.Launcher.Plugin.PluginsManager { _downloadManifestTask = pluginsManifest.DownloadManifest(); _downloadManifestTask.ContinueWith(_ => - Context.API.ShowMsg("Plugin Manifest Download Fail.", - "Please check if you can connect to github.com. " + - "This error means you may not be able to Install and Update Plugin.", icoPath, false), + Context.API.ShowMsg(Context.API.GetTranslation("plugin_pluginsmanager_update_failed_title"), + Context.API.GetTranslation("plugin_pluginsmanager_update_failed_subtitle"), icoPath, false), TaskContinuationOptions.OnlyOnFaulted); return _downloadManifestTask; }