Deletion button being disabled (#1403)

* used CDATA

* Improvements in Notification Activity (#1374)

* Improvements in Notification Activity

* Update NotificationActivity.java

* Share feature (#1338)

* added share app feature in About

* added share app feature in About

* a small fix

* Use custom tabs for nearby web views (#1347)

* Localisation updates from https://translatewiki.net.

* Fix for issue #1380 Improved Notification UI (#1387)

* Links added to TextView about_upload_to in aboutActivity (#1326)

*  Added the link in about_upload_to textfield

*  Merge conflicts resolved

*  Removed the extra textView

* Fix re-enabling delete button if the action is canceled.

* Keep delete button enabled until a reason is given.
This commit is contained in:
Gabriela Radu 2018-04-16 15:03:24 +03:00 committed by neslihanturan
parent 482b06ccf0
commit 9a3b6fc964
50 changed files with 488 additions and 76 deletions

View file

@ -304,9 +304,10 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
coordinates.setOnClickListener(v -> openMap(media.getCoordinates()));
}
if (delete.getVisibility() == View.VISIBLE) {
enableDeleteButton(true);
delete.setOnClickListener(v -> {
delete.setEnabled(false);
delete.setTextColor(getResources().getColor(R.color.deleteButtonLight));
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setMessage("Why should this file be deleted?");
final EditText input = new EditText(getActivity());
@ -317,6 +318,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
String reason = input.getText().toString();
DeleteTask deleteTask = new DeleteTask(getActivity(), media, reason);
deleteTask.execute();
enableDeleteButton(false);
}
});
alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@ -358,6 +360,15 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
}
}
private void enableDeleteButton(boolean visibility) {
delete.setEnabled(visibility);
if(visibility) {
delete.setTextColor(getResources().getColor(R.color.primaryTextColor));
} else {
delete.setTextColor(getResources().getColor(R.color.deleteButtonLight));
}
}
private void rebuildCatList() {
categoryContainer.removeAllViews();
// @fixme add the category items