Search in sources :

Example 6 with DocumentsActivity

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();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) DocumentsActivity(dev.dworks.apps.anexplorer.DocumentsActivity) DialogInterface(android.content.DialogInterface) View(android.view.View) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.content.DialogInterface.OnClickListener) DocumentInfo(dev.dworks.apps.anexplorer.model.DocumentInfo)

Aggregations

DocumentsActivity (dev.dworks.apps.anexplorer.DocumentsActivity)6 View (android.view.View)3 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 OnClickListener (android.content.DialogInterface.OnClickListener)2 Bundle (android.os.Bundle)2 AlertDialog (android.support.v7.app.AlertDialog)2 LayoutInflater (android.view.LayoutInflater)2 EditText (android.widget.EditText)2 RecyclerView (android.support.v7.widget.RecyclerView)1 TextView (android.widget.TextView)1 DocumentInfo (dev.dworks.apps.anexplorer.model.DocumentInfo)1 RootInfo (dev.dworks.apps.anexplorer.model.RootInfo)1 Timer (java.util.Timer)1