mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-02 15:01:01 +01:00
Merge pull request #5502 from Stypox/fix-minimize
Fix minimize on app switch always opens popup
This commit is contained in:
commit
0d522aae6c
@ -855,8 +855,7 @@ public final class Player implements
|
||||
|
||||
private void initVideoPlayer() {
|
||||
// restore last resize mode
|
||||
setResizeMode(prefs.getInt(context.getString(R.string.last_resize_mode),
|
||||
AspectRatioFrameLayout.RESIZE_MODE_FIT));
|
||||
setResizeMode(PlayerHelper.retrieveResizeModeFromPrefs(this));
|
||||
binding.getRoot().setLayoutParams(new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
@ -2012,7 +2011,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 +3822,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,44 +251,27 @@ 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(
|
||||
context.getString(R.string.autoplay_key),
|
||||
context.getString(R.string.autoplay_wifi_key));
|
||||
context.getString(R.string.autoplay_key), "");
|
||||
if (type.equals(context.getString(R.string.autoplay_always_key))) {
|
||||
return AUTOPLAY_TYPE_ALWAYS;
|
||||
} else if (type.equals(context.getString(R.string.autoplay_never_key))) {
|
||||
return AUTOPLAY_TYPE_NEVER;
|
||||
} else {
|
||||
return AUTOPLAY_TYPE_WIFI;
|
||||
return AUTOPLAY_TYPE_WIFI; // default
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,7 +426,7 @@ public final class PlayerHelper {
|
||||
private static SinglePlayQueue getAutoQueuedSinglePlayQueue(
|
||||
final StreamInfoItem streamInfoItem) {
|
||||
final SinglePlayQueue singlePlayQueue = new SinglePlayQueue(streamInfoItem);
|
||||
singlePlayQueue.getItem().setAutoQueued(true);
|
||||
Objects.requireNonNull(singlePlayQueue.getItem()).setAutoQueued(true);
|
||||
return singlePlayQueue;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user