version option

This commit is contained in:
khanhduytran0 2020-04-16 10:46:27 +07:00
parent 8f62e43f69
commit d37c4ff464
4 changed files with 113 additions and 33 deletions

View File

@ -1,14 +1,15 @@
package net.kdt.pojavlaunch.prefs;
import net.kdt.pojavlaunch.*;
import android.os.*;
import android.support.v7.app.*;
import android.widget.*;
import android.content.*;
import com.pojavdx.dex.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import android.widget.CompoundButton.*;
import com.kdt.mcgui.app.*;
import com.pojavdx.dex.*;
import net.kdt.pojavlaunch.*;
public class PojavPreferenceActivity extends MineActivity
public class PojavPreferenceActivity extends MineActivity implements OnCheckedChangeListener
{
public static boolean PREF_FREEFORM = false;
public static boolean PREF_FORGETOF = false;
@ -17,6 +18,7 @@ public class PojavPreferenceActivity extends MineActivity
private SeekBar viewSeekDxRef, viewSeekControlSize;
private TextView viewSeekProgressDxRef, viewSeekProgressControl;
private Switch viewSwitchFreeform, viewSwitchForgetOF;
private CheckBox viewCheckVTypeRelease, viewCheckVTypeSnapshot, viewCheckVTypeOldAlpha, viewCheckVTypeOldBeta;
private SharedPreferences mainPreference;
@Override
@ -36,8 +38,8 @@ public class PojavPreferenceActivity extends MineActivity
final SharedPreferences.Editor mainPrefEdit = mainPreference.edit();
// DX Refs
viewSeekDxRef = (SeekBar) findViewById(R.id.settings_seekbar_setmaxdxref);
viewSeekProgressDxRef = (TextView) findViewById(R.id.setting_progressseek_maxdxref);
viewSeekDxRef = (SeekBar) findView(R.id.settings_seekbar_setmaxdxref);
viewSeekProgressDxRef = (TextView) findView(R.id.setting_progressseek_maxdxref);
viewSeekDxRef.setMax(0xFFFF - 0xFFF);
viewSeekDxRef.setProgress(DexFormat.MAX_MEMBER_IDX - 0xFFF);
viewSeekDxRef.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
@ -62,8 +64,8 @@ public class PojavPreferenceActivity extends MineActivity
viewSeekProgressDxRef.setText((viewSeekDxRef.getProgress() + 0xFFF) + "/" + 0xFFFF);
// Control size
viewSeekControlSize = (SeekBar) findViewById(R.id.settings_seekbar_controlsize);
viewSeekProgressControl = (TextView) findViewById(R.id.setting_progressseek_control);
viewSeekControlSize = (SeekBar) findView(R.id.settings_seekbar_controlsize);
viewSeekProgressControl = (TextView) findView(R.id.setting_progressseek_control);
viewSeekControlSize.setMax(200);
viewSeekControlSize.setProgress((int) (PREF_BUTTONSIZE * 100));
viewSeekControlSize.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){
@ -90,39 +92,62 @@ public class PojavPreferenceActivity extends MineActivity
viewSeekProgressControl.setText(((float) viewSeekControlSize.getProgress() / 100f) + "/2");
// Freeform mode
viewSwitchFreeform = (Switch) findViewById(R.id.settings_switch_enablefreeform);
viewSwitchFreeform.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton b, boolean z)
{
mainPrefEdit.putBoolean("freeform", z);
mainPrefEdit.commit();
}
});
viewSwitchFreeform = (Switch) findView(R.id.settings_switch_enablefreeform);
viewSwitchFreeform.setChecked(PREF_FREEFORM);
viewSwitchFreeform.setEnabled(Build.VERSION.SDK_INT >= 24);
// Forget OptiFine path
viewSwitchForgetOF = (Switch) findViewById(R.id.settings_switch_forgetoptifpath);
viewSwitchForgetOF.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton b, boolean z)
{
mainPrefEdit.putBoolean("forgetOptifinePath", z);
mainPrefEdit.commit();
}
});
viewSwitchForgetOF = (Switch) findView(R.id.settings_switch_forgetoptifpath);
viewSwitchForgetOF.setChecked(PREF_FORGETOF);
viewCheckVTypeRelease = (CheckBox) findView(R.id.settings_checkbox_vertype_release);
viewCheckVTypeSnapshot = (CheckBox) findView(R.id.settings_checkbox_vertype_snapshot);
viewCheckVTypeOldAlpha = (CheckBox) findView(R.id.settings_checkbox_vertype_oldalpha);
viewCheckVTypeOldBeta = (CheckBox) findView(R.id.settings_checkbox_vertype_oldbeta);
}
@Override
public void onBackPressed()
{
public void onBackPressed() {
super.onBackPressed();
PojavPreferenceActivity.loadPreferences(this);
}
@Override
public void onCheckedChanged(CompoundButton btn, boolean isChecked) {
String prefName = null;
switch (btn.getId()) {
case R.id.settings_switch_enablefreeform:
prefName = "freeform";
break;
case R.id.settings_switch_forgetoptifpath:
prefName = "forgetOptifinePath";
break;
case R.id.settings_checkbox_vertype_release:
prefName = "vertype_release";
break;
case R.id.settings_checkbox_vertype_snapshot:
prefName = "vertype_snapshot";
break;
case R.id.settings_checkbox_vertype_oldalpha:
prefName = "vertype_oldalpha";
break;
case R.id.settings_checkbox_vertype_oldbeta:
prefName = "vertype_oldbeta";
break;
}
mainPreference.edit()
.putBoolean(prefName, isChecked)
.commit();
}
public View findView(int id) {
View view = findView(id);
if (view instanceof CompoundButton) {
((CompoundButton) view).setOnCheckedChangeListener(this);
}
return view;
}
public static void loadPreferences(Context ctx) {
SharedPreferences mainPreference = ctx.getSharedPreferences("pojav_preferences", MODE_PRIVATE);

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#F1EDEC"
android:layout_height="match_parent"
android:layout_width="match_parent">
@ -9,7 +10,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#F1EDEC"
android:paddingLeft="25dp"
android:paddingRight="25dp">

View File

@ -137,6 +137,56 @@
android:layout_height="2dp"
android:layout_width="match_parent"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_margin="10dp">
<TextView
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:text="@string/mcl_setting_title_veroption"
android:textStyle="bold"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal">
<CheckBox
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/mcl_setting_veroption_release"
android:layout_weight="1.0"
android:id="@+id/settings_checkbox_vertype_release"/>
<CheckBox
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/mcl_setting_veroption_snapshot"
android:layout_weight="1.0"
android:id="@+id/settings_checkbox_vertype_snapshot"/>
<CheckBox
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/mcl_setting_veroption_oldalpha"
android:layout_weight="1.0"
android:id="@+id/settings_checkbox_vertype_oldalpha"/>
<CheckBox
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/mcl_setting_veroption_oldbeta"
android:layout_weight="1.0"
android:id="@+id/settings_checkbox_vertype_oldbeta"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@ -97,6 +97,11 @@
<string name="mcl_setting_title_controlsize">Set control buttons size</string>
<string name="mcl_setting_title_forgetoptifpath">Make OptiFine unable to locate itself</string>
<string name="mcl_setting_subtitle_forgetoptifpath">Useful for making OptiFine launchable on some devices</string>
<string name="mcl_setting_title_veroption">Version type will be in version list</string>
<string name="mcl_setting_veroption_release">Release</string>
<string name="mcl_setting_veroption_snapshot">Snapshot</string>
<string name="mcl_setting_veroption_oldalpha">Old-alpha</string>
<string name="mcl_setting_veroption_oldbeta">Old-beta</string>
<string name="mcl_version_clone">Clone</string>