mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-29 11:10:27 +00:00
Merge pull request #371 from lioncash/master
[Android] Sort the cores in the CoreSelection activity alphabetically.
This commit is contained in:
commit
f666509e37
@ -4,6 +4,9 @@ import com.retroarch.R;
|
||||
import com.retroarch.browser.preferences.util.UserPreferences;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.*;
|
||||
import android.media.AudioManager;
|
||||
@ -11,8 +14,10 @@ import android.os.*;
|
||||
import android.widget.*;
|
||||
import android.view.*;
|
||||
|
||||
// JELLY_BEAN_MR1 = 17
|
||||
|
||||
/**
|
||||
* {@link ListActivity} subclass that displays the list
|
||||
* of selectable cores for emulating games.
|
||||
*/
|
||||
public final class CoreSelection extends ListActivity {
|
||||
private IconAdapter<ModuleWrapper> adapter;
|
||||
|
||||
@ -26,14 +31,11 @@ public final class CoreSelection extends ListActivity {
|
||||
// Setup the layout
|
||||
setContentView(R.layout.line_list);
|
||||
|
||||
// Setup the list
|
||||
adapter = new IconAdapter<ModuleWrapper>(this, R.layout.line_list_item);
|
||||
setListAdapter(adapter);
|
||||
|
||||
// Set the activity title.
|
||||
setTitle(R.string.select_libretro_core);
|
||||
|
||||
// Populate the list
|
||||
final List<ModuleWrapper> cores = new ArrayList<ModuleWrapper>();
|
||||
final File[] libs = new File(getApplicationInfo().dataDir, "/cores").listFiles();
|
||||
for (final File lib : libs) {
|
||||
String libName = lib.getName();
|
||||
@ -59,10 +61,17 @@ public final class CoreSelection extends ListActivity {
|
||||
if (hasNeonVersion)
|
||||
continue;
|
||||
}
|
||||
|
||||
adapter.add(new ModuleWrapper(this, lib));
|
||||
|
||||
cores.add(new ModuleWrapper(this, lib));
|
||||
}
|
||||
|
||||
// Sort the list of cores alphabetically
|
||||
Collections.sort(cores);
|
||||
|
||||
// Initialize the IconAdapter with the list of cores.
|
||||
adapter = new IconAdapter<ModuleWrapper>(this, R.layout.line_list_item, cores);
|
||||
setListAdapter(adapter);
|
||||
|
||||
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,10 @@ import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* {@link Activity} subclass that provides the functionality
|
||||
* for the refresh rate testing for device displays.
|
||||
*/
|
||||
public final class DisplayRefreshRateTest extends Activity {
|
||||
|
||||
private class Renderer implements GLSurfaceView.Renderer {
|
||||
|
@ -6,6 +6,9 @@ import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
/**
|
||||
* Basic {@link PreferenceActivity} responsible for displaying the help articles.
|
||||
*/
|
||||
public final class HelpActivity extends PreferenceActivity {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
|
@ -17,6 +17,10 @@ import android.view.View;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Represents the {@link ListActivity} responsible
|
||||
* for displaying the list of previously played games.
|
||||
*/
|
||||
public final class HistorySelection extends ListActivity {
|
||||
|
||||
private IconAdapter<HistoryWrapper> adapter;
|
||||
|
@ -4,13 +4,24 @@ import java.io.File;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
/**
|
||||
* Wraps a previously played game along with its core
|
||||
* for placement within the previously played history.
|
||||
*/
|
||||
public final class HistoryWrapper implements IconAdapterItem {
|
||||
|
||||
|
||||
private String gamePath;
|
||||
private String gamePathShort;
|
||||
private String corePath;
|
||||
private String coreName;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param gamePath Path to the previously played game.
|
||||
* @param corePath Path to the core the previously played game uses.
|
||||
* @param coreName The actual name of the core.
|
||||
*/
|
||||
public HistoryWrapper(String gamePath, String corePath, String coreName) {
|
||||
this.gamePath = gamePath;
|
||||
this.corePath = corePath;
|
||||
@ -23,15 +34,30 @@ public final class HistoryWrapper implements IconAdapterItem {
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the path to the previously played game.
|
||||
*
|
||||
* @return the path to the previously played game.
|
||||
*/
|
||||
public String getGamePath() {
|
||||
return gamePath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the path to the core that the previously played game uses.
|
||||
*
|
||||
* @return the path to the core that the previously played game uses.
|
||||
*/
|
||||
public String getCorePath() {
|
||||
return corePath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the name of the core used with the previously played game.
|
||||
*
|
||||
* @return the name of the core used with the previously played game.
|
||||
*/
|
||||
public String getCoreName() {
|
||||
return coreName;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.retroarch.browser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.retroarch.R;
|
||||
|
||||
import android.content.*;
|
||||
@ -7,24 +9,97 @@ import android.graphics.drawable.*;
|
||||
import android.view.*;
|
||||
import android.widget.*;
|
||||
|
||||
/**
|
||||
* Represents an item that is capable
|
||||
* of being within an {@link IconAdapter}.
|
||||
*/
|
||||
interface IconAdapterItem {
|
||||
|
||||
/**
|
||||
* Gets whether or not this item is
|
||||
* enabled within the adapter.
|
||||
* <p>
|
||||
* This can be used for deciding whether or
|
||||
* not to enable an item in a {@link ListView}
|
||||
* if an IconAdapter is backing it.
|
||||
*
|
||||
* @return true if this item is enabled; false otherwise.
|
||||
*/
|
||||
public boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Gets the title text of this IconAdapterItem.
|
||||
*
|
||||
* @return the title text of this IconAdapterItem.
|
||||
*/
|
||||
public String getText();
|
||||
|
||||
/**
|
||||
* Gets the subtitle text of this IconAdapterItem.
|
||||
*
|
||||
* @return the subtitle text of this IconAdapterItem.
|
||||
*/
|
||||
public String getSubText();
|
||||
|
||||
/**
|
||||
* Gets the resource ID of the icon to display
|
||||
* alongside the text in this IconAdapterItem.
|
||||
* <p>
|
||||
* Returning zero means no icon is to be displayed.
|
||||
*
|
||||
* @return the resource ID of this IconAdapterItem's icon.
|
||||
*/
|
||||
public int getIconResourceId();
|
||||
|
||||
/**
|
||||
* Gets the actual {@link Drawable} object that represents
|
||||
* the icon that is displayed with this IconAdapterItem.
|
||||
* <p>
|
||||
* Returning null means no icon is to be displayed.
|
||||
*
|
||||
* @return the actual {@link Drawable} of this IconAdapterItem's icon.
|
||||
*/
|
||||
public Drawable getIconDrawable();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An {@link ArrayAdapter} derivative that can back a {@link View}
|
||||
* that accepts ArrayAdapters. Items within this ArrayAdapter derivative
|
||||
* must implement the {@link IconAdapterItem} interface.
|
||||
*
|
||||
* @param <T> The type of the item that will be within this IconAdapter.
|
||||
* This type must implement the {@link IconAdapterItem} interface.
|
||||
*/
|
||||
public final class IconAdapter<T extends IconAdapterItem> extends ArrayAdapter<T> {
|
||||
private final int resourceId;
|
||||
private final Context context;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param context The current {@link Context}.
|
||||
* @param resourceId The resource ID for a layout file containing a layout to use when instantiating views.
|
||||
*/
|
||||
public IconAdapter(Context context, int resourceId) {
|
||||
super(context, resourceId);
|
||||
this.context = context;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param context The current {@link Context}.
|
||||
* @param resourceId The resource ID for a layout file containing a layout to use when instantiating views.
|
||||
* @param items The list of items to store within this IconAdapter.
|
||||
*/
|
||||
public IconAdapter(Context context, int resourceId, List<T> items) {
|
||||
super(context, resourceId, items);
|
||||
this.context = context;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// Build the view
|
||||
|
@ -21,6 +21,10 @@ import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* {@link PreferenceActivity} subclass that provides all of the
|
||||
* functionality of the main menu screen.
|
||||
*/
|
||||
public final class MainMenuActivity extends PreferenceActivity {
|
||||
private static MainMenuActivity instance = null;
|
||||
private static final int ACTIVITY_LOAD_ROM = 0;
|
||||
@ -30,30 +34,30 @@ public final class MainMenuActivity extends PreferenceActivity {
|
||||
private static String libretro_name;
|
||||
|
||||
private void showGPLWaiver() {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.gpl_waiver)
|
||||
.setMessage(R.string.gpl_waiver_desc)
|
||||
.setPositiveButton("Keep", null)
|
||||
.setNegativeButton("Remove non-GPL cores",
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final File[] libs = new File(getApplicationInfo().dataDir, "/cores").listFiles();
|
||||
for (final File lib : libs) {
|
||||
ModuleWrapper module = new ModuleWrapper(getApplicationContext(), lib);
|
||||
|
||||
boolean gplv3 = module.getCoreLicense().equals("GPLv3");
|
||||
boolean gplv2 = module.getCoreLicense().equals("GPLv2");
|
||||
|
||||
if (!gplv3 && !gplv2) {
|
||||
String libName = lib.getName();
|
||||
Log.i("GPL WAIVER", "Deleting non-GPL core" + libName + "...");
|
||||
lib.delete();
|
||||
}
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
||||
.setTitle(R.string.gpl_waiver)
|
||||
.setMessage(R.string.gpl_waiver_desc)
|
||||
.setPositiveButton("Keep", null)
|
||||
.setNegativeButton("Remove non-GPL cores",
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final File[] libs = new File(getApplicationInfo().dataDir, "/cores").listFiles();
|
||||
for (final File lib : libs) {
|
||||
ModuleWrapper module = new ModuleWrapper(getApplicationContext(), lib);
|
||||
|
||||
boolean gplv3 = module.getCoreLicense().equals("GPLv3");
|
||||
boolean gplv2 = module.getCoreLicense().equals("GPLv2");
|
||||
|
||||
if (!gplv3 && !gplv2) {
|
||||
String libName = lib.getName();
|
||||
Log.i("GPL WAIVER", "Deleting non-GPL core" + libName + "...");
|
||||
lib.delete();
|
||||
}
|
||||
}
|
||||
});
|
||||
alert.show();
|
||||
}
|
||||
});
|
||||
alert.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.retroarch.browser;
|
||||
|
||||
// Helper class which calls into JNI for various tasks.
|
||||
/**
|
||||
* Helper class which calls into JNI for various tasks.
|
||||
*/
|
||||
public final class NativeInterface {
|
||||
|
||||
static {
|
||||
|
@ -8,6 +8,9 @@ import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* The {@link Activity} derivative responsible for displaying the TV Mode feature.
|
||||
*/
|
||||
public final class RetroTVMode extends Activity {
|
||||
private static final String TAG = "RetroTVMode";
|
||||
private static final int ACTIVITY_RETROARCH = 1;
|
||||
|
@ -15,7 +15,17 @@ import android.os.*;
|
||||
import android.widget.*;
|
||||
import android.view.*;
|
||||
|
||||
|
||||
/**
|
||||
* {@link ListActivity} subclass that provides a file-browser
|
||||
* like UI for browsing for specific files.
|
||||
* <p>
|
||||
* This file browser also allows for custom filtering
|
||||
* depending on the type of class that inherits it.
|
||||
* <p>
|
||||
* This file browser also uses an implementation of a
|
||||
* backstack for remembering previously browsed folders
|
||||
* within this DirectoryActivity.
|
||||
*/
|
||||
public class DirectoryActivity extends ListActivity {
|
||||
private IconAdapter<FileWrapper> adapter;
|
||||
private File listedDirectory;
|
||||
@ -180,14 +190,37 @@ public class DirectoryActivity extends ListActivity {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allows specifying an allowed file extension.
|
||||
* <p>
|
||||
* Any files that contain this file extension will be shown
|
||||
* within the DirectoryActivity file browser. Those that don't
|
||||
* contain this extension will not be shows.
|
||||
* <p>
|
||||
* It is possible to specify more than one allowed extension by
|
||||
* simply calling this method with a different file extension specified.
|
||||
*
|
||||
* @param ext The file extension to allow being shown in this DirectoryActivity.
|
||||
*/
|
||||
protected void addAllowedExt(String ext) {
|
||||
if (allowedExt == null)
|
||||
allowedExt = new ArrayList<String>();
|
||||
|
||||
allowedExt.add(ext);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Allows specifying a disallowed file extension.
|
||||
* <p>
|
||||
* Any files that contain this file extension will not be shown
|
||||
* within the DirectoryActivity file browser.
|
||||
* <p>
|
||||
* It is possible to specify more than one disallowed extension by
|
||||
* simply calling this method with a different file extension specified.
|
||||
*
|
||||
* @param ext The file extension to hide from being shown in this DirectoryActivity.
|
||||
*/
|
||||
protected void addDisallowedExt(String ext) {
|
||||
if (disallowedExt == null)
|
||||
disallowedExt = new ArrayList<String>();
|
||||
|
@ -4,6 +4,12 @@ import java.io.File;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* {@link DirectoryActivity} subclass used for the sole
|
||||
* purpose of navigating the Android filesystem for input overlays.
|
||||
* @author Lioncash-yay
|
||||
*
|
||||
*/
|
||||
public final class OverlayActivity extends DirectoryActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -7,6 +7,11 @@ import com.retroarch.browser.preferences.util.UserPreferences;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* {@link DirectoryActivity} subclass used for the sole
|
||||
* purpose of navigating the Android filesystem for selecting
|
||||
* a ROM file to execute during emulation.
|
||||
*/
|
||||
public final class ROMActivity extends DirectoryActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -2,6 +2,11 @@ package com.retroarch.browser.diractivities;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* {@link DirectoryActivity} subclass used for the sole
|
||||
* purpose of navigating the Android filesystem to select
|
||||
* a custom ROM directory.
|
||||
*/
|
||||
public final class ROMDirActivity extends DirectoryActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -2,6 +2,11 @@ package com.retroarch.browser.diractivities;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* {@link DirectoryActivity} subclass used for the sole
|
||||
* purpose of navigating the Android filesystem for selecting
|
||||
* a custom save file directory.
|
||||
*/
|
||||
public final class SRMDirActivity extends DirectoryActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -4,6 +4,11 @@ import java.io.File;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* {@link DirectoryActivity} subclass used for the sole
|
||||
* purpose of navigating the Android filesystem for selecting
|
||||
* a shader to use during emulation.
|
||||
*/
|
||||
public final class ShaderActivity extends DirectoryActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -2,6 +2,11 @@ package com.retroarch.browser.diractivities;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* {@link DirectoryActivity} subclass used for the sole
|
||||
* purpose of navigating the Android filesystem to select
|
||||
* a custom save state directory.
|
||||
*/
|
||||
public final class StateDirActivity extends DirectoryActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -2,6 +2,13 @@ package com.retroarch.browser.diractivities;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
/**
|
||||
* {@link DirectoryActivity} subclass used for the sole
|
||||
* purpose of navigating the Android filesystem for selecting
|
||||
* a custom 'System' directory that the cores will look in for
|
||||
* required files, such as BIOS files and other miscellaneous
|
||||
* system-required files.
|
||||
*/
|
||||
public final class SystemDirActivity extends DirectoryActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
Loading…
Reference in New Issue
Block a user