mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-28 21:33:53 +01:00
* Fix bugs in peer review flow * Fix tests * Bug fixes * Fix remaining issues with peer review
This commit is contained in:
parent
4ec92c2e7b
commit
d7628959a7
8 changed files with 140 additions and 125 deletions
|
|
@ -1,9 +1,12 @@
|
|||
package fr.free.nrw.commons.delete;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
|
@ -12,17 +15,16 @@ import java.util.Locale;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import fr.free.nrw.commons.BuildConfig;
|
||||
import fr.free.nrw.commons.Media;
|
||||
import fr.free.nrw.commons.auth.SessionManager;
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||
import fr.free.nrw.commons.notification.NotificationHelper;
|
||||
import fr.free.nrw.commons.review.ReviewActivity;
|
||||
import fr.free.nrw.commons.utils.ViewUtil;
|
||||
import fr.free.nrw.commons.review.ReviewController;
|
||||
import fr.free.nrw.commons.utils.ViewUtilWrapper;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static fr.free.nrw.commons.notification.NotificationHelper.NOTIFICATION_DELETE;
|
||||
|
|
@ -57,7 +59,6 @@ public class DeleteHelper {
|
|||
*/
|
||||
public Single<Boolean> makeDeletion(Context context, Media media, String reason) {
|
||||
viewUtil.showShortToast(context, "Trying to nominate " + media.getDisplayTitle() + " for deletion");
|
||||
|
||||
return Single.fromCallable(() -> delete(media, reason))
|
||||
.flatMap(result -> Single.fromCallable(() ->
|
||||
showDeletionNotification(context, media, result)));
|
||||
|
|
@ -99,7 +100,8 @@ public class DeleteHelper {
|
|||
|
||||
try {
|
||||
editToken = mwApi.getEditToken();
|
||||
if (editToken.equals("+\\")) {
|
||||
|
||||
if(editToken == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +145,12 @@ public class DeleteHelper {
|
|||
* @param question
|
||||
* @param problem
|
||||
*/
|
||||
public void askReasonAndExecute(Media media, Context context, String question, ReviewController.DeleteReason problem) {
|
||||
@SuppressLint("CheckResult")
|
||||
public void askReasonAndExecute(Media media,
|
||||
Context context,
|
||||
String question,
|
||||
ReviewController.DeleteReason problem,
|
||||
ReviewController.ReviewCallback reviewCallback) {
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(context);
|
||||
alert.setTitle(question);
|
||||
|
||||
|
|
@ -183,12 +190,19 @@ public class DeleteHelper {
|
|||
}
|
||||
}
|
||||
|
||||
((ReviewActivity) context).reviewController.swipeToNext();
|
||||
((ReviewActivity) context).runRandomizer();
|
||||
makeDeletion(context, media, reason)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(aBoolean -> {
|
||||
if (aBoolean) {
|
||||
reviewCallback.onSuccess();
|
||||
} else {
|
||||
reviewCallback.onFailure();
|
||||
}
|
||||
});
|
||||
|
||||
makeDeletion(context, media, reason);
|
||||
});
|
||||
alert.setNegativeButton("Cancel", null);
|
||||
alert.setNegativeButton("Cancel", (dialog, which) -> reviewCallback.onFailure());
|
||||
AlertDialog d = alert.create();
|
||||
d.show();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue