Skip to content

Commit 108e28c

Browse files
PavelAplevichneslihanturan
authored andcommitted
Removed all hardcoded string in DeleteHelper (commons-app#3052)
* Removed hardcoded strings in DeleteHelper * Revert "Removed hardcoded strings in DeleteHelper" This reverts commit 4bc55fc. * Removed all hardcoded strings in DeleteHelper. * fixed test problems * Correction strings in DeleteHelper * decision problem with color of info icon commons-app#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 fe4ea52. * Revert "decision problem with color of info icon commons-app#2940" This reverts commit 5895cc8.
1 parent b71dac3 commit 108e28c

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

app/src/main/java/fr/free/nrw/commons/delete/DeleteHelper.java

+17-17
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public DeleteHelper(MediaWikiApi mwApi,
5959
* @return
6060
*/
6161
public Single<Boolean> makeDeletion(Context context, Media media, String reason) {
62-
viewUtil.showShortToast(context, "Trying to nominate " + media.getDisplayTitle() + " for deletion");
62+
viewUtil.showShortToast(context, context.getString((R.string.delete_helper_make_deletion_toast), media.getDisplayTitle()));
6363
return Single.fromCallable(() -> delete(media, reason))
6464
.flatMap(result -> Single.fromCallable(() ->
6565
showDeletionNotification(context, media, result)));
@@ -123,14 +123,14 @@ private boolean delete(Media media, String reason) {
123123

124124
private boolean showDeletionNotification(Context context, Media media, boolean result) {
125125
String message;
126-
String title = "Nominating for Deletion";
126+
String title = context.getString(R.string.delete_helper_show_deletion_title);
127127

128128
if (result) {
129-
title += ": Success";
130-
message = "Successfully nominated " + media.getDisplayTitle() + " deletion.";
129+
title += ": " + context.getString(R.string.delete_helper_show_deletion_title_success);
130+
message = context.getString((R.string.delete_helper_show_deletion_message_if),media.getDisplayTitle());
131131
} else {
132-
title += ": Failed";
133-
message = "Could not request deletion.";
132+
title += ": " + context.getString(R.string.delete_helper_show_deletion_title_failed);
133+
message = context.getString(R.string.delete_helper_show_deletion_message_else) ;
134134
}
135135

136136
String urlForDelete = BuildConfig.COMMONS_URL + "/wiki/Commons:Deletion_requests/" + media.getFilename();
@@ -162,15 +162,15 @@ public void askReasonAndExecute(Media media,
162162

163163

164164
if (problem == ReviewController.DeleteReason.SPAM) {
165-
reasonList[0] = context.getResources().getString(R.string.delete_reason_spam_selfie);
166-
reasonList[1] = context.getResources().getString(R.string.delete_reason_spam_blurry);
167-
reasonList[2] = context.getResources().getString(R.string.delete_reason_spam_nonsense);
168-
reasonList[3] = context.getResources().getString(R.string.delete_reason_spam_other);
165+
reasonList[0] = context.getString(R.string.delete_helper_ask_spam_selfie);
166+
reasonList[1] = context.getString(R.string.delete_helper_ask_spam_blurry);
167+
reasonList[2] = context.getString(R.string.delete_helper_ask_spam_nonsense);
168+
reasonList[3] = context.getString(R.string.delete_helper_ask_spam_other);
169169
} else if (problem == ReviewController.DeleteReason.COPYRIGHT_VIOLATION) {
170-
reasonList[0] = context.getResources().getString(R.string.delete_reason_copyright_pressphoto);
171-
reasonList[1] = context.getResources().getString(R.string.delete_reason_copyright_internetphoto);
172-
reasonList[2] = context.getResources().getString(R.string.delete_reason_copyright_logo);
173-
reasonList[3] = context.getResources().getString(R.string.delete_reason_copyright_other);
170+
reasonList[0] = context.getString(R.string.delete_helper_ask_reason_copyright_press_photo);
171+
reasonList[1] = context.getString(R.string.delete_helper_ask_reason_copyright_internet_photo);
172+
reasonList[2] = context.getString(R.string.delete_helper_ask_reason_copyright_logo);
173+
reasonList[3] = context.getString(R.string.delete_helper_ask_reason_copyright_other);
174174
}
175175

176176
alert.setMultiChoiceItems(reasonList, checkedItems, (dialogInterface, position, isChecked) -> {
@@ -181,9 +181,9 @@ public void askReasonAndExecute(Media media,
181181
}
182182
});
183183

184-
alert.setPositiveButton("OK", (dialogInterface, i) -> {
184+
alert.setPositiveButton(context.getString(R.string.ok), (dialogInterface, i) -> {
185185

186-
String reason = "Because it is ";
186+
String reason = context.getString(R.string.delete_helper_ask_alert_set_positive_button_reason) + " ";
187187
for (int j = 0; j < mUserReason.size(); j++) {
188188
reason = reason + reasonList[mUserReason.get(j)];
189189
if (j != mUserReason.size() - 1) {
@@ -203,7 +203,7 @@ public void askReasonAndExecute(Media media,
203203
});
204204

205205
});
206-
alert.setNegativeButton("Cancel", (dialog, which) -> reviewCallback.onFailure());
206+
alert.setNegativeButton(context.getString(R.string.cancel), (dialog, which) -> reviewCallback.onFailure());
207207
AlertDialog d = alert.create();
208208
d.show();
209209
}

app/src/main/res/values/strings.xml

+15-8
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,19 @@ Upload your first media by tapping on the add button.</string>
560560
<string name="dialog_box_text_nomination">Why should %1$s be deleted?</string>
561561
<string name="review_is_uploaded_by">%1$s is uploaded by: %2$s</string>
562562
<string name="default_description_language">Default description language</string>
563-
<string name="delete_reason_spam_selfie">A selfie</string>
564-
<string name="delete_reason_spam_blurry">Blurry</string>
565-
<string name="delete_reason_spam_nonsense">Nonsense</string>
566-
<string name="delete_reason_spam_other">Other</string>
567-
<string name="delete_reason_copyright_pressphoto">Press photo</string>
568-
<string name="delete_reason_copyright_internetphoto">Random photo from internet</string>
569-
<string name="delete_reason_copyright_logo">Logo</string>
570-
<string name="delete_reason_copyright_other">Other</string>
563+
<string name="delete_helper_make_deletion_toast">Trying to nominate %1$s for deletion</string>
564+
<string name="delete_helper_show_deletion_title">Nominating for deletion</string>
565+
<string name="delete_helper_show_deletion_title_success">Success</string>
566+
<string name="delete_helper_show_deletion_message_if">Successfully nominated %1$s for deletion.</string>
567+
<string name="delete_helper_show_deletion_title_failed">Failed</string>
568+
<string name="delete_helper_show_deletion_message_else">Could not request deletion.</string>
569+
<string name="delete_helper_ask_spam_selfie">A selfie</string>
570+
<string name="delete_helper_ask_spam_blurry">Blurry</string>
571+
<string name="delete_helper_ask_spam_nonsense">Nonsense</string>
572+
<string name="delete_helper_ask_spam_other">Other</string>
573+
<string name="delete_helper_ask_reason_copyright_press_photo">Press photo</string>
574+
<string name="delete_helper_ask_reason_copyright_internet_photo">Random photo from internet</string>
575+
<string name="delete_helper_ask_reason_copyright_logo">Logo</string>
576+
<string name="delete_helper_ask_reason_copyright_other">Other</string>
577+
<string name="delete_helper_ask_alert_set_positive_button_reason">Because it is</string>
571578
</resources>

0 commit comments

Comments
 (0)