From 219586341b01c5b67b582bd5e0c37772a05599ca Mon Sep 17 00:00:00 2001 From: zeromake Date: Thu, 23 May 2024 00:19:29 +0800 Subject: [PATCH] fix: android support more sd path --- .../java/com/zeromake/onscripter/Globals.java | 20 +++++----- .../com/zeromake/onscripter/MainActivity.java | 7 +++- .../com/zeromake/onscripter/Settings.java | 4 ++ .../main/java/org/libsdl/app/SDLActivity.java | 2 +- project/android/gradle.properties | 7 +++- project/android/settings.gradle.kts | 38 +++++++++---------- 6 files changed, 46 insertions(+), 32 deletions(-) diff --git a/project/android/app/src/main/java/com/zeromake/onscripter/Globals.java b/project/android/app/src/main/java/com/zeromake/onscripter/Globals.java index 3370059..99e6bcf 100644 --- a/project/android/app/src/main/java/com/zeromake/onscripter/Globals.java +++ b/project/android/app/src/main/java/com/zeromake/onscripter/Globals.java @@ -1,10 +1,10 @@ -package com.zeromake.onscripter; - -public class Globals { - public static String CurrentDirectoryPathForLauncher = null; - public static String CurrentDirectoryPath = null; - public static String[] CurrentDirectoryPathArray = null; - public static String[] CurrentDirectoryValidPathArray = null; - public static final String[] CURRENT_DIRECTORY_PATH_TEMPLATE_ARRAY = new String[]{"${SDCARD}/mine", "${SDCARD}/ons"}; - public static boolean CurrentGameRunning = false; -} +package com.zeromake.onscripter; + +public class Globals { + public static String CurrentDirectoryPathForLauncher = null; + public static String CurrentDirectoryPath = null; + public static String[] CurrentDirectoryPathArray = null; + public static String[] CurrentDirectoryValidPathArray = null; + public static final String[] CURRENT_DIRECTORY_PATH_TEMPLATE_ARRAY = new String[]{"${SDCARD}/mine", "${SDCARD}/ons"}; + public static boolean CurrentGameRunning = false; +} diff --git a/project/android/app/src/main/java/com/zeromake/onscripter/MainActivity.java b/project/android/app/src/main/java/com/zeromake/onscripter/MainActivity.java index fb403db..3d63e44 100644 --- a/project/android/app/src/main/java/com/zeromake/onscripter/MainActivity.java +++ b/project/android/app/src/main/java/com/zeromake/onscripter/MainActivity.java @@ -230,7 +230,12 @@ public void onClick(DialogInterface dialogInterface, int i) { loadCurrentDirectory(); return; } else if (Globals.CurrentDirectoryPathForLauncher == null || Globals.CurrentDirectoryPathForLauncher.equals("")) { - this.mDirBrowserCurDirPath = "/mnt"; + File f = new File("/storage"); + if (f.exists() && f.isDirectory() && f.canRead()) { + this.mDirBrowserCurDirPath = "/storage"; + } else { + this.mDirBrowserCurDirPath = "/mnt"; + } } else { this.mDirBrowserCurDirPath = Globals.CurrentDirectoryPathForLauncher; } diff --git a/project/android/app/src/main/java/com/zeromake/onscripter/Settings.java b/project/android/app/src/main/java/com/zeromake/onscripter/Settings.java index dce77da..93f60e0 100644 --- a/project/android/app/src/main/java/com/zeromake/onscripter/Settings.java +++ b/project/android/app/src/main/java/com/zeromake/onscripter/Settings.java @@ -66,7 +66,11 @@ private static void setupCurrentDirectory() { treeSet.add(str.replace("${SDCARD}", "/sdcard")); treeSet.add(str.replace("${SDCARD}", "/sdcard/sd")); treeSet.add(str.replace("${SDCARD}", "/storage/sdcard")); + treeSet.add(str.replace("${SDCARD}", "/storage/sdcard0")); + treeSet.add(str.replace("${SDCARD}", "/storage/sdcard1")); treeSet.add(str.replace("${SDCARD}", "/storage/emulated/0")); + treeSet.add(str.replace("${SDCARD}", "/storage/emulated/legacy")); + treeSet.add(str.replace("${SDCARD}", "/storage/usb0")); String str2 = System.getenv("EXTERNAL_STORAGE"); if (str2 != null) { treeSet.add(str.replace("${SDCARD}", str2)); diff --git a/project/android/app/src/main/java/org/libsdl/app/SDLActivity.java b/project/android/app/src/main/java/org/libsdl/app/SDLActivity.java index 7cbf9d3..d762e4e 100644 --- a/project/android/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/project/android/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh private static final String TAG = "SDL"; private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MINOR_VERSION = 30; - private static final int SDL_MICRO_VERSION = 2; + private static final int SDL_MICRO_VERSION = 3; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/project/android/gradle.properties b/project/android/gradle.properties index 06f4dd4..69ccf9f 100644 --- a/project/android/gradle.properties +++ b/project/android/gradle.properties @@ -19,4 +19,9 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects org.gradle.parallel=true -org.gradle.unsafe.configuration-cache=true \ No newline at end of file +org.gradle.unsafe.configuration-cache=true + +# systemProp.http.proxyHost=127.0.0.1 +# systemProp.http.proxyPort=10808 +# systemProp.https.proxyHost=127.0.0.1 +# systemProp.https.proxyPort=10808 diff --git a/project/android/settings.gradle.kts b/project/android/settings.gradle.kts index d995f82..a76d50c 100644 --- a/project/android/settings.gradle.kts +++ b/project/android/settings.gradle.kts @@ -1,19 +1,19 @@ -pluginManagement { - repositories { - google() - mavenCentral() - gradlePluginPortal() - } -} -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } -} -rootProject.name = "onscripter" -rootProject.buildFileName = "build.gradle.kts" - -include(":app") -include(":XXPermissions") +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} +rootProject.name = "onscripter" +rootProject.buildFileName = "build.gradle.kts" + +include(":app") +include(":XXPermissions")