|
1 | 1 | package com.paulds.simpleftp.presentation.model; |
2 | 2 |
|
3 | 3 | import android.content.Context; |
| 4 | +import android.content.DialogInterface; |
4 | 5 | import android.content.Intent; |
5 | 6 | import android.databinding.BaseObservable; |
6 | 7 | import android.databinding.Bindable; |
7 | 8 | import android.databinding.ObservableArrayList; |
| 9 | +import android.support.v7.app.AlertDialog; |
8 | 10 | import android.view.View; |
| 11 | +import android.widget.EditText; |
9 | 12 | import android.widget.Toast; |
10 | 13 |
|
11 | 14 | import com.paulds.simpleftp.BR; |
@@ -103,7 +106,31 @@ public void selectFile(FileViewModel model) { |
103 | 106 | * @param view The current view. |
104 | 107 | */ |
105 | 108 | public void addFolder(View view) { |
106 | | - Toast.makeText(this.context, "Add folder", Toast.LENGTH_SHORT).show(); |
| 109 | + AlertDialog.Builder builder = new AlertDialog.Builder(this.context); |
| 110 | + |
| 111 | + builder.setTitle(R.string.dialog_create_folder_title); |
| 112 | + |
| 113 | + final EditText input = new EditText(this.context); |
| 114 | + final String currentPath = this.path; |
| 115 | + |
| 116 | + builder.setView(input); |
| 117 | + |
| 118 | + builder.setPositiveButton("Create", new DialogInterface.OnClickListener() { |
| 119 | + @Override |
| 120 | + public void onClick(DialogInterface dialog, int which) { |
| 121 | + AndroidApplication.getRepository().getFileRepository().createFolder(currentPath, input.getText().toString()); |
| 122 | + } |
| 123 | + }); |
| 124 | + |
| 125 | + builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { |
| 126 | + @Override |
| 127 | + public void onClick(DialogInterface dialog, int which) { |
| 128 | + dialog.cancel(); |
| 129 | + } |
| 130 | + }); |
| 131 | + |
| 132 | + AlertDialog dialog = builder.create(); |
| 133 | + dialog.show(); |
107 | 134 | } |
108 | 135 |
|
109 | 136 | /** |
|
0 commit comments