From dc3f55674f09b09295095dd46c14e1c742f846f6 Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:27:08 +0100 Subject: [PATCH] Add support for secondary audio track type --- .../org/schabi/newpipe/util/ListHelper.java | 6 +++-- .../org/schabi/newpipe/util/Localization.java | 23 ++++++++----------- app/src/main/res/values/strings.xml | 1 + 3 files changed, 14 insertions(+), 16 deletions(-) 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 f1904565d..282a88b1e 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ListHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ListHelper.java @@ -48,10 +48,12 @@ public final class ListHelper { private static final Set HIGH_RESOLUTION_LIST = Set.of("1440p", "2160p"); // Audio track types in order of priority. 0=lowest, n=highest private static final List AUDIO_TRACK_TYPE_RANKING = - List.of(AudioTrackType.DESCRIPTIVE, AudioTrackType.DUBBED, AudioTrackType.ORIGINAL); + List.of(AudioTrackType.DESCRIPTIVE, AudioTrackType.SECONDARY, AudioTrackType.DUBBED, + AudioTrackType.ORIGINAL); // Audio track types in order of priority when descriptive audio is preferred. private static final List AUDIO_TRACK_TYPE_RANKING_DESCRIPTIVE = - List.of(AudioTrackType.ORIGINAL, AudioTrackType.DUBBED, AudioTrackType.DESCRIPTIVE); + List.of(AudioTrackType.SECONDARY, AudioTrackType.DUBBED, AudioTrackType.ORIGINAL, + AudioTrackType.DESCRIPTIVE); /** * List of supported YouTube Itag ids. diff --git a/app/src/main/java/org/schabi/newpipe/util/Localization.java b/app/src/main/java/org/schabi/newpipe/util/Localization.java index 17abaeb96..8f8ba596f 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -327,25 +327,20 @@ public final class Localization { if (track.getAudioTrackType() != null) { final String trackType = audioTrackType(context, track.getAudioTrackType()); - if (trackType != null) { - return context.getString(R.string.audio_track_name, name, trackType); - } + return context.getString(R.string.audio_track_name, name, trackType); } return name; } - @Nullable + @NonNull private static String audioTrackType(@NonNull final Context context, - final AudioTrackType trackType) { - switch (trackType) { - case ORIGINAL: - return context.getString(R.string.audio_track_type_original); - case DUBBED: - return context.getString(R.string.audio_track_type_dubbed); - case DESCRIPTIVE: - return context.getString(R.string.audio_track_type_descriptive); - } - return null; + @NonNull final AudioTrackType trackType) { + return switch (trackType) { + case ORIGINAL -> context.getString(R.string.audio_track_type_original); + case DUBBED -> context.getString(R.string.audio_track_type_dubbed); + case DESCRIPTIVE -> context.getString(R.string.audio_track_type_descriptive); + case SECONDARY -> context.getString(R.string.audio_track_type_secondary); + }; } /*////////////////////////////////////////////////////////////////////////// diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 56140441c..766491d53 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -816,6 +816,7 @@ original dubbed descriptive + secondary Videos Tracks Shorts