Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Make the file browser look much more nice and user friendly…
… to use.

This is what it now looks like: http://i.imgur.com/KOZgA1i.png

As usual, if any bugs arise from this rather large change. Please report it so I can fix it.
  • Loading branch information
lioncash committed Aug 13, 2013
1 parent 8fbf11a commit 53bf55b
Show file tree
Hide file tree
Showing 16 changed files with 346 additions and 97 deletions.
Binary file added Source/Android/res/drawable-hdpi/ic_menu_file.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Source/Android/res/drawable-mdpi/ic_menu_file.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Source/Android/res/drawable-xhdpi/ic_menu_file.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions Source/Android/res/layout/about_layout.xml
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/FolderTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginTop="5dip"
android:singleLine="true"
android:text="Title"
android:textStyle="bold" />

<TextView
android:id="@+id/FolderSubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:text="Subtitle" />

</LinearLayout>
</LinearLayout>
66 changes: 40 additions & 26 deletions Source/Android/res/layout/folderbrowser.xml
@@ -1,29 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="3dip">

<ImageView
android:id="@+id/ImageIcon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"

android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="6dip"/>

<TextView
android:id="@+id/FolderTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginTop="5dip"
android:singleLine="true"
android:text="Title"
android:textStyle="bold" />

<TextView
android:id="@+id/FolderSubTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:text="Subtitle" />

</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/FolderSubTitle"
android:layout_width="fill_parent"
android:layout_height="26dip"

android:layout_toRightOf="@id/ImageIcon"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"

android:singleLine="true"
android:ellipsize="marquee"
android:text="Subtitle" />

<TextView
android:id="@+id/FolderTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"

android:layout_toRightOf="@id/ImageIcon"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_above="@id/FolderSubTitle"
android:layout_alignWithParentIfMissing="true"

android:gravity="center_vertical"
android:text="Title" />

</RelativeLayout>
Expand Up @@ -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;

Expand All @@ -39,11 +38,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
String yes = getString(R.string.yes);
String no = getString(R.string.no);

List<GameListItem> Input = new ArrayList<GameListItem>();
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<FolderBrowserItem> Input = new ArrayList<FolderBrowserItem>();
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;
Expand Down
18 changes: 9 additions & 9 deletions Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java
Expand Up @@ -26,8 +26,8 @@ private void Fill(File currDir)
{
m_activity.setTitle(getString(R.string.current_dir) + currDir.getName());
File[] dirs = currDir.listFiles();
List<GameListItem>dir = new ArrayList<GameListItem>();
List<GameListItem>fls = new ArrayList<GameListItem>();
List<FolderBrowserItem>dir = new ArrayList<FolderBrowserItem>();
List<FolderBrowserItem>fls = new ArrayList<FolderBrowserItem>();

// Supported extensions to filter by
Set<String> validExts = new HashSet<String>(Arrays.asList(".gcm", ".iso", ".wbfs", ".gcz", ".dol", ".elf", ".dff"));
Expand All @@ -44,17 +44,17 @@ private void Fill(File currDir)
{
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));
}
}
}
Expand All @@ -70,7 +70,7 @@ else if (invalidExts.contains(entryName.toLowerCase().substring(entryName.lastIn

// 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);
Expand All @@ -94,15 +94,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
{
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();
Expand Down
@@ -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<GameListItem>{
public class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>{

private Context c;
private int id;
private List<GameListItem>items;
private List<FolderBrowserItem> items;

public FolderBrowserAdapter(Context context, int textViewResourceId,
List<GameListItem> objects) {
public FolderBrowserAdapter(Context context, int textViewResourceId, List<FolderBrowserItem> 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)
{
mainText.setText(item.getName());

if (!item.isValidItem())
{
mainText.setTextColor(0xFFFF0000);
}
}

if(subtitleText != null)
{
subtitleText.setText(item.getSubtitle());
}

if (iconView != null)
{
t1.setText(o.getName());
if (!o.isValid())
t1.setTextColor(0xFFFF0000);
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;
}



}

0 comments on commit 53bf55b

Please sign in to comment.