Merge settings and paths for simpler menu system

This commit is contained in:
TwistedUmbrella 2014-05-21 01:01:31 -04:00
parent 2bd1c4c976
commit b6aa26f5c9
9 changed files with 564 additions and 563 deletions

View File

@ -8,6 +8,141 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical" >
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/system_path" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/main_path"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" >
</EditText>
<Button
android:id="@+id/browse_main_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Browse" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/games_path" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/game_path"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" >
</EditText>
<Button
android:id="@+id/browse_game_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Browse" />
</LinearLayout>
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/details_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_details" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<de.ankri.views.Switch
android:id="@+id/details_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/select_bios" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Spinner
android:id="@+id/bios_spinner"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >
<requestFocus />
</Spinner>
</LinearLayout>
</LinearLayout>
<TableLayout <TableLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -369,6 +504,35 @@
android:focusable="true" /> android:focusable="true" />
</LinearLayout> </LinearLayout>
</TableRow> </TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/cable_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_cable" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Spinner
android:id="@+id/cable_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
</LinearLayout>
</TableRow>
<TableRow <TableRow
android:layout_marginTop="10dp" android:layout_marginTop="10dp"

View File

@ -74,42 +74,11 @@
android:textSize="28dp" /> android:textSize="28dp" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/paths_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:background="@drawable/game_selector"
android:focusable="true"
android:gravity="center_vertical|left"
android:orientation="horizontal" >
<ImageView
android:id="@+id/options"
android:layout_width="52dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:gravity="center_vertical|left"
android:scaleType="fitCenter"
android:src="@drawable/open_folder" />
<TextView
android:id="@+id/options_title"
style="@android:style/TextAppearance.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/paths"
android:textAppearance="@style/BaseText"
android:textSize="28dp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/input_menu" android:id="@+id/input_menu"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="26dp" android:layout_marginLeft="4dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:background="@drawable/game_selector" android:background="@drawable/game_selector"
android:focusable="true" android:focusable="true"
@ -140,7 +109,7 @@
android:id="@+id/about_menu" android:id="@+id/about_menu"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="4dp" android:layout_marginLeft="26dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:background="@drawable/game_selector" android:background="@drawable/game_selector"
android:focusable="true" android:focusable="true"
@ -171,7 +140,7 @@
android:id="@+id/rateme_menu" android:id="@+id/rateme_menu"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="26dp" android:layout_marginLeft="4dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:background="@drawable/game_selector" android:background="@drawable/game_selector"
android:focusable="true" android:focusable="true"
@ -196,6 +165,37 @@
android:textAppearance="@style/BaseText" android:textAppearance="@style/BaseText"
android:textSize="28dp" /> android:textSize="28dp" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/cloud_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="26dp"
android:layout_marginTop="10dp"
android:background="@drawable/game_selector"
android:focusable="true"
android:gravity="center_vertical|left"
android:orientation="horizontal" >
<ImageView
android:id="@+id/cloud"
android:layout_width="52dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:gravity="center_vertical|left"
android:scaleType="fitCenter"
android:src="@drawable/cloud" />
<TextView
android:id="@+id/cloud_title"
style="@android:style/TextAppearance.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/cloud"
android:textAppearance="@style/BaseText"
android:textSize="28dp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/message_menu" android:id="@+id/message_menu"
@ -228,36 +228,6 @@
android:textSize="28dp" /> android:textSize="28dp" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/cloud_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:background="@drawable/game_selector"
android:focusable="true"
android:gravity="center_vertical|left"
android:orientation="horizontal" >
<ImageView
android:id="@+id/cloud"
android:layout_width="52dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:gravity="center_vertical|left"
android:scaleType="fitCenter"
android:src="@drawable/cloud" />
<TextView
android:id="@+id/cloud_title"
style="@android:style/TextAppearance.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="@string/cloud"
android:textAppearance="@style/BaseText"
android:textSize="28dp" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@ -1,118 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/system_path" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/main_path"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" >
</EditText>
<Button
android:id="@+id/browse_main_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Browse" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/games_path" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="@+id/game_path"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" >
</EditText>
<Button
android:id="@+id/browse_game_path"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Browse" />
</LinearLayout>
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/details_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_details" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<de.ankri.views.Switch
android:id="@+id/details_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>

