Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Change the settings menu a little more. Instead of the sett…
…ings being a single view with settings from all components being displayed, I have broken it into sections. This future-proofs the settings menu in the sense that it won't get cluttered before people start asking "Hey, shouldn't this be broken into sections?".

As of this commit, it is broken into CPU Settings and Video Settings.
I also simplified the code that is responsible for setting the valid CPU cores and video backends by simply making UI string arrays that get chosen, based on the platform the Android device is running on.
  • Loading branch information
lioncash committed Aug 19, 2013
1 parent 814c1c9 commit 77a5af3
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 82 deletions.
46 changes: 26 additions & 20 deletions Source/Android/res/layout/prefs.xml
@@ -1,24 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
>
<PreferenceCategory
android:summary="@string/settings"
android:title="@string/cpu_settings"
android:key="cpuprefcat">
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<!-- CPU Settings -->
<PreferenceScreen
android:title="@string/cpu_settings">
<CheckBoxPreference
android:key="dualcorepref"
android:summary="@string/on_off"
android:title="@string/dual_core" />
</PreferenceCategory>
<PreferenceCategory
android:summary="@string/settings"
android:title="@string/video_settings"
android:key="videoprefcat">
android:key="dualCorePref"
android:summary="@string/on_off"
android:title="@string/dual_core" />

<ListPreference
android:entries="@array/gpuOptions"
android:entryValues="@array/gpuValues"
android:key="gpupref"
android:summary="@string/video_backend_to_use"
android:title="@string/video_backend" />
</PreferenceCategory>
android:key="cpuCorePref"
android:summary="@string/emu_core_to_use"
android:title="@string/cpu_core" />

</PreferenceScreen>

<!-- Video Settings -->
<PreferenceScreen
android:title="@string/video_settings">

<ListPreference
android:key="gpuPref"
android:summary="@string/video_backend_to_use"
android:title="@string/video_backend" />

</PreferenceScreen>
</PreferenceScreen>
1 change: 1 addition & 0 deletions Source/Android/res/values-ja/strings.xml
Expand Up @@ -73,6 +73,7 @@

<string name="video_settings">ビデオ設定</string>
<string name="software_renderer">Software Renderer</string>
<string name="opengl_es3">OpenGL ES 3</string>
<string name="video_backend">ビデオレンダラ</string>
<string name="video_backend_to_use">使用するビデオレンダラー</string>

Expand Down
55 changes: 55 additions & 0 deletions Source/Android/res/values/arrays.xml
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- All lists for ListPreference keys/values are placed here -->
<resources>

<!-- CPU core selection - X86 -->
<string-array name="emuCoreEntriesX86" translatable="false">
<item>@string/interpreter</item>
<item>@string/jit64_recompiler</item>
<item>@string/jitil_recompiler</item>
</string-array>
<string-array name="emuCoreValuesX86" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>

<!-- CPU core selection - ARM -->
<string-array name="emuCoreEntriesARM" translatable="false">
<item>@string/interpreter</item>
<item>@string/jit_arm_recompiler</item>
</string-array>
<string-array name="emuCoreValuesARM" translatable="false">
<item>0</item>
<item>3</item>
</string-array>

<!-- CPU core selection - Other -->
<string-array name="emuCoreEntriesOther" translatable="false">
<item>@string/interpreter</item>
</string-array>
<string-array name="emuCoreValuesOther" translatable="false">
<item>0</item>
</string-array>


<!-- Video Backend Selection - Supports OpenGL ES 3 -->
<string-array name="videoBackendEntriesGLES3" translatable="false">
<item>@string/software_renderer</item>
<item>@string/opengl_es3</item>
</string-array>
<string-array name="videoBackendValuesGLES3" translatable="false">
<item>Software Renderer</item>
<item>OGL</item>
</string-array>

<!-- Video Backend Selection - No OpenGL ES 3 support -->
<string-array name="videoBackendEntriesNoGLES3">
<item>@string/software_renderer</item>
</string-array>
<string-array name="videoBackendValuesNoGLES3">
<item>Software Renderer</item>
</string-array>

</resources>
12 changes: 0 additions & 12 deletions Source/Android/res/values/prefvalues.xml

This file was deleted.

1 change: 1 addition & 0 deletions Source/Android/res/values/strings.xml
Expand Up @@ -73,6 +73,7 @@

<string name="video_settings">Video Settings</string>
<string name="software_renderer">Software Renderer</string>
<string name="opengl_es3">OpenGL ES 3</string>
<string name="video_backend">Video Backend</string>
<string name="video_backend_to_use">Video backend to use</string>

