From f6abb8360f33a3c17597a0befdb6f13fc2169463 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 7 Jul 2015 21:14:59 +0200 Subject: [PATCH 1/5] (Java) Remove more code --- .../com/retroarch/browser/ModuleWrapper.java | 261 ------------------ .../browser/mainmenu/MainMenuActivity.java | 14 - 2 files changed, 275 deletions(-) delete mode 100644 android/phoenix/src/com/retroarch/browser/ModuleWrapper.java diff --git a/android/phoenix/src/com/retroarch/browser/ModuleWrapper.java b/android/phoenix/src/com/retroarch/browser/ModuleWrapper.java deleted file mode 100644 index 76127fb483..0000000000 --- a/android/phoenix/src/com/retroarch/browser/ModuleWrapper.java +++ /dev/null @@ -1,261 +0,0 @@ -package com.retroarch.browser; - -import com.retroarch.browser.preferences.util.ConfigFile; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import android.content.Context; -import android.graphics.drawable.Drawable; - -/** - * Wrapper class that encapsulates a libretro core - * along with information about said core. - */ -public final class ModuleWrapper implements IconAdapterItem, Comparable -{ - private final File file; - private final String displayName; - private final String coreName; - private final String manufacturer; - private final String systemName; - private final String license; - private final List authors; - private final List supportedExtensions; - private final List permissions; - - /** - * Constructor - * - * @param context The current {@link Context}. - * @param file The {@link File} instance of the core being wrapped. - */ - public ModuleWrapper(Context context, File file) - { - this.file = file; - - // Attempt to get the core's info file. - // Basically this is dataDir/info/[core name].info - - // So first, since the core name will have a platform-specific identifier at the end of its name, we trim this. - // If it turns out we have an invalid core name, simply assign the core name as the full name of the file. - final boolean isValidCoreName = (file.getName().lastIndexOf("_libretro.so") != -1); - final String coreName = (isValidCoreName) ? file.getName().substring(0, file.getName().lastIndexOf(".so")) - : file.getName(); - - // Now get the directory where all of the info files are kept (dataDir/info) - final String infoFileDir = context.getApplicationInfo().dataDir + File.separator + "info"; - - // Now, based off of the trimmed core name, we can get the core info file. - // and attempt to read it as a config file (since it has the same key-value layout). - final String infoFilePath = infoFileDir + File.separator + coreName + ".info"; - if (new File(infoFilePath).exists()) - { - final ConfigFile infoFile = new ConfigFile(infoFilePath); - - // Now read info out of the info file. Make them an empty string if the key doesn't exist. - this.displayName = (infoFile.keyExists("display_name")) ? infoFile.getString("display_name") : "N/A"; - this.coreName = (infoFile.keyExists("corename")) ? infoFile.getString("corename") : "N/A"; - this.systemName = (infoFile.keyExists("systemname")) ? infoFile.getString("systemname") : "N/A"; - this.manufacturer = (infoFile.keyExists("manufacturer")) ? infoFile.getString("manufacturer") : "N/A"; - this.license = (infoFile.keyExists("license")) ? infoFile.getString("license") : "N/A"; - - // Getting supported extensions and authors is a little different. - // We need to split at every '|' character, since it is - // the delimiter for a new extension that the core supports. - // - // Cores that don't have multiple extensions supported - // don't contain the '|' delimiter, so we just create a String list - // and just directly assign the retrieved extensions to it. - final String supportedExts = infoFile.getString("supported_extensions"); - if (supportedExts != null && supportedExts.contains("|")) - { - this.supportedExtensions = new ArrayList(Arrays.asList(supportedExts.split("\\|"))); - } - else - { - this.supportedExtensions = new ArrayList(); - this.supportedExtensions.add(supportedExts); - } - - final String emuAuthors = infoFile.getString("authors"); - if (emuAuthors != null && emuAuthors.contains("|")) - { - this.authors = new ArrayList(Arrays.asList(emuAuthors.split("\\|"))); - } - else - { - this.authors = new ArrayList(); - this.authors.add(emuAuthors); - } - - final String permissions = infoFile.getString("permissions"); - if (permissions != null && permissions.contains("|")) - { - this.permissions = new ArrayList(Arrays.asList(permissions.split("\\|"))); - } - else - { - this.permissions = new ArrayList(); - this.permissions.add(permissions); - } - } - else // No info file. - { - this.displayName = "N/A"; - this.systemName = "N/A"; - this.manufacturer = "N/A"; - this.license = "N/A"; - this.authors = new ArrayList(); - this.supportedExtensions = new ArrayList(); - this.coreName = coreName; - this.permissions = new ArrayList(); - } - } - - /** - * Same as the original constructor, but allows for string paths. - * - * @param context The current {@link Context}. - * @param path Path to the file to encapsulate. - */ - public ModuleWrapper(Context context, String path) - { - this(context, new File(path)); - } - - /** - * Gets the underlying {@link File} instance for this ModuleWrapper. - * - * @return the underlying {@link File} instance for this ModuleWrapper. - */ - public File getUnderlyingFile() - { - return file; - } - - /** - * Gets the display name for this wrapped core. - * - * @return the display name for this wrapped core. - */ - public String getDisplayName() - { - return displayName; - } - - /** - * Gets the internal core name for this wrapped core. - * - * @return the internal core name for this wrapped core. - */ - public String getInternalName() - { - return coreName; - } - - /** - * Gets the name of the system that is emulated by this wrapped core. - * (optional - in case core is an emulator) - * - * @return the name of the system that is emulated by this wrapped core. - */ - public String getEmulatedSystemName() - { - return systemName; - } - - /** - * Gets the license that this core is protected under. - * - * @return the license that this core is protected under. - */ - public String getCoreLicense() - { - return license; - } - - /** - * Gets the name of the manufacturer of the console that - * this core emulates. (optional - in case core is an - * emulator) - * - * @return the name of the manufacturer of the console that - * this core emulates. (optional) - */ - public String getManufacturer() - { - return manufacturer; - } - - /** - * Gets the list of authors of this core. - * - * @return the list of authors of this core. - */ - public List getAuthors() - { - return authors; - } - - /** - * Gets the list of permissions of this core. - * - * @return the list of authors of this core. - */ - public List getPermissions() - { - return permissions; - } - - /** - * Gets the List of supported extensions for this core. - * - * @return the List of supported extensions for this core. - */ - public List getSupportedExtensions() - { - return supportedExtensions; - } - - @Override - public boolean isEnabled() - { - return true; - } - - @Override - public String getText() - { - return coreName; - } - - @Override - public String getSubText() - { - return systemName; - } - - @Override - public int getIconResourceId() - { - return 0; - } - - @Override - public Drawable getIconDrawable() - { - return null; - } - - @Override - public int compareTo(ModuleWrapper other) - { - if(coreName != null) - return coreName.toLowerCase().compareTo(other.coreName.toLowerCase()); - else - throw new NullPointerException("The name of this ModuleWrapper is null"); - } -} \ No newline at end of file diff --git a/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuActivity.java b/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuActivity.java index 0a598c6ce6..ac72356e27 100644 --- a/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuActivity.java +++ b/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuActivity.java @@ -49,20 +49,6 @@ public final class MainMenuActivity extends FragmentActivity setVolumeControlStream(AudioManager.STREAM_MUSIC); } - public void setModule(String core_path, String core_name) - { - UserPreferences.updateConfigFile(this); - - SharedPreferences prefs = UserPreferences.getPreferences(this); - SharedPreferences.Editor edit = prefs.edit(); - edit.putString("libretro_path", core_path); - edit.putString("libretro_name", core_name); - edit.apply(); - - // Set the title section to contain the name of the selected core. - setCoreTitle(core_name); - } - public void setCoreTitle(String core_name) { setTitle("RetroArch : " + core_name); From 0350e0a495692de1dc66944b1fd3db5de8c3e586 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 7 Jul 2015 21:26:12 +0200 Subject: [PATCH 2/5] (Android) Kill off more Java code --- .../com/retroarch/browser/FileWrapper.java | 111 ----- .../com/retroarch/browser/IconAdapter.java | 152 ------- .../dirfragment/DirectoryFragment.java | 396 ------------------ .../browser/mainmenu/MainMenuFragment.java | 22 +- 4 files changed, 1 insertion(+), 680 deletions(-) delete mode 100644 android/phoenix/src/com/retroarch/browser/FileWrapper.java delete mode 100644 android/phoenix/src/com/retroarch/browser/IconAdapter.java delete mode 100644 android/phoenix/src/com/retroarch/browser/dirfragment/DirectoryFragment.java diff --git a/android/phoenix/src/com/retroarch/browser/FileWrapper.java b/android/phoenix/src/com/retroarch/browser/FileWrapper.java deleted file mode 100644 index 322d49b6b1..0000000000 --- a/android/phoenix/src/com/retroarch/browser/FileWrapper.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.retroarch.browser; - -import java.io.File; - -import com.retroarch.R; - -import android.graphics.drawable.Drawable; - -public final class FileWrapper implements IconAdapterItem, Comparable { - - public static final int DIRSELECT = 0; - public static final int PARENT = 1; - public static final int FILE = 2; - - private final File file; - private final boolean parentItem; - private final boolean dirSelectItem; - private final boolean enabled; - private final int typeIndex; - - public FileWrapper(File file, int type, boolean isEnabled) { - this.file = file; - - this.parentItem = (type == PARENT); - this.dirSelectItem = (type == DIRSELECT); - this.typeIndex = (type == FILE) ? (FILE + (file.isDirectory() ? 0 : 1)) : type; - - this.enabled = parentItem || dirSelectItem || isEnabled; - } - - @Override - public boolean isEnabled() { - return enabled; - } - - @Override - public String getText() { - if (dirSelectItem) - return "[[Use this directory]]"; - else if (parentItem) - return "[Parent Directory]"; - else - return file.getName(); - } - - @Override - public String getSubText() { - return null; - } - - @Override - public int getIconResourceId() { - if (!parentItem && !dirSelectItem) { - return file.isFile() ? R.drawable.ic_file : R.drawable.ic_dir; - } else { - return R.drawable.ic_dir; - } - } - - @Override - public Drawable getIconDrawable() { - return null; - } - - /** - * Checks whether or not the wrapped {@link File} is - * the "Parent Directory" item in the file browser. - * - * @return true if the wrapped {@link File} is the "Parent Directory" - * item in the file browser; false otherwise. - */ - public boolean isParentItem() { - return parentItem; - } - - /** - * Checks whether or not the wrapped {@link File} - * is the "use this directory" item. - * - * @return true if the wrapped {@link File} is the "Use this directory" - * item in the file browser; false otherwise. - */ - public boolean isDirSelectItem() { - return dirSelectItem; - } - - /** - * Gets the file wrapped by this FileWrapper. - * - * @return the file wrapped by this FileWrapper. - */ - public File getFile() { - return file; - } - - @Override - public int compareTo(FileWrapper other) { - if (other != null) { - // Who says ternary is hard to follow - if (isEnabled() == other.isEnabled()) { - return (typeIndex == other.typeIndex) ? file - .compareTo(other.file) - : ((typeIndex < other.typeIndex) ? -1 : 1); - } else { - return isEnabled() ? -1 : 1; - } - } - - return -1; - } -} diff --git a/android/phoenix/src/com/retroarch/browser/IconAdapter.java b/android/phoenix/src/com/retroarch/browser/IconAdapter.java deleted file mode 100644 index c3066fb03f..0000000000 --- a/android/phoenix/src/com/retroarch/browser/IconAdapter.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.retroarch.browser; - -import java.util.List; - -import com.retroarch.R; - -import android.content.*; -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. - *

- * 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. - *

- * 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. - *

- * 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 The type of the item that will be within this IconAdapter. - * This type must implement the {@link IconAdapterItem} interface. - */ -public final class IconAdapter extends ArrayAdapter { - 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 items) { - super(context, resourceId, items); - this.context = context; - this.resourceId = resourceId; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - // Build the view - if (convertView == null) { - LayoutInflater inflater = LayoutInflater.from(context); - convertView = inflater.inflate(resourceId, parent, false); - } - - // Fill the view - IconAdapterItem item = getItem(position); - final boolean enabled = item.isEnabled(); - - TextView title = (TextView) convertView.findViewById(R.id.name); - if (title != null) { - title.setText(item.getText()); - title.setEnabled(enabled); - } - - TextView subtitle = (TextView) convertView.findViewById(R.id.sub_name); - if (subtitle != null) { - String subText = item.getSubText(); - if (subText != null) { - subtitle.setVisibility(View.VISIBLE); - subtitle.setEnabled(item.isEnabled()); - subtitle.setText(subText); - } - } - - ImageView imageView = (ImageView) convertView.findViewById(R.id.icon); - if (imageView != null) { - if (enabled) { - final int id = item.getIconResourceId(); - if (id != 0) { - imageView.setImageResource(id); - } else { - imageView.setImageDrawable(item.getIconDrawable()); - } - } else { - imageView.setImageDrawable(null); - } - } - - return convertView; - } - - @Override - public boolean isEnabled(int aPosition) { - return getItem(aPosition).isEnabled(); - } -} diff --git a/android/phoenix/src/com/retroarch/browser/dirfragment/DirectoryFragment.java b/android/phoenix/src/com/retroarch/browser/dirfragment/DirectoryFragment.java deleted file mode 100644 index 03fc37158e..0000000000 --- a/android/phoenix/src/com/retroarch/browser/dirfragment/DirectoryFragment.java +++ /dev/null @@ -1,396 +0,0 @@ -package com.retroarch.browser.dirfragment; - -import android.content.SharedPreferences; -import android.os.Bundle; -import android.os.Environment; -import android.os.Parcel; -import android.os.Parcelable; -import android.support.v4.app.DialogFragment; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ListView; - -import com.retroarch.R; -import com.retroarch.browser.FileWrapper; -import com.retroarch.browser.IconAdapter; -import com.retroarch.browser.preferences.util.UserPreferences; - -import java.util.*; -import java.io.*; - - -/** - * {@link DialogFragment} subclass that provides a file-browser - * like UI for browsing for specific files. - *

- * This file browser also allows for custom filtering - * depending on the type of class that inherits it. - *

- * This file browser also uses an implementation of a - * backstack for remembering previously browsed folders - * within this DirectoryFragment. - *

- * To instantiate a new instance of this class - * you must use the {@code newInstance} method. - */ -public class DirectoryFragment extends DialogFragment -{ - protected IconAdapter adapter; - protected File listedDirectory; - - public static final class BackStackItem implements Parcelable - { - protected final String path; - protected boolean parentIsBack; - - public BackStackItem(String path, boolean parentIsBack) - { - this.path = path; - this.parentIsBack = parentIsBack; - } - - private BackStackItem(Parcel in) - { - this.path = in.readString(); - this.parentIsBack = in.readInt() != 0; - } - - public int describeContents() - { - return 0; - } - - public void writeToParcel(Parcel out, int flags) - { - out.writeString(path); - out.writeInt(parentIsBack ? 1 : 0); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() - { - public BackStackItem createFromParcel(Parcel in) - { - return new BackStackItem(in); - } - - public BackStackItem[] newArray(int size) - { - return new BackStackItem[size]; - } - }; - } - - /** - * Listener interface for executing content or performing - * other things upon the DirectoryFragment instance closing. - */ - public interface OnDirectoryFragmentClosedListener - { - /** - * Performs some arbitrary action after the - * {@link DirectoryFragment} closes. - * - * @param path The path to the file chosen within the {@link DirectoryFragment} - */ - void onDirectoryFragmentClosed(String path); - } - - - protected ArrayList backStack; - protected String startDirectory; - protected String pathSettingKey; - protected boolean isDirectoryTarget; - protected OnDirectoryFragmentClosedListener onClosedListener; - - /** - * Sets the starting directory for this DirectoryFragment - * when it is shown to the user. - * - * @param path the initial directory to show to the user - * when this DirectoryFragment is shown. - */ - public void setStartDirectory(String path) - { - startDirectory = path; - } - - /** - * Sets the key to save the selected item in the DialogFragment - * into the application SharedPreferences at. - * - * @param key the key to save the selected item's path to in - * the application's SharedPreferences. - */ - public void setPathSettingKey(String key) - { - pathSettingKey = key; - } - - /** - * Sets whether or not we are browsing for a specific - * directory or not. If enabled, it will allow the user - * to select a specific directory, rather than a file. - * - * @param enable Whether or not to enable this. - */ - public void setIsDirectoryTarget(boolean enable) - { - isDirectoryTarget = enable; - } - - /** - * Sets the listener for an action to perform upon the - * closing of this DirectoryFragment. - * - * @param onClosedListener the OnDirectoryFragmentClosedListener to set. - */ - public void setOnDirectoryFragmentClosedListener(OnDirectoryFragmentClosedListener onClosedListener) - { - this.onClosedListener = onClosedListener; - } - - /** - * Retrieves a new instance of a DirectoryFragment - * with a title specified by the given resource ID. - * - * @param titleResId String resource ID for the title - * of this DirectoryFragment. - * - * @return A new instance of a DirectoryFragment. - */ - public static DirectoryFragment newInstance(int titleResId) - { - final DirectoryFragment dFrag = new DirectoryFragment(); - final Bundle bundle = new Bundle(); - bundle.putInt("titleResId", titleResId); - dFrag.setArguments(bundle); - - return dFrag; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) - { - ListView rootView = (ListView) inflater.inflate(R.layout.line_list, container, false); - rootView.setOnItemClickListener(onItemClickListener); - - // Set the dialog title. - getDialog().setTitle(getArguments().getInt("titleResId")); - - // Setup the list - adapter = new IconAdapter(getActivity(), R.layout.line_list_item); - rootView.setAdapter(adapter); - - // Load Directory - if (savedInstanceState != null) - { - backStack = savedInstanceState.getParcelableArrayList("BACKSTACK"); - } - - if (backStack == null || backStack.isEmpty()) - { - backStack = new ArrayList(); - String startPath = (startDirectory == null || startDirectory.isEmpty()) ? Environment - .getExternalStorageDirectory().getPath() : startDirectory; - backStack.add(new BackStackItem(startPath, false)); - } - - wrapFiles(); - return rootView; - } - - private final OnItemClickListener onItemClickListener = new OnItemClickListener() - { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) - { - final FileWrapper item = adapter.getItem(position); - - if (item.isParentItem() && backStack.get(backStack.size() - 1).parentIsBack) - { - backStack.remove(backStack.size() - 1); - wrapFiles(); - return; - } - else if (item.isDirSelectItem()) - { - finishWithPath(listedDirectory.getAbsolutePath()); - return; - } - - final File selected = item.isParentItem() ? listedDirectory.getParentFile() : item.getFile(); - - if (selected.isDirectory()) - { - backStack.add(new BackStackItem(selected.getAbsolutePath(), !item.isParentItem())); - wrapFiles(); - } - else - { - String filePath = selected.getAbsolutePath(); - finishWithPath(filePath); - } - } - }; - - @Override - public void onSaveInstanceState(Bundle outState) - { - super.onSaveInstanceState(outState); - - outState.putParcelableArrayList("BACKSTACK", backStack); - } - - private void finishWithPath(String path) - { - if (pathSettingKey != null && !pathSettingKey.isEmpty()) - { - SharedPreferences settings = UserPreferences.getPreferences(getActivity()); - SharedPreferences.Editor editor = settings.edit(); - editor.putString(pathSettingKey, path); - editor.apply(); - } - - if (onClosedListener != null) - { - onClosedListener.onDirectoryFragmentClosed(path); - } - - dismiss(); - } - - // TODO: Hook this up to a callable interface (if backstack is desirable). - public boolean onKeyDown(int keyCode, KeyEvent event) - { - if (keyCode == KeyEvent.KEYCODE_BACK) - { - if (backStack.size() > 1) - { - backStack.remove(backStack.size() - 1); - wrapFiles(); - } - - return true; - } - - return false; - } - - private ArrayList allowedExt; - private ArrayList disallowedExt; - - private boolean filterPath(String path) - { - if (disallowedExt != null) - { - for (String ext : disallowedExt) - { - if (path.endsWith(ext)) - return false; - } - } - - if (allowedExt != null) - { - for (String ext : allowedExt) - { - if (path.endsWith(ext)) - return true; - } - - return false; - } - - return true; - } - - /** - * Allows specifying an allowed file extension. - *

- * Any files that contain this file extension will be shown - * within the DirectoryFragment file browser. Those that don't - * contain this extension will not be shows. - *

- * It is possible to specify more than one allowed extension by - * simply calling this method with a different file extension specified. - * - * @param exts The file extension(s) to allow being shown in this DirectoryFragment. - */ - public void addAllowedExts(String... exts) - { - if (allowedExt == null) - allowedExt = new ArrayList(); - - allowedExt.addAll(Arrays.asList(exts)); - } - - /** - * Allows specifying a disallowed file extension. - *

- * Any files that contain this file extension will not be shown - * within the DirectoryFragment file browser. - *

- * It is possible to specify more than one disallowed extension by - * simply calling this method with a different file extension specified. - * - * @param exts The file extension(s) to hide from being shown in this DirectoryFragment. - */ - public void addDisallowedExts(String... exts) - { - if (disallowedExt == null) - disallowedExt = new ArrayList(); - - disallowedExt.addAll(Arrays.asList(exts)); - } - - protected void wrapFiles() - { - listedDirectory = new File(backStack.get(backStack.size() - 1).path); - - if (!listedDirectory.isDirectory()) - { - throw new IllegalArgumentException("Directory is not valid."); - } - - adapter.clear(); - - if (isDirectoryTarget) - adapter.add(new FileWrapper(null, FileWrapper.DIRSELECT, true)); - - if (listedDirectory.getParentFile() != null) - adapter.add(new FileWrapper(null, FileWrapper.PARENT, true)); - - // Copy new items - final File[] files = listedDirectory.listFiles(); - if (files != null) - { - for (File file : files) - { - String path = file.getName(); - - boolean allowFile = file.isDirectory() || (filterPath(path) && !isDirectoryTarget); - if (allowFile) - { - adapter.add(new FileWrapper(file, FileWrapper.FILE, true)); - } - } - } - - // Sort items - adapter.sort(new Comparator() - { - @Override - public int compare(FileWrapper left, FileWrapper right) - { - return left.compareTo(right); - }; - }); - - // Update - adapter.notifyDataSetChanged(); - } -} diff --git a/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuFragment.java b/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuFragment.java index 7d890f81f5..3c86126909 100644 --- a/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuFragment.java +++ b/android/phoenix/src/com/retroarch/browser/mainmenu/MainMenuFragment.java @@ -25,8 +25,6 @@ import android.widget.Toast; import com.retroarch.R; import com.retroarch.browser.NativeInterface; -import com.retroarch.browser.dirfragment.DirectoryFragment; -import com.retroarch.browser.dirfragment.DirectoryFragment.OnDirectoryFragmentClosedListener; import com.retroarch.browser.preferences.fragments.util.PreferenceListFragment; import com.retroarch.browser.preferences.util.UserPreferences; import com.retroarch.browser.retroactivity.RetroActivityFuture; @@ -35,7 +33,7 @@ import com.retroarch.browser.retroactivity.RetroActivityPast; /** * Represents the fragment that handles the layout of the main menu. */ -public final class MainMenuFragment extends PreferenceListFragment implements OnPreferenceClickListener, OnDirectoryFragmentClosedListener +public final class MainMenuFragment extends PreferenceListFragment implements OnPreferenceClickListener { private static final String TAG = "MainMenuFragment"; private Context ctx; @@ -222,24 +220,6 @@ public final class MainMenuFragment extends PreferenceListFragment implements On return true; } - @Override - public void onDirectoryFragmentClosed(String path) - { - final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); - - UserPreferences.updateConfigFile(ctx); - Toast.makeText(ctx, String.format(getString(R.string.loading_data), path), Toast.LENGTH_SHORT).show(); - Intent retro = getRetroActivity(); - MainMenuFragment.startRetroActivity( - retro, - path, - prefs.getString("libretro_path", ""), - UserPreferences.getDefaultConfigPath(ctx), - Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD), - ctx.getApplicationInfo().dataDir); - startActivity(retro); - } - public static void startRetroActivity(Intent retro, String contentPath, String corePath, String configFilePath, String imePath, String dataDirPath) { From 7921d1d1e9811748f3f8f823b8f747625348d64e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 7 Jul 2015 21:36:09 +0200 Subject: [PATCH 3/5] Remove some code in UserPreferences.java --- .../preferences/util/UserPreferences.java | 89 ------------------- 1 file changed, 89 deletions(-) diff --git a/android/phoenix/src/com/retroarch/browser/preferences/util/UserPreferences.java b/android/phoenix/src/com/retroarch/browser/preferences/util/UserPreferences.java index 556ab10861..c90512f6dd 100644 --- a/android/phoenix/src/com/retroarch/browser/preferences/util/UserPreferences.java +++ b/android/phoenix/src/com/retroarch/browser/preferences/util/UserPreferences.java @@ -9,7 +9,6 @@ import java.io.InputStreamReader; import android.annotation.TargetApi; import android.content.Context; import android.content.SharedPreferences; -//import android.content.pm.PackageManager; import android.media.AudioManager; import android.media.AudioTrack; import android.os.Build; @@ -121,44 +120,6 @@ public final class UserPreferences */ public static void readbackConfigFile(Context ctx) { - String path = getDefaultConfigPath(ctx); - ConfigFile config = new ConfigFile(path); - - Log.i(TAG, "Config readback from: " + path); - - SharedPreferences prefs = getPreferences(ctx); - SharedPreferences.Editor edit = prefs.edit(); - - // General Settings - readbackBool(config, edit, "rewind_enable"); - readbackString(config, edit, "rewind_granularity"); - readbackBool(config, edit, "savestate_auto_load"); - readbackBool(config, edit, "savestate_auto_save"); - - // Audio Settings. - // TODO: Other audio settings - readbackBool(config, edit, "audio_rate_control"); - readbackBool(config, edit, "audio_enable"); - - // Input Settings - readbackString(config, edit, "input_overlay"); - readbackBool(config, edit, "input_overlay_enable"); - readbackDouble(config, edit, "input_overlay_opacity"); - readbackBool(config, edit, "input_autodetect_enable"); - - // Video Settings - readbackBool(config, edit, "video_scale_integer"); - readbackBool(config, edit, "video_smooth"); - readbackBool(config, edit, "video_threaded"); - readbackBool(config, edit, "video_allow_rotate"); - readbackBool(config, edit, "video_font_enable"); - readbackBool(config, edit, "video_vsync"); - readbackString(config, edit, "video_refresh_rate"); - - // Path settings - readbackString(config, edit, "rgui_browser_directory"); - - edit.apply(); } /** @@ -179,10 +140,7 @@ public final class UserPreferences final SharedPreferences prefs = getPreferences(ctx); - config.setString("libretro_path", prefs.getString("libretro_path", coreDir)); config.setString("libretro_directory", coreDir); - config.setString("rgui_browser_directory", prefs.getString("rgui_browser_directory", "")); - config.setBoolean("audio_rate_control", prefs.getBoolean("audio_rate_control", true)); config.setInt("audio_out_rate", getOptimalSamplingRate(ctx)); // Refactor this entire mess and make this usable for per-core config @@ -191,53 +149,6 @@ public final class UserPreferences config.setInt("audio_block_frames", getLowLatencyBufferSize(ctx)); } - config.setBoolean("audio_enable", prefs.getBoolean("audio_enable", true)); - config.setBoolean("video_smooth", prefs.getBoolean("video_smooth", true)); - config.setBoolean("video_allow_rotate", prefs.getBoolean("video_allow_rotate", true)); - config.setBoolean("savestate_auto_load", prefs.getBoolean("savestate_auto_load", true)); - config.setBoolean("savestate_auto_save", prefs.getBoolean("savestate_auto_save", false)); - config.setBoolean("rewind_enable", prefs.getBoolean("rewind_enable", false)); - config.setInt("rewind_granularity", Integer.parseInt(prefs.getString("rewind_granularity", "1"))); - config.setBoolean("video_vsync", prefs.getBoolean("video_vsync", true)); - config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true)); - config.setString("video_refresh_rate", prefs.getString("video_refresh_rate", "")); - config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", true)); - - // Refactor these weird values - 'full', 'auto', 'square', whatever - - // go by what we have in the menu - makes maintaining state easier too - String aspect = prefs.getString("video_aspect_ratio", "auto"); - if (aspect.equals("full")) - { - config.setBoolean("video_force_aspect", false); - } - else if (aspect.equals("auto")) - { - config.setBoolean("video_force_aspect", true); - config.setBoolean("video_force_aspect_auto", true); - config.setDouble("video_aspect_ratio", -1.0); - } - else if (aspect.equals("square")) - { - config.setBoolean("video_force_aspect", true); - config.setBoolean("video_force_aspect_auto", false); - config.setDouble("video_aspect_ratio", -1.0); - } - else - { - double aspect_ratio = Double.parseDouble(aspect); - config.setBoolean("video_force_aspect", true); - config.setDouble("video_aspect_ratio", aspect_ratio); - } - - config.setBoolean("video_scale_integer", prefs.getBoolean("video_scale_integer", false)); - - if (prefs.contains("input_overlay_enable")) - config.setBoolean("input_overlay_enable", prefs.getBoolean("input_overlay_enable", true)); - config.setString("input_overlay", prefs.getString("input_overlay", "")); - - config.setBoolean("video_font_enable", prefs.getBoolean("video_font_enable", true)); - config.setString("content_history_path", dataDir + "/content_history.rpl"); - try { config.write(path); From 6a6b419ddb1d68edab7961ac06c78ffe5184d8c7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 7 Jul 2015 22:04:25 +0200 Subject: [PATCH 4/5] (Android) Add screenshot dir default dir --- frontend/drivers/platform_android.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/drivers/platform_android.c b/frontend/drivers/platform_android.c index d93b8bf891..5973463b50 100644 --- a/frontend/drivers/platform_android.c +++ b/frontend/drivers/platform_android.c @@ -623,6 +623,8 @@ static void frontend_android_get_environment_settings(int *argc, path, "wallpapers", sizeof(g_defaults.wallpapers_dir)); fill_pathname_join(g_defaults.core_assets_dir, path, "downloads", sizeof(g_defaults.core_assets_dir)); + fill_pathname_join(g_defaults.screenshot_dir, + path, "screenshots", sizeof(g_defaults.screenshot_dir)); } } } From 648b9cf341bac07da4cd1ed378dd2db3d542e869 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 7 Jul 2015 22:24:49 +0200 Subject: [PATCH 5/5] (Android) Remove some now-obsolete content icons --- android/phoenix/res/drawable-hdpi/ic_dir.png | Bin 748 -> 0 bytes android/phoenix/res/drawable-hdpi/ic_file.png | Bin 495 -> 0 bytes android/phoenix/res/drawable-ldpi/ic_dir.png | Bin 401 -> 0 bytes android/phoenix/res/drawable-ldpi/ic_file.png | Bin 296 -> 0 bytes android/phoenix/res/drawable-mdpi/ic_dir.png | Bin 510 -> 0 bytes android/phoenix/res/drawable-mdpi/ic_file.png | Bin 391 -> 0 bytes android/phoenix/res/drawable-xhdpi/ic_dir.png | Bin 997 -> 0 bytes android/phoenix/res/drawable-xhdpi/ic_file.png | Bin 547 -> 0 bytes 8 files changed, 0 insertions(+), 0 deletions(-) delete mode 100755 android/phoenix/res/drawable-hdpi/ic_dir.png delete mode 100755 android/phoenix/res/drawable-hdpi/ic_file.png delete mode 100755 android/phoenix/res/drawable-ldpi/ic_dir.png delete mode 100755 android/phoenix/res/drawable-ldpi/ic_file.png delete mode 100755 android/phoenix/res/drawable-mdpi/ic_dir.png delete mode 100755 android/phoenix/res/drawable-mdpi/ic_file.png delete mode 100755 android/phoenix/res/drawable-xhdpi/ic_dir.png delete mode 100755 android/phoenix/res/drawable-xhdpi/ic_file.png diff --git a/android/phoenix/res/drawable-hdpi/ic_dir.png b/android/phoenix/res/drawable-hdpi/ic_dir.png deleted file mode 100755 index 48489b00dce7b70fd762c6d14028432c0f6b98ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 748 zcmVz}Vxbs>fK5;$2my(OS_N~;8FKS{SL8h8Zf`C(yWYm#`t5t)_r7mt-s~bI{K16d zhm^p-Rxni{RiMKTEFTLE3|wEYR+d+_(~w!j*}GEyZ08-*u{8y=IfLIuxif&PaM@PXgaQQ0*r`&ju%|}iD_^;`3w=j z$j{z+!AO3q5E5AIS>m7Q5`CPU5&?kYLdF#83+Ycr|cy!|eYL9JoC$ za5{A?tn3+aoXJoE7Que@z2eh#LMLf_G5C%*mRNI`+v(ES$ST_B0g{$l@LY( zM_g$^0E^7BpY8LOx6dApv@wQIU*Os=LJ1(?C92>kWYnknb0S8R%}Q0Bu~kYr-^xPM zd{rD{`<(9r(0?Ex+++Kk`x{etPos5cd3-qG%lv3k36#s0+SF*UONIgjV|*_-*2vPy zAOLuQcgEXEC9nV$Yg=$FH=8b4jF01uQO z*I8;OpS~)g1gOAQ$86X{P*Y$jpVy-vHFQ4TFP|SAQFk+{{HX#_byhcTs(@~%qKZou eh^n)?d4B_HOfx_b{)rF(0000|P3i7mA^i7{u?1H^<9scJ@J09%L+w>)r*k>P(HsYwH$`u_|J zO$-c-W*{~6NJ6Lkn(DxoQ418-HEjWwDBkq)0H}<9O)bYm%@G399Q5)4mEDeN96gfI zkoUmFzfAx9sObx)zfAKP85x}Dm4wd!{>|b}O%JfK{8{#&k->#t9-yY%G0Ymx14Pus ze}QVgQaKv9fabB#D+vwxitH@YH%@zM#=t+W?`whPfeQwDbz|Uv z1<*VNdc^>B-HvA3XibbQc!%4-)@TyK7XmcN14Dj-gQjVQ0>g=(;Gn<`nra>O08N9J l2*XEXfQUe%sgfZd0{{bEOh5<^1}Fdk002ovPDHLkV1kW{*rEUc diff --git a/android/phoenix/res/drawable-ldpi/ic_dir.png b/android/phoenix/res/drawable-ldpi/ic_dir.png deleted file mode 100755 index 28456b7fca458cf73deb8890fd7305f743bb1990..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 401 zcmV;C0dD?@P)$q^TA3Ib&h|Fe)g${r>+e5CZDywbmx1!Elv)6c zvGU&Lx-KLO7=Qm~_&14>fpGz)hJ&N+KZ8zxbKO;cl>8yQ~}BbQo(|&eNA;b zAaf8FFflg#|Mwr{dS1#c_}|&rR9}H&0g%H9#2_C~3>cZ1Y+3UyG zH6&NB4*N?R3m6#|^)=ST!(2vOPA0)0z|<2COg*b;Wx==KO#dV&H#B@gwE#zPO@hP0 vO8@_3xDRyw6l8tFq(&n(C`eIH^B@8M@;ZJQ8%eF000000NkvXXu0mjfelDz! diff --git a/android/phoenix/res/drawable-ldpi/ic_file.png b/android/phoenix/res/drawable-ldpi/ic_file.png deleted file mode 100755 index e22348ed601cc7843bcea8bc5fbbe3d4dcc40452..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 296 zcmV+@0oVSCP)j-chPP^d(RLUcN{7w|N~CC>V5QOp#ZyG^E> zoo~O{-3*iE#g^++Hh>_AN}iV#HFinjz2Z20{_go}5KiYSG8Ae6=tUIGCc|6-d?r3i zEDV_j47OT>Hrlk108o64IBEgb@1R-Wv?4Kh8}|l-OYRIhL?)IP5OE&{2dzQZFs&s3 z$B>WQy%sP)@rML}oH7hzEuijjT9p7k#=Qe@(gLhM(-uD3NMeA~FA+PfK@Y{RA^=eh ufQ=Sly+!r_)(4KT@1nG9X0qsL!lW+^TZb860i#d=0000UsG|zHSj0sHlfI;gP)s6pE9k1D?h4L|SpNeB zDGm;`{u2TZy01VF&70LZkFtFCJVOXn#~%XtF`*pZtqIl*eD zA*$oik)`ck*Bk)~m<57mAzRKz@MuP=V8fOg`!(z^$pPGnK}2UPJ=U z1koM}e&b_ukkw6CNmZ`_kcJIJ5tUqup8z0W+DxkVH2|FBB#}6ghAAHb9%cE*f8#rk zV4oA8BTjcdCYPZ_+SC*AdI0t?`jk(@sn{-@AdFc|x%dyD-S}Sq`S<7HXeP5(3|HzHJIn`g)1zyg6+PmYwz|S}IiruTgH=9$eAvT)kB>(^b07*qoM6N<$f+*$U AUH||9 diff --git a/android/phoenix/res/drawable-mdpi/ic_file.png b/android/phoenix/res/drawable-mdpi/ic_file.png deleted file mode 100755 index ff4a435259420ae24c1079f99884ed7809710950..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 391 zcmV;20eJq2P)3K_U?v4V7dQrR``|9=KSSjgP$*DH=p=-HAkiq8xo#m5 zk`;I6%IqdP$?ML2=ey^`MIfNDcsGhP5j z?=QIvfRJke^J@zQ^Po`>7cKyRoD+Pu00=Op`p5~uV*Op~0zknwLf%_2id^RP5j%1L z&`ml4<-r0V!a1F_T^9h0@lUN20FOW40t1W8s(9T6AP5-A8y^kska20EkP{aGi}61l z0m=-cNrhQ(NubOyY9)Kil;Y9_pyV(b)4FLdfYR4sxB)ie^gzI+((P*@A-CNu+3dH+ lVE>j^>HM#?qXcSC-~&%j(jnP4t``6R002ovPDHLkV1kbgqd5Qo diff --git a/android/phoenix/res/drawable-xhdpi/ic_dir.png b/android/phoenix/res/drawable-xhdpi/ic_dir.png deleted file mode 100755 index c6908c2f146bf40bd74f61dbcf16f0645d127a5e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 997 zcmVi0q}Gw<1al{AnXabN5c?5`kv!&T{X_&fa_Bvambn%sJnjGxwaiOTgn7 z@wors1Mnlj;{^N^@OS|Do1mWpehPS;z={-TZtE!JfkeOw6Am!buW8?%=vYtL6##lnPqyrE&#JzE(J!*tHMfLdrmXk_R34Xy1 z4e#u~u#&wRGr~7SEftCY0{nQy2;UM_s?su-L z4Kb4qivytKU`z`=3NrmDKF^it@KP*L0?YG~<>h(06!=BwHx~8votq1WjXOxMUggzC z+n+@ZR=eDXlmPI@7ZHQ)!^4gI9~S+Ff<-C=ARJmEChHLffY1I;Y-ZZeYG$ov@h2)f zkG5NcTDu~e_Es1GC*(j(4?S*XI#MI&)doOb;qG7cuMeqGVCE;aO1A)j2#~>u5o-FMfony;6cQ_*=e#7r^FE`X((e!nB}XD! z=x!ze;y~#kZY3*_-u0|qS~0`ofyE7Fy}cLWnE8-z?<-ZWYDVsl34wfVD&fUQ2=}tOZl2q0h8k?Kw7c->-H)DOn<1dYZ)8|KkYAfcpy?z9^O;j~~o{xav8nd2I TPX=$m00000NkvXXu0mjfN%76h diff --git a/android/phoenix/res/drawable-xhdpi/ic_file.png b/android/phoenix/res/drawable-xhdpi/ic_file.png deleted file mode 100755 index 4425035db788e340860e58ef48b86f4b1964e934..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 547 zcmV+;0^I$HP)K@clJL3|9gJx>tM``1pdR-Zs$KwFy=Z3H_zvA6O8zIAO> z1cfXiS;%~KCYzni?vUhTD*WTZ^Cu7h1r*KzN}zB7pb4S`Py$81J8Ko39@{N(~qB=lv=bBYA9?%0kh5&5Sl~G@jes~ zGo!${KtTSpfCzOf;j6%{GYzlTsui`t3uir`a2sT%OT8Z$o3=C%#4HP{fL&(_2+Sht za5TaEO)%<)22bWf0dhyo&%tZA04kc(3;i``J)m$G(5_tkY4DLqUMz|>U}hBa<4WE| z4=|(=4FUpSgAN`>_&}ei9-^uGpNT4wO}&3?xUxYe**G0^Z&DD@=nS{D;hwo7Krbnq zB66RCfI7>T#@lyAK#IiwjsX{d3pj8AO87EF^I8sz&U!$)vw%w%NO>4?N