From 22671ca16c6d4e2904116d1faebfb6f95b8103ea Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Mon, 1 May 2023 00:04:04 +0200 Subject: [PATCH] fix: audio stream cache key, code fmt --- .../java/org/schabi/newpipe/download/DownloadDialog.java | 4 +--- .../schabi/newpipe/player/resolver/PlaybackResolver.java | 5 +++++ app/src/main/java/org/schabi/newpipe/util/ListHelper.java | 3 ++- .../test/java/org/schabi/newpipe/util/ListHelperTest.java | 6 ++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index e0b1606dc..0a92efb93 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -470,9 +470,7 @@ public class DownloadDialog extends DialogFragment dialogBinding.audioTrackSpinner.setVisibility( isVideoOnly && wrappedAudioTracks.size() > 1 ? View.VISIBLE : View.GONE); dialogBinding.defaultAudioTrackPresentText.setVisibility( - !isVideoOnly && wrappedAudioTracks.size() > 1 ? View.VISIBLE : View.GONE - - ); + !isVideoOnly && wrappedAudioTracks.size() > 1 ? View.VISIBLE : View.GONE); } private void setupSubtitleSpinner() { diff --git a/app/src/main/java/org/schabi/newpipe/player/resolver/PlaybackResolver.java b/app/src/main/java/org/schabi/newpipe/player/resolver/PlaybackResolver.java index c15447418..e204b8372 100644 --- a/app/src/main/java/org/schabi/newpipe/player/resolver/PlaybackResolver.java +++ b/app/src/main/java/org/schabi/newpipe/player/resolver/PlaybackResolver.java @@ -161,6 +161,11 @@ public interface PlaybackResolver extends Resolver { cacheKey.append(audioStream.getAudioTrackId()); } + if (audioStream.getAudioLocale() != null) { + cacheKey.append(" "); + cacheKey.append(audioStream.getAudioLocale().getISO3Language()); + } + return cacheKey.toString(); } diff --git a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java index 9c58ed75e..f45f3786d 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java @@ -797,7 +797,8 @@ public final class ListHelper { * @return Comparator */ static Comparator getAudioTrackComparator( - final Locale preferredLanguage, final boolean preferOriginalAudio, + final Locale preferredLanguage, + final boolean preferOriginalAudio, final boolean preferDescriptiveAudio) { final String langCode = preferredLanguage.getISO3Language(); final List trackTypeRanking = preferDescriptiveAudio diff --git a/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java b/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java index b4a4167cf..c7c36eadc 100644 --- a/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java +++ b/app/src/test/java/org/schabi/newpipe/util/ListHelperTest.java @@ -451,8 +451,10 @@ public class ListHelperTest { } private static AudioStream generateAudioTrack( - @NonNull final String id, @Nullable final String trackId, - @Nullable final Locale locale, @Nullable final AudioTrackType trackType) { + @NonNull final String id, + @Nullable final String trackId, + @Nullable final Locale locale, + @Nullable final AudioTrackType trackType) { return new AudioStream.Builder() .setId(id) .setContent("", true)