From 1f634770f1aa3fcbd4de7a96f77c1aa84886aa66 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..5ec01c120 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.ORIGINAL, AudioTrackType.DUBBED, AudioTrackType.SECONDARY, + 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 bc113e8f8..acb50d3ef 100644 --- a/app/src/main/java/org/schabi/newpipe/util/Localization.java +++ b/app/src/main/java/org/schabi/newpipe/util/Localization.java @@ -342,25 +342,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