Skip to content

Commit 733f6aa

Browse files
committed
Fix add to playlist
1 parent 1daece3 commit 733f6aa

1 file changed

Lines changed: 25 additions & 27 deletions

File tree

app/src/main/java/org/schabi/newpipe/RouterActivity.java

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,10 @@ protected void onSuccess() {
264264
getString(R.string.preferred_open_action_default));
265265

266266
final String showInfoKey = getString(R.string.show_info_key);
267-
final String videoPlayerKey = getString(R.string.video_player_key);
268-
final String backgroundPlayerKey = getString(R.string.background_player_key);
269-
final String popupPlayerKey = getString(R.string.popup_player_key);
270-
final String downloadKey = getString(R.string.download_key);
271-
final String alwaysAskKey = getString(R.string.always_ask_open_action_key);
272267

273-
if (selectedChoiceKey.equals(alwaysAskKey)) {
274-
final List<AdapterChoiceItem> choices
275-
= getChoicesForService(currentService, currentLinkType);
268+
if (selectedChoiceKey.equals(getString(R.string.always_ask_open_action_key))) {
269+
final List<AdapterChoiceItem> choices =
270+
getChoicesForService(currentService, currentLinkType);
276271

277272
switch (choices.size()) {
278273
case 1:
@@ -285,36 +280,39 @@ protected void onSuccess() {
285280
showDialog(choices);
286281
break;
287282
}
288-
} else if (selectedChoiceKey.equals(showInfoKey)) {
289-
handleChoice(showInfoKey);
290-
} else if (selectedChoiceKey.equals(downloadKey)) {
291-
handleChoice(downloadKey);
283+
} else if (selectedChoiceKey.equals(showInfoKey)
284+
|| selectedChoiceKey.equals(getString(R.string.download_key))
285+
|| selectedChoiceKey.equals(getString(R.string.add_to_playlist_key))
286+
) {
287+
handleChoice(selectedChoiceKey);
292288
} else {
293289
final boolean isExtVideoEnabled = preferences.getBoolean(
294290
getString(R.string.use_external_video_player_key), false);
295291
final boolean isExtAudioEnabled = preferences.getBoolean(
296292
getString(R.string.use_external_audio_player_key), false);
297-
final boolean isVideoPlayerSelected = selectedChoiceKey.equals(videoPlayerKey)
298-
|| selectedChoiceKey.equals(popupPlayerKey);
299-
final boolean isAudioPlayerSelected = selectedChoiceKey.equals(backgroundPlayerKey);
300-
301-
if (currentLinkType != LinkType.STREAM) {
302-
if (isExtAudioEnabled && isAudioPlayerSelected
303-
|| isExtVideoEnabled && isVideoPlayerSelected) {
304-
Toast.makeText(this, R.string.external_player_unsupported_link_type,
305-
Toast.LENGTH_LONG).show();
306-
handleChoice(showInfoKey);
307-
return;
308-
}
293+
final boolean isVideoPlayerSelected =
294+
selectedChoiceKey.equals(getString(R.string.video_player_key))
295+
|| selectedChoiceKey.equals(getString(R.string.popup_player_key));
296+
final boolean isAudioPlayerSelected =
297+
selectedChoiceKey.equals(getString(R.string.background_player_key));
298+
299+
if (currentLinkType != LinkType.STREAM
300+
&& (isExtAudioEnabled && isAudioPlayerSelected
301+
|| isExtVideoEnabled && isVideoPlayerSelected)
302+
) {
303+
Toast.makeText(this, R.string.external_player_unsupported_link_type,
304+
Toast.LENGTH_LONG).show();
305+
handleChoice(showInfoKey);
306+
return;
309307
}
310308

311-
final List<StreamingService.ServiceInfo.MediaCapability> capabilities
312-
= currentService.getServiceInfo().getMediaCapabilities();
309+
final List<StreamingService.ServiceInfo.MediaCapability> capabilities =
310+
currentService.getServiceInfo().getMediaCapabilities();
313311

314312
boolean serviceSupportsChoice = false;
315313
if (isVideoPlayerSelected) {
316314
serviceSupportsChoice = capabilities.contains(VIDEO);
317-
} else if (selectedChoiceKey.equals(backgroundPlayerKey)) {
315+
} else if (isAudioPlayerSelected) {
318316
serviceSupportsChoice = capabilities.contains(AUDIO);
319317
}
320318

0 commit comments

Comments
 (0)