88
99import java .io .File ;
1010import java .util .ArrayList ;
11+ import java .util .Arrays ;
1112import java .util .TreeSet ;
1213
1314public class Settings {
@@ -38,7 +39,7 @@ public static void SaveGlobals(Activity activity) {
3839
3940 private static void setupCurrentDirectory () {
4041 if (Globals .CurrentDirectoryPathForLauncher != null ) {
41- if (Globals .CurrentDirectoryPathForLauncher .equals ( "" )) {
42+ if (Globals .CurrentDirectoryPathForLauncher .isEmpty ( )) {
4243 Globals .CurrentDirectoryPathForLauncher = null ;
4344 } else {
4445 File file = new File (Globals .CurrentDirectoryPathForLauncher );
@@ -51,58 +52,63 @@ private static void setupCurrentDirectory() {
5152 ArrayList <String > arrayList = new ArrayList <>();
5253 TreeSet <String > treeSet = new TreeSet <>();
5354 TreeSet <String > validDirectory = new TreeSet <>();
55+ validDirectory .add (Environment .getExternalStorageDirectory ().getAbsolutePath ());
56+ for (String inlineSd : Globals .FallbackDirectoryPathArray ) {
57+ File inlineSdF = new File (inlineSd );
58+ if (inlineSdF .exists () && inlineSdF .isDirectory () && inlineSdF .canRead ()) {
59+ validDirectory .add (inlineSd );
60+ }
61+ }
62+ TreeSet <String > validEnvDirectory = new TreeSet <>();
63+ String str2 = System .getenv ("EXTERNAL_STORAGE" );
64+ if (str2 != null ) {
65+ validEnvDirectory .add (str2 );
66+ }
67+ String str3 = System .getenv ("EXTERNAL_STORAGE2" );
68+ if (str3 != null ) {
69+ validEnvDirectory .add (str3 );
70+ }
71+ String str4 = System .getenv ("EXTERNAL_ALT_STORAGE" );
72+ if (str4 != null ) {
73+ validEnvDirectory .add (str4 );
74+ }
75+ String str5 = System .getenv ("SECOND_VOLUME_STORAGE" );
76+ if (str5 != null ) {
77+ validEnvDirectory .add (str5 );
78+ }
79+ String str6 = System .getenv ("THIRD_VOLUME_STORAGE" );
80+ if (str6 != null ) {
81+ validEnvDirectory .add (str6 );
82+ }
83+ String str7 = System .getenv ("SECONDARY_STORAGE" );
84+ if (str7 != null ) {
85+ validEnvDirectory .add (str7 );
86+ }
87+ String str8 = System .getenv ("EXTERNAL_STORAGE_ALL" );
88+ if (str8 != null ) {
89+ validEnvDirectory .addAll (Arrays .asList (str8 .split (";" )));
90+ }
91+
5492 for (String str : Globals .CURRENT_DIRECTORY_PATH_TEMPLATE_ARRAY ) {
5593 if (!str .contains ("${SDCARD}" )) {
5694 treeSet .add (str );
5795 } else {
5896 treeSet .add (str .replace ("${SDCARD}" , Environment .getExternalStorageDirectory ().getAbsolutePath ()));
59- validDirectory .add (Environment .getExternalStorageDirectory ().getAbsolutePath ());
60- for (String inlineSd : Globals .FallbackDirectoryPathArray ) {
61- File inlineSdF = new File (inlineSd );
62- if (inlineSdF .exists () && inlineSdF .isDirectory () && inlineSdF .canRead ()) {
63- treeSet .add (str .replace ("${SDCARD}" , inlineSd ));
64- validDirectory .add (inlineSd );
65- }
66- }
67- String str2 = System .getenv ("EXTERNAL_STORAGE" );
68- if (str2 != null ) {
69- treeSet .add (str .replace ("${SDCARD}" , str2 ));
70- }
71- String str3 = System .getenv ("EXTERNAL_STORAGE2" );
72- if (str3 != null ) {
73- treeSet .add (str .replace ("${SDCARD}" , str3 ));
74- }
75- String str4 = System .getenv ("EXTERNAL_ALT_STORAGE" );
76- if (str4 != null ) {
77- treeSet .add (str .replace ("${SDCARD}" , str4 ));
97+ for (String inlineSd : validDirectory ) {
98+ treeSet .add (str .replace ("${SDCARD}" , inlineSd ));
7899 }
79- String str5 = System .getenv ("SECOND_VOLUME_STORAGE" );
80- if (str5 != null ) {
81- treeSet .add (str .replace ("${SDCARD}" , str5 ));
82- }
83- String str6 = System .getenv ("THIRD_VOLUME_STORAGE" );
84- if (str6 != null ) {
85- treeSet .add (str .replace ("${SDCARD}" , str6 ));
86- }
87- String str7 = System .getenv ("SECONDARY_STORAGE" );
88- if (str7 != null ) {
89- treeSet .add (str .replace ("${SDCARD}" , str7 ));
90- }
91- String str8 = System .getenv ("EXTERNAL_STORAGE_ALL" );
92- if (str8 != null ) {
93- for (String str9 : str8 .split (";" )) {
94- treeSet .add (str .replace ("${SDCARD}" , str9 ));
95- }
100+ for (String envSd : validEnvDirectory ) {
101+ treeSet .add (str .replace ("${SDCARD}" , envSd ));
96102 }
97103 }
98104 for (String s : treeSet ) {
99105 File file2 = new File (s );
100106 if (file2 .exists () && file2 .isDirectory () && file2 .canRead () && file2 .canWrite ()) {
101107 String absolutePath = file2 .getAbsolutePath ();
102- if (Globals .CurrentDirectoryPathForLauncher == null || Globals .CurrentDirectoryPathForLauncher .equals ( "" )) {
108+ if (Globals .CurrentDirectoryPathForLauncher == null || Globals .CurrentDirectoryPathForLauncher .isEmpty ( )) {
103109 Globals .CurrentDirectoryPathForLauncher = absolutePath ;
104110 }
105- if (Globals .CurrentDirectoryPath == null || Globals .CurrentDirectoryPath .equals ( "" )) {
111+ if (Globals .CurrentDirectoryPath == null || Globals .CurrentDirectoryPath .isEmpty ( )) {
106112 Globals .CurrentDirectoryPath = absolutePath ;
107113 }
108114 arrayList .add (absolutePath );
0 commit comments