Skip to content

Commit c6ba54c

Browse files
add[Settings/JVM]: Add switch to revert to old "Execute a .jar" behaviour (#8)
2 parents a786497 + a66fbf3 commit c6ba54c

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/JavaGUILauncherActivity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.kdt.pojavlaunch;
22

3+
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF;
4+
35
import android.annotation.SuppressLint;
46
import android.app.ProgressDialog;
57
import android.content.ClipboardManager;
@@ -242,8 +244,8 @@ private void startModInstaller(File modFile, String javaArgs) {
242244
selectedMod = findModPath(argList);
243245
}
244246
Runtime selectedRuntime;
245-
if(selectedMod == null) {
246-
// We were unable to find out the path to the mod. In that case, use the default runtime.
247+
if(selectedMod == null || DEFAULT_PREF.getBoolean("disable_autojre_select", false)) {
248+
// If we are unable to find out the path to the mod or the user explicitly desires so, we use the default runtime
247249
selectedRuntime = MultiRTUtils.forceReread(LauncherPreferences.PREF_DEFAULT_RUNTIME);
248250
}else {
249251
// Autoselect it properly in the other case.

app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/prefs/screens/LauncherPreferenceJavaFragment.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import android.widget.TextView;
88

99
import androidx.activity.result.ActivityResultLauncher;
10+
import androidx.annotation.Nullable;
1011
import androidx.preference.EditTextPreference;
12+
import androidx.preference.Preference;
13+
import androidx.preference.SwitchPreference;
1114

1215
import net.kdt.pojavlaunch.R;
1316
import net.kdt.pojavlaunch.Tools;
@@ -18,11 +21,20 @@
1821

1922
public class LauncherPreferenceJavaFragment extends LauncherPreferenceFragment {
2023
private MultiRTConfigDialog mDialogScreen;
24+
private SwitchPreference mSwitchAutoJRE;
2125
private final ActivityResultLauncher<Object> mVmInstallLauncher =
2226
registerForActivityResult(new OpenDocumentWithExtension("xz"), (data)->{
2327
if(data != null) Tools.installRuntimeFromUri(getContext(), data);
2428
});
2529

30+
@Override
31+
public void onCreate(@Nullable Bundle savedInstanceState) {
32+
super.onCreate(savedInstanceState);
33+
mSwitchAutoJRE = findPreference("disable_autojre_select");
34+
mSwitchAutoJRE.setSummary("Stops automatic selection of which runtime to use in \"" + getString(R.string.main_install_jar_file) + "\"");
35+
36+
}
37+
2638
@Override
2739
public void onCreatePreferences(Bundle b, String str) {
2840
int ramAllocation = LauncherPreferences.PREF_RAM_ALLOCATION;

app_pojavlauncher/src/main/res/xml/pref_java.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
app2:seekBarIncrement="@integer/memory_seekbar_increment"
3030
app2:selectable="false"/>
3131

32+
<SwitchPreference
33+
android:defaultValue="false"
34+
android:key="disable_autojre_select"
35+
android:title="Disable automatic JRE selection"
36+
/>
37+
3238
<SwitchPreference
3339
android:defaultValue="true"
3440
android:key="java_sandbox"

0 commit comments

Comments
 (0)