Prepare for disk image selector.

This commit is contained in:
James Sanford 2012-12-20 13:17:16 -08:00
parent 611ed0eefc
commit a0e3306ee3
3 changed files with 26 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package com.froop.app.kegs;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
import java.io.File;
import java.io.BufferedInputStream;
@ -39,6 +40,17 @@ class ConfigFile {
return mContext.getExternalCacheDir().getPath();
}
public String[] getAllImageDirs() {
String externalStorage = Environment.getExternalStorageDirectory().getPath();
String[] dirs = {
getImagePath(),
externalStorage,
externalStorage + "/kegs",
externalStorage + "/Download"
};
return dirs;
}
public void ensureAssetCopied(String destPath, String zipfile, String exampleFile) {
// We only check for a local copy of a single file before unzipping...
final File local_copy = new File(destPath, exampleFile);

View File

@ -265,8 +265,7 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
public void run() {
withUIActive(new Runnable() {
public void run() {
new DiskImageFragment().show(getSupportFragmentManager(),
FRAGMENT_DISKIMAGE);
new DiskImageFragment(mConfigFile).show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
}
});
}
@ -438,7 +437,7 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
supportInvalidateOptionsMenu(); // update icon
return true;
} else if (item_id == R.id.action_diskimage) {
new DiskImageFragment().show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
new DiskImageFragment(mConfigFile).show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
return true;
} else if (item_id == R.id.action_more_keys) {
final int vis = areControlsVisible() ? View.GONE : View.VISIBLE;

View File

@ -4,7 +4,10 @@ import android.util.Log;
import java.lang.Integer;
import java.io.File;
class DiskImage {
class DiskImage implements Comparable {
// NOTE: "this class has a natural ordering that is inconsistent with equals"
// (sorted on the filename excluding path, case insensitive)
// template
public static final String BOOT_SLOT_5 = "boot_slot_5";
public static final String BOOT_SLOT_6 = "boot_slot_6";
@ -111,4 +114,12 @@ class DiskImage {
return null;
}
}
public int compareTo(Object other) {
if (other instanceof DiskImage) {
return this.getTitle().compareToIgnoreCase(((DiskImage)other).getTitle());
} else {
throw new ClassCastException();
}
}
}