mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Fixes #4255 - Media details activity shows depictions in random languages, rather than in the user's locale (#4275)
* fixes issue with depiction names in random languages * minor change * using if conditions to check Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
This commit is contained in:
parent
0a857974f0
commit
93cd89a34b
1 changed files with 13 additions and 1 deletions
|
|
@ -615,15 +615,27 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
||||||
*/
|
*/
|
||||||
private void buildDepictionList(List<IdAndCaptions> idAndCaptions) {
|
private void buildDepictionList(List<IdAndCaptions> idAndCaptions) {
|
||||||
depictionContainer.removeAllViews();
|
depictionContainer.removeAllViews();
|
||||||
|
String locale = Locale.getDefault().getLanguage();
|
||||||
for (IdAndCaptions idAndCaption : idAndCaptions) {
|
for (IdAndCaptions idAndCaption : idAndCaptions) {
|
||||||
depictionContainer.addView(buildDepictLabel(
|
depictionContainer.addView(buildDepictLabel(
|
||||||
idAndCaption.getCaptions().values().iterator().next(),
|
getDepictionCaption(idAndCaption, locale),
|
||||||
idAndCaption.getId(),
|
idAndCaption.getId(),
|
||||||
depictionContainer
|
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)
|
@OnClick(R.id.mediaDetailLicense)
|
||||||
public void onMediaDetailLicenceClicked(){
|
public void onMediaDetailLicenceClicked(){
|
||||||
String url = media.getLicenseUrl();
|
String url = media.getLicenseUrl();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue