Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions Flow.Launcher.Core/Configuration/Portable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
#endif
IndicateDeletion(DataLocation.PortableDataPath);

API.ShowMsgBox("Flow Launcher needs to restart to finish disabling portable mode, " +
"after the restart your portable data profile will be deleted and roaming data profile kept");
API.ShowMsgBox(API.GetTranslation("restartToDisablePortableMode"));

UpdateManager.RestartApp(Constant.ApplicationFileName);
}
Expand All @@ -62,15 +61,14 @@
{
MoveUserDataFolder(DataLocation.RoamingDataPath, DataLocation.PortableDataPath);
#if !DEBUG
// Remove shortcuts and uninstaller are not required in debug mode,

Check warning on line 64 in Flow.Launcher.Core/Configuration/Portable.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`uninstaller` is not a recognized word. (unrecognized-spelling)
// otherwise will delete the actual installed production version
RemoveShortcuts();
RemoveUninstallerEntry();

Check warning on line 67 in Flow.Launcher.Core/Configuration/Portable.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)
#endif
IndicateDeletion(DataLocation.RoamingDataPath);

API.ShowMsgBox("Flow Launcher needs to restart to finish enabling portable mode, " +
"after the restart your roaming data profile will be deleted and portable data profile kept");
API.ShowMsgBox(API.GetTranslation("restartToEnablePortableMode"));

UpdateManager.RestartApp(Constant.ApplicationFileName);
}
Expand All @@ -88,10 +86,10 @@
portabilityUpdater.RemoveShortcutsForExecutable(Constant.ApplicationFileName, ShortcutLocation.Startup);
}

public void RemoveUninstallerEntry()

Check warning on line 89 in Flow.Launcher.Core/Configuration/Portable.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)
{
using var portabilityUpdater = NewUpdateManager();
portabilityUpdater.RemoveUninstallerRegistryEntry();

Check warning on line 92 in Flow.Launcher.Core/Configuration/Portable.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)
}

public void MoveUserDataFolder(string fromLocation, string toLocation)
Expand All @@ -113,7 +111,7 @@
portabilityUpdater.CreateShortcutsForExecutable(Constant.ApplicationFileName, ShortcutLocation.Startup, false);
}

public void CreateUninstallerEntry()

Check warning on line 114 in Flow.Launcher.Core/Configuration/Portable.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Uninstaller` is not a recognized word. (unrecognized-spelling)
{
var uninstallRegSubKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";

Expand All @@ -130,7 +128,7 @@

private static void IndicateDeletion(string filePathTodelete)
{
var deleteFilePath = Path.Combine(filePathTodelete, DataLocation.DeletionIndicatorFile);

Check warning on line 131 in Flow.Launcher.Core/Configuration/Portable.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Todelete` is not a recognized word. (unrecognized-spelling)
using var _ = File.CreateText(deleteFilePath);
}

