diff --git a/app/src/main/java/in/andres/kandroid/ui/TaskDetailActivity.java b/app/src/main/java/in/andres/kandroid/ui/TaskDetailActivity.java index 4e4047e..3679a9b 100644 --- a/app/src/main/java/in/andres/kandroid/ui/TaskDetailActivity.java +++ b/app/src/main/java/in/andres/kandroid/ui/TaskDetailActivity.java @@ -101,6 +101,7 @@ import in.andres.kandroid.kanboard.events.OnOpenTaskListener; import in.andres.kandroid.kanboard.events.OnRemoveCommentListener; import in.andres.kandroid.kanboard.events.OnRemoveSubtaskListener; +import in.andres.kandroid.kanboard.events.OnRemoveTaskFileListener; import in.andres.kandroid.kanboard.events.OnRemoveTaskListener; import in.andres.kandroid.kanboard.events.OnSubtaskTimetrackingListener; import in.andres.kandroid.kanboard.events.OnUpdateCommentListener; @@ -349,6 +350,19 @@ public void onGetAllTaskFiles(boolean success, List result) { findViewById(R.id.card_files).setVisibility(View.VISIBLE); files = result; filesListview.setAdapter(new TaskFilesAdapter(getBaseContext(), files)); + } else { + findViewById(R.id.card_files).setVisibility(View.GONE); + } + } + }; + private OnRemoveTaskFileListener removeTaskFileListener = new OnRemoveTaskFileListener() { + @Override + public void onRemoveTaskFile(boolean success) { + if (success) { + showProgress(); + kanboardAPI.getAllTaskFiles(task.getId()); + } else { + Snackbar.make(findViewById(R.id.root_layout), getString(R.string.error_msg_remove_subtask), Snackbar.LENGTH_LONG).show(); } } }; @@ -536,6 +550,7 @@ public void onClick(View v) { kanboardAPI.addOnOpenTaskListener(openTaskListener); kanboardAPI.addOnCloseTaskListener(closeTaskListener); kanboardAPI.addOnGetAllTaskFilesListListeners(getAllTaskFilesListener); + kanboardAPI.addOnRemoveTaskFileListeners(removeTaskFileListener); } catch (IOException e) { e.printStackTrace(); } @@ -645,7 +660,7 @@ public boolean onContextItemSelected(MenuItem item) { Snackbar.make(findViewById(R.id.root_layout), getString(R.string.error_msg_not_implemented), Snackbar.LENGTH_LONG).show(); return true; case R.id.action_delete_file: - Snackbar.make(findViewById(R.id.root_layout), getString(R.string.error_msg_not_implemented), Snackbar.LENGTH_LONG).show(); + showDeleteTaskFileDialog((KanboardTaskFile) filesListview.getAdapter().getItem(info.position)); return true; default: return super.onContextItemSelected(item); @@ -946,6 +961,23 @@ public void onClick(DialogInterface dialog, int which) {} dlgBuilder.show(); } + private void showDeleteTaskFileDialog(final KanboardTaskFile taskfile) { + AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(TaskDetailActivity.this); + dlgBuilder.setTitle(getString(R.string.delete_dlg_file)); + dlgBuilder.setMessage(getString(R.string.delete_dlg_message)); + dlgBuilder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + kanboardAPI.removeTaskFile(taskfile.getId()); + } + }); + dlgBuilder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) {} + }); + dlgBuilder.show(); + } + private void showDeleteTaskDialog(final KanboardTask task) { AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(TaskDetailActivity.this); dlgBuilder.setTitle(getString(R.string.delete_dlg_task)); diff --git a/app/src/main/res/menu/activity_taskdetail_context_files.xml b/app/src/main/res/menu/activity_taskdetail_context_files.xml index d7595ed..c04f33a 100644 --- a/app/src/main/res/menu/activity_taskdetail_context_files.xml +++ b/app/src/main/res/menu/activity_taskdetail_context_files.xml @@ -2,7 +2,8 @@ + android:title="@string/action_download" + android:visible="false"/> diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 046e510..1e4cae3 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -152,4 +152,6 @@ Auf diesem Server läuft eine Entwicklerversion von Kanboard. Kandroid funktioniert möglicherweise nicht mit diesem Server. Herunterladen Datei #%d + Datei löschen + Fehler beim löschen der Datei! diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cfde9e7..a6eb374 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -130,7 +130,9 @@ Delete Task Delete Subtask Delete Comment + Delete File Error while removing task! + Error while deleting file! Error while opening task! Error while closing task! Error while removing task!