From 49b16493488d87e79fc7296bcc5af1fee0bbdfb7 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:00:30 +0100 Subject: [PATCH 1/2] Revert "Merge pull request #7568 from vhouriet/vhouriet_feature_already-playing-in-backgroud" This reverts commit ee19ea66b3f4f182f78634c2d791dab6cab77257, reversing changes made to 6b490ee547879033ec3e7d9ca3433f35babbfa7b. --- .../org/schabi/newpipe/util/NavigationHelper.java | 12 ++++-------- app/src/main/res/values/strings.xml | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index 2a3f3c2dd..c01e051b0 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -168,14 +168,10 @@ public final class NavigationHelper { public static void playOnBackgroundPlayer(final Context context, final PlayQueue queue, final boolean resumePlayback) { - Toast.makeText( - context, - PlayerHolder.getInstance().getType() == PlayerType.AUDIO - ? R.string.background_player_already_playing_toast - : R.string.background_player_playing_toast, - Toast.LENGTH_SHORT) - .show(); - + if (PlayerHolder.getInstance().getType() != MainPlayer.PlayerType.AUDIO) { + Toast.makeText(context, R.string.background_player_playing_toast, Toast.LENGTH_SHORT) + .show(); + } final Intent intent = getPlayerIntent(context, MainPlayer.class, queue, resumePlayback); intent.putExtra(Player.PLAYER_TYPE, MainPlayer.PlayerType.AUDIO.ordinal()); ContextCompat.startForegroundService(context, intent); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba7f18ce8..ffddf94b0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -143,7 +143,6 @@ Updates Notification Playing in background - Already playing in background Playing in popup mode Content Show age restricted content From e127db6fa66d71b69b81458e2663289a9106a11d Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sun, 23 Jan 2022 15:33:59 +0100 Subject: [PATCH 2/2] Simplified toast showing behavior after feedback from the review --- .../org/schabi/newpipe/util/NavigationHelper.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index c01e051b0..22e0a2dd0 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -157,9 +157,8 @@ public final class NavigationHelper { return; } - if (PlayerHolder.getInstance().getType() != PlayerType.POPUP) { - Toast.makeText(context, R.string.popup_playing_toast, Toast.LENGTH_SHORT).show(); - } + Toast.makeText(context, R.string.popup_playing_toast, Toast.LENGTH_SHORT).show(); + final Intent intent = getPlayerIntent(context, MainPlayer.class, queue, resumePlayback); intent.putExtra(Player.PLAYER_TYPE, MainPlayer.PlayerType.POPUP.ordinal()); ContextCompat.startForegroundService(context, intent); @@ -168,10 +167,9 @@ public final class NavigationHelper { public static void playOnBackgroundPlayer(final Context context, final PlayQueue queue, final boolean resumePlayback) { - if (PlayerHolder.getInstance().getType() != MainPlayer.PlayerType.AUDIO) { - Toast.makeText(context, R.string.background_player_playing_toast, Toast.LENGTH_SHORT) - .show(); - } + Toast.makeText(context, R.string.background_player_playing_toast, Toast.LENGTH_SHORT) + .show(); + final Intent intent = getPlayerIntent(context, MainPlayer.class, queue, resumePlayback); intent.putExtra(Player.PLAYER_TYPE, MainPlayer.PlayerType.AUDIO.ordinal()); ContextCompat.startForegroundService(context, intent);