diff --git a/Source/Android/res/drawable-hdpi/ic_menu_file.png b/Source/Android/res/drawable-hdpi/ic_menu_file.png new file mode 100644 index 0000000000..f204740905 Binary files /dev/null and b/Source/Android/res/drawable-hdpi/ic_menu_file.png differ diff --git a/Source/Android/res/drawable-hdpi/ic_menu_folder.png b/Source/Android/res/drawable-hdpi/ic_menu_folder.png new file mode 100644 index 0000000000..6f441b41da Binary files /dev/null and b/Source/Android/res/drawable-hdpi/ic_menu_folder.png differ diff --git a/Source/Android/res/drawable-mdpi/ic_menu_file.png b/Source/Android/res/drawable-mdpi/ic_menu_file.png new file mode 100644 index 0000000000..dee2577897 Binary files /dev/null and b/Source/Android/res/drawable-mdpi/ic_menu_file.png differ diff --git a/Source/Android/res/drawable-mdpi/ic_menu_folder.png b/Source/Android/res/drawable-mdpi/ic_menu_folder.png new file mode 100644 index 0000000000..cc81e57f7e Binary files /dev/null and b/Source/Android/res/drawable-mdpi/ic_menu_folder.png differ diff --git a/Source/Android/res/drawable-xhdpi/ic_menu_file.png b/Source/Android/res/drawable-xhdpi/ic_menu_file.png new file mode 100644 index 0000000000..85369c338e Binary files /dev/null and b/Source/Android/res/drawable-xhdpi/ic_menu_file.png differ diff --git a/Source/Android/res/drawable-xhdpi/ic_menu_folder.png b/Source/Android/res/drawable-xhdpi/ic_menu_folder.png new file mode 100644 index 0000000000..78500a93c1 Binary files /dev/null and b/Source/Android/res/drawable-xhdpi/ic_menu_folder.png differ diff --git a/Source/Android/res/layout/about_layout.xml b/Source/Android/res/layout/about_layout.xml new file mode 100644 index 0000000000..7189fd7ce5 --- /dev/null +++ b/Source/Android/res/layout/about_layout.xml @@ -0,0 +1,29 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Source/Android/res/layout/folderbrowser.xml b/Source/Android/res/layout/folderbrowser.xml index 82b94e238f..61c6fba1ea 100644 --- a/Source/Android/res/layout/folderbrowser.xml +++ b/Source/Android/res/layout/folderbrowser.xml @@ -1,29 +1,43 @@ - - + android:layout_height="?android:attr/listPreferredItemHeight" + android:padding="3dip"> + + - - - - - - + + + + + diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java index 4a7b636ed6..4905027ae1 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/AboutFragment.java @@ -22,7 +22,6 @@ public class AboutFragment extends Fragment { private ListView mMainList; private FolderBrowserAdapter adapter; - private int configPosition = 0; boolean Configuring = false; boolean firstEvent = true; @@ -39,11 +38,11 @@ public class AboutFragment extends Fragment { String yes = getString(R.string.yes); String no = getString(R.string.no); - List Input = new ArrayList(); - Input.add(new GameListItem(m_activity, getString(R.string.build_revision), NativeLibrary.GetVersionString(), "", true)); - Input.add(new GameListItem(m_activity, getString(R.string.supports_gles3), PrefsFragment.SupportsGLES3() ? yes : no, "", true)); + List Input = new ArrayList(); + Input.add(new FolderBrowserItem(m_activity, getString(R.string.build_revision), NativeLibrary.GetVersionString(), "", true)); + Input.add(new FolderBrowserItem(m_activity, getString(R.string.supports_gles3), PrefsFragment.SupportsGLES3() ? yes : no, "", true)); - adapter = new FolderBrowserAdapter(m_activity, R.layout.folderbrowser, Input); + adapter = new FolderBrowserAdapter(m_activity, R.layout.about_layout, Input); mMainList.setAdapter(adapter); return mMainList; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java index 817a9152c5..aa44ad83ca 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java @@ -26,8 +26,8 @@ public class FolderBrowser extends Fragment { { m_activity.setTitle(getString(R.string.current_dir) + currDir.getName()); File[] dirs = currDir.listFiles(); - Listdir = new ArrayList(); - Listfls = new ArrayList(); + Listdir = new ArrayList(); + Listfls = new ArrayList(); // Supported extensions to filter by Set validExts = new HashSet(Arrays.asList(".gcm", ".iso", ".wbfs", ".gcz", ".dol", ".elf", ".dff")); @@ -44,17 +44,17 @@ public class FolderBrowser extends Fragment { { if(entry.isDirectory()) { - dir.add(new GameListItem(m_activity, entryName, getString(R.string.folder), entry.getAbsolutePath(), true)); + dir.add(new FolderBrowserItem(m_activity, entryName, getString(R.string.folder), entry.getAbsolutePath(), true)); } else { if (validExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) { - fls.add(new GameListItem(m_activity, entryName,getString(R.string.file_size)+entry.length(),entry.getAbsolutePath(), true)); + fls.add(new FolderBrowserItem(m_activity, entryName,getString(R.string.file_size)+entry.length(),entry.getAbsolutePath(), true)); } else if (invalidExts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) { - fls.add(new GameListItem(m_activity, entryName,getString(R.string.file_size)+entry.length(),entry.getAbsolutePath(), false)); + fls.add(new FolderBrowserItem(m_activity, entryName,getString(R.string.file_size)+entry.length(),entry.getAbsolutePath(), false)); } } } @@ -70,7 +70,7 @@ public class FolderBrowser extends Fragment { // Check for a parent directory to the one we're currently in. if (!currDir.getPath().equalsIgnoreCase("/")) - dir.add(0, new GameListItem(m_activity, "..", getString(R.string.parent_directory), currDir.getParent(), true)); + dir.add(0, new FolderBrowserItem(m_activity, "..", getString(R.string.parent_directory), currDir.getParent(), true)); adapter = new FolderBrowserAdapter(m_activity, R.layout.folderbrowser, dir); mDrawerList = (ListView) rootView.findViewById(R.id.gamelist); @@ -94,15 +94,15 @@ public class FolderBrowser extends Fragment { { public void onItemClick(AdapterView parent, View view, int position, long id) { - GameListItem o = adapter.getItem(position); - if(o.getData().equalsIgnoreCase(getString(R.string.folder)) || o.getData().equalsIgnoreCase(getString(R.string.parent_directory))) + FolderBrowserItem o = adapter.getItem(position); + if(o.isDirectory() || o.getSubtitle().equalsIgnoreCase(getString(R.string.parent_directory))) { currentDir = new File(o.getPath()); Fill(currentDir); } else { - if (o.isValid()) + if (o.isValidItem()) FolderSelected(); else Toast.makeText(m_activity, getString(R.string.cant_use_compressed_filetypes), Toast.LENGTH_LONG).show(); diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java index 30c1747781..0c38aa7b2f 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserAdapter.java @@ -1,58 +1,79 @@ package org.dolphinemu.dolphinemu; import android.content.Context; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.ImageView; import android.widget.TextView; import java.util.List; -public class FolderBrowserAdapter extends ArrayAdapter{ +public class FolderBrowserAdapter extends ArrayAdapter{ private Context c; private int id; - private Listitems; + private List items; - public FolderBrowserAdapter(Context context, int textViewResourceId, - List objects) { + public FolderBrowserAdapter(Context context, int textViewResourceId, List objects) { super(context, textViewResourceId, objects); c = context; id = textViewResourceId; items = objects; } - public GameListItem getItem(int i) + public FolderBrowserItem getItem(int i) { return items.get(i); } + @Override - public View getView(int position, View convertView, ViewGroup parent) { + public View getView(int position, View convertView, ViewGroup parent) + { View v = convertView; - if (v == null) { - LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - v = vi.inflate(id, null); + if (v == null) + { + LayoutInflater vi = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + v = vi.inflate(id, parent, false); } - final GameListItem o = items.get(position); - if (o != null) { - TextView t1 = (TextView) v.findViewById(R.id.FolderTitle); - TextView t2 = (TextView) v.findViewById(R.id.FolderSubTitle); + + final FolderBrowserItem item = items.get(position); + if (item != null) + { + ImageView iconView = (ImageView) v.findViewById(R.id.ImageIcon); + TextView mainText = (TextView) v.findViewById(R.id.FolderTitle); + TextView subtitleText = (TextView) v.findViewById(R.id.FolderSubTitle); - if(t1!=null) + if(mainText != null) { - t1.setText(o.getName()); - if (!o.isValid()) - t1.setTextColor(0xFFFF0000); + mainText.setText(item.getName()); + + if (!item.isValidItem()) + { + mainText.setTextColor(0xFFFF0000); + } + } + + if(subtitleText != null) + { + subtitleText.setText(item.getSubtitle()); + } + + if (iconView != null) + { + if (item.isDirectory()) + { + iconView.setImageResource(R.drawable.ic_menu_folder); + } + else + { + iconView.setImageResource(R.drawable.ic_menu_file); + } } - if(t2!=null) - t2.setText(o.getData()); } return v; } - - - } - diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java new file mode 100644 index 0000000000..d2f8773e24 --- /dev/null +++ b/Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowserItem.java @@ -0,0 +1,113 @@ +package org.dolphinemu.dolphinemu; + +import java.io.File; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.drawable.Drawable; + +/** + * Represents an item in the folder browser list. + */ +public final class FolderBrowserItem implements Comparable +{ + private final Context ctx; + private final String name; + private final String subtitle; + private final String path; + private final boolean isValid; + private final File underlyingFile; + + /** + * Constructor + * + * @param ctx Context this FolderBrowserItem is being used in. + * @param name The name of the file/folder represented by this item. + * @param subtitle The subtitle of this FolderBrowserItem to display. + * @param path The path of the file/folder represented by this item. + * @param isValid Whether or not this item represents a file type that can be handled. + */ + public FolderBrowserItem(Context ctx, String name, String subtitle, String path, boolean isValid) + { + this.ctx = ctx; + this.name = name; + this.subtitle = subtitle; + this.path = path; + this.isValid = isValid; + this.underlyingFile = new File(path); + } + + /** + * Gets the name of the file/folder represented by this FolderBrowserItem. + * + * @return the name of the file/folder represented by this FolderBrowserItem. + */ + public String getName() + { + return name; + } + + /** + * Gets the subtitle text of this FolderBrowserItem. + * + * @return the subtitle text of this FolderBrowserItem. + */ + public String getSubtitle() + { + return subtitle; + } + + /** + * Gets the path of the file/folder represented by this FolderBrowserItem. + * + * @return the path of the file/folder represented by this FolderBrowserItem. + */ + public String getPath() + { + return path; + } + + /** + * Gets whether or not the file represented + * by this FolderBrowserItem is supported + * and can be handled correctly. + * + * @return whether or not the file represented + * by this FolderBrowserItem is supported + * and can be handled correctly. + */ + public boolean isValidItem() + { + return isValid; + } + + /** + * Gets the {@link File} representation of the underlying file/folder + * represented by this FolderBrowserItem. + * + * @return the {@link File} representation of the underlying file/folder + * represented by this FolderBrowserItem. + */ + public File getUnderlyingFile() + { + return underlyingFile; + } + + /** + * Gets whether or not this FolderBrowserItem represents a directory. + * + * @return true if this FolderBrowserItem represents a directory, false otherwise. + */ + public boolean isDirectory() + { + return underlyingFile.isDirectory(); + } + + public int compareTo(FolderBrowserItem other) + { + if(this.name != null) + return this.name.toLowerCase().compareTo(other.getName().toLowerCase()); + else + throw new IllegalArgumentException(); + } +} diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java index ff8a077703..0a6f69a1d0 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/InputConfigItem.java @@ -1,10 +1,14 @@ -package org.dolphinemu.dolphinemu; - -/** +/* * Copyright 2013 Dolphin Emulator Project * Licensed under GPLv2 * Refer to the license.txt file included. */ + +package org.dolphinemu.dolphinemu; + +/** + * Represents a controller input item (button, stick, etc). + */ public class InputConfigItem implements Comparable{ private String m_name; private String m_Config; @@ -20,27 +24,65 @@ public class InputConfigItem implements Comparable{ m_bind = NativeLibrary.GetConfig("Dolphin.ini", Key, Value, defaultBind); } + /** + * Constructor + * + * @param name Name of the input config item. + * @param config Name of the key in the configuration file that this control modifies. + * @param defaultBind Default binding to fall back upon if binding fails. + */ public InputConfigItem(String name, String config, String defaultBind) { Init(name, config, defaultBind); } + /** + * Constructor that creates an InputConfigItem + * that has a default binding of "None" + * + * @param name Name of the input config item. + * @param config Name of the key in the configuration file that this control modifies. + */ public InputConfigItem(String name, String config) { Init(name, config, "None"); } + + /** + * Gets the name of this InputConfigItem. + * + * @return the name of this InputConfigItem + */ public String getName() { return m_name; } + + /** + * Gets the config key this InputConfigItem modifies. + * + * @return the config key this InputConfigItem modifies. + */ public String getConfig() { return m_Config; } + + /** + * Gets the currently set binding of this InputConfigItem + * + * @return the currently set binding of this InputConfigItem + */ public String getBind() { return m_bind; } + + /** + * Sets a new binding for this InputConfigItem. + * + * @param bind The new binding. + */ public void setBind(String bind) { m_bind = bind; diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java index f089362c38..da58274c5f 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/NativeLibrary.java @@ -1,12 +1,17 @@ +/* + * Copyright 2013 Dolphin Emulator Project + * Licensed under GPLv2 + * Refer to the license.txt file included. + */ + package org.dolphinemu.dolphinemu; import android.util.Log; import android.view.Surface; /** - * Copyright 2013 Dolphin Emulator Project - * Licensed under GPLv2 - * Refer to the license.txt file included. + * Class which contains methods that interact + * with the native side of the Dolphin code. */ public class NativeLibrary { public static native void onTouchEvent(int Action, float X, float Y); diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java index 599ce5007a..eb2143becb 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuAdapter.java @@ -16,34 +16,38 @@ public class SideMenuAdapter extends ArrayAdapter{ private Listitems; public SideMenuAdapter(Context context, int textViewResourceId, - List objects) { + List objects) + { super(context, textViewResourceId, objects); c = context; id = textViewResourceId; items = objects; } + public SideMenuItem getItem(int i) - { + { return items.get(i); - } - @Override - public View getView(int position, View convertView, ViewGroup parent) { - View v = convertView; - if (v == null) { - LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - v = vi.inflate(id, null); - } - final SideMenuItem o = items.get(position); - if (o != null) { - TextView t1 = (TextView) v.findViewById(R.id.SideMenuTitle); - - if(t1!=null) - t1.setText(o.getName()); - } - return v; - } - - - + } + @Override + public View getView(int position, View convertView, ViewGroup parent) + { + View v = convertView; + if (v == null) + { + LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + v = vi.inflate(id, null); + } + + final SideMenuItem o = items.get(position); + if (o != null) + { + TextView t1 = (TextView) v.findViewById(R.id.SideMenuTitle); + + if(t1!=null) + t1.setText(o.getName()); + } + + return v; + } } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java index e24842bed1..6d204d0d69 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/SideMenuItem.java @@ -1,25 +1,47 @@ -package org.dolphinemu.dolphinemu; - -/** +/* * Copyright 2013 Dolphin Emulator Project * Licensed under GPLv2 * Refer to the license.txt file included. */ -public class SideMenuItem implements Comparable{ +package org.dolphinemu.dolphinemu; + + +/** + * Represents an item that goes in the sidemenu of the app. + */ +public class SideMenuItem implements Comparable +{ private String m_name; private int m_id; - public SideMenuItem(String n, int id) + /** + * Constructor + * + * @param name The name of the SideMenuItem. + * @param id ID number of this specific SideMenuItem. + */ + public SideMenuItem(String name, int id) { - m_name = n; + m_name = name; m_id = id; } + /** + * Gets the name of this SideMenuItem. + * + * @return the name of this SideMenuItem. + */ public String getName() { return m_name; } + + /** + * Gets the ID of this SideMenuItem. + * + * @return the ID of this SideMenuItem. + */ public int getID() { return m_id;