Expand Down
Expand Up @@ -127,9 +127,9 @@ public void onCreate(Bundle savedInstanceState)

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("cpupref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "CPUCore", "3"));
editor.putBoolean("dualcorepref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "CPUThread", "False").equals("True") ? true : false);
editor.putString("gpupref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "GFXBackend ", "Software Renderer"));
editor.putString("cpuCorePref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "CPUCore", "3"));
editor.putBoolean("dualCorePref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "CPUThread", "False").equals("True") ? true : false);
editor.putString("gpuPref", NativeLibrary.GetConfig("Dolphin.ini", "Core", "GFXBackend ", "Software Renderer"));
editor.commit();
}
}
Expand Down
Expand Up @@ -113,9 +113,9 @@ public void SwitchPage(int toPage)
case 2:
{
String Keys[] = {
"cpupref",
"dualcorepref",
"gpupref",
"cpuCorePref",
"dualCorePref",
"gpuPref",
};
String ConfigKeys[] = {
"Core-CPUCore",
Expand Down
70 changes: 26 additions & 44 deletions Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java
@@ -1,12 +1,9 @@
package org.dolphinemu.dolphinemu;

import java.util.HashMap;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;

import javax.microedition.khronos.egl.*;
Expand Down Expand Up @@ -111,11 +108,11 @@ static public boolean SupportsGLES3()
boolean mSupportsGLES3 = false;

// Check for OpenGL ES 3 support (General case).
if (m_GLVersion.contains("OpenGL ES 3.0") || m_GLVersion.equals("OpenGL ES 3.0"))
if (m_GLVersion != null && (m_GLVersion.contains("OpenGL ES 3.0") || m_GLVersion.equals("OpenGL ES 3.0")))
mSupportsGLES3 = true;

// Checking for OpenGL ES 3 support for certain Qualcomm devices.
if (!mSupportsGLES3 && m_GLVendor.equals("Qualcomm"))
if (!mSupportsGLES3 && m_GLVendor != null && m_GLVendor.equals("Qualcomm"))
{
if (m_GLRenderer.contains("Adreno (TM) 3"))
{
Expand Down Expand Up @@ -149,58 +146,43 @@ public void onCreate(Bundle savedInstanceState)
// Load the preferences from an XML resource
addPreferencesFromResource(R.layout.prefs);

final ListPreference etp = new ListPreference(m_activity);
final HashMap<CharSequence, CharSequence> entries = new HashMap<CharSequence, CharSequence>();
final ListPreference cpuCores = (ListPreference) findPreference("cpuCorePref");

//
// Set valid emulation cores depending on the CPU architecture
// that the Android device is running on.
//
if (Build.CPU_ABI.contains("x86"))
{
entries.put(getString(R.string.interpreter), "0");
entries.put(getString(R.string.jit64_recompiler), "1");
entries.put(getString(R.string.jitil_recompiler), "2");
cpuCores.setEntries(R.array.emuCoreEntriesX86);
cpuCores.setEntryValues(R.array.emuCoreValuesX86);
}
else if (Build.CPU_ABI.contains("arm"))
{
entries.put(getString(R.string.interpreter), "0");
entries.put(getString(R.string.jit_arm_recompiler), "3");
cpuCores.setEntries(R.array.emuCoreEntriesARM);
cpuCores.setEntryValues(R.array.emuCoreValuesARM);
}
else
{
entries.put(getString(R.string.interpreter), "0");
cpuCores.setEntries(R.array.emuCoreEntriesOther);
cpuCores.setEntryValues(R.array.emuCoreValuesOther);
}

// Convert the key/value sections to arrays respectively so the list can be set.
// If Java had proper generics it wouldn't look this disgusting.
etp.setEntries(entries.keySet().toArray(new CharSequence[entries.size()]));
etp.setEntryValues(entries.values().toArray(new CharSequence[entries.size()]));
etp.setKey("cpupref");
etp.setTitle(getString(R.string.cpu_core));
etp.setSummary(getString(R.string.emu_core_to_use));

PreferenceCategory mCategory = (PreferenceCategory) findPreference("cpuprefcat");
mCategory.addPreference(etp);

boolean mSupportsGLES3 = SupportsGLES3();
//
// Setting valid video backends.
//
final ListPreference videoBackends = (ListPreference) findPreference("gpuPref");
final boolean deviceSupportsGLES3 = SupportsGLES3();

if (!mSupportsGLES3)
if (deviceSupportsGLES3)
{
mCategory = (PreferenceCategory) findPreference("videoprefcat");
ListPreference mPref = (ListPreference) findPreference("gpupref");
mCategory.removePreference(mPref);

final ListPreference videobackend = new ListPreference(m_activity);

// Add available graphics renderers to the hashmap to add to the list.
entries.clear();
entries.put(getString(R.string.software_renderer), "Software Renderer");

videobackend.setKey("gpupref");
videobackend.setTitle(getString(R.string.video_backend));
videobackend.setSummary(getString(R.string.video_backend_to_use));

videobackend.setEntries(entries.keySet().toArray(new CharSequence[entries.size()]));
videobackend.setEntryValues(entries.values().toArray(new CharSequence[entries.size()]));

mCategory.addPreference(videobackend);
videoBackends.setEntries(R.array.videoBackendEntriesGLES3);
videoBackends.setEntryValues(R.array.videoBackendValuesGLES3);
}
else
{
videoBackends.setEntries(R.array.videoBackendEntriesNoGLES3);
videoBackends.setEntryValues(R.array.videoBackendValuesNoGLES3);
}
}

Expand Down

0 comments on commit 77a5af3

Please sign in to comment.