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
3b1ad64342,
which simply used the default runtime selected by the user.
This commit is contained in:
alexytomi 2025-05-24 07:25:02 +08:00
parent 442bcdeebe
commit a66fbf3364
3 changed files with 22 additions and 2 deletions

View File

@ -1,5 +1,7 @@
package net.kdt.pojavlaunch; package net.kdt.pojavlaunch;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.ClipboardManager; import android.content.ClipboardManager;
@ -242,8 +244,8 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
selectedMod = findModPath(argList); selectedMod = findModPath(argList);
} }
Runtime selectedRuntime; Runtime selectedRuntime;
if(selectedMod == null) { if(selectedMod == null || DEFAULT_PREF.getBoolean("disable_autojre_select", false)) {
// We were unable to find out the path to the mod. In that case, use the default runtime. // 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); selectedRuntime = MultiRTUtils.forceReread(LauncherPreferences.PREF_DEFAULT_RUNTIME);
}else { }else {
// Autoselect it properly in the other case. // Autoselect it properly in the other case.

View File

@ -7,7 +7,10 @@ import android.os.Bundle;
import android.widget.TextView; import android.widget.TextView;
import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.Nullable;
import androidx.preference.EditTextPreference; import androidx.preference.EditTextPreference;
import androidx.preference.Preference;
import androidx.preference.SwitchPreference;
import net.kdt.pojavlaunch.R; import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools; import net.kdt.pojavlaunch.Tools;
@ -18,11 +21,20 @@ import net.kdt.pojavlaunch.prefs.LauncherPreferences;
public class LauncherPreferenceJavaFragment extends LauncherPreferenceFragment { public class LauncherPreferenceJavaFragment extends LauncherPreferenceFragment {
private MultiRTConfigDialog mDialogScreen; private MultiRTConfigDialog mDialogScreen;
private SwitchPreference mSwitchAutoJRE;
private final ActivityResultLauncher<Object> mVmInstallLauncher = private final ActivityResultLauncher<Object> mVmInstallLauncher =
registerForActivityResult(new OpenDocumentWithExtension("xz"), (data)->{ registerForActivityResult(new OpenDocumentWithExtension("xz"), (data)->{
if(data != null) Tools.installRuntimeFromUri(getContext(), 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 @Override
public void onCreatePreferences(Bundle b, String str) { public void onCreatePreferences(Bundle b, String str) {
int ramAllocation = LauncherPreferences.PREF_RAM_ALLOCATION; int ramAllocation = LauncherPreferences.PREF_RAM_ALLOCATION;

View File

@ -29,6 +29,12 @@
app2:seekBarIncrement="@integer/memory_seekbar_increment" app2:seekBarIncrement="@integer/memory_seekbar_increment"
app2:selectable="false"/> app2:selectable="false"/>
<SwitchPreference
android:defaultValue="false"
android:key="disable_autojre_select"
android:title="Disable automatic JRE selection"
/>
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="java_sandbox" android:key="java_sandbox"