From 91e202e0e34d780dc5dd8356d1e5366bf7bd7d96 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 23 Oct 2023 19:10:24 +0300 Subject: [PATCH 1/3] Ignore case when checking whether path is white-listed. Fixes data import with H3 data that has different case in directory names --- .../vcmi/vcmi/settings/CopyDataController.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CopyDataController.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CopyDataController.java index 9acf5e0a2..9b39f6e78 100644 --- a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CopyDataController.java +++ b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CopyDataController.java @@ -127,9 +127,21 @@ public class CopyDataController extends LauncherSettingController for (DocumentFile child : sourceDir.listFiles()) { - if (allowed != null && !allowed.contains(child.getName())) + if (allowed != null) { - continue; + boolean fileAllowed = false; + + for (String str : allowed) + { + if (str.equalsIgnoreCase(child.getName())) + { + fileAllowed = true; + break; + } + } + + if (fileAllowed) + continue; } File exported = new File(targetDir, child.getName()); From 7dfdee2db80649440802566c53cc5d7a18a9bed5 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 23 Oct 2023 19:17:58 +0300 Subject: [PATCH 2/3] Check whether H3 data has been imported using most common spellings of data directory --- android/vcmi-app/src/main/java/eu/vcmi/vcmi/Storage.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/Storage.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/Storage.java index 9986f890e..b3fc1b9db 100644 --- a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/Storage.java +++ b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/Storage.java @@ -22,7 +22,9 @@ public class Storage public static boolean testH3DataFolder(final File baseDir) { final File testH3Data = new File(baseDir, "Data"); - return testH3Data.exists(); + final File testH3data = new File(baseDir, "data"); + final File testH3DATA = new File(baseDir, "DATA"); + return testH3Data.exists() || testH3data.exists() || testH3DATA.exists(); } public static String getH3DataFolder(Context context){ From 2315ea84ec7fe7eb061af0c696f0ede61db861bb Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 23 Oct 2023 22:18:21 +0300 Subject: [PATCH 3/3] Invert condition --- .../src/main/java/eu/vcmi/vcmi/settings/CopyDataController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CopyDataController.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CopyDataController.java index 9b39f6e78..2d5396d88 100644 --- a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CopyDataController.java +++ b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CopyDataController.java @@ -140,7 +140,7 @@ public class CopyDataController extends LauncherSettingController } } - if (fileAllowed) + if (!fileAllowed) continue; }