use of dev.dworks.apps.anexplorer.DocumentsActivity in project AnExplorer by 1hakr.
the class CreateFileFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
final View view = dialogInflater.inflate(R.layout.dialog_create_dir, null, false);
final EditText text1 = (EditText) view.findViewById(android.R.id.text1);
Utils.tintWidget(text1);
String title = getArguments().getString(EXTRA_DISPLAY_NAME);
if (!TextUtils.isEmpty(title)) {
text1.setText(title);
text1.setSelection(title.length());
}
builder.setTitle(R.string.menu_create_file);
builder.setView(view);
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String displayName = text1.getText().toString();
final String mimeType = getArguments().getString(EXTRA_MIME_TYPE);
String extension = FileUtils.getExtFromFilename(displayName);
final DocumentsActivity activity = (DocumentsActivity) getActivity();
final DocumentInfo cwd = activity.getCurrentDirectory();
new CreateFileTask(activity, cwd, TextUtils.isEmpty(extension) ? mimeType : extension, displayName).executeOnExecutor(ProviderExecutor.forAuthority(cwd.authority));
}
});
builder.setNegativeButton(android.R.string.cancel, null);
return builder.create();
}
Aggregations