mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Deletion Language is in english (#4841)
* Deletion Language is in english * Added Tests * Added Tests * Added Tests
This commit is contained in:
parent
0f515823e9
commit
d81587b85a
5 changed files with 144 additions and 18 deletions
|
|
@ -4,6 +4,7 @@ import static fr.free.nrw.commons.notification.NotificationHelper.NOTIFICATION_D
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import static fr.free.nrw.commons.utils.LangCodeUtils.getLocalizedResources;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
|
@ -78,7 +79,7 @@ public class DeleteHelper {
|
|||
String fileDeleteString = "{{delete|reason=" + reason +
|
||||
"|subpage=" + media.getFilename() +
|
||||
"|day=" + calendar.get(Calendar.DAY_OF_MONTH) +
|
||||
"|month=" + calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault()) +
|
||||
"|month=" + calendar.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.ENGLISH) +
|
||||
"|year=" + calendar.get(Calendar.YEAR) +
|
||||
"}}";
|
||||
|
||||
|
|
@ -156,16 +157,23 @@ public class DeleteHelper {
|
|||
ArrayList<Integer> mUserReason = new ArrayList<>();
|
||||
|
||||
String[] reasonList = {"Reason 1", "Reason 2", "Reason 3"};
|
||||
|
||||
// Messages posted on-wiki should not be in the app user's locale, but rather in Commons' lingua franca English.
|
||||
String[] reasonListEnglish = {"Eng1", "Eng2", "Eng3"};
|
||||
|
||||
if (problem == ReviewController.DeleteReason.SPAM) {
|
||||
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);
|
||||
reasonListEnglish[0] = getLocalizedResources(context, Locale.ENGLISH).getString(R.string.delete_helper_ask_spam_selfie);
|
||||
reasonListEnglish[1] = getLocalizedResources(context, Locale.ENGLISH).getString(R.string.delete_helper_ask_spam_blurry);
|
||||
reasonListEnglish[2] = getLocalizedResources(context, Locale.ENGLISH).getString(R.string.delete_helper_ask_spam_nonsense);
|
||||
} else if (problem == ReviewController.DeleteReason.COPYRIGHT_VIOLATION) {
|
||||
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);
|
||||
reasonListEnglish[0] = getLocalizedResources(context, Locale.ENGLISH).getString(R.string.delete_helper_ask_reason_copyright_press_photo);
|
||||
reasonListEnglish[1] = getLocalizedResources(context, Locale.ENGLISH).getString(R.string.delete_helper_ask_reason_copyright_internet_photo);
|
||||
reasonListEnglish[2] = getLocalizedResources(context, Locale.ENGLISH).getString(R.string.delete_helper_ask_reason_copyright_logo);
|
||||
}
|
||||
|
||||
alert.setMultiChoiceItems(reasonList, checkedItems, (dialogInterface, position, isChecked) -> {
|
||||
|
|
@ -178,9 +186,10 @@ public class DeleteHelper {
|
|||
|
||||
alert.setPositiveButton(context.getString(R.string.ok), (dialogInterface, i) -> {
|
||||
|
||||
String reason = context.getString(R.string.delete_helper_ask_alert_set_positive_button_reason) + " ";
|
||||
String reason = getLocalizedResources(context, Locale.ENGLISH).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)];
|
||||
reason = reason + reasonListEnglish[mUserReason.get(j)];
|
||||
if (j != mUserReason.size() - 1) {
|
||||
reason = reason + ", ";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ import static fr.free.nrw.commons.description.EditDescriptionConstants.LIST_OF_D
|
|||
import static fr.free.nrw.commons.description.EditDescriptionConstants.UPDATED_WIKITEXT;
|
||||
import static fr.free.nrw.commons.description.EditDescriptionConstants.WIKITEXT;
|
||||
import static fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_LOCATION;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import static fr.free.nrw.commons.utils.LangCodeUtils.getLocalizedResources;
|
||||
import android.annotation.SuppressLint;
|
||||
import java.lang.reflect.Field;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
|
@ -264,6 +266,7 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
|||
//Had to make this class variable, to implement various onClicks, which access the media, also I fell why make separate variables when one can serve the purpose
|
||||
private Media media;
|
||||
private ArrayList<String> reasonList;
|
||||
private ArrayList<String> reasonListEnglishMappings;
|
||||
|
||||
/**
|
||||
* Height stores the height of the frame layout as soon as it is initialised and updates itself on
|
||||
|
|
@ -324,6 +327,14 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
|||
reasonList.add(getString(R.string.deletion_reason_no_longer_want_public));
|
||||
reasonList.add(getString(R.string.deletion_reason_bad_for_my_privacy));
|
||||
|
||||
// Add corresponding mappings in english locale so that we can upload it in deletion request
|
||||
reasonListEnglishMappings = new ArrayList<>();
|
||||
reasonListEnglishMappings.add(getLocalizedResources(getContext(), Locale.ENGLISH).getString(R.string.deletion_reason_uploaded_by_mistake));
|
||||
reasonListEnglishMappings.add(getLocalizedResources(getContext(), Locale.ENGLISH).getString(R.string.deletion_reason_publicly_visible));
|
||||
reasonListEnglishMappings.add(getLocalizedResources(getContext(), Locale.ENGLISH).getString(R.string.deletion_reason_not_interesting));
|
||||
reasonListEnglishMappings.add(getLocalizedResources(getContext(), Locale.ENGLISH).getString(R.string.deletion_reason_no_longer_want_public));
|
||||
reasonListEnglishMappings.add(getLocalizedResources(getContext(), Locale.ENGLISH).getString(R.string.deletion_reason_bad_for_my_privacy));
|
||||
|
||||
final View view = inflater.inflate(R.layout.fragment_media_detail, container, false);
|
||||
|
||||
ButterKnife.bind(this,view);
|
||||
|
|
@ -1201,9 +1212,10 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
|||
private void onDeleteClicked(Spinner spinner) {
|
||||
applicationKvStore.putBoolean(String.format(NOMINATING_FOR_DELETION_MEDIA, media.getImageUrl()), true);
|
||||
enableProgressBar();
|
||||
String reason = spinner.getSelectedItem().toString();
|
||||
String reason = reasonListEnglishMappings.get(spinner.getSelectedItemPosition());
|
||||
String finalReason = reason;
|
||||
Single<Boolean> resultSingle = reasonBuilder.getReason(media, reason)
|
||||
.flatMap(reasonString -> deleteHelper.makeDeletion(getContext(), media, reason));
|
||||
.flatMap(reasonString -> deleteHelper.makeDeletion(getContext(), media, finalReason));
|
||||
resultSingle
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Utilities class for miscellaneous strings
|
||||
|
|
@ -20,4 +24,16 @@ public class LangCodeUtils {
|
|||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns configuration for locale of
|
||||
* our choice regardless of user's device settings
|
||||
*/
|
||||
public static Resources getLocalizedResources(Context context, Locale desiredLocale) {
|
||||
Configuration conf = context.getResources().getConfiguration();
|
||||
conf = new Configuration(conf);
|
||||
conf.setLocale(desiredLocale);
|
||||
Context localizedContext = context.createConfigurationContext(conf);
|
||||
return localizedContext.getResources();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue