App: rename "locales" to "supportedLocales" for clarity

This commit is contained in:
Hans-Christoph Steiner 2021-02-06 00:37:57 +01:00
parent 57cee93647
commit cb1b4330ef

View File

@ -514,43 +514,43 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
if (systemLocaleList == null) { if (systemLocaleList == null) {
systemLocaleList = ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration()); systemLocaleList = ConfigurationCompat.getLocales(Resources.getSystem().getConfiguration());
} }
Set<String> localesToUse = localized.keySet(); Set<String> supportedLocales = localized.keySet();
setIsLocalized(localesToUse); setIsLocalized(supportedLocales);
String value = getLocalizedEntry(localized, localesToUse, "whatsNew"); String value = getLocalizedEntry(localized, supportedLocales, "whatsNew");
if (!TextUtils.isEmpty(value)) { if (!TextUtils.isEmpty(value)) {
whatsNew = value; whatsNew = value;
} }
value = getLocalizedEntry(localized, localesToUse, "video"); value = getLocalizedEntry(localized, supportedLocales, "video");
if (!TextUtils.isEmpty(value)) { if (!TextUtils.isEmpty(value)) {
video = value.trim(); video = value.trim();
} }
value = getLocalizedEntry(localized, localesToUse, "name"); value = getLocalizedEntry(localized, supportedLocales, "name");
if (!TextUtils.isEmpty(value)) { if (!TextUtils.isEmpty(value)) {
name = value.trim(); name = value.trim();
} }
value = getLocalizedEntry(localized, localesToUse, "summary"); value = getLocalizedEntry(localized, supportedLocales, "summary");
if (!TextUtils.isEmpty(value)) { if (!TextUtils.isEmpty(value)) {
summary = value.trim(); summary = value.trim();
} }
value = getLocalizedEntry(localized, localesToUse, "description"); value = getLocalizedEntry(localized, supportedLocales, "description");
if (!TextUtils.isEmpty(value)) { if (!TextUtils.isEmpty(value)) {
description = formatDescription(value); description = formatDescription(value);
} }
value = getLocalizedGraphicsEntry(localized, localesToUse, "icon"); value = getLocalizedGraphicsEntry(localized, supportedLocales, "icon");
if (!TextUtils.isEmpty(value)) { if (!TextUtils.isEmpty(value)) {
iconUrl = value; iconUrl = value;
} }
featureGraphic = getLocalizedGraphicsEntry(localized, localesToUse, "featureGraphic"); featureGraphic = getLocalizedGraphicsEntry(localized, supportedLocales, "featureGraphic");
promoGraphic = getLocalizedGraphicsEntry(localized, localesToUse, "promoGraphic"); promoGraphic = getLocalizedGraphicsEntry(localized, supportedLocales, "promoGraphic");
tvBanner = getLocalizedGraphicsEntry(localized, localesToUse, "tvBanner"); tvBanner = getLocalizedGraphicsEntry(localized, supportedLocales, "tvBanner");
wearScreenshots = getLocalizedListEntry(localized, localesToUse, "wearScreenshots"); wearScreenshots = getLocalizedListEntry(localized, supportedLocales, "wearScreenshots");
phoneScreenshots = getLocalizedListEntry(localized, localesToUse, "phoneScreenshots"); phoneScreenshots = getLocalizedListEntry(localized, supportedLocales, "phoneScreenshots");
sevenInchScreenshots = getLocalizedListEntry(localized, localesToUse, "sevenInchScreenshots"); sevenInchScreenshots = getLocalizedListEntry(localized, supportedLocales, "sevenInchScreenshots");
tenInchScreenshots = getLocalizedListEntry(localized, localesToUse, "tenInchScreenshots"); tenInchScreenshots = getLocalizedListEntry(localized, supportedLocales, "tenInchScreenshots");
tvScreenshots = getLocalizedListEntry(localized, localesToUse, "tvScreenshots"); tvScreenshots = getLocalizedListEntry(localized, supportedLocales, "tvScreenshots");
} }
/** /**
@ -579,8 +579,8 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
* @see LocaleList * @see LocaleList
*/ */
private String getLocalizedEntry(Map<String, Map<String, Object>> localized, private String getLocalizedEntry(Map<String, Map<String, Object>> localized,
Set<String> locales, @NonNull String key) { Set<String> supportedLocales, @NonNull String key) {
Map<String, Object> localizedLocaleMap = getLocalizedLocaleMap(localized, locales, key); Map<String, Object> localizedLocaleMap = getLocalizedLocaleMap(localized, supportedLocales, key);
if (localizedLocaleMap != null && !localizedLocaleMap.isEmpty()) { if (localizedLocaleMap != null && !localizedLocaleMap.isEmpty()) {
for (Object entry : localizedLocaleMap.values()) { for (Object entry : localizedLocaleMap.values()) {
return (String) entry; // NOPMD return (String) entry; // NOPMD
@ -590,8 +590,8 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
} }
private String getLocalizedGraphicsEntry(Map<String, Map<String, Object>> localized, private String getLocalizedGraphicsEntry(Map<String, Map<String, Object>> localized,
Set<String> locales, String key) { Set<String> supportedLocales, @NonNull String key) {
Map<String, Object> localizedLocaleMap = getLocalizedLocaleMap(localized, locales, key); Map<String, Object> localizedLocaleMap = getLocalizedLocaleMap(localized, supportedLocales, key);
if (localizedLocaleMap != null && !localizedLocaleMap.isEmpty()) { if (localizedLocaleMap != null && !localizedLocaleMap.isEmpty()) {
for (String locale : localizedLocaleMap.keySet()) { for (String locale : localizedLocaleMap.keySet()) {
return locale + "/" + localizedLocaleMap.get(locale); // NOPMD return locale + "/" + localizedLocaleMap.get(locale); // NOPMD
@ -601,8 +601,8 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
} }
private String[] getLocalizedListEntry(Map<String, Map<String, Object>> localized, private String[] getLocalizedListEntry(Map<String, Map<String, Object>> localized,
Set<String> locales, String key) { Set<String> supportedLocales, @NonNull String key) {
Map<String, Object> localizedLocaleMap = getLocalizedLocaleMap(localized, locales, key); Map<String, Object> localizedLocaleMap = getLocalizedLocaleMap(localized, supportedLocales, key);
if (localizedLocaleMap != null && !localizedLocaleMap.isEmpty()) { if (localizedLocaleMap != null && !localizedLocaleMap.isEmpty()) {
for (String locale : localizedLocaleMap.keySet()) { for (String locale : localizedLocaleMap.keySet()) {
ArrayList<String> entry = (ArrayList<String>) localizedLocaleMap.get(locale); ArrayList<String> entry = (ArrayList<String>) localizedLocaleMap.get(locale);
@ -625,8 +625,8 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
* in the index JSON. * in the index JSON.
*/ */
private Map<String, Object> getLocalizedLocaleMap(Map<String, Map<String, Object>> localized, private Map<String, Object> getLocalizedLocaleMap(Map<String, Map<String, Object>> localized,
Set<String> locales, String key) { Set<String> supportedLocales, @NonNull String key) {
String[] localesToUse = getLocalesForKey(localized, locales, key); String[] localesToUse = getLocalesForKey(localized, supportedLocales, key);
if (localesToUse.length > 0) { if (localesToUse.length > 0) {
Locale firstMatch = systemLocaleList.getFirstMatch(localesToUse); Locale firstMatch = systemLocaleList.getFirstMatch(localesToUse);
if (firstMatch != null) { if (firstMatch != null) {
@ -653,9 +653,9 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
* Get all locales that have an entry for {@code key}. * Get all locales that have an entry for {@code key}.
*/ */
private String[] getLocalesForKey(Map<String, Map<String, Object>> localized, private String[] getLocalesForKey(Map<String, Map<String, Object>> localized,
Set<String> locales, String key) { Set<String> supportedLocales, @NonNull String key) {
Set<String> localesToUse = new HashSet<>(); Set<String> localesToUse = new HashSet<>();
for (String locale : locales) { for (String locale : supportedLocales) {
Map<String, Object> localeEntry = localized.get(locale); Map<String, Object> localeEntry = localized.get(locale);
if (localeEntry != null && localeEntry.get(key) != null) { if (localeEntry != null && localeEntry.get(key) != null) {
localesToUse.add(locale); localesToUse.add(locale);