From a66fbf33648523539bc8844101db59f13f896e08 Mon Sep 17 00:00:00 2001 From: alexytomi <60690056+alexytomi@users.noreply.github.com> Date: Sat, 24 May 2025 07:25:02 +0800 Subject: [PATCH] add[Settings/JVM]: Add switch to revert to old "Execute a .jar" behaviour Some edge cases, like jars that try to gracefully handle users using the wrong Java version with a Swing pop-up, cause the Java version detection to give the wrong result because the pop-up is made for Java 8. This adds a switch to override that behaviour with the old one, from before https://github.com/AngelAuraMC/Amethyst-Android/commit/3b1ad643427a21fea527e7252764f3c94d97c973, which simply used the default runtime selected by the user. --- .../net/kdt/pojavlaunch/JavaGUILauncherActivity.java | 6 ++++-- .../screens/LauncherPreferenceJavaFragment.java | 12 ++++++++++++ app_pojavlauncher/src/main/res/xml/pref_java.xml | 6 ++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java index 6db1ccbf2..6374c22fc 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java @@ -1,5 +1,7 @@ package net.kdt.pojavlaunch; +import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF; + import android.annotation.SuppressLint; import android.app.ProgressDialog; import android.content.ClipboardManager; @@ -242,8 +244,8 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc selectedMod = findModPath(argList); } Runtime selectedRuntime; - if(selectedMod == null) { - // We were unable to find out the path to the mod. In that case, use the default runtime. + if(selectedMod == null || DEFAULT_PREF.getBoolean("disable_autojre_select", false)) { + // If we are unable to find out the path to the mod or the user explicitly desires so, we use the default runtime selectedRuntime = MultiRTUtils.forceReread(LauncherPreferences.PREF_DEFAULT_RUNTIME); }else { // Autoselect it properly in the other case. diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceJavaFragment.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceJavaFragment.java index 975ec8e08..344630cdf 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceJavaFragment.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceJavaFragment.java @@ -7,7 +7,10 @@ import android.os.Bundle; import android.widget.TextView; import androidx.activity.result.ActivityResultLauncher; +import androidx.annotation.Nullable; import androidx.preference.EditTextPreference; +import androidx.preference.Preference; +import androidx.preference.SwitchPreference; import net.kdt.pojavlaunch.R; import net.kdt.pojavlaunch.Tools; @@ -18,11 +21,20 @@ import net.kdt.pojavlaunch.prefs.LauncherPreferences; public class LauncherPreferenceJavaFragment extends LauncherPreferenceFragment { private MultiRTConfigDialog mDialogScreen; + private SwitchPreference mSwitchAutoJRE; private final ActivityResultLauncher mVmInstallLauncher = registerForActivityResult(new OpenDocumentWithExtension("xz"), (data)->{ if(data != null) Tools.installRuntimeFromUri(getContext(), data); }); + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mSwitchAutoJRE = findPreference("disable_autojre_select"); + mSwitchAutoJRE.setSummary("Stops automatic selection of which runtime to use in \"" + getString(R.string.main_install_jar_file) + "\""); + + } + @Override public void onCreatePreferences(Bundle b, String str) { int ramAllocation = LauncherPreferences.PREF_RAM_ALLOCATION; diff --git a/app_pojavlauncher/src/main/res/xml/pref_java.xml b/app_pojavlauncher/src/main/res/xml/pref_java.xml index 6a23c06ff..d688688b2 100644 --- a/app_pojavlauncher/src/main/res/xml/pref_java.xml +++ b/app_pojavlauncher/src/main/res/xml/pref_java.xml @@ -29,6 +29,12 @@ app2:seekBarIncrement="@integer/memory_seekbar_increment" app2:selectable="false"/> + +