View File

@ -23,10 +23,12 @@
<string name="optimization_opts">Optimization and Debugging Options</string> <string name="optimization_opts">Optimization and Debugging Options</string>
<string name="experimental_opts">Experimental (May cause widespread panic)</string> <string name="experimental_opts">Experimental (May cause widespread panic)</string>
<string name="select_bios">BIOS Region (dc_flash[X].bin)</string>
<string name="select_details">Enable Game Details</string> <string name="select_details">Enable Game Details</string>
<string name="select_native">Enable Native Interface</string> <string name="select_native">Enable Native Interface</string>
<string name="select_dynarec">Dynarec Options</string> <string name="select_dynarec">Dynarec Options</string>
<string name="select_unstable">Unstable Optimisations</string> <string name="select_unstable">Unstable Optimisations</string>
<string name="select_cable">Cable Type</string>
<string name="select_region">DC Region</string> <string name="select_region">DC Region</string>
<string name="select_broadcast">Broadcast</string> <string name="select_broadcast">Broadcast</string>
<string name="select_limitfps">Limit FPS</string> <string name="select_limitfps">Limit FPS</string>

View File

@ -6,7 +6,6 @@ import java.util.HashMap;
import tv.ouya.console.api.OuyaController; import tv.ouya.console.api.OuyaController;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.net.Uri; import android.net.Uri;

View File

@ -6,7 +6,6 @@ import java.util.HashMap;
import tv.ouya.console.api.OuyaController; import tv.ouya.console.api.OuyaController;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.NativeActivity; import android.app.NativeActivity;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.net.Uri; import android.net.Uri;

View File

