|
9 | 9 | import android.os.Environment; |
10 | 10 | import android.support.v7.app.AppCompatActivity; |
11 | 11 | import android.support.v7.view.ActionMode; |
12 | | -import android.text.InputType; |
13 | 12 | import android.util.Log; |
14 | | -import android.util.SparseBooleanArray; |
15 | 13 | import android.view.KeyEvent; |
16 | | -import android.view.Menu; |
17 | | -import android.view.MenuItem; |
18 | 14 | import android.view.View; |
19 | 15 | import android.view.View.OnClickListener; |
20 | 16 | import android.view.inputmethod.InputMethodManager; |
@@ -186,82 +182,6 @@ private AbsListView getListView() { |
186 | 182 | return findViewById(R.id.list_view); |
187 | 183 | } |
188 | 184 |
|
189 | | - @Override |
190 | | - public boolean onCreateOptionsMenu(Menu menu) { |
191 | | - getMenuInflater().inflate(R.menu.file_dialog_menu, menu); |
192 | | - return true; |
193 | | - } |
194 | | - |
195 | | - @Override |
196 | | - public boolean onOptionsItemSelected(MenuItem item) { |
197 | | - int i = item.getItemId(); |
198 | | - if (i == R.id.home_folder) { |
199 | | - if (currentPath.startsWith(Environment.getExternalStorageDirectory().getPath())) { |
200 | | - sdDirectory = currentPath; |
201 | | - } |
202 | | - if (!currentPath.startsWith(getCacheDir().getParentFile().getAbsolutePath())) { |
203 | | - getDir(homeDirectory); |
204 | | - if (selectionMode == SelectionMode.MODE_SELECT_DIR) { |
205 | | - selectedFile = new File(currentPath); |
206 | | - mFileName.setText(selectedFile.getName()); |
207 | | - selectButton.setEnabled(true); |
208 | | - } |
209 | | - } |
210 | | - |
211 | | - } else if (i == R.id.sd_folder) { |
212 | | - if (currentPath.startsWith(getCacheDir().getParentFile().getAbsolutePath())) { |
213 | | - homeDirectory = currentPath; |
214 | | - } |
215 | | - if (!currentPath.startsWith(Environment.getExternalStorageDirectory().getPath())) { |
216 | | - getDir(sdDirectory); |
217 | | - if (selectionMode == SelectionMode.MODE_SELECT_DIR) { |
218 | | - selectedFile = new File(currentPath); |
219 | | - mFileName.setText(selectedFile.getName()); |
220 | | - selectButton.setEnabled(true); |
221 | | - } |
222 | | - } |
223 | | - |
224 | | - } else if (i == R.id.new_folder) { |
225 | | - newDir(); |
226 | | - |
227 | | - } |
228 | | - return true; |
229 | | - } |
230 | | - |
231 | | - private void newDir() { |
232 | | - final EditText input = new EditText(context); |
233 | | - input.setInputType(InputType.TYPE_CLASS_TEXT); |
234 | | - input.setSingleLine(true); |
235 | | - new AlertDialog.Builder(context) |
236 | | - .setMessage(getString(R.string.create_new)) |
237 | | - .setView(input) |
238 | | - .setPositiveButton(getString(R.string.button_continue), new DialogInterface.OnClickListener() { |
239 | | - public void onClick(DialogInterface dialog, int whichButton) { |
240 | | - if ((new File(currentPath + "/" + input.getText().toString())).mkdirs() == false) { |
241 | | - new AlertDialog.Builder(context) |
242 | | - .setIcon(android.R.drawable.ic_dialog_alert) |
243 | | - .setTitle(R.string.newDirectory) |
244 | | - .setMessage(getString(R.string.cannot_create)) |
245 | | - .show(); |
246 | | - } else { |
247 | | - getDir(currentPath + "/" + input.getText().toString()); |
248 | | - if (selectionMode == SelectionMode.MODE_SELECT_DIR) { |
249 | | - selectedFile = new File(currentPath); |
250 | | - mFileName.setText(selectedFile.getName()); |
251 | | - selectButton.setEnabled(true); |
252 | | - } |
253 | | - } |
254 | | - } |
255 | | - }) |
256 | | - .setNegativeButton(getString(R.string.button_cancel), new DialogInterface.OnClickListener() { |
257 | | - |
258 | | - public void onClick(DialogInterface dialog, int which) { |
259 | | - // TODO Auto-generated method stub |
260 | | - |
261 | | - } |
262 | | - }).show(); |
263 | | - } |
264 | | - |
265 | 185 | private void getDir(String dirPath) { |
266 | 186 |
|
267 | 187 | boolean useAutoSelection = dirPath.length() < currentPath.length(); |
@@ -377,8 +297,6 @@ private void addItem(String fileName, int imageId) { |
377 | 297 | } |
378 | 298 |
|
379 | 299 | protected void onLongListItemClick(View v, int pos, long id) { |
380 | | - Log.i(TAG, "onLongListItemClick id=" + id); |
381 | | - mMode = startSupportActionMode(new FileActionMode()); |
382 | 300 | } |
383 | 301 |
|
384 | 302 |
|
@@ -453,69 +371,6 @@ public void onClick(DialogInterface dialog, int which) { |
453 | 371 | } |
454 | 372 | } |
455 | 373 |
|
456 | | - private final class FileActionMode implements ActionMode.Callback { |
457 | | - private List<String> getSelectedFiles() { |
458 | | - List<String> files = new ArrayList<String>(); |
459 | | - SparseBooleanArray checked = getListView().getCheckedItemPositions(); |
460 | | - |
461 | | - for (int i = 0; i < checked.size(); i++) { |
462 | | - if (checked.valueAt(i)) { |
463 | | - HashMap<String, Object> item = (HashMap<String, Object>) getListView().getAdapter().getItem(checked.keyAt(i)); |
464 | | - if (item.get(ITEM_KEY).equals("..")) { |
465 | | - continue; |
466 | | - } |
467 | | - files.add(currentPath + "/" + item.get(ITEM_KEY)); |
468 | | - } |
469 | | - } |
470 | | - |
471 | | - return files; |
472 | | - } |
473 | | - |
474 | | - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { |
475 | | - int i = item.getItemId(); |
476 | | - if (i == R.id.file_delete) { |
477 | | - List<String> files = getSelectedFiles(); |
478 | | - if (files.size() > 0) { |
479 | | - actionOp = item.getItemId(); |
480 | | - new ActionFiles().execute(files); |
481 | | - } |
482 | | - |
483 | | - } else if (i == R.id.file_copy || i == R.id.file_cut) { |
484 | | - actionFiles = getSelectedFiles(); |
485 | | - if (actionFiles.size() > 0) { |
486 | | - actionOp = item.getItemId(); |
487 | | - } |
488 | | - |
489 | | - } else if (i == R.id.file_paste) { |
490 | | - if (actionOp == R.id.file_copy || actionOp == R.id.file_cut) { |
491 | | - new ActionFiles().execute(actionFiles); |
492 | | - } |
493 | | - |
494 | | - } |
495 | | - mode.finish(); |
496 | | - return true; |
497 | | - } |
498 | | - |
499 | | - public boolean onCreateActionMode(ActionMode mode, Menu menu) { |
500 | | - getMenuInflater().inflate(R.menu.file_action_menu, menu); |
501 | | - if (actionOp == 0) { |
502 | | - menu.findItem(R.id.file_paste).setVisible(false); |
503 | | - } |
504 | | - return true; |
505 | | - } |
506 | | - |
507 | | - public void onDestroyActionMode(ActionMode mode) { |
508 | | - getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE); |
509 | | - getDir(currentPath); |
510 | | - mMode = null; |
511 | | - } |
512 | | - |
513 | | - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { |
514 | | - getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); |
515 | | - return false; |
516 | | - } |
517 | | - } |
518 | | - |
519 | 374 | private class ActionFiles extends AsyncTask<List<String>, String, Boolean> { |
520 | 375 | protected void onPreExecute() { |
521 | 376 | super.onPreExecute(); |
|
0 commit comments