Skip to content

Commit

Permalink
UI to delete task files
Browse files Browse the repository at this point in the history
  • Loading branch information
andresth committed May 3, 2017
1 parent 76011d0 commit b6142b0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
34 changes: 33 additions & 1 deletion app/src/main/java/in/andres/kandroid/ui/TaskDetailActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -349,6 +350,19 @@ public void onGetAllTaskFiles(boolean success, List<KanboardTaskFile> 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();
}
}
};
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/menu/activity_taskdetail_context_files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_download_file"
android:title="@string/action_download" />
android:title="@string/action_download"
android:visible="false"/>
<item
android:id="@+id/action_delete_file"
android:title="@string/action_delete" />
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,6 @@
<string name="dlg_devel_version">Auf diesem Server läuft eine Entwicklerversion von Kanboard. Kandroid funktioniert möglicherweise nicht mit diesem Server.</string>
<string name="action_download">Herunterladen</string>
<string name="menu_caption_file">Datei #%d</string>
<string name="delete_dlg_file">Datei löschen</string>
<string name="error_msg_remove_File">Fehler beim löschen der Datei!</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@
<string name="delete_dlg_task">Delete Task</string>
<string name="delete_dlg_subtask">Delete Subtask</string>
<string name="delete_dlg_comment">Delete Comment</string>
<string name="delete_dlg_file">Delete File</string>
<string name="error_msg_remove_task">Error while removing task!</string>
<string name="error_msg_remove_File">Error while deleting file!</string>
<string name="error_msg_open_task">Error while opening task!</string>
<string name="error_msg_close_task">Error while closing task!</string>
<string name="error_msg_create_comment">Error while removing task!</string>
Expand Down

0 comments on commit b6142b0

Please sign in to comment.