From 4f828fbe005be89a9f34c3a81b239fd90756339e Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 28 Jan 2021 14:33:12 +0100 Subject: [PATCH] Fix always minimizing to popup player --- .../org/schabi/newpipe/player/Player.java | 6 ++++- .../newpipe/player/helper/PlayerHelper.java | 26 ++++--------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 9d239e781..aa82c0a72 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -2012,7 +2012,8 @@ public final class Player implements changePopupWindowFlags(IDLE_WINDOW_FLAGS); // Remove running notification when user does not want minimization to background or popup - if (PlayerHelper.isMinimizeOnExitDisabled(context) && videoPlayerSelected()) { + if (PlayerHelper.getMinimizeOnExitAction(context) == MINIMIZE_ON_EXIT_MODE_NONE + && videoPlayerSelected()) { NotificationUtil.getInstance().cancelNotificationAndStopForeground(service); } else { NotificationUtil.getInstance().createNotificationIfNeededAndUpdate(this, false); @@ -3822,11 +3823,14 @@ public final class Player implements switch (getMinimizeOnExitAction(context)) { case MINIMIZE_ON_EXIT_MODE_BACKGROUND: useVideoSource(false); + break; case MINIMIZE_ON_EXIT_MODE_POPUP: setRecovery(); NavigationHelper.playOnPopupPlayer(getParentActivity(), playQueue, true); + break; case MINIMIZE_ON_EXIT_MODE_NONE: default: pause(); + break; } } } diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java index 54021b616..8169f99e5 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java @@ -251,33 +251,17 @@ public final class PlayerHelper { @MinimizeMode public static int getMinimizeOnExitAction(@NonNull final Context context) { - final String defaultAction = context.getString(R.string.minimize_on_exit_none_key); - final String popupAction = context.getString(R.string.minimize_on_exit_popup_key); - final String backgroundAction = context.getString(R.string.minimize_on_exit_background_key); - final String action = getPreferences(context) - .getString(context.getString(R.string.minimize_on_exit_key), defaultAction); - if (action.equals(popupAction)) { + .getString(context.getString(R.string.minimize_on_exit_key), ""); + if (action.equals(context.getString(R.string.minimize_on_exit_popup_key))) { return MINIMIZE_ON_EXIT_MODE_POPUP; - } else if (action.equals(backgroundAction)) { - return MINIMIZE_ON_EXIT_MODE_BACKGROUND; - } else { + } else if (action.equals(context.getString(R.string.minimize_on_exit_none_key))) { return MINIMIZE_ON_EXIT_MODE_NONE; + } else { + return MINIMIZE_ON_EXIT_MODE_BACKGROUND; // default } } - public static boolean isMinimizeOnExitToPopup(@NonNull final Context context) { - return getMinimizeOnExitAction(context) == MINIMIZE_ON_EXIT_MODE_POPUP; - } - - public static boolean isMinimizeOnExitToBackground(@NonNull final Context context) { - return getMinimizeOnExitAction(context) == MINIMIZE_ON_EXIT_MODE_BACKGROUND; - } - - public static boolean isMinimizeOnExitDisabled(@NonNull final Context context) { - return getMinimizeOnExitAction(context) == MINIMIZE_ON_EXIT_MODE_NONE; - } - @AutoplayType public static int getAutoplayType(@NonNull final Context context) { final String type = getPreferences(context).getString(