Expand All @@ -154,9 +152,8 @@
{
FilesFolders.RemoveFolderIfExists(roamingDataDir, (s) => API.ShowMsgBox(s));

if (API.ShowMsgBox("Flow Launcher has detected you enabled portable mode, " +
"would you like to move it to a different location?", string.Empty,
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
if (API.ShowMsgBox(API.GetTranslation("moveToDifferentLocation"),
string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
FilesFolders.OpenPath(Constant.RootDirectory, (s) => API.ShowMsgBox(s));

Expand All @@ -169,8 +166,7 @@
{
FilesFolders.RemoveFolderIfExists(portableDataDir, (s) => API.ShowMsgBox(s));

API.ShowMsgBox("Flow Launcher has detected you disabled portable mode, " +
"the relevant shortcuts and uninstaller entry have been created");
API.ShowMsgBox(API.GetTranslation("shortcutsUninstallerCreated"));
}
}

Expand All @@ -181,9 +177,8 @@

if (roamingLocationExists && portableLocationExists)
{
API.ShowMsgBox(string.Format("Flow Launcher detected your user data exists both in {0} and " +
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred.",
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
API.ShowMsgBox(string.Format(API.GetTranslation("userDataDuplicated"),
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));

return false;
}
Expand Down
6 changes: 5 additions & 1 deletion Flow.Launcher.Core/ExternalPlugins/PluginsManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public static class PluginsManifest
private static DateTime lastFetchedAt = DateTime.MinValue;
private static readonly TimeSpan fetchTimeout = TimeSpan.FromMinutes(2);

// We should not initialize API in static constructor because it will create another API instance
private static IPublicAPI api = null;
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();

public static List<UserPlugin> UserPlugins { get; private set; }

public static async Task<bool> UpdateManifestAsync(bool usePrimaryUrlOnly = false, CancellationToken token = default)
Expand All @@ -46,7 +50,7 @@ public static async Task<bool> UpdateManifestAsync(bool usePrimaryUrlOnly = fals
}
catch (Exception e)
{
Ioc.Default.GetRequiredService<IPublicAPI>().LogException(ClassName, "Http request failed", e);
API.LogException(ClassName, "Http request failed", e);
}
finally
{
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher.Core/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ internal static async Task<bool> UninstallPluginAsync(PluginMetadata plugin, boo
catch (Exception e)
{
API.LogException(ClassName, $"Failed to delete plugin settings folder for {plugin.Name}", e);
API.ShowMsg(API.GetTranslation("failedToRemovePluginSettingsTitle"),
API.ShowMsgError(API.GetTranslation("failedToRemovePluginSettingsTitle"),
string.Format(API.GetTranslation("failedToRemovePluginSettingsMessage"), plugin.Name));
}
}
Expand All @@ -735,7 +735,7 @@ internal static async Task<bool> UninstallPluginAsync(PluginMetadata plugin, boo
catch (Exception e)
{
API.LogException(ClassName, $"Failed to delete plugin cache folder for {plugin.Name}", e);
API.ShowMsg(API.GetTranslation("failedToRemovePluginCacheTitle"),
API.ShowMsgError(API.GetTranslation("failedToRemovePluginCacheTitle"),
string.Format(API.GetTranslation("failedToRemovePluginCacheMessage"), plugin.Name));
}
Settings.RemovePluginSettings(plugin.ID);
Expand Down
10 changes: 5 additions & 5 deletions Flow.Launcher.Core/Plugin/PluginsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ private static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source
{
var errorPluginString = string.Join(Environment.NewLine, erroredPlugins);

var errorMessage = "The following "
+ (erroredPlugins.Count > 1 ? "plugins have " : "plugin has ")
+ "errored and cannot be loaded:";
var errorMessage = erroredPlugins.Count > 1 ?
API.GetTranslation("pluginsHaveErrored") :
API.GetTranslation("pluginHasErrored");

_ = Task.Run(() =>
{
Ioc.Default.GetRequiredService<IPublicAPI>().ShowMsgBox($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
API.ShowMsgBox($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
$"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" +
$"Please refer to the logs for more information", "",
API.GetTranslation("referToLogs"), string.Empty,
MessageBoxButton.OK, MessageBoxImage.Warning);
});
}
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher.Core/Resource/Internationalization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public bool PromptShouldUsePinyin(string languageCodeToSet)
// "Do you want to search with pinyin?"
string text = languageToSet == AvailableLanguages.Chinese ? "是否启用拼音搜索?" : "是否啓用拼音搜索?" ;

if (Ioc.Default.GetRequiredService<IPublicAPI>().ShowMsgBox(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
if (API.ShowMsgBox(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
return false;

return true;
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher.Core/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
}

if (!silentUpdate)
_api.ShowMsg(_api.GetTranslation("update_flowlauncher_fail"),
_api.ShowMsgError(_api.GetTranslation("update_flowlauncher_fail"),
_api.GetTranslation("update_flowlauncher_check_connection"));
}
finally
Expand Down Expand Up @@ -142,7 +142,7 @@
var latest = releases.Where(r => !r.Prerelease).OrderByDescending(r => r.PublishedAt).First();
var latestUrl = latest.HtmlUrl.Replace("/tag/", "/download/");

var client = new WebClient { Proxy = Http.WebProxy };

Check warning on line 145 in Flow.Launcher.Core/Updater.cs

View workflow job for this annotation

GitHub Actions / build

'WebClient.WebClient()' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
var downloader = new FileDownloader(client);

var manager = new UpdateManager(latestUrl, urlDownloader: downloader);
Expand Down
6 changes: 5 additions & 1 deletion Flow.Launcher.Infrastructure/Http/Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@

private static readonly HttpClient client = new();

// We should not initialize API in static constructor because it will create another API instance
private static IPublicAPI api = null;
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();

static Http()
{
// need to be added so it would work on a win10 machine
ServicePointManager.Expect100Continue = true;

Check warning on line 30 in Flow.Launcher.Infrastructure/Http/Http.cs

View workflow job for this annotation

GitHub Actions / build

'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls

Check warning on line 31 in Flow.Launcher.Infrastructure/Http/Http.cs

View workflow job for this annotation

GitHub Actions / build

'ServicePointManager' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead. Settings on ServicePointManager no longer affect SslStream or HttpClient.' (https://aka.ms/dotnet-warnings/SYSLIB0014)
| SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

client.DefaultRequestHeaders.Add("User-Agent", UserAgent);
Expand Down Expand Up @@ -78,7 +82,7 @@
}
catch (UriFormatException e)
{
Ioc.Default.GetRequiredService<IPublicAPI>().ShowMsg("Please try again", "Unable to parse Http Proxy");
API.ShowMsgError(API.GetTranslation("pleaseTryAgain"), API.GetTranslation("parseProxyFailed"));
Log.Exception(ClassName, "Unable to parse Uri", e);
}
}
Expand Down Expand Up @@ -207,7 +211,7 @@
}

/// <summary>
/// Asynchrously send an HTTP request.

Check warning on line 214 in Flow.Launcher.Infrastructure/Http/Http.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Asynchrously` is not a recognized word. (unrecognized-spelling)
/// </summary>
public static async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption = HttpCompletionOption.ResponseContentRead, CancellationToken token = default)
{
Expand All @@ -228,7 +232,7 @@
Log.Debug(ClassName, $"Url <{url}>");
return await client.GetStringAsync(url, token);
}
catch (System.Exception e)

Check warning on line 235 in Flow.Launcher.Infrastructure/Http/Http.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'e' is declared but never used
{
return string.Empty;
}
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
// Change language after all plugins are initialized because we need to update plugin title based on their api
await Ioc.Default.GetRequiredService<Internationalization>().InitializeLanguageAsync();

await imageLoadertask;

Check warning on line 222 in Flow.Launcher/App.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Loadertask` is not a recognized word. (unrecognized-spelling)

_mainWindow = new MainWindow();

Expand Down Expand Up @@ -267,7 +267,7 @@
// but if it fails (permissions, etc) then don't keep retrying
// this also gives the user a visual indication in the Settings widget
_settings.StartFlowLauncherOnSystemStartup = false;
API.ShowMsg(API.GetTranslation("setAutoStartFailed"), e.Message);
API.ShowMsgError(API.GetTranslation("setAutoStartFailed"), e.Message);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
<system:String x:Key="failedToInitializePluginsTitle">Fail to Init Plugins</system:String>
<system:String x:Key="failedToInitializePluginsMessage">Plugins: {0} - fail to load and would be disabled, please contact plugin creator for help</system:String>

<!-- Portable -->
<system:String x:Key="restartToDisablePortableMode">Flow Launcher needs to restart to finish disabling portable mode, after the restart your portable data profile will be deleted and roaming data profile kept</system:String>
<system:String x:Key="restartToEnablePortableMode">Flow Launcher needs to restart to finish enabling portable mode, after the restart your roaming data profile will be deleted and portable data profile kept</system:String>
<system:String x:Key="moveToDifferentLocation">Flow Launcher has detected you enabled portable mode, would you like to move it to a different location?</system:String>
<system:String x:Key="shortcutsUninstallerCreated">Flow Launcher has detected you disabled portable mode, the relevant shortcuts and uninstaller entry have been created</system:String>

Check warning on line 25 in Flow.Launcher/Languages/en.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`uninstaller` is not a recognized word. (unrecognized-spelling)
<system:String x:Key="userDataDuplicated">Flow Launcher detected your user data exists both in {0} and {1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred.</system:String>

<!-- Plugin Loader -->
<system:String x:Key="pluginHasErrored">The following plugin has errored and cannot be loaded:</system:String>
<system:String x:Key="pluginsHaveErrored">The following plugins have errored and cannot be loaded:</system:String>
<system:String x:Key="referToLogs">Please refer to the logs for more information</system:String>

<!-- Http -->
<system:String x:Key="pleaseTryAgain">Please try again</system:String>
<system:String x:Key="parseProxyFailed">Unable to parse Http Proxy</system:String>

<!-- MainWindow -->
<system:String x:Key="registerHotkeyFailed">Failed to register hotkey "{0}". The hotkey may be in use by another program. Change to a different hotkey, or exit another program.</system:String>
<system:String x:Key="unregisterHotkeyFailed">Failed to unregister hotkey "{0}". Please try again or see log for details</system:String>
Expand Down Expand Up @@ -140,6 +156,8 @@
<system:String x:Key="KoreanImeOpenLinkButton">Open</system:String>
<system:String x:Key="KoreanImeRegistry">Use Previous Korean IME</system:String>
<system:String x:Key="KoreanImeRegistryTooltip">You can change the Previous Korean IME settings directly from here</system:String>
<system:String x:Key="KoreanImeSettingChangeFailTitle">Failed to change Korean IME setting</system:String>
<system:String x:Key="KoreanImeSettingChangeFailSubTitle">Please check your system registry access or contact support.</system:String>
<system:String x:Key="homePage">Home Page</system:String>
<system:String x:Key="homePageToolTip">Show home page results when query text is empty.</system:String>
<system:String x:Key="historyResultsForHomePage">Show History Results in Home Page</system:String>
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/Resources/Pages/WelcomePage5.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void ChangeAutoStartup(bool value)
}
catch (Exception e)
{
App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message);
App.API.ShowMsgError(App.API.GetTranslation("setAutoStartFailed"), e.Message);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public bool StartFlowLauncherOnSystemStartup
}
catch (Exception e)
{
App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message);
App.API.ShowMsgError(App.API.GetTranslation("setAutoStartFailed"), e.Message);
}
}
}
Expand All @@ -91,7 +91,7 @@ public bool UseLogonTaskForStartup
}
catch (Exception e)
{
App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message);
App.API.ShowMsgError(App.API.GetTranslation("setAutoStartFailed"), e.Message);
}
}
}
Expand Down Expand Up @@ -216,8 +216,8 @@ public bool LegacyKoreanIMEEnabled
}
else
{
//Since this is rarely seen text, language support is not provided.
App.API.ShowMsg("Failed to change Korean IME setting", "Please check your system registry access or contact support.");
// Since this is rarely seen text, language support is not provided.
App.API.ShowMsgError(App.API.GetTranslation("KoreanImeSettingChangeFailTitle"), App.API.GetTranslation("KoreanImeSettingChangeFailSubTitle"));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<system:String x:Key="flowlauncher_plugin_browserbookmark_plugin_name">Browser Bookmarks</system:String>
<system:String x:Key="flowlauncher_plugin_browserbookmark_plugin_description">Search your browser bookmarks</system:String>

<!-- Main -->
<system:String x:Key="flowlauncher_plugin_browserbookmark_copy_failed">Failed to set url in clipboard</system:String>

<!-- Settings -->
<system:String x:Key="flowlauncher_plugin_browserbookmark_bookmarkDataSetting">Bookmark Data</system:String>
<system:String x:Key="flowlauncher_plugin_browserbookmark_settings_openBookmarks">Open bookmarks in:</system:String>
Expand All @@ -27,5 +30,5 @@
<system:String x:Key="flowlauncher_plugin_browserbookmark_browserEngine">Browser Engine</system:String>
<system:String x:Key="flowlauncher_plugin_browserbookmark_guideMessage01">If you are not using Chrome, Firefox or Edge, or you are using their portable version, you need to add bookmarks data directory and select correct browser engine to make this plugin work.</system:String>
<system:String x:Key="flowlauncher_plugin_browserbookmark_guideMessage02">For example: Brave's engine is Chromium; and its default bookmarks data location is: "%LOCALAPPDATA%\BraveSoftware\Brave-Browser\UserData". For Firefox engine, the bookmarks directory is the userdata folder contains the places.sqlite file.</system:String>
<system:String x:Key="flowlauncher_plugin_browserbookmark_enable_favicons">Load favicons (can be time consuming during startup)</system:String>

Check warning on line 33 in Plugins/Flow.Launcher.Plugin.BrowserBookmark/Languages/en.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`favicons` is not a recognized word. (unrecognized-spelling)

Expand Down
7 changes: 2 additions & 5 deletions Plugins/Flow.Launcher.Plugin.BrowserBookmark/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,8 @@ public List<Result> LoadContextMenus(Result selectedResult)
}
catch (Exception e)
{
var message = "Failed to set url in clipboard";
_context.API.LogException(ClassName, message, e);

_context.API.ShowMsg(message);

_context.API.LogException(ClassName, "Failed to set url in clipboard", e);
_context.API.ShowMsgError(_context.API.GetTranslation("flowlauncher_plugin_browserbookmark_copy_failed"));
return false;
}
},
Expand Down
8 changes: 5 additions & 3 deletions Plugins/Flow.Launcher.Plugin.Calculator/Languages/en.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib">

<system:String x:Key="flowlauncher_plugin_caculator_plugin_name">Calculator</system:String>
<system:String x:Key="flowlauncher_plugin_caculator_plugin_description">Allows to do mathematical calculations.(Try 5*3-2 in Flow Launcher)</system:String>
Expand All @@ -13,4 +14,5 @@
<system:String x:Key="flowlauncher_plugin_calculator_decimal_seperator_comma">Comma (,)</system:String>
<system:String x:Key="flowlauncher_plugin_calculator_decimal_seperator_dot">Dot (.)</system:String>
<system:String x:Key="flowlauncher_plugin_calculator_max_decimal_places">Max. decimal places</system:String>
<system:String x:Key="flowlauncher_plugin_calculator_failed_to_copy">Copy failed, please try later</system:String>
</ResourceDictionary>
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public List<Result> Query(Query query)
}
catch (ExternalException)
{
Context.API.ShowMsgBox("Copy failed, please try later");
Context.API.ShowMsgBox(Context.API.GetTranslation("flowlauncher_plugin_calculator_failed_to_copy"));
return false;
}
}
Expand Down
Loading
Loading