Skip to content

Commit 88e8437

Browse files
committed
Use api in app extensions to call api functions
1 parent 8b91050 commit 88e8437

File tree

10 files changed

+26
-26
lines changed

10 files changed

+26
-26
lines changed

Flow.Launcher.Core/Configuration/Portable.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void DisablePortableMode()
4040
#endif
4141
IndicateDeletion(DataLocation.PortableDataPath);
4242

43-
MessageBoxEx.Show("Flow Launcher needs to restart to finish disabling portable mode, " +
43+
AppExtensions.API.ShowMsgBox("Flow Launcher needs to restart to finish disabling portable mode, " +
4444
"after the restart your portable data profile will be deleted and roaming data profile kept");
4545

4646
UpdateManager.RestartApp(Constant.ApplicationFileName);
@@ -64,7 +64,7 @@ public void EnablePortableMode()
6464
#endif
6565
IndicateDeletion(DataLocation.RoamingDataPath);
6666

67-
MessageBoxEx.Show("Flow Launcher needs to restart to finish enabling portable mode, " +
67+
AppExtensions.API.ShowMsgBox("Flow Launcher needs to restart to finish enabling portable mode, " +
6868
"after the restart your roaming data profile will be deleted and portable data profile kept");
6969

7070
UpdateManager.RestartApp(Constant.ApplicationFileName);
@@ -95,13 +95,13 @@ public void RemoveUninstallerEntry()
9595

9696
public void MoveUserDataFolder(string fromLocation, string toLocation)
9797
{
98-
FilesFolders.CopyAll(fromLocation, toLocation, MessageBoxEx.Show);
98+
FilesFolders.CopyAll(fromLocation, toLocation, (s) => AppExtensions.API.ShowMsgBox(s));
9999
VerifyUserDataAfterMove(fromLocation, toLocation);
100100
}
101101

102102
public void VerifyUserDataAfterMove(string fromLocation, string toLocation)
103103
{
104-
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation, MessageBoxEx.Show);
104+
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation, (s) => AppExtensions.API.ShowMsgBox(s));
105105
}
106106

