Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Derp Squad. Show compressed files in the browse folder dial…
…og. Show in red text and if one clicks on it. Say we don't support compressed file formats.
  • Loading branch information
Sonicadvance1 committed Jul 11, 2013
1 parent 1aca5fe commit 33ca010
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 98 deletions.
198 changes: 108 additions & 90 deletions Source/Android/.idea/workspace.xml

Large diffs are not rendered by default.

Expand Up @@ -24,7 +24,7 @@ public void onCreate(Bundle savedInstanceState)
List<GameListItem> Input = new ArrayList<GameListItem>();
int a = 0;

Input.add(a++, new GameListItem(getApplicationContext(), "Build Revision", NativeLibrary.GetVersionString(), ""));
Input.add(a++, new GameListItem(getApplicationContext(), "Build Revision", NativeLibrary.GetVersionString(), "", true));
adapter = new FolderBrowserAdapter(this, R.layout.folderbrowser, Input);
setListAdapter(adapter);
}
Expand Down
20 changes: 15 additions & 5 deletions Source/Android/src/org/dolphinemu/dolphinemu/FolderBrowser.java
Expand Up @@ -9,6 +9,7 @@
import android.view.MenuItem;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

import java.io.File;
import java.util.ArrayList;
Expand All @@ -31,16 +32,22 @@ private void Fill(File f)
{
if (ff.getName().charAt(0) != '.')
if(ff.isDirectory())
dir.add(new GameListItem(getApplicationContext(), ff.getName(),"Folder",ff.getAbsolutePath()));
dir.add(new GameListItem(getApplicationContext(), ff.getName(),"Folder",ff.getAbsolutePath(), true));
else
{
if (ff.getName().toLowerCase().contains(".gcm") ||
ff.getName().toLowerCase().contains(".iso") ||
ff.getName().toLowerCase().contains(".wbfs") ||
ff.getName().toLowerCase().contains(".gcz") ||
ff.getName().toLowerCase().contains(".dol") ||
ff.getName().toLowerCase().contains(".elf"))
fls.add(new GameListItem(getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath()));
}
fls.add(new GameListItem(getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath(), true));
else if (ff.getName().toLowerCase().contains(".zip") ||
ff.getName().toLowerCase().contains(".rar") ||
ff.getName().toLowerCase().contains(".7z"))
fls.add(new GameListItem(getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath(), false));
}
}
}
catch(Exception e)
{
Expand All @@ -50,7 +57,7 @@ private void Fill(File f)
Collections.sort(fls);
dir.addAll(fls);
if (!f.getPath().equalsIgnoreCase("/"))
dir.add(0, new GameListItem(getApplicationContext(), "..", "Parent Directory", f.getParent()));
dir.add(0, new GameListItem(getApplicationContext(), "..", "Parent Directory", f.getParent(), true));

adapter = new FolderBrowserAdapter(this,R.layout.folderbrowser,dir);
this.setListAdapter(adapter);
Expand All @@ -65,7 +72,10 @@ protected void onListItemClick(ListView l, View v, int position, long id) {
Fill(currentDir);
}
else
FolderSelected();
if (o.isValid())
FolderSelected();
else
Toast.makeText(this, "Can not use compressed file types.", Toast.LENGTH_LONG).show();
}

@Override
Expand Down
Expand Up @@ -22,6 +22,7 @@ public FolderBrowserAdapter(Context context, int textViewResourceId,
id = textViewResourceId;
items = objects;
}

public GameListItem getItem(int i)
{
return items.get(i);
Expand All @@ -39,7 +40,11 @@ public View getView(int position, View convertView, ViewGroup parent) {
TextView t2 = (TextView) v.findViewById(R.id.FolderSubTitle);

if(t1!=null)
{
t1.setText(o.getName());
if (!o.isValid())
t1.setTextColor(0xFFFF0000);
}
if(t2!=null)
t2.setText(o.getData());

Expand Down
Expand Up @@ -58,7 +58,7 @@ private void Fill()
ff.getName().toLowerCase().contains(".dol") ||
ff.getName().toLowerCase().contains(".elf") ||
ff.getName().toLowerCase().contains(".dff"))
fls.add(new GameListItem(mMe.getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath()));
fls.add(new GameListItem(mMe.getApplicationContext(), ff.getName(),"File Size: "+ff.length(),ff.getAbsolutePath(), true));
}
}
catch(Exception ignored)
Expand Down
Expand Up @@ -13,12 +13,14 @@ public class GameListItem implements Comparable<GameListItem>{
private String data;
private String path;
private Bitmap image;
private boolean m_valid;

public GameListItem(Context ctx, String n,String d,String p)
public GameListItem(Context ctx, String n,String d,String p, boolean valid)
{
name = n;
data = d;
path = p;
m_valid = valid;
File file = new File(path);
if (!file.isDirectory() && !path.equals(""))
{
Expand Down Expand Up @@ -58,6 +60,10 @@ public Bitmap getImage()
{
return image;
}
public boolean isValid()
{
return m_valid;
}

public int compareTo(GameListItem o)
{
Expand Down

0 comments on commit 33ca010

Please sign in to comment.