summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java112
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java134
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java212
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java61
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java2
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java85
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/FileViewHolder.java27
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java47
8 files changed, 588 insertions, 92 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java
new file mode 100644
index 0000000000..1c536d8f91
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AddDirectoryActivity.java
@@ -0,0 +1,112 @@
+package org.dolphinemu.dolphinemu.activities;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Environment;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.Toolbar;
+
+import org.dolphinemu.dolphinemu.BuildConfig;
+import org.dolphinemu.dolphinemu.R;
+import org.dolphinemu.dolphinemu.adapters.FileAdapter;
+
+/**
+ * An Activity that shows a list of files and folders, allowing the user to tell the app which folder(s)
+ * contains the user's games.
+ */
+public class AddDirectoryActivity extends Activity implements FileAdapter.FileClickListener
+{
+ public static final String KEY_CURRENT_PATH = BuildConfig.APPLICATION_ID + ".path";
+
+ private FileAdapter mAdapter;
+ private Toolbar mToolbar;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_add_directory);
+
+ mToolbar = (Toolbar) findViewById(R.id.toolbar_folder_list);
+ setActionBar(mToolbar);
+
+ RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list_files);
+
+ // Specifying the LayoutManager determines how the RecyclerView arranges views.
+ RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
+ recyclerView.setLayoutManager(layoutManager);
+
+ String path;
+ // Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
+ if (savedInstanceState == null)
+ {
+ path = Environment.getExternalStorageDirectory().getPath();
+ }
+ else
+ {
+ // Get the path we were looking at before we rotated.
+ path = savedInstanceState.getString(KEY_CURRENT_PATH);
+ }
+
+ mAdapter = new FileAdapter(path, this);
+ recyclerView.setAdapter(mAdapter);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu)
+ {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu_add_directory, menu);
+
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ switch (item.getItemId())
+ {
+ case R.id.menu_up_one_level:
+ mAdapter.upOneLevel();
+ break;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState)
+ {
+ super.onSaveInstanceState(outState);
+
+ // Save the path we're looking at so when rotation is done, we start from same folder.
+ outState.putString(KEY_CURRENT_PATH, mAdapter.getPath());
+ }
+
+ /**
+ * Tell the GameGridActivity that launched this Activity that the user picked a folder.
+ */
+ @Override
+ public void finishSuccessfully()
+ {
+ Intent resultData = new Intent();
+
+ resultData.putExtra(KEY_CURRENT_PATH, mAdapter.getPath());
+ setResult(RESULT_OK, resultData);
+
+ finish();
+ }
+
+ @Override
+ public void updateSubtitle(String path)
+ {
+ mToolbar.setSubtitle(path);
+ }
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java
index be0fbbed1a..bd922ecbed 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/GameGridActivity.java
@@ -2,13 +2,16 @@ package org.dolphinemu.dolphinemu.activities;
import android.app.Activity;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Environment;
+import android.preference.PreferenceManager;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
-import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
+import android.view.View;
+import android.widget.ImageButton;
import android.widget.Toolbar;
import org.dolphinemu.dolphinemu.AssetCopyService;
@@ -24,11 +27,15 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-public class GameGridActivity extends Activity
+/**
+ * The main Activity of the Lollipop style UI. Shows a grid of games on tablets & landscape phones,
+ * shows a list of games on portrait phones.
+ */
+public final class GameGridActivity extends Activity
{
- private RecyclerView mRecyclerView;
- private RecyclerView.Adapter mAdapter;
- private RecyclerView.LayoutManager mLayoutManager;
+ private static final int REQUEST_ADD_DIRECTORY = 1;
+
+ private GameAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState)
@@ -39,21 +46,34 @@ public class GameGridActivity extends Activity
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_game_list);
setActionBar(toolbar);
- mRecyclerView = (RecyclerView) findViewById(R.id.grid_games);
+ ImageButton buttonAddDirectory = (ImageButton) findViewById(R.id.button_add_directory);
+ RecyclerView recyclerView = (RecyclerView) findViewById(R.id.grid_games);
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
//mRecyclerView.setHasFixedSize(true);
// Specifying the LayoutManager determines how the RecyclerView arranges views.
- mLayoutManager = new GridLayoutManager(this, 4);
- mRecyclerView.setLayoutManager(mLayoutManager);
+ RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this, 4);
+ recyclerView.setLayoutManager(layoutManager);
- mRecyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(8));
+ recyclerView.addItemDecoration(new GameAdapter.SpacesItemDecoration(8));
// Create an adapter that will relate the dataset to the views on-screen.
mAdapter = new GameAdapter(getGameList());
- mRecyclerView.setAdapter(mAdapter);
+ recyclerView.setAdapter(mAdapter);
+
+ buttonAddDirectory.setOnClickListener(new View.OnClickListener()
+ {
+ @Override
+ public void onClick(View view)
+ {
+ Intent fileChooser = new Intent(GameGridActivity.this, AddDirectoryActivity.class);
+
+ // The second argument to this method is read below in onActivityResult().
+ startActivityForResult(fileChooser, REQUEST_ADD_DIRECTORY);
+ }
+ });
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
if (savedInstanceState == null)
@@ -64,11 +84,46 @@ public class GameGridActivity extends Activity
}
}
+ /**
+ * Callback from AddDirectoryActivity. Applies any changes necessary to the GameGridActivity.
+ *
+ * @param requestCode An int describing whether the Activity that is returning did so successfully.
+ * @param resultCode An int describing what Activity is giving us this callback.
+ * @param result The information the returning Activity is providing us.
+ */
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent result)
+ {
+ // If the user picked a file, as opposed to just backing out.
+ if (resultCode == RESULT_OK)
+ {
+ // Sanity check to make sure the Activity that just returned was the AddDirectoryActivity;
+ // other activities might use this callback in the future (don't forget to change Javadoc!)
+ if (requestCode == REQUEST_ADD_DIRECTORY)
+ {
+ // Get the path the user selected in AddDirectoryActivity.
+ String path = result.getStringExtra(AddDirectoryActivity.KEY_CURRENT_PATH);
+
+ // Store this path as a preference.
+ // TODO Use SQLite instead.
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ SharedPreferences.Editor editor = prefs.edit();
+
+ editor.putString(AddDirectoryActivity.KEY_CURRENT_PATH, path);
+
+ // Using commit, not apply, in order to block so the next method has the correct data to load.
+ editor.commit();
+
+ mAdapter.setGameList(getGameList());
+ }
+ }
+ }
+
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.gamelist_menu, menu);
+ inflater.inflate(R.menu.menu_game_grid, menu);
return true;
}
@@ -82,48 +137,43 @@ public class GameGridActivity extends Activity
NativeLibrary.SetUserDirectory(DefaultDir);
- String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "ISOPaths", "0");
- Log.v("DolphinEmu", "Directories: " + Directories);
- int intDirectories = Integer.parseInt(Directories);
-
// Extensions to filter by.
Set<String> exts = new HashSet<String>(Arrays.asList(".dff", ".dol", ".elf", ".gcm", ".gcz", ".iso", ".wad", ".wbfs"));
- for (int a = 0; a < intDirectories; ++a)
- {
- String BrowseDir = NativeLibrary.GetConfig("Dolphin.ini", "General", "ISOPath" + a, "");
- Log.v("DolphinEmu", "Directory " + a + ": " + BrowseDir);
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+
+ String path = prefs.getString(AddDirectoryActivity.KEY_CURRENT_PATH, "/");
- File currentDir = new File(BrowseDir);
- File[] dirs = currentDir.listFiles();
- try
+ File currentDir = new File(path);
+ File[] dirs = currentDir.listFiles();
+ try
+ {
+ for (File entry : dirs)
{
- for (File entry : dirs)
+ if (!entry.isHidden() && !entry.isDirectory())
{
- if (!entry.isHidden() && !entry.isDirectory())
- {
- String entryName = entry.getName();
-
- // Check that the file has an appropriate extension before trying to read out of it.
- if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.'))))
- {
- GcGame game = new GcGame(NativeLibrary.GetTitle(entry.getAbsolutePath()),
- NativeLibrary.GetDescription(entry.getAbsolutePath()).replace("\n", " "),
- // TODO Some games might actually not be from this region, believe it or not.
- "United States",
- entry.getAbsolutePath(),
- NativeLibrary.GetGameId(entry.getAbsolutePath()),
- NativeLibrary.GetDate(entry.getAbsolutePath()));
-
- gameList.add(game);
- }
+ String entryName = entry.getName();
+ // Check that the file has an appropriate extension before trying to read out of it.
+ if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.'))))
+ {
+ GcGame game = new GcGame(NativeLibrary.GetTitle(entry.getAbsolutePath()),
+ NativeLibrary.GetDescription(entry.getAbsolutePath()).replace("\n", " "),
+ // TODO Some games might actually not be from this region, believe it or not.
+ "United States",
+ entry.getAbsolutePath(),
+ NativeLibrary.GetGameId(entry.getAbsolutePath()),
+ NativeLibrary.GetDate(entry.getAbsolutePath()));
+
+ gameList.add(game);
}
}
- } catch (Exception ignored)
- {
+
}
+ } catch (Exception ignored)
+ {
+
}
return gameList;
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java
new file mode 100644
index 0000000000..7ce0047b08
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/FileAdapter.java
@@ -0,0 +1,212 @@
+package org.dolphinemu.dolphinemu.adapters;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Toast;
+
+import org.dolphinemu.dolphinemu.R;
+import org.dolphinemu.dolphinemu.model.FileListItem;
+import org.dolphinemu.dolphinemu.viewholders.FileViewHolder;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+
+public class FileAdapter extends RecyclerView.Adapter<FileViewHolder> implements View.OnClickListener
+{
+ private ArrayList<FileListItem> mFileList;
+
+ private String mPath;
+
+ private FileClickListener mListener;
+
+ /**
+ * Initializes the dataset to be displayed, and associates the Adapter with the
+ * Activity as an event listener.
+ *
+ * @param path A String containing the path to the directory to be shown by this Adapter.
+ * @param listener An Activity that can respond to callbacks from this Adapter.
+ */
+ public FileAdapter(String path, FileClickListener listener)
+ {
+ mFileList = generateFileList(new File(path));
+ mListener = listener;
+ mListener.updateSubtitle(path);
+ }
+
+ /**
+ * Called by the LayoutManager when it is necessary to create a new view.
+ *
+ * @param parent The RecyclerView (I think?) the created view will be thrown into.
+ * @param viewType Not used here, but useful when more than one type of child will be used in the RecyclerView.
+ * @return The created ViewHolder with references to all the child view's members.
+ */
+ @Override
+ public FileViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
+ {
+ // Create a new view.
+ View listItem = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.list_item_file, parent, false);
+
+ listItem.setOnClickListener(this);
+
+ // Use that view to create a ViewHolder.
+ return new FileViewHolder(listItem);
+ }
+
+ /**
+ * Called by the LayoutManager when a new view is not necessary because we can recycle
+ * an existing one (for example, if a view just scrolled onto the screen from the bottom, we
+ * can use the view that just scrolled off the top instead of inflating a new one.)
+ *
+ * @param holder A ViewHolder representing the view we're recycling.
+ * @param position The position of the 'new' view in the dataset.
+ */
+ @Override
+ public void onBindViewHolder(FileViewHolder holder, int position)
+ {
+ // Get a reference to the item from the dataset; we'll use this to fill in the view contents.
+ final FileListItem file = mFileList.get(position);
+
+ // Fill in the view contents.
+ switch (file.getType())
+ {
+ case FileListItem.TYPE_FOLDER:
+ holder.imageType.setImageResource(R.drawable.ic_folder);
+ break;
+
+ case FileListItem.TYPE_GC:
+ holder.imageType.setImageResource(R.drawable.ic_gamecube);
+ break;
+
+ case FileListItem.TYPE_WII:
+ holder.imageType.setImageResource(R.drawable.ic_wii);
+ break;
+
+ case FileListItem.TYPE_OTHER:
+ holder.imageType.setImageResource(android.R.color.transparent);
+ break;
+ }
+
+ holder.textFileName.setText(file.getFilename());
+ holder.itemView.setTag(file.getPath());
+ }
+
+ /**
+ * Called by the LayoutManager to find out how much data we have.
+ *
+ * @return Size of the dataset.
+ */
+ @Override
+ public int getItemCount()
+ {
+ return mFileList.size();
+ }
+
+ /**
+ * When a file is clicked, determine if it is a directory; if it is, show that new directory's
+ * contents. If it is not, end the activity successfully.
+ *
+ * @param view The View representing the file the user clicked on.
+ */
+ @Override
+ public void onClick(final View view)
+ {
+ final String path = (String) view.getTag();
+
+ File clickedFile = new File(path);
+
+ if (clickedFile.isDirectory())
+ {
+ final ArrayList<FileListItem> fileList = generateFileList(clickedFile);
+
+ if (fileList.isEmpty())
+ {
+ Toast.makeText(view.getContext(), R.string.add_directory_empty_folder, Toast.LENGTH_SHORT).show();
+ }
+ else
+ {
+ // Delay the loading of the new directory to give a little bit of time for UI feedback
+ // to happen. Hacky, but good enough for now; this is necessary because we're modifying
+ // the RecyclerView's contents, rather than constructing a new one.
+ view.getHandler().postDelayed(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ mFileList = fileList;
+ notifyDataSetChanged();
+ mListener.updateSubtitle(path);
+ }
+ }, 200);
+ }
+ }
+ else
+ {
+ // Pass the activity the path of the parent directory of the clicked file.
+ mListener.finishSuccessfully();
+ }
+ }
+
+ /**
+ * For a given directory, return a list of Files it contains.
+ *
+ * @param directory A File representing the directory that should have its contents displayed.
+ * @return
+ */
+ private ArrayList<FileListItem> generateFileList(File directory)
+ {
+ File[] children = directory.listFiles();
+ ArrayList<FileListItem> fileList = new ArrayList<FileListItem>(children.length);
+
+ for (File child : children)
+ {
+ if (!child.isHidden())
+ {
+ FileListItem item = new FileListItem(child);
+ fileList.add(item);
+ }
+ }
+
+ mPath = directory.getAbsolutePath();
+
+ Collections.sort(fileList);
+ return fileList;
+ }
+
+ public String getPath()
+ {
+ return mPath;
+ }
+
+ public void setPath(String path)
+ {
+ File directory = new File(path);
+
+ mFileList = generateFileList(directory);
+ notifyDataSetChanged();
+ mListener.updateSubtitle(path);
+ }
+
+ public void upOneLevel()
+ {
+ File currentDirectory = new File(mPath);
+ File parentDirectory = currentDirectory.getParentFile();
+
+ mFileList = generateFileList(parentDirectory);
+ notifyDataSetChanged();
+ mListener.updateSubtitle(mPath);
+ }
+
+ /**
+ * Callback to the containing Activity.
+ */
+ public interface FileClickListener
+ {
+ void finishSuccessfully();
+
+ void updateSubtitle(String path);
+ }
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java
index 30bc9daad6..883107a410 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java
@@ -1,5 +1,7 @@
package org.dolphinemu.dolphinemu.adapters;
+import android.app.Activity;
+import android.content.Intent;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@@ -9,12 +11,16 @@ import android.view.ViewGroup;
import com.squareup.picasso.Picasso;
import org.dolphinemu.dolphinemu.R;
+import org.dolphinemu.dolphinemu.dialogs.GameDetailsDialog;
+import org.dolphinemu.dolphinemu.emulation.EmulationActivity;
import org.dolphinemu.dolphinemu.model.Game;
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;
import java.util.ArrayList;
-public class GameAdapter extends RecyclerView.Adapter<GameViewHolder>
+public class GameAdapter extends RecyclerView.Adapter<GameViewHolder> implements
+ View.OnClickListener,
+ View.OnLongClickListener
{
private ArrayList<Game> mGameList;
@@ -42,6 +48,9 @@ public class GameAdapter extends RecyclerView.Adapter<GameViewHolder>
View gameCard = LayoutInflater.from(parent.getContext())
.inflate(R.layout.card_game, parent, false);
+ gameCard.setOnClickListener(this);
+ gameCard.setOnLongClickListener(this);
+
// Use that view to create a ViewHolder.
GameViewHolder holder = new GameViewHolder(gameCard);
return holder;
@@ -64,6 +73,8 @@ public class GameAdapter extends RecyclerView.Adapter<GameViewHolder>
// Fill in the view contents.
Picasso.with(holder.imageScreenshot.getContext())
.load(game.getScreenPath())
+ .fit()
+ .centerCrop()
.error(R.drawable.no_banner)
.into(holder.imageScreenshot);
@@ -72,12 +83,10 @@ public class GameAdapter extends RecyclerView.Adapter<GameViewHolder>
{
holder.textDescription.setText(game.getDescription());
}
- holder.buttonDetails.setTag(game.getGameId());
holder.path = game.getPath();
holder.screenshotPath = game.getScreenPath();
holder.game = game;
-
}
/**
@@ -91,6 +100,45 @@ public class GameAdapter extends RecyclerView.Adapter<GameViewHolder>
return mGameList.size();
}
+ /**
+ * Launches the game that was clicked on.
+ *
+ * @param view The card representing the game the user wants to play.
+ */
+ @Override
+ public void onClick(View view)
+ {
+ GameViewHolder holder = (GameViewHolder) view.getTag();
+
+ // Start the emulation activity and send the path of the clicked ISO to it.
+ Intent intent = new Intent(view.getContext(), EmulationActivity.class);
+
+ intent.putExtra("SelectedGame", holder.path);
+
+ view.getContext().startActivity(intent);
+ }
+
+ /**
+ * Launches the details activity for this Game, using an ID stored in the
+ * details button's Tag.
+ *
+ * @param view The Card button that was long-clicked.
+ */
+ @Override
+ public boolean onLongClick(View view)
+ {
+ GameViewHolder holder = (GameViewHolder) view.getTag();
+
+ // Get the ID of the game we want to look at.
+ // TODO This should be all we need to pass in, eventually.
+ // String gameId = (String) holder.gameId;
+
+ Activity activity = (Activity) view.getContext();
+ GameDetailsDialog.newInstance(holder.game).show(activity.getFragmentManager(), "game_details");
+
+ return true;
+ }
+
public static class SpacesItemDecoration extends RecyclerView.ItemDecoration
{
private int space;
@@ -107,7 +155,12 @@ public class GameAdapter extends RecyclerView.Adapter<GameViewHolder>
outRect.right = space;
outRect.bottom = space;
outRect.top = space;
-
}
}
+
+ public void setGameList(ArrayList<Game> gameList)
+ {
+ mGameList = gameList;
+ notifyDataSetChanged();
+ }
}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java
index 19c6621345..e22b30ea18 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java
@@ -84,6 +84,8 @@ public class GameDetailsDialog extends DialogFragment
// Fill in the view contents.
Picasso.with(imageGameScreen.getContext())
.load(getArguments().getString(ARGUMENT_GAME_SCREENSHOT_PATH))
+ .fit()
+ .centerCrop()
.noFade()
.noPlaceholder()
.into(imageGameScreen);
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java
new file mode 100644
index 0000000000..69b39438e8
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/FileListItem.java
@@ -0,0 +1,85 @@
+package org.dolphinemu.dolphinemu.model;
+
+
+import org.dolphinemu.dolphinemu.NativeLibrary;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+public class FileListItem implements Comparable<FileListItem>
+{
+ public static final int TYPE_FOLDER = 0;
+ public static final int TYPE_GC = 1;
+ public static final int TYPE_WII = 2;
+ public static final int TYPE_OTHER = 3;
+
+ private int mType;
+ private String mFilename;
+ private String mPath;
+
+ public FileListItem(File file)
+ {
+ mPath = file.getAbsolutePath();
+
+ if (file.isDirectory())
+ {
+ mType = TYPE_FOLDER;
+ }
+ else
+ {
+ String fileExtension = mPath.substring(mPath.lastIndexOf('.'));
+
+ // Extensions to filter by.
+ Set<String> allowedExtensions = new HashSet<String>(Arrays.asList(".dff", ".dol", ".elf", ".gcm", ".gcz", ".iso", ".wad", ".wbfs"));
+
+ // Check that the file has an appropriate extension before trying to read out of it.
+ if (allowedExtensions.contains(fileExtension))
+ {
+ mType = NativeLibrary.IsWiiTitle(mPath) ? TYPE_WII : TYPE_GC;
+ }
+ else
+ {
+ mType = TYPE_OTHER;
+ }
+ }
+
+ mFilename = file.getName();
+ }
+
+ public int getType()
+ {
+ return mType;
+ }
+
+ public String getFilename()
+ {
+ return mFilename;
+ }
+
+ public String getPath()
+ {
+ return mPath;
+ }
+
+ @Override
+ public int compareTo(FileListItem theOther)
+ {
+ if (theOther.getType() == getType())
+ {
+ return getFilename().toLowerCase().compareTo(theOther.getFilename().toLowerCase());
+ }
+ else
+ {
+ if (getType() > theOther.getType())
+ {
+ return 1;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ }
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/FileViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/FileViewHolder.java
new file mode 100644
index 0000000000..79acc8400b
--- /dev/null
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/FileViewHolder.java
@@ -0,0 +1,27 @@
+package org.dolphinemu.dolphinemu.viewholders;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import org.dolphinemu.dolphinemu.R;
+
+
+public class FileViewHolder extends RecyclerView.ViewHolder
+{
+ public View itemView;
+
+ public TextView textFileName;
+ public ImageView imageType;
+
+ public FileViewHolder(View itemView)
+ {
+ super(itemView);
+
+ this.itemView = itemView;
+
+ textFileName = (TextView) itemView.findViewById(R.id.text_file_name);
+ imageType = (ImageView) itemView.findViewById(R.id.image_type);
+ }
+}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java
index 47acf588de..18e271e0f5 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/viewholders/GameViewHolder.java
@@ -19,7 +19,6 @@ public class GameViewHolder extends RecyclerView.ViewHolder
public ImageView imageScreenshot;
public TextView textGameTitle;
public TextView textDescription;
- public ImageButton buttonDetails;
// Used to handle onClick(). Set this in onBindViewHolder().
public String path;
@@ -30,54 +29,10 @@ public class GameViewHolder extends RecyclerView.ViewHolder
{
super(itemView);
- itemView.setOnClickListener(mCardClickListener);
+ itemView.setTag(this);
imageScreenshot = (ImageView) itemView.findViewById(R.id.image_game_screen);
textGameTitle = (TextView) itemView.findViewById(R.id.text_game_title);
textDescription = (TextView) itemView.findViewById(R.id.text_game_description);
- buttonDetails = (ImageButton) itemView.findViewById(R.id.button_details);
-
- buttonDetails.setOnClickListener(mDetailsButtonListener);
}
-
- private View.OnClickListener mCardClickListener = new View.OnClickListener()
- {
- /**
- * Launches the game that was clicked on.
- *
- * @param view The card representing the game the user wants to play.
- */
- @Override
- public void onClick(View view)
- {
- // Start the emulation activity and send the path of the clicked ROM to it.
- Intent intent = new Intent(view.getContext(), EmulationActivity.class);
-
- intent.putExtra("SelectedGame", path);
-
- view.getContext().startActivity(intent);
- }
- };
-
- private View.OnClickListener mDetailsButtonListener = new View.OnClickListener()
- {
-
- /**
- * Launches the details activity for this Game, using an ID stored in the
- * details button's Tag.
- *
- * @param view The Details button that was clicked on.
- */
- @Override
- public void onClick(View view)
- {
- // Get the ID of the game we want to look at.
- // TODO This should be all we need to pass in, eventually.
- // String gameId = (String) view.getTag();
-
- Activity activity = (Activity) view.getContext();
- GameDetailsDialog.newInstance(game).show(activity.getFragmentManager(), "game_details");
- }
- };
-
}