From 023922cd5ba260ff12e69feeb36dc8449445b734 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 16 Jul 2013 05:32:14 -0500 Subject: [PATCH] [Android] Start making it so the side pane is visible on all activities by converting them to fragments. Only Browse Folder and Gamepad Config remain. Fix a issue that Lioncash introduced where no games would show up in the folder browser or the game list. --- Source/Android/AndroidManifest.xml | 4 +- .../dolphinemu/dolphinemu/AboutActivity.java | 31 --- .../dolphinemu/dolphinemu/AboutFragment.java | 61 +++++ .../dolphinemu/dolphinemu/FolderBrowser.java | 4 +- .../dolphinemu/GameListActivity.java | 154 +++++++------ .../dolphinemu/GameListFragment.java | 2 +- .../dolphinemu/dolphinemu/PrefsActivity.java | 217 ------------------ .../dolphinemu/dolphinemu/PrefsFragment.java | 207 +++++++++++++++++ 8 files changed, 363 insertions(+), 317 deletions(-) delete mode 100644 Source/Android/src/org/dolphinemu/dolphinemu/AboutActivity.java create mode 100644 Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java delete mode 100644 Source/Android/src/org/dolphinemu/dolphinemu/PrefsActivity.java create mode 100644 Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java diff --git a/Source/Android/AndroidManifest.xml b/Source/Android/AndroidManifest.xml index a265840ea2..3cd0b19614 100644 --- a/Source/Android/AndroidManifest.xml +++ b/Source/Android/AndroidManifest.xml @@ -36,13 +36,13 @@ android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" > + android:name=".PrefsFragment" > + android:name=".AboutFragment" > diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/AboutActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/AboutActivity.java deleted file mode 100644 index 5725651c9b..0000000000 --- a/Source/Android/src/org/dolphinemu/dolphinemu/AboutActivity.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.dolphinemu.dolphinemu; - -import android.app.ListActivity; -import android.os.Bundle; - -import java.util.ArrayList; -import java.util.List; - -/** - * Copyright 2013 Dolphin Emulator Project - * Licensed under GPLv2 - * Refer to the license.txt file included. - */ -public class AboutActivity extends ListActivity { - private FolderBrowserAdapter adapter; - private int configPosition = 0; - boolean Configuring = false; - boolean firstEvent = true; - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - List Input = new ArrayList(); - int a = 0; - - Input.add(a++, new GameListItem(getApplicationContext(), "Build Revision", NativeLibrary.GetVersionString(), "", true)); - adapter = new FolderBrowserAdapter(this, R.layout.folderbrowser, Input); - setListAdapter(adapter); - } -} diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java new file mode 100644 index 0000000000..4f0cf10702 --- /dev/null +++ b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java @@ -0,0 +1,61 @@ +package org.dolphinemu.dolphinemu; + +import android.app.Activity; +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ListView; + +import java.util.ArrayList; +import java.util.List; + +/** + * Copyright 2013 Dolphin Emulator Project + * Licensed under GPLv2 + * Refer to the license.txt file included. + */ +public class AboutFragment extends Fragment { + private static Activity m_activity; + + private ListView mMainList; + + private FolderBrowserAdapter adapter; + private int configPosition = 0; + boolean Configuring = false; + boolean firstEvent = true; + + public AboutFragment() { + // Empty constructor required for fragment subclasses + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.gamelist_listview, container, false); + mMainList = (ListView) rootView.findViewById(R.id.gamelist); + + List Input = new ArrayList(); + int a = 0; + + Input.add(a++, new GameListItem(m_activity, "Build Revision", NativeLibrary.GetVersionString(), "", true)); + adapter = new FolderBrowserAdapter(m_activity, R.layout.folderbrowser, Input); + mMainList.setAdapter(adapter); + + return mMainList; + } + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + + // This makes sure that the container activity has implemented + // the callback interface. If not, it throws an exception + try { + m_activity = activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement OnGameListZeroListener"); + } + } +} diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java index c5bfc380f8..130919cf8d 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java @@ -50,11 +50,11 @@ public class FolderBrowser extends ListActivity { } else { - if (validExts.contains(entryName.toLowerCase())) + if (validExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) { fls.add(new GameListItem(getApplicationContext(), entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), true)); } - else if (archiveExts.contains(entryName.toLowerCase())) + else if (archiveExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) { fls.add(new GameListItem(getApplicationContext(), entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), false)); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java index cedf728574..2c8a0e61a8 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListActivity.java @@ -28,6 +28,7 @@ import java.util.List; public class GameListActivity extends Activity implements GameListFragment.OnGameListZeroListener{ + private int mCurPage = 0; enum keyTypes {TYPE_STRING, TYPE_BOOL}; private ActionBarDrawerToggle mDrawerToggle; @@ -53,10 +54,11 @@ public class GameListActivity extends Activity mDrawerList = (ListView) findViewById(R.id.left_drawer); List dir = new ArrayList(); - dir.add(new SideMenuItem("Browse Folder", 0)); - dir.add(new SideMenuItem("Settings", 1)); - dir.add(new SideMenuItem("Gamepad Config", 2)); - dir.add(new SideMenuItem("About", 3)); + dir.add(new SideMenuItem("Game List", 0)); + dir.add(new SideMenuItem("Browse Folder", 1)); + dir.add(new SideMenuItem("Settings", 2)); + dir.add(new SideMenuItem("Gamepad Config", 3)); + dir.add(new SideMenuItem("About", 4)); mDrawerAdapter = new SideMenuAdapter(this, R.layout.sidemenu, dir); mDrawerList.setAdapter(mDrawerAdapter); @@ -94,67 +96,15 @@ public class GameListActivity extends Activity FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); } - - private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener() + private void SwitchPage(int toPage) { - public void onItemClick(AdapterView parent, View view, int position, long id) + if (mCurPage == toPage) + return; + switch (mCurPage) { - SideMenuItem o = mDrawerAdapter.getItem(position); - mDrawerLayout.closeDrawer(mDrawerList); - - switch(o.getID()) - { - case 0: - Toast.makeText(mMe, "Loading up the browser", Toast.LENGTH_SHORT).show(); - Intent ListIntent = new Intent(mMe, FolderBrowser.class); - startActivityForResult(ListIntent, 1); - break; - case 1: - Toast.makeText(mMe, "Loading up settings", Toast.LENGTH_SHORT).show(); - Intent SettingIntent = new Intent(mMe, PrefsActivity.class); - startActivityForResult(SettingIntent, 2); - break; - case 2: - Toast.makeText(mMe, "Loading up gamepad config", Toast.LENGTH_SHORT).show(); - Intent ConfigIntent = new Intent(mMe, InputConfigActivity.class); - startActivityForResult(ConfigIntent, 3); - break; - case 3: - Toast.makeText(mMe, "Loading up About", Toast.LENGTH_SHORT).show(); - Intent AboutIntent = new Intent(mMe, AboutActivity.class); - startActivityForResult(AboutIntent, 3); - break; - default: - break; - } - - } - }; - @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) - { - super.onActivityResult(requestCode, resultCode, data); - - 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 = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0"); - int intDirectories = Integer.parseInt(Directories); - Directories = Integer.toString(intDirectories + 1); - NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPathes", Directories); - NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(intDirectories), FileName); - - recreateFragment(); - } - break; // Settings case 2: - + { String Keys[] = { "cpupref", "dualcorepref", @@ -193,9 +143,85 @@ public class GameListActivity extends Activity } } - break; + } + break; + case 0: // Settings case 3: // Gamepad settings - /* Do Nothing */ + /* Do Nothing */ + break; + } + switch(toPage) + { + case 0: + { + mCurPage = 0; + Fragment fragment = new GameListFragment(); + FragmentManager fragmentManager = getFragmentManager(); + fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); + } + break; + case 1: + Toast.makeText(mMe, "Loading up the browser", Toast.LENGTH_SHORT).show(); + Intent ListIntent = new Intent(mMe, FolderBrowser.class); + startActivityForResult(ListIntent, 1); + break; + case 2: + { + Toast.makeText(mMe, "Loading up settings", Toast.LENGTH_SHORT).show(); + mCurPage = 2; + Fragment fragment = new PrefsFragment(); + FragmentManager fragmentManager = getFragmentManager(); + fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); + } + break; + case 3: + Toast.makeText(mMe, "Loading up gamepad config", Toast.LENGTH_SHORT).show(); + Intent ConfigIntent = new Intent(mMe, InputConfigActivity.class); + startActivityForResult(ConfigIntent, 3); + break; + case 4: + { + Toast.makeText(mMe, "Loading up About", Toast.LENGTH_SHORT).show(); + mCurPage = 4; + Fragment fragment = new AboutFragment(); + FragmentManager fragmentManager = getFragmentManager(); + fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit(); + } + break; + default: + break; + } + } + private AdapterView.OnItemClickListener mMenuItemClickListener = new AdapterView.OnItemClickListener() + { + public void onItemClick(AdapterView parent, View view, int position, long id) + { + SideMenuItem o = mDrawerAdapter.getItem(position); + mDrawerLayout.closeDrawer(mDrawerList); + SwitchPage(o.getID()); + } + }; + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) + { + super.onActivityResult(requestCode, resultCode, data); + + 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 = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0"); + int intDirectories = Integer.parseInt(Directories); + Directories = Integer.toString(intDirectories + 1); + NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPathes", Directories); + NativeLibrary.SetConfig("Dolphin.ini", "General", "GCMPath" + Integer.toString(intDirectories), FileName); + + recreateFragment(); + } break; } } @@ -235,7 +261,7 @@ public class GameListActivity extends Activity } public void onBackPressed() { - + SwitchPage(0); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java index 627549b926..152c18662b 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/GameListFragment.java @@ -62,7 +62,7 @@ public class GameListFragment extends Fragment { if(!entry.isDirectory()) { - if (exts.contains(entryName.toLowerCase())) + if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) fls.add(new GameListItem(mMe.getApplicationContext(), entryName,"File Size: "+entry.length(),entry.getAbsolutePath(), true)); } } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsActivity.java deleted file mode 100644 index 772f2b9cb6..0000000000 --- a/Source/Android/src/org/dolphinemu/dolphinemu/PrefsActivity.java +++ /dev/null @@ -1,217 +0,0 @@ -package org.dolphinemu.dolphinemu; - -import android.app.Activity; -import android.content.Intent; -import android.os.Build; -import android.os.Bundle; -import android.preference.ListPreference; -import android.preference.PreferenceActivity; -import android.preference.PreferenceCategory; -import android.preference.PreferenceFragment; - -import javax.microedition.khronos.egl.*; -import javax.microedition.khronos.opengles.GL10; - -/** - * Copyright 2013 Dolphin Emulator Project - * Licensed under GPLv2 - * Refer to the license.txt file included. - */ -public class PrefsActivity extends PreferenceActivity { - private PrefsActivity m_activity; - - private String m_GLVersion; - private String m_GLVendor; - private String m_GLRenderer; - - - public class VersionCheck { - EGL10 mEGL; - EGLDisplay mEGLDisplay; - EGLConfig[] mEGLConfigs; - EGLConfig mEGLConfig; - EGLContext mEGLContext; - EGLSurface mEGLSurface; - GL10 mGL; - - String mThreadOwner; - - public VersionCheck() { - - int[] version = new int[2]; - int[] attribList = new int[] { - EGL10.EGL_WIDTH, 1, - EGL10.EGL_HEIGHT, 1, - EGL10.EGL_RENDERABLE_TYPE, 4, - EGL10.EGL_NONE - }; - - // No error checking performed, minimum required code to elucidate logic - mEGL = (EGL10) EGLContext.getEGL(); - mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); - mEGL.eglInitialize(mEGLDisplay, version); - mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated - mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, null); - mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList); - mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext); - mGL = (GL10) mEGLContext.getGL(); - - // Record thread owner of OpenGL context - mThreadOwner = Thread.currentThread().getName(); - } - - public String getVersion() - { - return mGL.glGetString(GL10.GL_VERSION); - } - - public String getVendor() - { - return mGL.glGetString(GL10.GL_VENDOR); - } - public String getRenderer() - { - return mGL.glGetString(GL10.GL_RENDERER); - } - private EGLConfig chooseConfig() { - int[] attribList = new int[] { - EGL10.EGL_DEPTH_SIZE, 0, - EGL10.EGL_STENCIL_SIZE, 0, - EGL10.EGL_RED_SIZE, 8, - EGL10.EGL_GREEN_SIZE, 8, - EGL10.EGL_BLUE_SIZE, 8, - EGL10.EGL_ALPHA_SIZE, 8, - EGL10.EGL_NONE - }; - - // No error checking performed, minimum required code to elucidate logic - // Expand on this logic to be more selective in choosing a configuration - int[] numConfig = new int[1]; - mEGL.eglChooseConfig(mEGLDisplay, attribList, null, 0, numConfig); - int configSize = numConfig[0]; - mEGLConfigs = new EGLConfig[configSize]; - mEGL.eglChooseConfig(mEGLDisplay, attribList, mEGLConfigs, configSize, numConfig); - - return mEGLConfigs[0]; // Best match is probably the first configuration - } - } - - - - 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); - - final ListPreference etp = new ListPreference(m_activity); - CharSequence[] _entries; - CharSequence[] _entryvalues; - - if (Build.CPU_ABI.contains("x86")) - { - _entries = new CharSequence[] { - "Interpreter", - "JIT64 Recompiler", - "JITIL Recompiler", - }; - _entryvalues = new CharSequence[] {"0", "1", "2"}; - } - else if (Build.CPU_ABI.contains("arm")) - { - _entries = new CharSequence[] { - "Interpreter", - "JIT ARM Recompiler", - }; - _entryvalues = new CharSequence[] {"0", "3"}; - } - else - { - _entries = new CharSequence[] { - "Interpreter", - }; - _entryvalues = new CharSequence[] {"0"}; - } - - etp.setEntries(_entries); - etp.setEntryValues(_entryvalues); - etp.setKey("cpupref"); - etp.setTitle("CPU Core"); - etp.setSummary("Emulation core to use"); - - PreferenceCategory mCategory = (PreferenceCategory) findPreference("cpuprefcat"); - mCategory.addPreference(etp); - VersionCheck mbuffer = new VersionCheck(); - m_GLVersion = mbuffer.getVersion(); - m_GLVendor = mbuffer.getVendor(); - m_GLRenderer = mbuffer.getRenderer(); - - boolean mSupportsGLES3 = false; - - if (m_GLVersion.contains("OpenGL ES 3.0")) // 3.0 support - mSupportsGLES3 = true; - if (!mSupportsGLES3 && m_GLVendor.equals("Qualcomm")) - { - if (m_GLRenderer.contains("Adreno (TM) 3")) - { - int mVStart, mVEnd = 0; - float mVersion; - mVStart = m_GLVersion.indexOf("V@") + 2; - for (int a = mVStart; a < m_GLVersion.length(); ++a) - if (m_GLVersion.charAt(a) == ' ') - { - mVEnd = a; - break; - } - mVersion = Float.parseFloat(m_GLVersion.substring(mVStart, mVEnd)); - - if (mVersion >= 14.0f) - mSupportsGLES3 = true; - } - } - - if (!mSupportsGLES3) - { - mCategory = (PreferenceCategory) findPreference("videoprefcat"); - ListPreference mPref = (ListPreference) findPreference("gpupref"); - mCategory.removePreference(mPref); - - final ListPreference videobackend = new ListPreference(m_activity); - - _entries = new CharSequence[] { - "Software Renderer", - }; - _entryvalues = new CharSequence[] {"Software Renderer"}; - - videobackend.setKey("gpupref"); - videobackend.setTitle("Video Backend"); - videobackend.setSummary("Video backend to use"); - - videobackend.setEntries(_entries); - videobackend.setEntryValues(_entryvalues); - - mCategory.addPreference(videobackend); - } - } - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - m_activity = this; - - 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/PrefsFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java new file mode 100644 index 0000000000..d039c236bb --- /dev/null +++ b/Source/Android/src/org/dolphinemu/dolphinemu/PrefsFragment.java @@ -0,0 +1,207 @@ +package org.dolphinemu.dolphinemu; + +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.*; +import javax.microedition.khronos.opengles.GL10; + +/** + * Copyright 2013 Dolphin Emulator Project + * Licensed under GPLv2 + * Refer to the license.txt file included. + */ +public class PrefsFragment extends PreferenceFragment { + private Activity m_activity; + + private String m_GLVersion; + private String m_GLVendor; + private String m_GLRenderer; + + + public class VersionCheck { + EGL10 mEGL; + EGLDisplay mEGLDisplay; + EGLConfig[] mEGLConfigs; + EGLConfig mEGLConfig; + EGLContext mEGLContext; + EGLSurface mEGLSurface; + GL10 mGL; + + String mThreadOwner; + + public VersionCheck() { + + int[] version = new int[2]; + int[] attribList = new int[] { + EGL10.EGL_WIDTH, 1, + EGL10.EGL_HEIGHT, 1, + EGL10.EGL_RENDERABLE_TYPE, 4, + EGL10.EGL_NONE + }; + + // No error checking performed, minimum required code to elucidate logic + mEGL = (EGL10) EGLContext.getEGL(); + mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); + mEGL.eglInitialize(mEGLDisplay, version); + mEGLConfig = chooseConfig(); // Choosing a config is a little more complicated + mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, null); + mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList); + mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext); + mGL = (GL10) mEGLContext.getGL(); + + // Record thread owner of OpenGL context + mThreadOwner = Thread.currentThread().getName(); + } + + public String getVersion() + { + return mGL.glGetString(GL10.GL_VERSION); + } + + public String getVendor() + { + return mGL.glGetString(GL10.GL_VENDOR); + } + public String getRenderer() + { + return mGL.glGetString(GL10.GL_RENDERER); + } + private EGLConfig chooseConfig() { + int[] attribList = new int[] { + EGL10.EGL_DEPTH_SIZE, 0, + EGL10.EGL_STENCIL_SIZE, 0, + EGL10.EGL_RED_SIZE, 8, + EGL10.EGL_GREEN_SIZE, 8, + EGL10.EGL_BLUE_SIZE, 8, + EGL10.EGL_ALPHA_SIZE, 8, + EGL10.EGL_NONE + }; + + // No error checking performed, minimum required code to elucidate logic + // Expand on this logic to be more selective in choosing a configuration + int[] numConfig = new int[1]; + mEGL.eglChooseConfig(mEGLDisplay, attribList, null, 0, numConfig); + int configSize = numConfig[0]; + mEGLConfigs = new EGLConfig[configSize]; + mEGL.eglChooseConfig(mEGLDisplay, attribList, mEGLConfigs, configSize, numConfig); + + return mEGLConfigs[0]; // Best match is probably the first configuration + } + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Load the preferences from an XML resource + addPreferencesFromResource(R.layout.prefs); + + final ListPreference etp = new ListPreference(m_activity); + CharSequence[] _entries; + CharSequence[] _entryvalues; + + if (Build.CPU_ABI.contains("x86")) + { + _entries = new CharSequence[] { + "Interpreter", + "JIT64 Recompiler", + "JITIL Recompiler", + }; + _entryvalues = new CharSequence[] {"0", "1", "2"}; + } + else if (Build.CPU_ABI.contains("arm")) + { + _entries = new CharSequence[] { + "Interpreter", + "JIT ARM Recompiler", + }; + _entryvalues = new CharSequence[] {"0", "3"}; + } + else + { + _entries = new CharSequence[] { + "Interpreter", + }; + _entryvalues = new CharSequence[] {"0"}; + } + + etp.setEntries(_entries); + etp.setEntryValues(_entryvalues); + etp.setKey("cpupref"); + etp.setTitle("CPU Core"); + etp.setSummary("Emulation core to use"); + + PreferenceCategory mCategory = (PreferenceCategory) findPreference("cpuprefcat"); + mCategory.addPreference(etp); + VersionCheck mbuffer = new VersionCheck(); + m_GLVersion = mbuffer.getVersion(); + m_GLVendor = mbuffer.getVendor(); + m_GLRenderer = mbuffer.getRenderer(); + + boolean mSupportsGLES3 = false; + + if (m_GLVersion.contains("OpenGL ES 3.0")) // 3.0 support + mSupportsGLES3 = true; + if (!mSupportsGLES3 && m_GLVendor.equals("Qualcomm")) + { + if (m_GLRenderer.contains("Adreno (TM) 3")) + { + int mVStart, mVEnd = 0; + float mVersion; + mVStart = m_GLVersion.indexOf("V@") + 2; + for (int a = mVStart; a < m_GLVersion.length(); ++a) + if (m_GLVersion.charAt(a) == ' ') + { + mVEnd = a; + break; + } + mVersion = Float.parseFloat(m_GLVersion.substring(mVStart, mVEnd)); + + if (mVersion >= 14.0f) + mSupportsGLES3 = true; + } + } + + if (!mSupportsGLES3) + { + mCategory = (PreferenceCategory) findPreference("videoprefcat"); + ListPreference mPref = (ListPreference) findPreference("gpupref"); + mCategory.removePreference(mPref); + + final ListPreference videobackend = new ListPreference(m_activity); + + _entries = new CharSequence[] { + "Software Renderer", + }; + _entryvalues = new CharSequence[] {"Software Renderer"}; + + videobackend.setKey("gpupref"); + videobackend.setTitle("Video Backend"); + videobackend.setSummary("Video backend to use"); + + videobackend.setEntries(_entries); + videobackend.setEntryValues(_entryvalues); + + mCategory.addPreference(videobackend); + } + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + + // This makes sure that the container activity has implemented + // the callback interface. If not, it throws an exception + try { + m_activity = activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement OnGameListZeroListener"); + } + } +}