-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix the the dialog box error and the user talk issue #3009
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; | ||
|
|
@@ -366,66 +367,68 @@ public void onCopyWikicodeClicked(){ | |
| } | ||
|
|
||
| @OnClick(R.id.nominateDeletion) | ||
| public void onDeleteButtonClicked(){ | ||
| final ArrayAdapter<String> languageAdapter = new ArrayAdapter<>(getActivity(), | ||
| R.layout.simple_spinner_dropdown_list, reasonList); | ||
| final Spinner spinner = new Spinner(getActivity()); | ||
| spinner.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); | ||
| spinner.setAdapter(languageAdapter); | ||
| spinner.setGravity(17); | ||
|
|
||
| AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
| builder.setView(spinner); | ||
| builder.setTitle(R.string.nominate_delete) | ||
| .setPositiveButton(R.string.about_translate_proceed, (dialog, which) -> onDeleteClicked(spinner)); | ||
| builder.setNegativeButton(R.string.about_translate_cancel, (dialog, which) -> dialog.dismiss()); | ||
| AlertDialog dialog = builder.create(); | ||
| dialog.show(); | ||
| if(isDeleted) { | ||
| dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); | ||
| public void onDeleteButtonClicked() { | ||
| if (media.getCreator().equals(AccountUtil.getUserName(getContext()))) { | ||
| final ArrayAdapter<String> languageAdapter = new ArrayAdapter<>(getActivity(), | ||
| R.layout.simple_spinner_dropdown_list, reasonList); | ||
| final Spinner spinner = new Spinner(getActivity()); | ||
| spinner.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); | ||
| spinner.setAdapter(languageAdapter); | ||
| spinner.setGravity(17); | ||
|
|
||
| AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
| builder.setView(spinner); | ||
| builder.setTitle(R.string.nominate_delete) | ||
| .setPositiveButton(R.string.about_translate_proceed, (dialog, which) -> onDeleteClicked(spinner)); | ||
| builder.setNegativeButton(R.string.about_translate_cancel, (dialog, which) -> dialog.dismiss()); | ||
| AlertDialog dialog = builder.create(); | ||
| dialog.show(); | ||
| if (isDeleted) { | ||
| dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); | ||
| } | ||
|
Member
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 seems that you have reformatted the code? That makes it difficult to see what has actually changed. Better send a first pull request with only the real changes, and then optionally later a second pull request with only the reformatting. Thanks! :-) |
||
| } | ||
| //Reviewer correct me if i have misunderstood something over here | ||
| //But how does this if (delete.getVisibility() == View.VISIBLE) { | ||
| // enableDeleteButton(true); makes sense ? | ||
| AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); | ||
| alert.setMessage("Why should this fileckathon-2018 be deleted?"); | ||
| 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); | ||
| }); | ||
| alert.setNegativeButton(R.string.cancel, (dialog12, whichButton) -> { | ||
| }); | ||
| AlertDialog d = alert.create(); | ||
| input.addTextChangedListener(new TextWatcher() { | ||
| private void handleText() { | ||
| final Button okButton = d.getButton(AlertDialog.BUTTON_POSITIVE); | ||
| if (input.getText().length() == 0) { | ||
| okButton.setEnabled(false); | ||
| } else { | ||
| okButton.setEnabled(true); | ||
| else { | ||
|
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. Same thing @nicolas-raoul pointed happened here too. Indentation of several lines are changed. Reviewers click "files changed" tab on your pull request page and see changed lines. When you made additional changes it is hard to understand for us what will be inserted into our code base if we merge this changes. Even if your additional changes are beneficial for code quality etc. please send them in separate pull request. We should be seeing only relevant lines changed under a single pull request. |
||
| AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); | ||
| alert.setMessage("Why should "+ media.getDisplayTitle() +" be deleted?"); | ||
| final EditText input = new EditText(getActivity()); | ||
| alert.setView(input); | ||
| input.requestFocus(); | ||
| alert.setPositiveButton(R.string.ok, (dialog1, whichButton) -> { | ||
| String reason = input.getText().toString(); | ||
| onDeleteClickedOthers(reason); | ||
| }); | ||
| alert.setNegativeButton(R.string.cancel, (dialog12, whichButton) -> { | ||
| }); | ||
| AlertDialog d = alert.create(); | ||
| input.addTextChangedListener(new TextWatcher() { | ||
| private void handleText() { | ||
| final Button okButton = d.getButton(AlertDialog.BUTTON_POSITIVE); | ||
| if (input.getText().length() == 0) { | ||
| okButton.setEnabled(false); | ||
| } else { | ||
| okButton.setEnabled(true); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void afterTextChanged(Editable arg0) { | ||
| handleText(); | ||
| } | ||
| @Override | ||
| public void afterTextChanged(Editable arg0) { | ||
| handleText(); | ||
| } | ||
|
|
||
| @Override | ||
| public void beforeTextChanged(CharSequence s, int start, int count, int after) { | ||
| } | ||
| @Override | ||
| public void beforeTextChanged(CharSequence s, int start, int count, int after) { | ||
| } | ||
|
|
||
| @Override | ||
| public void onTextChanged(CharSequence s, int start, int before, int count) { | ||
| } | ||
| }); | ||
| d.show(); | ||
| d.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); | ||
| @Override | ||
| public void onTextChanged(CharSequence s, int start, int before, int count) { | ||
| } | ||
| }); | ||
| d.show(); | ||
| d.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); | ||
| } | ||
| } | ||
|
|
||
| @SuppressLint("CheckResult") | ||
|
|
@@ -443,6 +446,20 @@ private void onDeleteClicked(Spinner spinner) { | |
| } | ||
| })); | ||
|
|
||
| } | ||
| private void onDeleteClickedOthers(String reason){ | ||
| Single<Boolean> resultSingles = reasonBuilder.getReason(media, reason) | ||
| .flatMap(reasonString -> deleteHelper.makeDeletion(getContext(), media, reason)); | ||
| compositeDisposable.add(resultSingles | ||
| .subscribeOn(Schedulers.io()) | ||
| .observeOn(AndroidSchedulers.mainThread()) | ||
| .subscribe(s -> { | ||
| if (getActivity() != null) { | ||
| isDeleted = true; | ||
| enableDeleteButton(false); | ||
| } | ||
| })); | ||
|
|
||
| } | ||
|
|
||
| @OnClick(R.id.seeMore) | ||
|
|
||
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.
Good :-)