Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4255 - Media details activity shows depictions in random languages, rather than in the user's locale #4275

Merged
merged 3 commits into from Mar 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -615,15 +615,27 @@ public void someResultsFound() {
*/
private void buildDepictionList(List<IdAndCaptions> idAndCaptions) {
depictionContainer.removeAllViews();
String locale = Locale.getDefault().getLanguage();
for (IdAndCaptions idAndCaption : idAndCaptions) {
depictionContainer.addView(buildDepictLabel(
idAndCaption.getCaptions().values().iterator().next(),
getDepictionCaption(idAndCaption, locale),
idAndCaption.getId(),
depictionContainer
));
}
}

private String getDepictionCaption(IdAndCaptions idAndCaption, String locale) {
//Check if the Depiction Caption is available in user's locale if not then check for english, else show any available.
if(idAndCaption.getCaptions().get(locale) != null) {
return idAndCaption.getCaptions().get(locale);
}
if(idAndCaption.getCaptions().get("en") != null) {
return idAndCaption.getCaptions().get("en");
}
return idAndCaption.getCaptions().values().iterator().next();
}

@OnClick(R.id.mediaDetailLicense)
public void onMediaDetailLicenceClicked(){
String url = media.getLicenseUrl();
Expand Down