diff --git a/Source/Android/.idea/workspace.xml b/Source/Android/.idea/workspace.xml index 49334515f9..87d98b0e1e 100644 --- a/Source/Android/.idea/workspace.xml +++ b/Source/Android/.idea/workspace.xml @@ -1,9 +1,26 @@ + + + - + + android-17 + + + + + Nexus 4 + @android:style/Theme.Holo + + + @@ -14,11 +31,17 @@ - - + + - + + + + + + + + + + + + @@ -82,25 +110,25 @@ - + - + - + - - + + - + @@ -109,19 +137,22 @@ - + - - + + - + + + + @@ -143,15 +174,26 @@ + + + - - - - - - - - - + + + + + - - - + + - + + + + + + + + + + + + - - - @@ -450,29 +581,30 @@ - - - - - - - - - - + - - + + + + + + + + + + + + + + + + - - + - - - - + @@ -536,107 +668,85 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - + - + + + + + + + + + + + - + - + + + + + - + - + + + - + + + + - + - + + + + + + + + diff --git a/Source/Android/AndroidManifest.xml b/Source/Android/AndroidManifest.xml index 2eb749d1a2..2812e35815 100644 --- a/Source/Android/AndroidManifest.xml +++ b/Source/Android/AndroidManifest.xml @@ -37,11 +37,9 @@ android:theme="@android:style/Theme" android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" > - + diff --git a/Source/Android/res/layout/prefs.xml b/Source/Android/res/layout/prefs.xml new file mode 100644 index 0000000000..bceb581c36 --- /dev/null +++ b/Source/Android/res/layout/prefs.xml @@ -0,0 +1,28 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Source/Android/res/values/prefvalues.xml b/Source/Android/res/values/prefvalues.xml new file mode 100644 index 0000000000..77354f76a4 --- /dev/null +++ b/Source/Android/res/values/prefvalues.xml @@ -0,0 +1,22 @@ + + + + Interpreter + ARM JIT Recompiler + + + + 0 + 3 + + + + Software Renderer + OpenGL + + + + Software Renderer + OGL + + \ No newline at end of file diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListView.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListView.java index 96b67c2130..760f0445ec 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListView.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListView.java @@ -3,7 +3,9 @@ package org.dolphinemu.dolphinemu; 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; @@ -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() { @@ -88,19 +92,67 @@ public class GameListView extends ListActivity { 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 @@ -138,8 +190,8 @@ public class GameListView extends ListActivity { 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; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsActivity.java new file mode 100644 index 0000000000..e12e37c10a --- /dev/null +++ b/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(); + } +} diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SettingBrowser.java b/Source/Android/src/org/dolphinemu/dolphinemu/SettingBrowser.java deleted file mode 100644 index 123bb174ed..0000000000 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SettingBrowser.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.dolphinemu.dolphinemu; - -import android.app.ListActivity; -import android.os.Bundle; -import android.view.View; -import android.widget.ListView; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Copyright 2013 Dolphin Emulator Project - * Licensed under GPLv2 - * Refer to the license.txt file included. - */ - -public class SettingBrowser extends ListActivity { - private SettingMenuAdapter adapter; - private void Fill() - { - this.setTitle("Settings"); - List dir = new ArrayList(); - - dir.add(new SettingMenuItem("Setting 1", "SubTitle 1", 0)); - Collections.sort(dir); - - adapter = new SettingMenuAdapter(this,R.layout.folderbrowser,dir); - this.setListAdapter(adapter); - } - - @Override - protected void onListItemClick(ListView l, View v, int position, long id) { - super.onListItemClick(l, v, position, id); - SettingMenuItem o = adapter.getItem(position); - switch (o.getID()) - { - default: - // Do nothing yet - break; - } - } - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - - Fill(); - } - @Override - public void onBackPressed() { - this.finish(); - super.onBackPressed(); - } -} diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SettingMenuAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/SettingMenuAdapter.java deleted file mode 100644 index 8fb0b237f6..0000000000 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SettingMenuAdapter.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.dolphinemu.dolphinemu; - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.TextView; - -import java.util.List; - -/** - * Copyright 2013 Dolphin Emulator Project - * Licensed under GPLv2 - * Refer to the license.txt file included. - */ - -public class SettingMenuAdapter extends ArrayAdapter{ - - private Context c; - private int id; - private Listitems; - - public SettingMenuAdapter(Context context, int textViewResourceId, - List objects) { - super(context, textViewResourceId, objects); - c = context; - id = textViewResourceId; - items = objects; - } - public SettingMenuItem getItem(int i) - { - return items.get(i); - } - @Override - public View getView(int position, View convertView, ViewGroup parent) { - View v = convertView; - if (v == null) { - LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - v = vi.inflate(id, null); - if (v == null) - return null; // This should never be hit, but have it to clear a warning - } - final SettingMenuItem o = items.get(position); - if (o != null) { - TextView t1 = (TextView) v.findViewById(R.id.TextView01); - TextView t2 = (TextView) v.findViewById(R.id.TextView02); - - if (t1 != null) - t1.setText(o.getName()); - if (t2 != null) - t2.setText(o.getSubtitle()); - } - return v; - } - - - -} - diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SettingMenuItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/SettingMenuItem.java deleted file mode 100644 index fcb0da942c..0000000000 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SettingMenuItem.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.dolphinemu.dolphinemu; - -public class SettingMenuItem implements Comparable{ - private String name; - private String subtitle; - private int m_id; - - public SettingMenuItem(String n,String d, int id) - { - name = n; - subtitle = d; - m_id = id; - } - - public String getName() - { - return name; - } - - public String getSubtitle() - { - return subtitle; - } - public int getID() - { - return m_id; - } - - public int compareTo(SettingMenuItem o) - { - if(this.name != null) - return this.name.toLowerCase().compareTo(o.getName().toLowerCase()); - else - throw new IllegalArgumentException(); - } -} -