Skip to content

Commit c42628b

Browse files
Merge pull request #3765 from Flow-Launcher/code_quality
Use Flow.Launcher.Localization to improve code quality
2 parents 65cfb29 + b637e0a commit c42628b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+426
-486
lines changed

.github/actions/spelling/allow.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ ssh
44
ubuntu
55
runcount
66
Firefox
7+
Português
8+
Português (Brasil)
9+
favicons
10+
moz
711
workaround

.github/actions/spelling/expect.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,7 @@ metadatas
104104
WMP
105105
VSTHRD
106106
CJK
107+
Msix
108+
dummyprofile
109+
browserbookmark
110+
copyurl

.github/actions/spelling/patterns.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@
124124
# version suffix <word>v#
125125
(?:(?<=[A-Z]{2})V|(?<=[a-z]{2}|[A-Z]{2})v)\d+(?:\b|(?=[a-zA-Z_]))
126126

127+
# Non-English
128+
[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
129+
130+
127131
\bjjw24\b
128132
\bappref-ms\b
129133
\bTobiasSekan\b
@@ -143,3 +147,4 @@
143147
\bXing\s*Kong\s*Jian\s*Dao\b
144148
\bDa\s*Niu\b
145149
\bXiao\s*Lang\b
150+
\b[Ss]ettings [Ss]ettings\b

Flow.Launcher.Core/Resource/LocalizationConverter.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

Flow.Launcher.Infrastructure/UI/EnumBindingSource.cs

Lines changed: 0 additions & 58 deletions
This file was deleted.

Plugins/Flow.Launcher.Plugin.BrowserBookmark/ChromiumBookmarkLoader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected List<Bookmark> LoadBookmarks(string browserDataPath, string name)
4545
}
4646
catch (Exception ex)
4747
{
48-
Main._context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex);
48+
Main.Context.API.LogException(ClassName, $"Failed to register bookmark file monitoring: {bookmarkPath}", ex);
4949
continue;
5050
}
5151

@@ -58,7 +58,7 @@ protected List<Bookmark> LoadBookmarks(string browserDataPath, string name)
5858
var faviconDbPath = Path.Combine(profile, "Favicons");
5959
if (File.Exists(faviconDbPath))
6060
{
61-
Main._context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () =>
61+
Main.Context.API.StopwatchLogInfo(ClassName, $"Load {profileBookmarks.Count} favicons cost", () =>
6262
{
6363
LoadFaviconsFromDb(faviconDbPath, profileBookmarks);
6464
});
@@ -125,7 +125,7 @@ private static void EnumerateFolderBookmark(JsonElement folderElement, ICollecti
125125
}
126126
else
127127
{
128-
Main._context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}");
128+
Main.Context.API.LogError(ClassName, $"type property not found for {subElement.GetString()}");
129129
}
130130
}
131131
}
@@ -190,7 +190,7 @@ ORDER BY b.width DESC
190190
}
191191
catch (Exception ex)
192192
{
193-
Main._context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex);
193+
Main.Context.API.LogException(ClassName, $"Failed to extract bookmark favicon: {bookmark.Url}", ex);
194194
}
195195
finally
196196
{

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Commands/BookmarkLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ internal static class BookmarkLoader
99
{
1010
internal static MatchResult MatchProgram(Bookmark bookmark, string queryString)
1111
{
12-
var match = Main._context.API.FuzzySearch(queryString, bookmark.Name);
12+
var match = Main.Context.API.FuzzySearch(queryString, bookmark.Name);
1313
if (match.IsSearchPrecisionScoreMet())
1414
return match;
1515

16-
return Main._context.API.FuzzySearch(queryString, bookmark.Url);
16+
return Main.Context.API.FuzzySearch(queryString, bookmark.Url);
1717
}
1818

1919
internal static List<Bookmark> LoadAllBookmarks(Settings setting)

Plugins/Flow.Launcher.Plugin.BrowserBookmark/FirefoxBookmarkLoader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
4949
}
5050
catch (Exception ex)
5151
{
52-
Main._context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
52+
Main.Context.API.LogException(ClassName, $"Failed to register Firefox bookmark file monitoring: {placesPath}", ex);
5353
return bookmarks;
5454
}
5555

@@ -84,7 +84,7 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
8484
var faviconDbPath = Path.Combine(Path.GetDirectoryName(placesPath), "favicons.sqlite");
8585
if (File.Exists(faviconDbPath))
8686
{
87-
Main._context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () =>
87+
Main.Context.API.StopwatchLogInfo(ClassName, $"Load {bookmarks.Count} favicons cost", () =>
8888
{
8989
LoadFaviconsFromDb(faviconDbPath, bookmarks);
9090
});
@@ -98,7 +98,7 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
9898
}
9999
catch (Exception ex)
100100
{
101-
Main._context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex);
101+
Main.Context.API.LogException(ClassName, $"Failed to load Firefox bookmarks: {placesPath}", ex);
102102
}
103103

104104
// Delete temporary file
@@ -111,7 +111,7 @@ protected List<Bookmark> GetBookmarksFromPath(string placesPath)
111111
}
112112
catch (Exception ex)
113113
{
114-
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
114+
Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
115115
}
116116

117117
return bookmarks;
@@ -186,7 +186,7 @@ ORDER BY i.width DESC -- Select largest icon available
186186
}
187187
catch (Exception ex)
188188
{
189-
Main._context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex);
189+
Main.Context.API.LogException(ClassName, $"Failed to extract Firefox favicon: {bookmark.Url}", ex);
190190
}
191191
finally
192192
{

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Flow.Launcher.Plugin.BrowserBookmark.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
</ItemGroup>
8282

8383
<ItemGroup>
84-
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
8584
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
8685
</ItemGroup>
8786

@@ -96,6 +95,7 @@
9695

9796
<ItemGroup>
9897
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
98+
<PackageReference Include="Flow.Launcher.Localization" Version="0.0.4" />
9999
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.7" />
100100
</ItemGroup>
101101

Plugins/Flow.Launcher.Plugin.BrowserBookmark/Helper/FaviconHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
2727
}
2828
catch (Exception ex1)
2929
{
30-
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1);
30+
Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex1);
3131
}
32-
Main._context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex);
32+
Main.Context.API.LogException(ClassName, $"Failed to copy favicon DB: {dbPath}", ex);
3333
return;
3434
}
3535

@@ -39,7 +39,7 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
3939
}
4040
catch (Exception ex)
4141
{
42-
Main._context.API.LogException(ClassName, $"Failed to connect to SQLite: {tempDbPath}", ex);
42+
Main.Context.API.LogException(ClassName, $"Failed to connect to SQLite: {tempDbPath}", ex);
4343
}
4444

4545
// Delete temporary file
@@ -49,7 +49,7 @@ public static void LoadFaviconsFromDb(string faviconCacheDir, string dbPath, Act
4949
}
5050
catch (Exception ex)
5151
{
52-
Main._context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
52+
Main.Context.API.LogException(ClassName, $"Failed to delete temporary favicon DB: {tempDbPath}", ex);
5353
}
5454
}
5555

@@ -61,7 +61,7 @@ public static void SaveBitmapData(byte[] imageData, string outputPath)
6161
}
6262
catch (Exception ex)
6363
{
64-
Main._context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex);
64+
Main.Context.API.LogException(ClassName, $"Failed to save image: {outputPath}", ex);
6565
}
6666
}
6767

0 commit comments

Comments
 (0)