Skip to content

Commit 7fcc886

Browse files
committed
ANDROID: make home folder location available from any path
1 parent bfe3162 commit 7fcc886

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

src/platform/android/app/src/main/assets/main.bas

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const scratch_file = HOME + "/scratch.bas"
3737

3838
func mk_bn(value, lab, fg)
3939
local bn
40-
bn.x = 2
40+
bn.x = 3
4141
bn.y = -lineSpacing
4242
bn.value = value
4343
bn.label = lab
@@ -331,24 +331,26 @@ sub listFiles(byref frm, path, sortDir, byref basList)
331331
date_col = colNav2
332332
end select
333333

334+
sub mk_label(labText, labCol)
335+
bn = mk_bn(0, labText, labCol)
336+
bn.type = "label"
337+
frm.inputs << bn
338+
end
339+
334340
if (is_android) then
335341
pathx = mid(path, 1, len(path) - 1)
336342
if (pathx == env("LEGACY_DIR")) then
337-
bn = mk_bn(0, "SmallBASIC legacy project files", colText2)
343+
mk_label("SmallBASIC legacy project files", colText2)
338344
elseif (pathx == env("INTERNAL_DIR")) then
339-
bn = mk_bn(0, "Temporary files", colText2)
345+
mk_label("Temporary files", colText2)
340346
elseif (pathx == env("EXTERNAL_DIR")) then
341-
bn = mk_bn(0, "SmallBASIC project files", colText)
347+
mk_label("SmallBASIC project files", colText)
342348
else
343-
bn = mk_bn(0, "Files in " + path, colText)
349+
mk_label("Files in " + path, colText)
344350
endif
345351
else
346-
bn = mk_bn(0, "Files in " + path, colText)
352+
mk_label("Files in " + path, colText)
347353
endif
348-
bn.type = "label"
349-
bn.x = 0
350-
bn.y = -lineSpacing
351-
frm.inputs << bn
352354

353355
bn = mk_bn(backId, "[Go up]", colNav)
354356
bn.type = "link"
@@ -377,6 +379,17 @@ sub listFiles(byref frm, path, sortDir, byref basList)
377379
frm.inputs << bn
378380
endif
379381

382+
if (is_android && pathx != env("EXTERNAL_DIR")) then
383+
bn = mk_bn(env("EXTERNAL_DIR"), "SmallBASIC project files", colDir)
384+
bn.type = "link"
385+
frm.inputs << bn
386+
bn = mk_bn(0, datefmt("YYYY-MM-DD", date), colText)
387+
bn.type = "label"
388+
bn.x = txtw(" ") * 41
389+
bn.y = -1
390+
frm.inputs << bn
391+
endif
392+
380393
lastItem = len(basList) - 1
381394
for i = 0 to lastItem
382395
node = basList(i)

src/platform/android/app/src/main/java/net/sourceforge/smallbasic/MainActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,12 +882,11 @@ public boolean accept(File dir, String name) {
882882
};
883883
File[] toFiles = toDir.listFiles(filter);
884884
File[] fromFiles = fromDir.listFiles(filter);
885-
if ((toFiles == null || toFiles.length == 0) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
885+
if (fromFiles != null && (toFiles == null || toFiles.length == 0)) {
886886
// only attempt file copy into a clean destination folder
887887
for (File file : fromFiles) {
888888
try {
889-
Path to = toDir.toPath().resolve(file.getName());
890-
Files.copy(file.toPath(), to);
889+
copy(file, new File(toDir, file.getName()));
891890
} catch (IOException e) {
892891
Log.d(TAG, "failed to copy: ", e);
893892
}

0 commit comments

Comments
 (0)