Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Redo the Settings menu, Can now change the CPU Core, dual c…
…ore setting, and video backend in the settings"
  • Loading branch information
Sonicadvance1 committed May 20, 2013
1 parent 9a1b9e9 commit f8a5d05
Show file tree
Hide file tree
Showing 9 changed files with 437 additions and 340 deletions.
444 changes: 277 additions & 167 deletions Source/Android/.idea/workspace.xml

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions Source/Android/AndroidManifest.xml
Expand Up @@ -37,11 +37,9 @@
android:theme="@android:style/Theme"
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
</activity>
<activity
android:name="org.dolphinemu.dolphinemu.SettingBrowser"
android:label="@string/app_name"
android:theme="@android:style/Theme"
android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" >
<activity
android:name=".PrefsActivity"
android:theme="@android:style/Theme.Black.NoTitleBar" >
</activity>
</application>

Expand Down
28 changes: 28 additions & 0 deletions Source/Android/res/layout/prefs.xml
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
>
<PreferenceCategory
android:summary="Settings"
android:title="CPU Settings" >
<ListPreference
android:entries="@array/cpuOptions"
android:entryValues="@array/cpuValues"
android:key="cpupref"
android:summary="Emulation core to use"
android:title="CPU Core" />
<CheckBoxPreference
android:key="dualcorepref"
android:summary="On/Off"
android:title="Dual Core" />
</PreferenceCategory>
<PreferenceCategory
android:summary="Settings"
android:title="Video Settings" >
<ListPreference
android:entries="@array/gpuOptions"
android:entryValues="@array/gpuValues"
android:key="gpupref"
android:summary="Video backend to use"
android:title="Video Backend" />
</PreferenceCategory>
</PreferenceScreen>
22 changes: 22 additions & 0 deletions Source/Android/res/values/prefvalues.xml
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="cpuOptions">
<item>Interpreter</item>
<item>ARM JIT Recompiler</item>
</string-array>

<string-array name="cpuValues">
<item>0</item>
<item>3</item>
</string-array>

<string-array name="gpuOptions">
<item>Software Renderer</item>
<item>OpenGL</item>
</string-array>

<string-array name="gpuValues">
<item>Software Renderer</item>
<item>OGL</item>
</string-array>
</resources>
82 changes: 67 additions & 15 deletions Source/Android/src/org/dolphinemu/dolphinemu/GameListView.java
Expand Up @@ -3,7 +3,9 @@
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
Expand All @@ -24,6 +26,8 @@ public class GameListView extends ListActivity {
private static GameListView me;
public static native String GetConfig(String Key, String Value, String Default);
public static native void SetConfig(String Key, String Value, String Default);

enum keyTypes {TYPE_STRING, TYPE_BOOL};

private void Fill()
{
Expand Down Expand Up @@ -88,19 +92,67 @@ private void onFileClick(String o)
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);

if (resultCode == Activity.RESULT_OK)
{
String FileName = data.getStringExtra("Select");
Toast.makeText(this, "Folder Selected: " + FileName, Toast.LENGTH_SHORT).show();
String Directories = GetConfig("General", "GCMPathes", "0");
int intDirectories = Integer.parseInt(Directories);
Directories = Integer.toString(intDirectories + 1);
SetConfig("General", "GCMPathes", Directories);
SetConfig("General", "GCMPaths" + Integer.toString(intDirectories), FileName);

Fill();
}

switch (requestCode)
{
// Browse
case 1:
if (resultCode == Activity.RESULT_OK)
{
String FileName = data.getStringExtra("Select");
Toast.makeText(this, "Folder Selected: " + FileName, Toast.LENGTH_SHORT).show();
String Directories = GetConfig("General", "GCMPathes", "0");
int intDirectories = Integer.parseInt(Directories);
Directories = Integer.toString(intDirectories + 1);
SetConfig("General", "GCMPathes", Directories);
SetConfig("General", "GCMPaths" + Integer.toString(intDirectories), FileName);

Fill();
}
break;
// Settings
case 2:

String Keys[] = {
"cpupref",
"dualcorepref",
"gpupref",
};
String ConfigKeys[] = {
"Core-CPUCore",
"Core-CPUThread",
"Core-GFXBackend",
};

keyTypes KeysTypes[] = {
keyTypes.TYPE_STRING,
keyTypes.TYPE_BOOL,
keyTypes.TYPE_STRING,
};
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

// Set our preferences here
for (int a = 0; a < Keys.length; ++a)
{
String ConfigValues[] = ConfigKeys[a].split("-");
String Key = ConfigValues[0];
String Value = ConfigValues[1];

switch(KeysTypes[a])
{
case TYPE_STRING:
String strPref = prefs.getString(Keys[a], "");
SetConfig(Key, Value, strPref);
break;
case TYPE_BOOL:
boolean boolPref = prefs.getBoolean(Keys[a], true);
SetConfig(Key, Value, boolPref ? "True" : "False");
break;
}

}
break;
}
}

@Override
Expand Down Expand Up @@ -138,8 +190,8 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
break;
case 1:
Toast.makeText(me, "Loading up settings", Toast.LENGTH_SHORT).show();
Intent SettingIntent = new Intent(me, SettingBrowser.class);
startActivityForResult(SettingIntent, 1);
Intent SettingIntent = new Intent(me, PrefsActivity.class);
startActivityForResult(SettingIntent, 2);
break;
default:
break;
Expand Down
40 changes: 40 additions & 0 deletions Source/Android/src/org/dolphinemu/dolphinemu/PrefsActivity.java
@@ -0,0 +1,40 @@
package org.dolphinemu.dolphinemu;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;

/**
* Copyright 2013 Dolphin Emulator Project
* Licensed under GPLv2
* Refer to the license.txt file included.
*/
public class PrefsActivity extends PreferenceActivity {

public class PrefsFragment extends PreferenceFragment {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Load the preferences from an XML resource
addPreferencesFromResource(R.layout.prefs);
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getFragmentManager().beginTransaction().replace(android.R.id.content,
new PrefsFragment()).commit();
}
@Override
public void onBackPressed() {
Intent intent = new Intent();
setResult(Activity.RESULT_OK, intent);
this.finish();
super.onBackPressed();
}
}
56 changes: 0 additions & 56 deletions Source/Android/src/org/dolphinemu/dolphinemu/SettingBrowser.java

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions Source/Android/src/org/dolphinemu/dolphinemu/SettingMenuItem.java

This file was deleted.

0 comments on commit f8a5d05

Please sign in to comment.