@ -33,7 +33,6 @@ import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnOpenListener; import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnOpenListener;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity; import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;
import com.reicast.emulator.config.Config; import com.reicast.emulator.config.Config;
import com.reicast.emulator.config.ConfigureFragment;
import com.reicast.emulator.config.InputFragment; import com.reicast.emulator.config.InputFragment;
import com.reicast.emulator.config.OptionsFragment; import com.reicast.emulator.config.OptionsFragment;
import com.reicast.emulator.emu.JNIdc; import com.reicast.emulator.emu.JNIdc;
@ -209,28 +208,8 @@ public class MainActivity extends SlidingFragmentActivity implements
} }
}); });
findViewById(R.id.settings_menu).setOnClickListener(new OnClickListener() {
public void onClick(View view) {
ConfigureFragment configFrag = (ConfigureFragment) getSupportFragmentManager()
.findFragmentByTag("CONFIG_FRAG");
if (configFrag != null) {
if (configFrag.isVisible()) {
return;
}
}
configFrag = new ConfigureFragment();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragment_container, configFrag,
"CONFIG_FRAG").addToBackStack(null)
.commit();
setTitle(R.string.settings);
sm.toggle(true);
}
}); findViewById(R.id.settings_menu).setOnClickListener(
findViewById(R.id.paths_menu).setOnClickListener(
new OnClickListener() { new OnClickListener() {
public void onClick(View view) { public void onClick(View view) {
OptionsFragment optionsFrag = (OptionsFragment) getSupportFragmentManager() OptionsFragment optionsFrag = (OptionsFragment) getSupportFragmentManager()
@ -246,7 +225,7 @@ public class MainActivity extends SlidingFragmentActivity implements
.replace(R.id.fragment_container, .replace(R.id.fragment_container,
optionsFrag, "OPTIONS_FRAG") optionsFrag, "OPTIONS_FRAG")
.addToBackStack(null).commit(); .addToBackStack(null).commit();
setTitle(R.string.paths); setTitle(R.string.settings);
sm.toggle(true); sm.toggle(true);
} }

View File

@ -1,350 +0,0 @@
package com.reicast.emulator.config;
import java.io.File;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import android.widget.TextView;
import com.reicast.emulator.R;
import com.reicast.emulator.emu.GL2JNIView;
import de.ankri.views.Switch;
public class ConfigureFragment extends Fragment {
private Config config;
private SharedPreferences mPrefs;
private File sdcard = Environment.getExternalStorageDirectory();
private String home_directory = sdcard + "/dc";
// Container Activity must implement this interface
public interface OnClickListener {
public void onMainBrowseSelected(String path_entry, boolean games);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.configure_fragment, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// setContentView(R.layout.activity_main);
//parentActivity = getActivity();
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
home_directory = mPrefs.getString(Config.pref_home, home_directory);
config = new Config(getActivity());
config.getConfigurationPrefs();
// Generate the menu options and fill in existing settings
OnCheckedChangeListener native_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_nativeact, isChecked).commit();
Config.nativeact = isChecked;
}
};
Switch native_opt = (Switch) getView().findViewById(
R.id.native_option);
native_opt.setChecked(Config.nativeact);
native_opt.setOnCheckedChangeListener(native_options);
OnCheckedChangeListener dynarec_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_dynarecopt, isChecked).commit();
Config.dynarecopt = isChecked;
}
};
Switch dynarec_opt = (Switch) getView().findViewById(
R.id.dynarec_option);
dynarec_opt.setChecked(Config.dynarecopt);
dynarec_opt.setOnCheckedChangeListener(dynarec_options);
OnCheckedChangeListener unstable_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_unstable, isChecked).commit();
Config.unstableopt = isChecked;
}
};
Switch unstable_opt = (Switch) getView().findViewById(
R.id.unstable_option);
if (Config.unstableopt) {
unstable_opt.setChecked(true);
} else {
unstable_opt.setChecked(false);
}
unstable_opt.setOnCheckedChangeListener(unstable_option);
String[] regions = getResources().getStringArray(R.array.region);
Spinner region_spnr = (Spinner) getView().findViewById(R.id.region_spinner);
ArrayAdapter<String> regionAdapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, regions);
regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
region_spnr.setAdapter(regionAdapter);
region_spnr.setSelection(Config.dcregion, true);
region_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mPrefs.edit().putInt(Config.pref_dcregion, pos).commit();
Config.dcregion = pos;
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
String[] broadcasts = getResources().getStringArray(R.array.broadcast);
Spinner broadcast_spnr = (Spinner) getView().findViewById(R.id.broadcast_spinner);
ArrayAdapter<String> broadcastAdapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, broadcasts);
broadcastAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
broadcast_spnr.setAdapter(broadcastAdapter);
int select = 0;
String cast = String.valueOf(Config.broadcast);
for (int i = 0; i < broadcasts.length; i++) {
if (broadcasts[i].startsWith(cast + " - "))
select = i;
}
broadcast_spnr.setSelection(select, true);
broadcast_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
String item = parent.getItemAtPosition(pos).toString();
String selection = item.substring(0, item.indexOf(" - "));
mPrefs.edit()
.putInt(Config.pref_broadcast, Integer.parseInt(selection))
.commit();
Config.broadcast = Integer.parseInt(selection);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
OnCheckedChangeListener limitfps_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_limitfps, isChecked).commit();
Config.limitfps = isChecked;
}
};
Switch limit_fps = (Switch) getView().findViewById(R.id.limitfps_option);
limit_fps.setChecked(Config.limitfps);
limit_fps.setOnCheckedChangeListener(limitfps_option);
OnCheckedChangeListener mipmaps_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_mipmaps, isChecked).commit();
Config.mipmaps = isChecked;
}
};
Switch mipmap_opt = (Switch) getView().findViewById(R.id.mipmaps_option);
mipmap_opt.setChecked(Config.mipmaps);
mipmap_opt.setOnCheckedChangeListener(mipmaps_option);
OnCheckedChangeListener full_screen = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_widescreen, isChecked).commit();
Config.widescreen = isChecked;
}
};
Switch stretch_view = (Switch) getView().findViewById(R.id.stretch_option);
stretch_view.setChecked(Config.widescreen);
stretch_view.setOnCheckedChangeListener(full_screen);
final TextView mainFrames = (TextView) getView().findViewById(R.id.current_frames);
mainFrames.setText(String.valueOf(Config.frameskip));
SeekBar frameSeek = (SeekBar) getView().findViewById(R.id.frame_seekbar);
frameSeek.setProgress(Config.frameskip);
frameSeek.setIndeterminate(false);
frameSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mainFrames.setText(String.valueOf(progress));
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
mPrefs.edit().putInt(Config.pref_frameskip, progress).commit();
Config.frameskip = progress;
}
});
OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_pvrrender, isChecked).commit();
Config.pvrrender = isChecked;
}
};
Switch pvr_render = (Switch) getView().findViewById(R.id.render_option);
pvr_render.setChecked(Config.pvrrender);
pvr_render.setOnCheckedChangeListener(pvr_rendering);
final EditText cheatEdit = (EditText) getView().findViewById(R.id.cheat_disk);
String disk = Config.cheatdisk;
if (disk != null && disk.contains("/")) {
cheatEdit.setText(disk.substring(disk.lastIndexOf("/"),
disk.length()));
} else {
cheatEdit.setText(disk);
}
cheatEdit.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
if (cheatEdit.getText() != null) {
String disk = cheatEdit.getText().toString();
if (disk != null && disk.contains("/")) {
cheatEdit.setText(disk.substring(disk.lastIndexOf("/"),
disk.length()));
} else {
cheatEdit.setText(disk);
}
mPrefs.edit().putString(Config.pref_cheatdisk, disk).commit();
Config.cheatdisk = disk;
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
final Switch fps_opt = (Switch) getView().findViewById(R.id.fps_option);
OnCheckedChangeListener fps_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_showfps, isChecked).commit();
}
};
boolean counter = mPrefs.getBoolean(Config.pref_showfps, false);
fps_opt.setChecked(counter);
fps_opt.setOnCheckedChangeListener(fps_options);
final Switch force_gpu_opt = (Switch) getView().findViewById(R.id.force_gpu_option);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
OnCheckedChangeListener force_gpu_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_forcegpu, isChecked).commit();
}
};
boolean enhanced = mPrefs.getBoolean(Config.pref_forcegpu, true);
force_gpu_opt.setChecked(enhanced);
force_gpu_opt.setOnCheckedChangeListener(force_gpu_options);
} else {
force_gpu_opt.setEnabled(false);
}
Switch force_software_opt = (Switch) getView().findViewById(
R.id.software_option);
OnCheckedChangeListener force_software = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit()
.putInt(Config.pref_rendertype,
isChecked ? GL2JNIView.LAYER_TYPE_SOFTWARE
: GL2JNIView.LAYER_TYPE_HARDWARE)
.commit();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (isChecked) {
force_gpu_opt.setEnabled(false);
mPrefs.edit().putBoolean(Config.pref_forcegpu, false).commit();
} else {
force_gpu_opt.setEnabled(true);
}
}
}
};
int software = mPrefs.getInt(Config.pref_rendertype, GL2JNIView.LAYER_TYPE_HARDWARE);
force_software_opt.setChecked(software == GL2JNIView.LAYER_TYPE_SOFTWARE);
force_software_opt.setOnCheckedChangeListener(force_software);
Switch sound_opt = (Switch) getView().findViewById(R.id.sound_option);
OnCheckedChangeListener emu_sound = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_nosound, isChecked).commit();
Config.nosound = isChecked;
}
};
boolean sound = mPrefs.getBoolean(Config.pref_nosound, false);
sound_opt.setChecked(sound);
sound_opt.setOnCheckedChangeListener(emu_sound);
String[] depths = getResources().getStringArray(R.array.depth);
Spinner depth_spnr = (Spinner) getView().findViewById(R.id.depth_spinner);
ArrayAdapter<String> depthAdapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, depths);
depthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
depth_spnr.setAdapter(depthAdapter);
String depth = String.valueOf(mPrefs.getInt(Config.pref_renderdepth, 24));
depth_spnr.setSelection(depthAdapter.getPosition(depth), true);
depth_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
int render = Integer.parseInt(parent.getItemAtPosition(pos).toString());
mPrefs.edit().putInt(Config.pref_renderdepth, render).commit();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
}
}

