From 989bcbf895c1879ca7cfd3e47f65d50bd0ce19d8 Mon Sep 17 00:00:00 2001 From: vhouriet Date: Wed, 22 Dec 2021 12:36:26 +0100 Subject: [PATCH 1/3] Add Already playing in background toast --- .../org/schabi/newpipe/util/NavigationHelper.java | 12 +++++++++--- app/src/main/res/values/strings.xml | 1 + 2 files changed, 10 insertions(+), 3 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..d5be71f15 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -168,10 +168,16 @@ 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(); + final int toastText; + if (PlayerHolder.getInstance().getType() == MainPlayer.PlayerType.AUDIO) { + toastText = R.string.background_player_already_playing_toast; + } else { + toastText = R.string.background_player_playing_toast; } + + Toast.makeText(context, toastText, 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 b4d46a3e2..303e7bb3f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -147,6 +147,7 @@ Updates Notification Playing in background + Already playing in background Playing in popup mode Content Show age restricted content From b67bf16d4f3f0a238472021f58eb467b48560a2b Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Sun, 26 Dec 2021 23:57:54 +0100 Subject: [PATCH 2/3] Minified code --- .../org/schabi/newpipe/util/NavigationHelper.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 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 d5be71f15..bb305aec7 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,12 @@ public final class NavigationHelper { public static void playOnBackgroundPlayer(final Context context, final PlayQueue queue, final boolean resumePlayback) { - final int toastText; - if (PlayerHolder.getInstance().getType() == MainPlayer.PlayerType.AUDIO) { - toastText = R.string.background_player_already_playing_toast; - } else { - toastText = R.string.background_player_playing_toast; - } - - Toast.makeText(context, toastText, Toast.LENGTH_SHORT) + Toast.makeText( + context, + PlayerHolder.getInstance().getType() == PlayerType.AUDIO + ? R.string.background_player_playing_toast + : R.string.background_player_playing_toast, + Toast.LENGTH_SHORT) .show(); final Intent intent = getPlayerIntent(context, MainPlayer.class, queue, resumePlayback); From fc0e709817d8629d106dbfdd7078baf58500e707 Mon Sep 17 00:00:00 2001 From: litetex <40789489+litetex@users.noreply.github.com> Date: Mon, 27 Dec 2021 00:14:04 +0100 Subject: [PATCH 3/3] Fixed usage of wrong string --- app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 bb305aec7..2a3f3c2dd 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -171,7 +171,7 @@ public final class NavigationHelper { Toast.makeText( context, PlayerHolder.getInstance().getType() == PlayerType.AUDIO - ? R.string.background_player_playing_toast + ? R.string.background_player_already_playing_toast : R.string.background_player_playing_toast, Toast.LENGTH_SHORT) .show();