FileChooser returns flag to indicate whether the chosen file already exists and must be overwritten or if it's new

This commit is contained in:
Philipp Crocoll 2013-10-27 20:32:18 +01:00
parent f8e17a8144
commit 0bf3a3ee7f

View File

@ -22,10 +22,8 @@ import group.pals.android.lib.ui.filechooser.utils.FileUtils;
import group.pals.android.lib.ui.filechooser.utils.Texts; import group.pals.android.lib.ui.filechooser.utils.Texts;
import group.pals.android.lib.ui.filechooser.utils.Utils; import group.pals.android.lib.ui.filechooser.utils.Utils;
import group.pals.android.lib.ui.filechooser.utils.history.History; import group.pals.android.lib.ui.filechooser.utils.history.History;
import group.pals.android.lib.ui.filechooser.utils.history.HistoryFilter;
import group.pals.android.lib.ui.filechooser.utils.history.HistoryListener; import group.pals.android.lib.ui.filechooser.utils.history.HistoryListener;
import group.pals.android.lib.ui.filechooser.utils.history.HistoryStore; import group.pals.android.lib.ui.filechooser.utils.history.HistoryStore;
import group.pals.android.lib.ui.filechooser.utils.ui.ContextMenuUtils;
import group.pals.android.lib.ui.filechooser.utils.ui.Dlg; import group.pals.android.lib.ui.filechooser.utils.ui.Dlg;
import group.pals.android.lib.ui.filechooser.utils.ui.LoadingDialog; import group.pals.android.lib.ui.filechooser.utils.ui.LoadingDialog;
import group.pals.android.lib.ui.filechooser.utils.ui.Ui; import group.pals.android.lib.ui.filechooser.utils.ui.Ui;
@ -1737,7 +1735,7 @@ public class FragmentFiles extends Fragment implements
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog,
int which) { int which) {
finish(result); finish(result, true);
}// onClick() }// onClick()
}); });
@ -1745,10 +1743,7 @@ public class FragmentFiles extends Fragment implements
}// FILE_TYPE_FILE }// FILE_TYPE_FILE
case BaseFile.FILE_TYPE_NOT_EXISTED: { case BaseFile.FILE_TYPE_NOT_EXISTED: {
/* finish(result, false);
* TODO file type unknown?
*/
finish(result);
break; break;
}// FILE_TYPE_NOT_EXISTED }// FILE_TYPE_NOT_EXISTED
} }
@ -2009,6 +2004,25 @@ public class FragmentFiles extends Fragment implements
}.execute(); }.execute();
}// buildAddressBar() }// buildAddressBar()
/**
* Finishes this activity when save-as.
*
* @param file
* @link Uri.
*/
private void finish(Uri file, boolean fileExists) {
ArrayList<Uri> list = new ArrayList<Uri>();
list.add(file);
Intent intent = new Intent();
intent.putParcelableArrayListExtra(FileChooserActivity.EXTRA_RESULTS,
list);
intent.putExtra(FileChooserActivity.EXTRA_RESULT_FILE_EXISTS,
fileExists);
getActivity().setResult(FileChooserActivity.RESULT_OK, intent);
getActivity().finish();
}// finish()
/** /**
* Finishes this activity. * Finishes this activity.
* *