33using System . Linq ;
44using System . Reflection ;
55using System . Windows ;
6- using CommunityToolkit . Mvvm . DependencyInjection ;
76using Flow . Launcher . Infrastructure ;
87using Flow . Launcher . Infrastructure . UserSettings ;
9- using Flow . Launcher . Plugin ;
108using Flow . Launcher . Plugin . SharedCommands ;
119using Microsoft . Win32 ;
1210using Squirrel ;
@@ -17,8 +15,6 @@ public class Portable : IPortable
1715 {
1816 private static readonly string ClassName = nameof ( Portable ) ;
1917
20- private readonly IPublicAPI API = Ioc . Default . GetRequiredService < IPublicAPI > ( ) ;
21-
2218 /// <summary>
2319 /// As at Squirrel.Windows version 1.5.2, UpdateManager needs to be disposed after finish
2420 /// </summary>
@@ -45,13 +41,13 @@ public void DisablePortableMode()
4541#endif
4642 IndicateDeletion ( DataLocation . PortableDataPath ) ;
4743
48- API . ShowMsgBox ( API . GetTranslation ( " restartToDisablePortableMode" ) ) ;
44+ PublicApi . Instance . ShowMsgBox ( Localize . restartToDisablePortableMode ( ) ) ;
4945
5046 UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
5147 }
5248 catch ( Exception e )
5349 {
54- API . LogException ( ClassName , "Error occurred while disabling portable mode" , e ) ;
50+ PublicApi . Instance . LogException ( ClassName , "Error occurred while disabling portable mode" , e ) ;
5551 }
5652 }
5753
@@ -68,13 +64,13 @@ public void EnablePortableMode()
6864#endif
6965 IndicateDeletion ( DataLocation . RoamingDataPath ) ;
7066
71- API . ShowMsgBox ( API . GetTranslation ( " restartToEnablePortableMode" ) ) ;
67+ PublicApi . Instance . ShowMsgBox ( Localize . restartToEnablePortableMode ( ) ) ;
7268
7369 UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
7470 }
7571 catch ( Exception e )
7672 {
77- API . LogException ( ClassName , "Error occurred while enabling portable mode" , e ) ;
73+ PublicApi . Instance . LogException ( ClassName , "Error occurred while enabling portable mode" , e ) ;
7874 }
7975 }
8076
@@ -94,13 +90,13 @@ public void RemoveUninstallerEntry()
9490
9591 public void MoveUserDataFolder ( string fromLocation , string toLocation )
9692 {
97- FilesFolders . CopyAll ( fromLocation , toLocation , ( s ) => API . ShowMsgBox ( s ) ) ;
93+ FilesFolders . CopyAll ( fromLocation , toLocation , ( s ) => PublicApi . Instance . ShowMsgBox ( s ) ) ;
9894 VerifyUserDataAfterMove ( fromLocation , toLocation ) ;
9995 }
10096
10197 public void VerifyUserDataAfterMove ( string fromLocation , string toLocation )
10298 {
103- FilesFolders . VerifyBothFolderFilesEqual ( fromLocation , toLocation , ( s ) => API . ShowMsgBox ( s ) ) ;
99+ FilesFolders . VerifyBothFolderFilesEqual ( fromLocation , toLocation , ( s ) => PublicApi . Instance . ShowMsgBox ( s ) ) ;
104100 }
105101
106102 public void CreateShortcuts ( )
@@ -150,12 +146,12 @@ public void PreStartCleanUpAfterPortabilityUpdate()
150146 // delete it and prompt the user to pick the portable data location
151147 if ( File . Exists ( roamingDataDeleteFilePath ) )
152148 {
153- FilesFolders . RemoveFolderIfExists ( roamingDataDir , ( s ) => API . ShowMsgBox ( s ) ) ;
149+ FilesFolders . RemoveFolderIfExists ( roamingDataDir , ( s ) => PublicApi . Instance . ShowMsgBox ( s ) ) ;
154150
155- if ( API . ShowMsgBox ( API . GetTranslation ( " moveToDifferentLocation" ) ,
151+ if ( PublicApi . Instance . ShowMsgBox ( Localize . moveToDifferentLocation ( ) ,
156152 string . Empty , MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
157153 {
158- FilesFolders . OpenPath ( Constant . RootDirectory , ( s ) => API . ShowMsgBox ( s ) ) ;
154+ FilesFolders . OpenPath ( Constant . RootDirectory , ( s ) => PublicApi . Instance . ShowMsgBox ( s ) ) ;
159155
160156 Environment . Exit ( 0 ) ;
161157 }
@@ -164,9 +160,9 @@ public void PreStartCleanUpAfterPortabilityUpdate()
164160 // delete it and notify the user about it.
165161 else if ( File . Exists ( portableDataDeleteFilePath ) )
166162 {
167- FilesFolders . RemoveFolderIfExists ( portableDataDir , ( s ) => API . ShowMsgBox ( s ) ) ;
163+ FilesFolders . RemoveFolderIfExists ( portableDataDir , ( s ) => PublicApi . Instance . ShowMsgBox ( s ) ) ;
168164
169- API . ShowMsgBox ( API . GetTranslation ( " shortcutsUninstallerCreated" ) ) ;
165+ PublicApi . Instance . ShowMsgBox ( Localize . shortcutsUninstallerCreated ( ) ) ;
170166 }
171167 }
172168
@@ -177,8 +173,7 @@ public bool CanUpdatePortability()
177173
178174 if ( roamingLocationExists && portableLocationExists )
179175 {
180- API . ShowMsgBox ( string . Format ( API . GetTranslation ( "userDataDuplicated" ) ,
181- DataLocation . PortableDataPath , DataLocation . RoamingDataPath , Environment . NewLine ) ) ;
176+ PublicApi . Instance . ShowMsgBox ( Localize . userDataDuplicated ( DataLocation . PortableDataPath , DataLocation . RoamingDataPath , Environment . NewLine ) ) ;
182177
183178 return false ;
184179 }
0 commit comments