diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs index 6e6b2e5f4ad..6dc0f7a9a33 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs @@ -45,7 +45,7 @@ protected List LoadBookmarks(string browserDataPath, string name) } catch (Exception ex) { - Main._context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex); + Main.Context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex); continue; } @@ -58,7 +58,7 @@ protected List LoadBookmarks(string browserDataPath, string name) var faviconDbPath = Path.Combine(profile, "Favicons"); if (File.Exists(faviconDbPath)) { - Main._context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () => + Main.Context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () => { LoadFaviconsFromDb(faviconDbPath, profileBookmarks); }); @@ -125,7 +125,7 @@ private static void EnumerateFolderBookmark(JsonElement folderElement, ICollecti } else { - Main._context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}"); + Main.Context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}"); } } } @@ -190,7 +190,7 @@ ORDER BY b.width DESC } catch (Exception ex) { - Main._context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex); + Main.Context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex); } finally { diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs index 758ce68ae78..b76adae93c3 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs @@ -9,11 +9,11 @@ internal static class BookmarkLoader { internal static MatchResult MatchProgram(Bookmark bookmark, string queryString) { - var match = Main._context.API.FuzzySearch(queryString, bookmark.Name); + var match = Main.Context.API.FuzzySearch(queryString, bookmark.Name); if (match.IsSearchPrecisionScoreMet()) return match; - return Main._context.API.FuzzySearch(queryString, bookmark.Url); + return Main.Context.API.FuzzySearch(queryString, bookmark.Url); } internal static List LoadAllBookmarks(Settings setting) diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs index ec3b867ea81..68e5d5caadd 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs @@ -49,7 +49,7 @@ protected List GetBookmarksFromPath(string placesPath) } catch (Exception ex) { - Main._context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex); + Main.Context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex); return bookmarks; } @@ -84,7 +84,7 @@ protected List GetBookmarksFromPath(string placesPath) var faviconDbPath = Path.Combine(Path.GetDirectoryName(placesPath), "favicons.sqlite"); if (File.Exists(faviconDbPath)) { - Main._context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () => + Main.Context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () => { LoadFaviconsFromDb(faviconDbPath, bookmarks); }); @@ -98,7 +98,7 @@ protected List GetBookmarksFromPath(string placesPath) } catch (Exception ex) { - Main._context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex); + Main.Context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex); } // Delete temporary file @@ -111,7 +111,7 @@ protected List GetBookmarksFromPath(string placesPath) } catch (Exception ex) { - Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex); + Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex); } return bookmarks; @@ -186,7 +186,7 @@ ORDER BY i.width DESC -- Select largest icon available } catch (Exception ex) { - Main._context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex); + Main.Context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex); } finally { diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj index 953b7a54e3b..9ff6a97ac09 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj @@ -96,6 +96,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs index a879dcefd1b..b88bd764042 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs @@ -27,9 +27,9 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act } catch (Exception ex1) { - Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1); + Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1); } - Main._context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex); + Main.Context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex); return; } @@ -39,7 +39,7 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act } catch (Exception ex) { - Main._context.API.LogException(ClassName, $"Failed to connect to SQLite: {tempDbPath}", ex); + Main.Context.API.LogException(ClassName, $"Failed to connect to SQLite: {tempDbPath}", ex); } // Delete temporary file @@ -49,7 +49,7 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act } catch (Exception ex) { - Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex); + Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex); } } @@ -61,7 +61,7 @@ public static void SaveBitmapData(byte[] imageData, string outputPath) } catch (Exception ex) { - Main._context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex); + Main.Context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex); } } diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs index b1600862e56..8a7f0ac2e16 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs @@ -19,7 +19,7 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex internal static string _faviconCacheDir; - internal static PluginInitContext _context; + internal static PluginInitContext Context { get; private set; } internal static Settings _settings; @@ -29,7 +29,7 @@ public class Main : ISettingProvider, IPlugin, IReloadable, IPluginI18n, IContex public void Init(PluginInitContext context) { - _context = context; + Context = context; _settings = context.API.LoadSettingJsonStorage(); @@ -42,7 +42,7 @@ public void Init(PluginInitContext context) private static void LoadBookmarksIfEnabled() { - if (_context.CurrentPluginMetadata.Disabled) + if (Context.CurrentPluginMetadata.Disabled) { // Don't load or monitor files if disabled return; @@ -84,7 +84,7 @@ public List Query(Query query) Score = BookmarkLoader.MatchProgram(c, param).Score, Action = _ => { - _context.API.OpenUrl(c.Url); + Context.API.OpenUrl(c.Url); return true; }, @@ -108,7 +108,7 @@ public List Query(Query query) Score = 5, Action = _ => { - _context.API.OpenUrl(c.Url); + Context.API.OpenUrl(c.Url); return true; }, ContextData = new BookmarkAttributes { Url = c.Url } @@ -192,12 +192,12 @@ public static void ReloadAllBookmarks(bool disposeFileWatchers = true) public string GetTranslatedPluginTitle() { - return _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_name"); + return Localize.flowlauncher_plugin_browserbookmark_plugin_name(); } public string GetTranslatedPluginDescription() { - return _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_description"); + return Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_plugin_description"); } public Control CreateSettingPanel() @@ -211,20 +211,20 @@ public List LoadContextMenus(Result selectedResult) { new() { - Title = _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_title"), - SubTitle = _context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_subtitle"), + Title = Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_title"), + SubTitle = Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copyurl_subtitle"), Action = _ => { try { - _context.API.CopyToClipboard(((BookmarkAttributes)selectedResult.ContextData).Url); + Context.API.CopyToClipboard(((BookmarkAttributes)selectedResult.ContextData).Url); return true; } catch (Exception e) { - _context.API.LogException(ClassName, "Failed to set url in clipboard", e); - _context.API.ShowMsgError(_context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copy_failed")); + Context.API.LogException(ClassName, "Failed to set url in clipboard", e); + Context.API.ShowMsgError(Context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copy_failed")); return false; } },