Skip to content

Commit 5a66451

Browse files
authored
Make sure all constants are defined
1 parent 662a388 commit 5a66451

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilFS.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,11 @@ static Map<String, Object> getSystemfolders(ReactApplicationContext ctx) {
355355
} else {
356356
res.put("SDCardApplicationDir", "");
357357
}
358+
} else {
359+
res.put("SDCardDir", "");
360+
res.put("SDCardApplicationDir", "");
358361
}
362+
359363
res.put("MainBundleDir", ctx.getApplicationInfo().dataDir);
360364

361365
// TODO Change me with the correct path
@@ -376,7 +380,20 @@ static Map<String, Object> getSystemfolders(ReactApplicationContext ctx) {
376380
static Map<String, Object> getLegacySystemfolders(ReactApplicationContext ctx) {
377381
Map<String, Object> res = new HashMap<>();
378382

379-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) return ReactNativeBlobUtilFS.getSystemfolders(ctx);
383+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
384+
res = ReactNativeBlobUtilFS.getSystemfolders(ctx);
385+
386+
// Include legacy folders anyway, since on the new arch compatibility between the spec and the turbomodule is enforced
387+
res.put("LegacyDCIMDir", "");
388+
res.put("LegacyPictureDir", "");
389+
res.put("LegacyMusicDir", "");
390+
res.put("LegacyDownloadDir", "");
391+
res.put("LegacyMovieDir", "");
392+
res.put("LegacyRingtoneDir", "");
393+
res.put("LegacySDCardDir", "");
394+
395+
return res;
396+
}
380397

381398
res.put("LegacyDCIMDir", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath());
382399
res.put("LegacyPictureDir", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath());
@@ -388,6 +405,8 @@ static Map<String, Object> getLegacySystemfolders(ReactApplicationContext ctx) {
388405
String state = Environment.getExternalStorageState();
389406
if (state.equals(Environment.MEDIA_MOUNTED)) {
390407
res.put("LegacySDCardDir", Environment.getExternalStorageDirectory().getAbsolutePath());
408+
} else {
409+
res.put("LegacySDCardDir", "");
391410
}
392411

393412
return res;

0 commit comments

Comments
 (0)