-
Notifications
You must be signed in to change notification settings - Fork 1.3k
user talk and dialog box fix #3014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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()); | ||
|
|
@@ -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?"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) -> { | ||
| }); | ||
|
|
@@ -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) { | ||
|
|
@@ -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) { | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 .