Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private boolean delete(Media media, String reason) {
mwApi.appendEdit(editToken, logPageString + "\n",
"Commons:Deletion_requests/" + date, summary);
mwApi.appendEdit(editToken, userPageString + "\n",
"User_Talk:" + sessionManager.getCurrentAccount().name, summary);
"User_Talk:" + media.getCreator(), summary);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add/update the corresponding unit test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maskaravivek can you help me with unit test. i have never done a test. like what should be the result and where should it be placed .

} catch (Exception e) {
Timber.e(e);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import fr.free.nrw.commons.MediaDataExtractor;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.auth.AccountUtil;
import fr.free.nrw.commons.category.CategoryDetailsActivity;
import fr.free.nrw.commons.contributions.ContributionsFragment;
import fr.free.nrw.commons.delete.DeleteHelper;
Expand Down Expand Up @@ -367,6 +368,7 @@ public void onCopyWikicodeClicked(){

@OnClick(R.id.nominateDeletion)
public void onDeleteButtonClicked(){
if(AccountUtil.getUserName(getContext()).equals(media.getCreator())){
final ArrayAdapter<String> languageAdapter = new ArrayAdapter<>(getActivity(),
R.layout.simple_spinner_dropdown_list, reasonList);
final Spinner spinner = new Spinner(getActivity());
Expand All @@ -384,19 +386,19 @@ public void onDeleteButtonClicked(){
if(isDeleted) {
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
}
//Reviewer correct me if i have misunderstood something over here
//But how does this if (delete.getVisibility() == View.VISIBLE) {
// enableDeleteButton(true); makes sense ?
else{
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setMessage("Why should this fileckathon-2018 be deleted?");
alert.setMessage("Why should "+ media.getDisplayTitle() +" be deleted?");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if you move this hard coded string into strings.xml file in another pull request @sherlockbeard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neslihanturan i added the string value in #3015

final EditText input = new EditText(getActivity());
alert.setView(input);
input.requestFocus();
alert.setPositiveButton(R.string.ok, (dialog1, whichButton) -> {
String reason = input.getText().toString();

deleteHelper.makeDeletion(getContext(), media, reason);
enableDeleteButton(false);
onDeleteClickeddialogtext(reason);
});
alert.setNegativeButton(R.string.cancel, (dialog12, whichButton) -> {
});
Expand Down Expand Up @@ -427,6 +429,7 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
d.show();
d.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
}

@SuppressLint("CheckResult")
private void onDeleteClicked(Spinner spinner) {
Expand All @@ -445,6 +448,22 @@ private void onDeleteClicked(Spinner spinner) {

}

@SuppressLint("CheckResult")
private void onDeleteClickeddialogtext(String reason) {
Single<Boolean> resultSingletext = reasonBuilder.getReason(media, reason)
.flatMap(reasonString -> deleteHelper.makeDeletion(getContext(), media, reason));
compositeDisposable.add(resultSingletext
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(s -> {
if (getActivity() != null) {
isDeleted = true;
enableDeleteButton(false);
}
}));

}

@OnClick(R.id.seeMore)
public void onSeeMoreClicked(){
if (nominatedForDeletion.getVisibility() == VISIBLE && getActivity() != null) {
Expand Down