From 733f6aae85669ee533025f51e36e37fd2cc6b842 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sun, 1 May 2022 22:46:15 +0200 Subject: [PATCH] Fix add to playlist --- .../org/schabi/newpipe/RouterActivity.java | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 8f92f104d..ac503ac29 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -264,15 +264,10 @@ public class RouterActivity extends AppCompatActivity { getString(R.string.preferred_open_action_default)); final String showInfoKey = getString(R.string.show_info_key); - final String videoPlayerKey = getString(R.string.video_player_key); - final String backgroundPlayerKey = getString(R.string.background_player_key); - final String popupPlayerKey = getString(R.string.popup_player_key); - final String downloadKey = getString(R.string.download_key); - final String alwaysAskKey = getString(R.string.always_ask_open_action_key); - if (selectedChoiceKey.equals(alwaysAskKey)) { - final List choices - = getChoicesForService(currentService, currentLinkType); + if (selectedChoiceKey.equals(getString(R.string.always_ask_open_action_key))) { + final List choices = + getChoicesForService(currentService, currentLinkType); switch (choices.size()) { case 1: @@ -285,36 +280,39 @@ public class RouterActivity extends AppCompatActivity { showDialog(choices); break; } - } else if (selectedChoiceKey.equals(showInfoKey)) { - handleChoice(showInfoKey); - } else if (selectedChoiceKey.equals(downloadKey)) { - handleChoice(downloadKey); + } else if (selectedChoiceKey.equals(showInfoKey) + || selectedChoiceKey.equals(getString(R.string.download_key)) + || selectedChoiceKey.equals(getString(R.string.add_to_playlist_key)) + ) { + handleChoice(selectedChoiceKey); } else { final boolean isExtVideoEnabled = preferences.getBoolean( getString(R.string.use_external_video_player_key), false); final boolean isExtAudioEnabled = preferences.getBoolean( getString(R.string.use_external_audio_player_key), false); - final boolean isVideoPlayerSelected = selectedChoiceKey.equals(videoPlayerKey) - || selectedChoiceKey.equals(popupPlayerKey); - final boolean isAudioPlayerSelected = selectedChoiceKey.equals(backgroundPlayerKey); + final boolean isVideoPlayerSelected = + selectedChoiceKey.equals(getString(R.string.video_player_key)) + || selectedChoiceKey.equals(getString(R.string.popup_player_key)); + final boolean isAudioPlayerSelected = + selectedChoiceKey.equals(getString(R.string.background_player_key)); - if (currentLinkType != LinkType.STREAM) { - if (isExtAudioEnabled && isAudioPlayerSelected - || isExtVideoEnabled && isVideoPlayerSelected) { - Toast.makeText(this, R.string.external_player_unsupported_link_type, - Toast.LENGTH_LONG).show(); - handleChoice(showInfoKey); - return; - } + if (currentLinkType != LinkType.STREAM + && (isExtAudioEnabled && isAudioPlayerSelected + || isExtVideoEnabled && isVideoPlayerSelected) + ) { + Toast.makeText(this, R.string.external_player_unsupported_link_type, + Toast.LENGTH_LONG).show(); + handleChoice(showInfoKey); + return; } - final List capabilities - = currentService.getServiceInfo().getMediaCapabilities(); + final List capabilities = + currentService.getServiceInfo().getMediaCapabilities(); boolean serviceSupportsChoice = false; if (isVideoPlayerSelected) { serviceSupportsChoice = capabilities.contains(VIDEO); - } else if (selectedChoiceKey.equals(backgroundPlayerKey)) { + } else if (isAudioPlayerSelected) { serviceSupportsChoice = capabilities.contains(AUDIO); }