mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Fix for wrong case after language normalization
This commit is contained in:
parent
7f246b2d3d
commit
a2aa0aa9a8
@ -509,11 +509,11 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
|
|
||||||
// Normalize mismatching language strings
|
// Normalize mismatching language strings
|
||||||
final String preferredLanguage = trackSelector.getParameters().preferredTextLanguage;
|
final String preferredLanguage = trackSelector.getParameters().preferredTextLanguage;
|
||||||
|
|
||||||
// Build UI
|
// Build UI
|
||||||
buildCaptionMenu(availableLanguages);
|
buildCaptionMenu(availableLanguages);
|
||||||
if (trackSelector.getParameters().getRendererDisabled(textRenderer) ||
|
if (trackSelector.getParameters().getRendererDisabled(textRenderer) ||
|
||||||
preferredLanguage == null || !availableLanguages.contains(preferredLanguage)) {
|
preferredLanguage == null || (!availableLanguages.contains(preferredLanguage)
|
||||||
|
&& !containsCaseInsensitive(availableLanguages, preferredLanguage))) {
|
||||||
captionTextView.setText(R.string.caption_none);
|
captionTextView.setText(R.string.caption_none);
|
||||||
} else {
|
} else {
|
||||||
captionTextView.setText(preferredLanguage);
|
captionTextView.setText(preferredLanguage);
|
||||||
@ -521,6 +521,15 @@ public abstract class VideoPlayer extends BasePlayer
|
|||||||
captionTextView.setVisibility(availableLanguages.isEmpty() ? View.GONE : View.VISIBLE);
|
captionTextView.setVisibility(availableLanguages.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// workaround to match normalized captions like english to English or deutsch to Deutsch
|
||||||
|
private static boolean containsCaseInsensitive(List<String> list, String toFind) {
|
||||||
|
for(String i : list){
|
||||||
|
if(i.equalsIgnoreCase(toFind))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// General Player
|
// General Player
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
Loading…
Reference in New Issue
Block a user