107107
public void CreateShortcuts()
@@ -157,13 +157,13 @@ public void PreStartCleanUpAfterPortabilityUpdate()
157157
// delete it and prompt the user to pick the portable data location
158158
if (File.Exists(roamingDataDeleteFilePath))
159159
{
160-
FilesFolders.RemoveFolderIfExists(roamingDataDir, MessageBoxEx.Show);
160+
FilesFolders.RemoveFolderIfExists(roamingDataDir, (s) => AppExtensions.API.ShowMsgBox(s));
161161

162-
if (MessageBoxEx.Show("Flow Launcher has detected you enabled portable mode, " +
162+
if (AppExtensions.API.ShowMsgBox("Flow Launcher has detected you enabled portable mode, " +
163163
"would you like to move it to a different location?", string.Empty,
164164
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
165165
{
166-
FilesFolders.OpenPath(Constant.RootDirectory, MessageBoxEx.Show);
166+
FilesFolders.OpenPath(Constant.RootDirectory, (s) => AppExtensions.API.ShowMsgBox(s));
167167

168168
Environment.Exit(0);
169169
}
@@ -172,9 +172,9 @@ public void PreStartCleanUpAfterPortabilityUpdate()
172172
// delete it and notify the user about it.
173173
else if (File.Exists(portableDataDeleteFilePath))
174174
{
175-
FilesFolders.RemoveFolderIfExists(portableDataDir, MessageBoxEx.Show);
175+
FilesFolders.RemoveFolderIfExists(portableDataDir, (s) => AppExtensions.API.ShowMsgBox(s));
176176

177-
MessageBoxEx.Show("Flow Launcher has detected you disabled portable mode, " +
177+
AppExtensions.API.ShowMsgBox("Flow Launcher has detected you disabled portable mode, " +
178178
"the relevant shortcuts and uninstaller entry have been created");
179179
}
180180
}
@@ -186,7 +186,7 @@ public bool CanUpdatePortability()
186186

187187
if (roamingLocationExists && portableLocationExists)
188188
{
189-
MessageBoxEx.Show(string.Format("Flow Launcher detected your user data exists both in {0} and " +
189+
AppExtensions.API.ShowMsgBox(string.Format("Flow Launcher detected your user data exists both in {0} and " +
190190
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred.",
191191
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
192192

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ internal IEnumerable<PluginPair> Setup()
5757
EnvName,
5858
Environment.NewLine
5959
);
60-
if (MessageBoxEx.Show(noRuntimeMessage, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
60+
if (AppExtensions.API.ShowMsgBox(noRuntimeMessage, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
6161
{
6262
var msg = string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginChooseRuntimeExecutable"), EnvName);
6363
string selectedFile;
@@ -82,7 +82,7 @@ internal IEnumerable<PluginPair> Setup()
8282
}
8383
else
8484
{
85-
MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
85+
AppExtensions.API.ShowMsgBox(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
8686
Log.Error("PluginsLoader",
8787
$"Not able to successfully set {EnvName} path, setting's plugin executable path variable is still an empty string.",
8888
$"{Language}Environment");
@@ -98,7 +98,7 @@ private void EnsureLatestInstalled(string expectedPath, string currentPath, stri
9898
if (expectedPath == currentPath)
9999
return;
100100

101-
FilesFolders.RemoveFolderIfExists(installedDirPath, MessageBoxEx.Show);
101+
FilesFolders.RemoveFolderIfExists(installedDirPath, (s) => AppExtensions.API.ShowMsgBox(s));
102102

103103
InstallEnvironment();
104104

Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal PythonEnvironment(List<PluginMetadata> pluginMetadataList, PluginsSetti
2828

2929
internal override void InstallEnvironment()
3030
{
31-
FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
31+
FilesFolders.RemoveFolderIfExists(InstallPath, (s) => AppExtensions.API.ShowMsgBox(s));
3232

3333
// Python 3.11.4 is no longer Windows 7 compatible. If user is on Win 7 and
3434
// uses Python plugin they need to custom install and use v3.8.9

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal TypeScriptEnvironment(List<PluginMetadata> pluginMetadataList, PluginsS
2525

2626
internal override void InstallEnvironment()
2727
{
28-
FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
28+
FilesFolders.RemoveFolderIfExists(InstallPath, (s) => AppExtensions.API.ShowMsgBox(s));
2929

3030
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();
3131

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal TypeScriptV2Environment(List<PluginMetadata> pluginMetadataList, Plugin
2525

2626
internal override void InstallEnvironment()
2727
{
28-
FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
28+
FilesFolders.RemoveFolderIfExists(InstallPath, (s) => AppExtensions.API.ShowMsgBox(s));
2929

3030
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();
3131

Flow.Launcher.Core/Plugin/PluginManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ internal static void InstallPlugin(UserPlugin plugin, string zipFilePath, bool c
519519

520520
var newPluginPath = Path.Combine(installDirectory, folderName);
521521

522-
FilesFolders.CopyAll(pluginFolderPath, newPluginPath, MessageBoxEx.Show);
522+
FilesFolders.CopyAll(pluginFolderPath, newPluginPath, (s) => AppExtensions.API.ShowMsgBox(s));
523523

524524
Directory.Delete(tempFolderPluginPath, true);
525525

Flow.Launcher.Core/Plugin/PluginsLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
119119

120120
_ = Task.Run(() =>
121121
{
122-
MessageBoxEx.Show($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
122+
AppExtensions.API.ShowMsgBox($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
123123
$"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" +
124124
$"Please refer to the logs for more information", "",
125125
MessageBoxButton.OK, MessageBoxImage.Warning);

Flow.Launcher.Core/Resource/Internationalization.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public bool PromptShouldUsePinyin(string languageCodeToSet)
124124
// "Do you want to search with pinyin?"
125125
string text = languageToSet == AvailableLanguages.Chinese ? "是否启用拼音搜索?" : "是否啓用拼音搜索?" ;
126126

127-
if (MessageBoxEx.Show(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
127+
if (AppExtensions.API.ShowMsgBox(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
128128
return false;
129129

130130
return true;

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public bool ChangeTheme(string theme)
108108
Log.Error($"|Theme.ChangeTheme|Theme <{theme}> path can't be found");
109109
if (theme != defaultTheme)
110110
{
111-
MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme));
111+
AppExtensions.API.ShowMsgBox(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme));
112112
ChangeTheme(defaultTheme);
113113
}
114114
return false;
@@ -118,7 +118,7 @@ public bool ChangeTheme(string theme)
118118
Log.Error($"|Theme.ChangeTheme|Theme <{theme}> fail to parse");
119119
if (theme != defaultTheme)
120120
{
121-
MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme));
121+
AppExtensions.API.ShowMsgBox(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme));
122122
ChangeTheme(defaultTheme);
123123
}
124124
return false;

Flow.Launcher.Core/Updater.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
5353
if (newReleaseVersion <= currentVersion)
5454
{
5555
if (!silentUpdate)
56-
MessageBoxEx.Show(api.GetTranslation("update_flowlauncher_already_on_latest"));
56+
AppExtensions.API.ShowMsgBox(api.GetTranslation("update_flowlauncher_already_on_latest"));
5757
return;
5858
}
5959

@@ -68,9 +68,9 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
6868
if (DataLocation.PortableDataLocationInUse())
6969
{
7070
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
71-
FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination, MessageBoxEx.Show);
72-
if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination, MessageBoxEx.Show))
73-
MessageBoxEx.Show(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
71+
FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination, (s) => AppExtensions.API.ShowMsgBox(s));
72+
if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination, (s) => AppExtensions.API.ShowMsgBox(s)))
73+
AppExtensions.API.ShowMsgBox(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
7474
DataLocation.PortableDataPath,
7575
targetDestination));
7676
}
@@ -83,7 +83,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
8383

8484
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
8585

86-
if (MessageBoxEx.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
86+
if (AppExtensions.API.ShowMsgBox(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
8787
{
8888
UpdateManager.RestartApp(Constant.ApplicationFileName);
8989
}

0 commit comments

Comments
 (0)