View File

@ -1,9 +1,14 @@
package com.reicast.emulator.config; package com.reicast.emulator.config;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android.app.Activity; import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
@ -13,18 +18,28 @@ import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button; import android.widget.Button;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.Toast;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Toast; import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.Spinner;
import android.widget.TextView;
import com.reicast.emulator.R; import com.reicast.emulator.R;
import com.reicast.emulator.emu.GL2JNIView;
import de.ankri.views.Switch; import de.ankri.views.Switch;
public class OptionsFragment extends Fragment { public class OptionsFragment extends Fragment {
private Config config;
private Button mainBrowse; private Button mainBrowse;
private Button gameBrowse; private Button gameBrowse;
private OnClickListener mCallback; private OnClickListener mCallback;
@ -33,6 +48,8 @@ public class OptionsFragment extends Fragment {
private File sdcard = Environment.getExternalStorageDirectory(); private File sdcard = Environment.getExternalStorageDirectory();
private String home_directory = sdcard + "/dc"; private String home_directory = sdcard + "/dc";
private String game_directory = sdcard + "/dc"; private String game_directory = sdcard + "/dc";
private String[] codes;
// Container Activity must implement this interface // Container Activity must implement this interface
public interface OnClickListener { public interface OnClickListener {
@ -42,7 +59,7 @@ public class OptionsFragment extends Fragment {
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
// This makes sure that the container activity has implemented // This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception // the callback interface. If not, it throws an exception
try { try {
@ -51,22 +68,30 @@ public class OptionsFragment extends Fragment {
throw new ClassCastException(activity.toString() throw new ClassCastException(activity.toString()
+ " must implement OnClickListener"); + " must implement OnClickListener");
} }
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
return inflater.inflate(R.layout.options_fragment, container, false); return inflater.inflate(R.layout.configure_fragment, container, false);
} }
@Override @Override
public void onViewCreated(View view, Bundle savedInstanceState) { public void onViewCreated(View view, Bundle savedInstanceState) {
// setContentView(R.layout.activity_main); // setContentView(R.layout.activity_main);
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
home_directory = mPrefs.getString("home_directory", home_directory);
//parentActivity = getActivity();
mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
home_directory = mPrefs.getString(Config.pref_home, home_directory);
config = new Config(getActivity());
config.getConfigurationPrefs();
// Generate the menu options and fill in existing settings
mainBrowse = (Button) getView().findViewById(R.id.browse_main_path); mainBrowse = (Button) getView().findViewById(R.id.browse_main_path);
final EditText editBrowse = (EditText) getView().findViewById( final EditText editBrowse = (EditText) getView().findViewById(
@ -148,5 +173,336 @@ public class OptionsFragment extends Fragment {
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
} }
}); });
String[] bios = getResources().getStringArray(R.array.bios);
codes = getResources().getStringArray(R.array.bioscode);
Spinner bios_spnr = (Spinner) getView().findViewById(
R.id.bios_spinner);
ArrayAdapter<String> biosAdapter = new ArrayAdapter<String>(
getActivity(), android.R.layout.simple_spinner_item, bios);
biosAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
bios_spnr.setAdapter(biosAdapter);
String region = mPrefs.getString("localized", codes[4]);
bios_spnr.setSelection(biosAdapter.getPosition(region), true);
bios_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
//flashBios(codes[pos]);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
OnCheckedChangeListener native_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_nativeact, isChecked).commit();
Config.nativeact = isChecked;
}
};
Switch native_opt = (Switch) getView().findViewById(
R.id.native_option);
native_opt.setChecked(Config.nativeact);
native_opt.setOnCheckedChangeListener(native_options);
OnCheckedChangeListener dynarec_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_dynarecopt, isChecked).commit();
Config.dynarecopt = isChecked;
}
};
Switch dynarec_opt = (Switch) getView().findViewById(
R.id.dynarec_option);
dynarec_opt.setChecked(Config.dynarecopt);
dynarec_opt.setOnCheckedChangeListener(dynarec_options);
OnCheckedChangeListener unstable_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_unstable, isChecked).commit();
Config.unstableopt = isChecked;
}
};
Switch unstable_opt = (Switch) getView().findViewById(
R.id.unstable_option);
if (Config.unstableopt) {
unstable_opt.setChecked(true);
} else {
unstable_opt.setChecked(false);
}
unstable_opt.setOnCheckedChangeListener(unstable_option);
String[] cables = getResources().getStringArray(
R.array.cable);
Spinner cable_spnr = (Spinner) getView().findViewById(
R.id.cable_spinner);
ArrayAdapter<String> cableAdapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, cables);
cableAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cable_spnr.setAdapter(cableAdapter);
cable_spnr.setSelection(Config.cable - 1, true);
cable_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) {
mPrefs.edit().putInt(Config.pref_cable, pos + 1).commit();
Config.cable = pos + 1;
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
// String[] regions = ArrayUtils.remove(parentActivity.getResources()
// .getStringArray(R.array.region), 4);
String[] regions = getResources()
.getStringArray(R.array.region);
Spinner region_spnr = (Spinner) getView().findViewById(
R.id.region_spinner);
ArrayAdapter<String> regionAdapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, regions);
regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
region_spnr.setAdapter(regionAdapter);
region_spnr.setSelection(Config.dcregion, true);
region_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mPrefs.edit().putInt(Config.pref_dcregion, pos).commit();
Config.dcregion = pos;
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
String[] broadcasts = getResources().getStringArray(R.array.broadcast);
Spinner broadcast_spnr = (Spinner) getView().findViewById(R.id.broadcast_spinner);
ArrayAdapter<String> broadcastAdapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, broadcasts);
broadcastAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
broadcast_spnr.setAdapter(broadcastAdapter);
int select = 0;
String cast = String.valueOf(Config.broadcast);
for (int i = 0; i < broadcasts.length; i++) {
if (broadcasts[i].startsWith(cast + " - "))
select = i;
}
broadcast_spnr.setSelection(select, true);
broadcast_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
String item = parent.getItemAtPosition(pos).toString();
String selection = item.substring(0, item.indexOf(" - "));
mPrefs.edit()
.putInt(Config.pref_broadcast, Integer.parseInt(selection))
.commit();
Config.broadcast = Integer.parseInt(selection);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
OnCheckedChangeListener limitfps_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_limitfps, isChecked).commit();
Config.limitfps = isChecked;
}
};
Switch limit_fps = (Switch) getView().findViewById(R.id.limitfps_option);
limit_fps.setChecked(Config.limitfps);
limit_fps.setOnCheckedChangeListener(limitfps_option);
OnCheckedChangeListener mipmaps_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_mipmaps, isChecked).commit();
Config.mipmaps = isChecked;
}
};
Switch mipmap_opt = (Switch) getView().findViewById(R.id.mipmaps_option);
mipmap_opt.setChecked(Config.mipmaps);
mipmap_opt.setOnCheckedChangeListener(mipmaps_option);
OnCheckedChangeListener full_screen = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_widescreen, isChecked).commit();
Config.widescreen = isChecked;
}
};
Switch stretch_view = (Switch) getView().findViewById(R.id.stretch_option);
stretch_view.setChecked(Config.widescreen);
stretch_view.setOnCheckedChangeListener(full_screen);
final TextView mainFrames = (TextView) getView().findViewById(R.id.current_frames);
mainFrames.setText(String.valueOf(Config.frameskip));
SeekBar frameSeek = (SeekBar) getView().findViewById(R.id.frame_seekbar);
frameSeek.setProgress(Config.frameskip);
frameSeek.setIndeterminate(false);
frameSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mainFrames.setText(String.valueOf(progress));
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress();
mPrefs.edit().putInt(Config.pref_frameskip, progress).commit();
Config.frameskip = progress;
}
});
OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_pvrrender, isChecked).commit();
Config.pvrrender = isChecked;
}
};
Switch pvr_render = (Switch) getView().findViewById(R.id.render_option);
pvr_render.setChecked(Config.pvrrender);
pvr_render.setOnCheckedChangeListener(pvr_rendering);
final EditText cheatEdit = (EditText) getView().findViewById(R.id.cheat_disk);
String disk = Config.cheatdisk;
if (disk != null && disk.contains("/")) {
cheatEdit.setText(disk.substring(disk.lastIndexOf("/"),
disk.length()));
} else {
cheatEdit.setText(disk);
}
cheatEdit.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
if (cheatEdit.getText() != null) {
String disk = cheatEdit.getText().toString();
if (disk != null && disk.contains("/")) {
cheatEdit.setText(disk.substring(disk.lastIndexOf("/"),
disk.length()));
} else {
cheatEdit.setText(disk);
}
mPrefs.edit().putString(Config.pref_cheatdisk, disk).commit();
Config.cheatdisk = disk;
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
});
final Switch fps_opt = (Switch) getView().findViewById(R.id.fps_option);
OnCheckedChangeListener fps_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_showfps, isChecked).commit();
}
};
boolean counter = mPrefs.getBoolean(Config.pref_showfps, false);
fps_opt.setChecked(counter);
fps_opt.setOnCheckedChangeListener(fps_options);
final Switch force_gpu_opt = (Switch) getView().findViewById(R.id.force_gpu_option);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
OnCheckedChangeListener force_gpu_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_forcegpu, isChecked).commit();
}
};
boolean enhanced = mPrefs.getBoolean(Config.pref_forcegpu, true);
force_gpu_opt.setChecked(enhanced);
force_gpu_opt.setOnCheckedChangeListener(force_gpu_options);
} else {
force_gpu_opt.setEnabled(false);
}
Switch force_software_opt = (Switch) getView().findViewById(
R.id.software_option);
OnCheckedChangeListener force_software = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit()
.putInt(Config.pref_rendertype,
isChecked ? GL2JNIView.LAYER_TYPE_SOFTWARE
: GL2JNIView.LAYER_TYPE_HARDWARE)
.commit();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
if (isChecked) {
force_gpu_opt.setEnabled(false);
mPrefs.edit().putBoolean(Config.pref_forcegpu, false).commit();
} else {
force_gpu_opt.setEnabled(true);
}
}
}
};
int software = mPrefs.getInt(Config.pref_rendertype, GL2JNIView.LAYER_TYPE_HARDWARE);
force_software_opt.setChecked(software == GL2JNIView.LAYER_TYPE_SOFTWARE);
force_software_opt.setOnCheckedChangeListener(force_software);
Switch sound_opt = (Switch) getView().findViewById(R.id.sound_option);
OnCheckedChangeListener emu_sound = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_nosound, isChecked).commit();
Config.nosound = isChecked;
}
};
boolean sound = mPrefs.getBoolean(Config.pref_nosound, false);
sound_opt.setChecked(sound);
sound_opt.setOnCheckedChangeListener(emu_sound);
String[] depths = getResources().getStringArray(R.array.depth);
Spinner depth_spnr = (Spinner) getView().findViewById(R.id.depth_spinner);
ArrayAdapter<String> depthAdapter = new ArrayAdapter<String>(
getActivity(), R.layout.spinner_selected, depths);
depthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
depth_spnr.setAdapter(depthAdapter);
String depth = String.valueOf(mPrefs.getInt(Config.pref_renderdepth, 24));
depth_spnr.setSelection(depthAdapter.getPosition(depth), true);
depth_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
int render = Integer.parseInt(parent.getItemAtPosition(pos).toString());
mPrefs.edit().putInt(Config.pref_renderdepth, render).commit();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
} }
} }