mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
user talk and dialog box fix (#3014)
This commit is contained in:
parent
6a9018b550
commit
09459a3765
2 changed files with 24 additions and 5 deletions
|
|
@ -110,7 +110,7 @@ public class DeleteHelper {
|
|||
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);
|
||||
} catch (Exception e) {
|
||||
Timber.e(e);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import fr.free.nrw.commons.Media;
|
|||
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 class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
|
||||
@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 class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
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?");
|
||||
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 class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
d.show();
|
||||
d.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void onDeleteClicked(Spinner spinner) {
|
||||
|
|
@ -445,6 +448,22 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
|||
|
||||
}
|
||||
|
||||
@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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue