@@ -1140,12 +1140,37 @@ public void openWallet(boolean forceSameWindow) {
11401140 AppServices .moveToActiveWindowScreen (window , 800 , 450 );
11411141 List <File > files = fileChooser .showOpenMultipleDialog (window );
11421142 if (files != null ) {
1143+ configureWalletsDir (files );
11431144 for (File file : files ) {
11441145 openWalletFile (file , forceSameWindow );
11451146 }
11461147 }
11471148 }
11481149
1150+ private static void configureWalletsDir (List <File > files ) {
1151+ List <File > parentDirs = files .stream ().map (File ::getParentFile ).distinct ().collect (Collectors .toList ());
1152+ if (parentDirs .size () == 1 && !Boolean .FALSE .equals (Config .get ().getSuggestChangeWalletsDir ())) {
1153+ File selectedDir = parentDirs .getFirst ();
1154+ boolean sameDir ;
1155+ try {
1156+ sameDir = Files .isSameFile (selectedDir .toPath (), Storage .getWalletsDir ().toPath ());
1157+ } catch (IOException e ) {
1158+ sameDir = selectedDir .toPath ().normalize ().equals (Storage .getWalletsDir ().toPath ().normalize ());
1159+ }
1160+ if (!sameDir ) {
1161+ ConfirmationAlert alert = new ConfirmationAlert ("Change wallets directory?" ,
1162+ "Do you want to configure Sparrow to use " + selectedDir + " as the default wallets directory?" , ButtonType .NO , ButtonType .YES );
1163+ Optional <ButtonType > optType = alert .showAndWait ();
1164+ if (optType .isPresent () && optType .get () == ButtonType .YES ) {
1165+ Config .get ().setWalletsDir (selectedDir );
1166+ Config .get ().setSuggestChangeWalletsDir (null );
1167+ } else if (alert .isDontAskAgain ()) {
1168+ Config .get ().setSuggestChangeWalletsDir (Boolean .FALSE );
1169+ }
1170+ }
1171+ }
1172+ }
1173+
11491174 public void openWalletFile (File file , boolean forceSameWindow ) {
11501175 try {
11511176 Storage storage = new Storage (file );
0 commit comments