Skip to content

Commit

Permalink
preference download subtitles: do get at least locale language in the…
Browse files Browse the repository at this point in the history
… list when empty
  • Loading branch information
courville committed May 24, 2024
1 parent 8f69c8b commit dcca822
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -684,6 +685,14 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
CharSequence[] listEntriesValues = OpensubtitlesLanguageListEntryValues.toArray(new CharSequence[0]);
mSubtitlesDownloadLanguagePreferences.setEntries(listEntries);
mSubtitlesDownloadLanguagePreferences.setEntryValues(listEntriesValues);
mSubtitlesDownloadLanguagePreferences.setDefaultValue(new HashSet<>(List.of(Locale.getDefault().getLanguage())));
Set<String> currentValues = mSubtitlesDownloadLanguagePreferences.getValues();
if (currentValues.isEmpty()) { // enforce at least locale on subtitles download
Set<String> newValues = new HashSet<>(currentValues);
newValues.add(Locale.getDefault().getLanguage());
mSubtitlesDownloadLanguagePreferences.setValues(newValues);
log.debug("onCreatePreferences: getValues " + mSubtitlesDownloadLanguagePreferences.getValues());
}
mSubtitlesFavLangPreferences.setEntries(listEntries);
mSubtitlesFavLangPreferences.setEntryValues(listEntriesValues);
if (OpensubtitlesSystemLanguageIndex>=0) mSubtitlesFavLangPreferences.setValueIndex(OpensubtitlesSystemLanguageIndex);
Expand Down

0 comments on commit dcca822

Please sign in to comment.