Replace with enum two strings that were in strings.xml but were used as (#2939)

constants. Remove strings from strings.xml Issue # 2931
This commit is contained in:
kateOmally 2019-05-08 11:37:29 -07:00 committed by neslihanturan
parent 2164fb00f3
commit 41b53f4560
3 changed files with 11 additions and 7 deletions

View file

@ -20,6 +20,7 @@ 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 timber.log.Timber;
@ -142,7 +143,7 @@ public class DeleteHelper {
* @param question
* @param problem
*/
public void askReasonAndExecute(Media media, Context context, String question, String problem) {
public void askReasonAndExecute(Media media, Context context, String question, ReviewController.DeleteReason problem) {
AlertDialog.Builder alert = new AlertDialog.Builder(context);
alert.setTitle(question);
@ -152,12 +153,12 @@ public class DeleteHelper {
String[] reasonList = {"Reason 1", "Reason 2", "Reason 3", "Reason 4"};
if (problem.equals("spam")) {
if (problem == ReviewController.DeleteReason.SPAM) {
reasonList[0] = "A selfie";
reasonList[1] = "Blurry";
reasonList[2] = "Nonsense";
reasonList[3] = "Other";
} else if (problem.equals("copyRightViolation")) {
} else if (problem == ReviewController.DeleteReason.COPYRIGHT_VIOLATION) {
reasonList[0] = "Press photo";
reasonList[1] = "Random photo from internet";
reasonList[2] = "Logo";

View file

@ -74,18 +74,23 @@ public class ReviewController {
}
}
public enum DeleteReason {
SPAM,
COPYRIGHT_VIOLATION
}
public void reportSpam(@NonNull Activity activity) {
deleteHelper.askReasonAndExecute(new Media("File:" + fileName),
activity,
activity.getResources().getString(R.string.review_spam_report_question),
activity.getResources().getString(R.string.review_spam_report_problem));
DeleteReason.SPAM);
}
public void reportPossibleCopyRightViolation(@NonNull Activity activity) {
deleteHelper.askReasonAndExecute(new Media("File:" + fileName),
activity,
activity.getResources().getString(R.string.review_c_violation_report_question),
activity.getResources().getString(R.string.review_c_violation_report_problem));
DeleteReason.COPYRIGHT_VIOLATION);
}
@SuppressLint("CheckResult")