fixed test problems

This commit is contained in:
Pavel 2019-07-02 23:17:19 +03:00
parent 5e1a8f961a
commit bd89cacfa8

View file

@ -59,8 +59,8 @@ public class DeleteHelper {
* @return
*/
public Single<Boolean> makeDeletion(Context context, Media media, String reason) {
viewUtil.showShortToast(context, context.getResources().getString(R.string.delete_helper_make_deletion_toast_1)
+ media.getDisplayTitle() + context.getResources().getString(R.string.delete_helper_make_deletion_toast_2));
viewUtil.showShortToast(context, context.getString(R.string.delete_helper_make_deletion_toast_1)
+ media.getDisplayTitle() + context.getString(R.string.delete_helper_make_deletion_toast_2));
return Single.fromCallable(() -> delete(context, media, reason))
.flatMap(result -> Single.fromCallable(() ->
showDeletionNotification(context, media, result)));
@ -75,30 +75,30 @@ public class DeleteHelper {
private boolean delete(Context context, Media media, String reason) {
String editToken;
String authCookie;
String summary = context.getResources().getString(R.string.delete_helper_delete_summary_1)
+ media.getFilename() + context.getResources().getString(R.string.delete_helper_delete_summary_2);
String summary = context.getString(R.string.delete_helper_delete_summary_1)
+ media.getFilename() + context.getString(R.string.delete_helper_delete_summary_2);
authCookie = sessionManager.getAuthCookie();
mwApi.setAuthCookie(authCookie);
Calendar calendar = Calendar.getInstance();
String fileDeleteString = context.getResources().getString(R.string.delete_helper_delete_file_delete_string_1) + reason +
context.getResources().getString(R.string.delete_helper_delete_file_delete_string_2) + media.getFilename() +
context.getResources().getString(R.string.delete_helper_delete_file_delete_string_3) + calendar.get(Calendar.DAY_OF_MONTH) +
context.getResources().getString(R.string.delete_helper_delete_file_delete_string_4) + calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) +
context.getResources().getString(R.string.delete_helper_delete_file_delete_string_5) + calendar.get(Calendar.YEAR) +
String fileDeleteString = context.getString(R.string.delete_helper_delete_file_delete_string_1) + reason +
context.getString(R.string.delete_helper_delete_file_delete_string_2) + media.getFilename() +
context.getString(R.string.delete_helper_delete_file_delete_string_3) + calendar.get(Calendar.DAY_OF_MONTH) +
context.getString(R.string.delete_helper_delete_file_delete_string_4) + calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) +
context.getString(R.string.delete_helper_delete_file_delete_string_5) + calendar.get(Calendar.YEAR) +
"}}";
String subpageString = "=== [[:" + media.getFilename() + "]] ===\n" +
reason +
" ~~~~";
String logPageString = "\n" + context.getResources().getString(R.string.delete_helper_delete_log_page_string) + media.getFilename() +
String logPageString = "\n" + context.getString(R.string.delete_helper_delete_log_page_string) + media.getFilename() +
"}}\n";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd", Locale.getDefault());
String date = sdf.format(calendar.getTime());
String userPageString = "\n" + context.getResources().getString(R.string.delete_helper_delete_user_page_string) + media.getFilename() +
String userPageString = "\n" + context.getString(R.string.delete_helper_delete_user_page_string) + media.getFilename() +
"}} ~~~~";
try {
@ -111,11 +111,11 @@ public class DeleteHelper {
mwApi.prependEdit(editToken, fileDeleteString + "\n",
media.getFilename(), summary);
mwApi.edit(editToken, subpageString + "\n",
context.getResources().getString(R.string.delete_helper_delete_try_commons) + media.getFilename(), summary);
context.getString(R.string.delete_helper_delete_try_commons) + media.getFilename(), summary);
mwApi.appendEdit(editToken, logPageString + "\n",
context.getResources().getString(R.string.delete_helper_delete_try_commons) + date, summary);
context.getString(R.string.delete_helper_delete_try_commons) + date, summary);
mwApi.appendEdit(editToken, userPageString + "\n",
context.getResources().getString(R.string.delete_helper_delete_try_talk) + media.getCreator(), summary);
context.getString(R.string.delete_helper_delete_try_talk) + media.getCreator(), summary);
} catch (Exception e) {
Timber.e(e);
return false;
@ -125,18 +125,18 @@ public class DeleteHelper {
private boolean showDeletionNotification(Context context, Media media, boolean result) {
String message;
String title = context.getResources().getString(R.string.delete_helper_show_deletion_notification_title);
String title = context.getString(R.string.delete_helper_show_deletion_notification_title);
if (result) {
title += context.getResources().getString(R.string.delete_helper_show_deletion_notification_title_if);
message = context.getResources().getString(R.string.delete_helper_show_deletion_notification_message_if_1)
+ media.getDisplayTitle() + context.getResources().getString(R.string.delete_helper_show_deletion_notification_message_if_2);
title += context.getString(R.string.delete_helper_show_deletion_notification_title_if);
message = context.getString(R.string.delete_helper_show_deletion_notification_message_if_1)
+ media.getDisplayTitle() + context.getString(R.string.delete_helper_show_deletion_notification_message_if_2);
} else {
title += context.getResources().getString(R.string.delete_helper_show_deletion_notification_title_else);
message = context.getResources().getString(R.string.delete_helper_show_deletion_notification_message_else);
title += context.getString(R.string.delete_helper_show_deletion_notification_title_else);
message = context.getString(R.string.delete_helper_show_deletion_notification_message_else);
}
String urlForDelete = BuildConfig.COMMONS_URL + context.getResources().getString(R.string.delete_helper_show_deletion_notification_url_for_delete) + media.getFilename();
String urlForDelete = BuildConfig.COMMONS_URL + context.getString(R.string.delete_helper_show_deletion_notification_url_for_delete) + media.getFilename();
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlForDelete));
notificationHelper.showNotification(context, title, message, NOTIFICATION_DELETE, browserIntent);
return result;
@ -165,15 +165,15 @@ public class DeleteHelper {
if (problem == ReviewController.DeleteReason.SPAM) {
reasonList[0] = context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_reason_spam_selfie);
reasonList[1] = context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_reason_spam_blurry);
reasonList[2] = context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_reason_spam_nonsense);
reasonList[3] = context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_reason_spam_other);
reasonList[0] = context.getString(R.string.delete_helper_ask_reason_and_execute_reason_spam_selfie);
reasonList[1] = context.getString(R.string.delete_helper_ask_reason_and_execute_reason_spam_blurry);
reasonList[2] = context.getString(R.string.delete_helper_ask_reason_and_execute_reason_spam_nonsense);
reasonList[3] = context.getString(R.string.delete_helper_ask_reason_and_execute_reason_spam_other);
} else if (problem == ReviewController.DeleteReason.COPYRIGHT_VIOLATION) {
reasonList[0] = context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_reason_copyright_press_photo);
reasonList[1] = context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_reason_copyright_internet_photo);
reasonList[2] = context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_reason_copyright_logo);
reasonList[3] = context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_reason_copyright_other);
reasonList[0] = context.getString(R.string.delete_helper_ask_reason_and_execute_reason_copyright_press_photo);
reasonList[1] = context.getString(R.string.delete_helper_ask_reason_and_execute_reason_copyright_internet_photo);
reasonList[2] = context.getString(R.string.delete_helper_ask_reason_and_execute_reason_copyright_logo);
reasonList[3] = context.getString(R.string.delete_helper_ask_reason_and_execute_reason_copyright_other);
}
alert.setMultiChoiceItems(reasonList, checkedItems, (dialogInterface, position, isChecked) -> {
@ -184,9 +184,9 @@ public class DeleteHelper {
}
});
alert.setPositiveButton(context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_alert_set_positive_button), (dialogInterface, i) -> {
alert.setPositiveButton(context.getString(R.string.delete_helper_ask_reason_and_execute_alert_set_positive_button), (dialogInterface, i) -> {
String reason = context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_alert_set_positive_button_reason);
String reason = context.getString(R.string.delete_helper_ask_reason_and_execute_alert_set_positive_button_reason);
for (int j = 0; j < mUserReason.size(); j++) {
reason = reason + reasonList[mUserReason.get(j)];
if (j != mUserReason.size() - 1) {
@ -206,7 +206,7 @@ public class DeleteHelper {
});
});
alert.setNegativeButton(context.getResources().getString(R.string.delete_helper_ask_reason_and_execute_alert_set_negative_button), (dialog, which) -> reviewCallback.onFailure());
alert.setNegativeButton(context.getString(R.string.delete_helper_ask_reason_and_execute_alert_set_negative_button), (dialog, which) -> reviewCallback.onFailure());
AlertDialog d = alert.create();
d.show();
}