Make basic settings work.

This commit is contained in:
Themaister 2012-12-31 17:46:15 +01:00
parent 0270c106c5
commit cb9bb8455f
5 changed files with 69 additions and 33 deletions

View File

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/general_settings" android:title="@string/general_settings" android:showAsAction="ifRoom" />
<item android:id="@+id/video_settings" android:title="@string/video_settings" android:showAsAction="ifRoom" />
<item android:id="@+id/audio_settings" android:title="@string/audio_settings" android:showAsAction="ifRoom" />
<item android:id="@+id/rarch_settings" android:title="@string/rarch_settings" android:showAsAction="ifRoom" />
<item android:id="@+id/input_method_select" android:title="@string/input_method" android:showAsAction="ifRoom" />
</menu>

View File

@ -4,6 +4,7 @@
<string name="input_method">Input Method</string>
<string name="file_type_icon">File type icon</string>
<string name="video_settings">Video Config</string>
<string name="rarch_settings">RetroArch Config</string>
<string name="audio_settings">Audio Config</string>
<string name="general_settings">General Config</string>
<string name="settings">Settings</string>

View File

@ -1,8 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<CheckBoxPreference
android:key="foo"
android:title="Check me!"
android:summary="Check me if you can!"
android:defaultValue="true" />
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="RetroArch Config" >
<PreferenceScreen android:title="System Config" >
<CheckBoxPreference
android:defaultValue="false"
android:key="savestate_auto_save"
android:summary="Automatically saves and restores game state"
android:title="Auto save state" />
</PreferenceScreen>
<PreferenceScreen android:title="Video Config" >
<CheckBoxPreference
android:defaultValue="true"
android:key="video_smooth"
android:summary="Applies bilinear filter, smooths out edges"
android:title="Bilinear filter" />
<CheckBoxPreference
android:defaultValue="true"
android:key="video_force_aspect"
android:summary="Let game decide aspect ratio"
android:title="Force aspect correction" />
</PreferenceScreen>
<PreferenceScreen android:title="Audio Config" >
<CheckBoxPreference
android:defaultValue="true"
android:key="audio_enable"
android:summary="Enable audio"
android:title="Audio enable" />
<CheckBoxPreference
android:defaultValue="true"
android:key="audio_rate_control"
android:summary="Enable dynamic rate control"
android:title="Dynamic Rate Control" />
</PreferenceScreen>
</PreferenceScreen>

View File

@ -7,6 +7,7 @@ import java.io.*;
import android.content.*;
import android.app.*;
import android.os.*;
import android.preference.PreferenceManager;
import android.widget.*;
import android.util.Log;
import android.view.*;
@ -128,10 +129,28 @@ public class ModuleActivity extends Activity implements
else
return getCacheDir().getAbsolutePath() + File.separator + "retroarch.cfg";
}
private void updateConfigFile() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
config.setBoolean("video_force_aspect", prefs.getBoolean("video_force_aspect", true));
config.setBoolean("audio_rate_control", prefs.getBoolean("audio_rate_control", true));
config.setBoolean("audio_enable", prefs.getBoolean("audio_enable", true));
config.setBoolean("video_smooth", prefs.getBoolean("video_smooth", true));
config.setBoolean("savestate_auto_save", prefs.getBoolean("savestate_auto_save", false));
String confPath = getDefaultConfigPath();
try {
config.write(new File(confPath));
} catch (IOException e) {
Log.e(TAG, "Failed to save config file to: " + confPath);
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Intent myIntent;
updateConfigFile();
switch (requestCode) {
case ACTIVITY_LOAD_ROM:
if (data.getStringExtra("PATH") != null) {
@ -186,27 +205,12 @@ public class ModuleActivity extends Activity implements
imm.showInputMethodPicker();
return true;
case R.id.video_settings:
Log.i(TAG, "Video settings clicked!");
Intent vset = new Intent(this, SettingsActivity.class);
vset.putExtra("TITLE", "Video Config");
startActivity(vset);
return true;
case R.id.audio_settings:
Log.i(TAG, "Audio settings clicked!");
Intent aset = new Intent(this, SettingsActivity.class);
aset.putExtra("TITLE", "Audio Config");
startActivity(aset);
return true;
case R.id.general_settings:
Log.i(TAG, "General settings clicked!");
Intent gset = new Intent(this, SettingsActivity.class);
gset.putExtra("TITLE", "General Config");
startActivity(gset);
case R.id.rarch_settings:
Log.i(TAG, "Rarch settings clicked!");
Intent rset = new Intent(this, SettingsActivity.class);
startActivity(rset);
return true;
default:
return false;
}

View File

@ -1,12 +1,16 @@
package org.retroarch.browser;
import java.util.prefs.Preferences;
import org.retroarch.R;
import android.app.Activity;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
class SettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -20,10 +24,8 @@ public class SettingsActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(getIntent().getStringExtra("TITLE"));
getFragmentManager().beginTransaction().
replace(android.R.id.content, new SettingsFragment()).commit();
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);
}
}