From 108e28c89a8493852b7a3f4711db0c148690f4b4 Mon Sep 17 00:00:00 2001 From: PavelAplevich <52326878+PavelAplevich@users.noreply.github.com> Date: Sat, 6 Jul 2019 23:25:53 +0300 Subject: [PATCH] Removed all hardcoded string in DeleteHelper (#3052) * Removed hardcoded strings in DeleteHelper * Revert "Removed hardcoded strings in DeleteHelper" This reverts commit 4bc55fc3afc0142c72934c63b75630239e566aa8. * Removed all hardcoded strings in DeleteHelper. * fixed test problems * Correction strings in DeleteHelper * decision problem with color of info icon #2940 * Correction DeleteHelper and string.xml * minor fix * fixed problems in DeleteHelper.java and strings.xml * and another little fix * Revert "and another little fix" This reverts commit fe4ea5255f0d55230ce2573758c153408b3ba0c1. * Revert "decision problem with color of info icon #2940" This reverts commit 5895cc8785c9701b080909012bbe16ea4b775873. --- .../free/nrw/commons/delete/DeleteHelper.java | 34 +++++++++---------- app/src/main/res/values/strings.xml | 23 ++++++++----- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/delete/DeleteHelper.java b/app/src/main/java/fr/free/nrw/commons/delete/DeleteHelper.java index fe91010eb..a5d7e7ef7 100644 --- a/app/src/main/java/fr/free/nrw/commons/delete/DeleteHelper.java +++ b/app/src/main/java/fr/free/nrw/commons/delete/DeleteHelper.java @@ -59,7 +59,7 @@ public class DeleteHelper { * @return */ public Single makeDeletion(Context context, Media media, String reason) { - viewUtil.showShortToast(context, "Trying to nominate " + media.getDisplayTitle() + " for deletion"); + viewUtil.showShortToast(context, context.getString((R.string.delete_helper_make_deletion_toast), media.getDisplayTitle())); return Single.fromCallable(() -> delete(media, reason)) .flatMap(result -> Single.fromCallable(() -> showDeletionNotification(context, media, result))); @@ -123,14 +123,14 @@ public class DeleteHelper { private boolean showDeletionNotification(Context context, Media media, boolean result) { String message; - String title = "Nominating for Deletion"; + String title = context.getString(R.string.delete_helper_show_deletion_title); if (result) { - title += ": Success"; - message = "Successfully nominated " + media.getDisplayTitle() + " deletion."; + title += ": " + context.getString(R.string.delete_helper_show_deletion_title_success); + message = context.getString((R.string.delete_helper_show_deletion_message_if),media.getDisplayTitle()); } else { - title += ": Failed"; - message = "Could not request deletion."; + title += ": " + context.getString(R.string.delete_helper_show_deletion_title_failed); + message = context.getString(R.string.delete_helper_show_deletion_message_else) ; } String urlForDelete = BuildConfig.COMMONS_URL + "/wiki/Commons:Deletion_requests/" + media.getFilename(); @@ -162,15 +162,15 @@ public class DeleteHelper { if (problem == ReviewController.DeleteReason.SPAM) { - reasonList[0] = context.getResources().getString(R.string.delete_reason_spam_selfie); - reasonList[1] = context.getResources().getString(R.string.delete_reason_spam_blurry); - reasonList[2] = context.getResources().getString(R.string.delete_reason_spam_nonsense); - reasonList[3] = context.getResources().getString(R.string.delete_reason_spam_other); + reasonList[0] = context.getString(R.string.delete_helper_ask_spam_selfie); + reasonList[1] = context.getString(R.string.delete_helper_ask_spam_blurry); + reasonList[2] = context.getString(R.string.delete_helper_ask_spam_nonsense); + reasonList[3] = context.getString(R.string.delete_helper_ask_spam_other); } else if (problem == ReviewController.DeleteReason.COPYRIGHT_VIOLATION) { - reasonList[0] = context.getResources().getString(R.string.delete_reason_copyright_pressphoto); - reasonList[1] = context.getResources().getString(R.string.delete_reason_copyright_internetphoto); - reasonList[2] = context.getResources().getString(R.string.delete_reason_copyright_logo); - reasonList[3] = context.getResources().getString(R.string.delete_reason_copyright_other); + reasonList[0] = context.getString(R.string.delete_helper_ask_reason_copyright_press_photo); + reasonList[1] = context.getString(R.string.delete_helper_ask_reason_copyright_internet_photo); + reasonList[2] = context.getString(R.string.delete_helper_ask_reason_copyright_logo); + reasonList[3] = context.getString(R.string.delete_helper_ask_reason_copyright_other); } alert.setMultiChoiceItems(reasonList, checkedItems, (dialogInterface, position, isChecked) -> { @@ -181,9 +181,9 @@ public class DeleteHelper { } }); - alert.setPositiveButton("OK", (dialogInterface, i) -> { + alert.setPositiveButton(context.getString(R.string.ok), (dialogInterface, i) -> { - String reason = "Because it is "; + String reason = context.getString(R.string.delete_helper_ask_alert_set_positive_button_reason) + " "; for (int j = 0; j < mUserReason.size(); j++) { reason = reason + reasonList[mUserReason.get(j)]; if (j != mUserReason.size() - 1) { @@ -203,7 +203,7 @@ public class DeleteHelper { }); }); - alert.setNegativeButton("Cancel", (dialog, which) -> reviewCallback.onFailure()); + alert.setNegativeButton(context.getString(R.string.cancel), (dialog, which) -> reviewCallback.onFailure()); AlertDialog d = alert.create(); d.show(); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 08cad0620..9fe8836aa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -560,12 +560,19 @@ Upload your first media by tapping on the add button. Why should %1$s be deleted? %1$s is uploaded by: %2$s Default description language - A selfie - Blurry - Nonsense - Other - Press photo - Random photo from internet - Logo - Other + Trying to nominate %1$s for deletion + Nominating for deletion + Success + Successfully nominated %1$s for deletion. + Failed + Could not request deletion. + A selfie + Blurry + Nonsense + Other + Press photo + Random photo from internet + Logo + Other + Because it is