Ask user what to do with each image.

This commit is contained in:
James Sanford 2012-12-20 14:34:14 -08:00
parent 39d3208185
commit b0db2876b9
2 changed files with 17 additions and 5 deletions

View File

@ -265,7 +265,9 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
public void run() {
withUIActive(new Runnable() {
public void run() {
new DiskImageFragment(mConfigFile).show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
if (findFragment(FRAGMENT_DISKIMAGE) == null) {
new DiskImageFragment(mConfigFile, DiskImage.BOOT).show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
}
}
});
}
@ -437,7 +439,7 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
supportInvalidateOptionsMenu(); // update icon
return true;
} else if (item_id == R.id.action_diskimage) {
new DiskImageFragment(mConfigFile).show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
new DiskImageFragment(mConfigFile, DiskImage.ASK).show(getSupportFragmentManager(), FRAGMENT_DISKIMAGE);
return true;
} else if (item_id == R.id.action_more_keys) {
final int vis = areControlsVisible() ? View.GONE : View.VISIBLE;
@ -452,8 +454,12 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
return false;
}
private boolean dismissFragment(String tag) {
final SherlockDialogFragment frag = (SherlockDialogFragment)getSupportFragmentManager().findFragmentByTag(tag);
private SherlockDialogFragment findFragment(final String tag) {
return (SherlockDialogFragment)getSupportFragmentManager().findFragmentByTag(tag);
}
private boolean dismissFragment(final String tag) {
final SherlockDialogFragment frag = findFragment(tag);
if (frag == null) {
return false;
} else {

View File

@ -25,9 +25,14 @@ public class DiskImageFragment extends SherlockDialogFragment {
// TODO: This should be the title name, and then we should index to it.
private static int mLastSelected = -1;
public DiskImageFragment(final ConfigFile config) {
// DiskImage.BOOT, DiskImage.ASK, etc.
private final int mDiskImageAction;
public DiskImageFragment(final ConfigFile config, int image_action) {
super();
mDiskImageAction = image_action;
// NOTE: We scan the directories in the UI thread before displaying
// the dialog. The user is waiting, but considering this is just
// peeking at the directory listing on local disk it should be quick.
@ -70,6 +75,7 @@ public class DiskImageFragment extends SherlockDialogFragment {
mLastSelected = item;
DiskImage image = mFoundImages.get(item);
if (image != null) {
image.action = mDiskImageAction;
((KegsMain)getActivity()).prepareDiskImage(image);
}
}