Merge pull request #5502 from Stypox/fix-minimize

Fix minimize on app switch always opens popup
pull/5466/head
Stypox 2021-01-28 17:59:18 +01:00 zatwierdzone przez GitHub
commit 0d522aae6c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 14 dodań i 28 usunięć

Wyświetl plik

@ -855,8 +855,7 @@ public final class Player implements
private void initVideoPlayer() { private void initVideoPlayer() {
// restore last resize mode // restore last resize mode
setResizeMode(prefs.getInt(context.getString(R.string.last_resize_mode), setResizeMode(PlayerHelper.retrieveResizeModeFromPrefs(this));
AspectRatioFrameLayout.RESIZE_MODE_FIT));
binding.getRoot().setLayoutParams(new FrameLayout.LayoutParams( binding.getRoot().setLayoutParams(new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
} }
@ -2012,7 +2011,8 @@ public final class Player implements
changePopupWindowFlags(IDLE_WINDOW_FLAGS); changePopupWindowFlags(IDLE_WINDOW_FLAGS);
// Remove running notification when user does not want minimization to background or popup // 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); NotificationUtil.getInstance().cancelNotificationAndStopForeground(service);
} else { } else {
NotificationUtil.getInstance().createNotificationIfNeededAndUpdate(this, false); NotificationUtil.getInstance().createNotificationIfNeededAndUpdate(this, false);
@ -3822,11 +3822,14 @@ public final class Player implements
switch (getMinimizeOnExitAction(context)) { switch (getMinimizeOnExitAction(context)) {
case MINIMIZE_ON_EXIT_MODE_BACKGROUND: case MINIMIZE_ON_EXIT_MODE_BACKGROUND:
useVideoSource(false); useVideoSource(false);
break;
case MINIMIZE_ON_EXIT_MODE_POPUP: case MINIMIZE_ON_EXIT_MODE_POPUP:
setRecovery(); setRecovery();
NavigationHelper.playOnPopupPlayer(getParentActivity(), playQueue, true); NavigationHelper.playOnPopupPlayer(getParentActivity(), playQueue, true);
break;
case MINIMIZE_ON_EXIT_MODE_NONE: default: case MINIMIZE_ON_EXIT_MODE_NONE: default:
pause(); pause();
break;
} }
} }
} }

Wyświetl plik

@ -251,44 +251,27 @@ public final class PlayerHelper {
@MinimizeMode @MinimizeMode
public static int getMinimizeOnExitAction(@NonNull final Context context) { 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) final String action = getPreferences(context)
.getString(context.getString(R.string.minimize_on_exit_key), defaultAction); .getString(context.getString(R.string.minimize_on_exit_key), "");
if (action.equals(popupAction)) { if (action.equals(context.getString(R.string.minimize_on_exit_popup_key))) {
return MINIMIZE_ON_EXIT_MODE_POPUP; return MINIMIZE_ON_EXIT_MODE_POPUP;
} else if (action.equals(backgroundAction)) { } else if (action.equals(context.getString(R.string.minimize_on_exit_none_key))) {
return MINIMIZE_ON_EXIT_MODE_BACKGROUND;
} else {
return MINIMIZE_ON_EXIT_MODE_NONE; 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 @AutoplayType
public static int getAutoplayType(@NonNull final Context context) { public static int getAutoplayType(@NonNull final Context context) {
final String type = getPreferences(context).getString( final String type = getPreferences(context).getString(
context.getString(R.string.autoplay_key), context.getString(R.string.autoplay_key), "");
context.getString(R.string.autoplay_wifi_key));
if (type.equals(context.getString(R.string.autoplay_always_key))) { if (type.equals(context.getString(R.string.autoplay_always_key))) {
return AUTOPLAY_TYPE_ALWAYS; return AUTOPLAY_TYPE_ALWAYS;
} else if (type.equals(context.getString(R.string.autoplay_never_key))) { } else if (type.equals(context.getString(R.string.autoplay_never_key))) {
return AUTOPLAY_TYPE_NEVER; return AUTOPLAY_TYPE_NEVER;
} else { } else {
return AUTOPLAY_TYPE_WIFI; return AUTOPLAY_TYPE_WIFI; // default
} }
} }
@ -443,7 +426,7 @@ public final class PlayerHelper {
private static SinglePlayQueue getAutoQueuedSinglePlayQueue( private static SinglePlayQueue getAutoQueuedSinglePlayQueue(
final StreamInfoItem streamInfoItem) { final StreamInfoItem streamInfoItem) {
final SinglePlayQueue singlePlayQueue = new SinglePlayQueue(streamInfoItem); final SinglePlayQueue singlePlayQueue = new SinglePlayQueue(streamInfoItem);
singlePlayQueue.getItem().setAutoQueued(true); Objects.requireNonNull(singlePlayQueue.getItem()).setAutoQueued(true);
return singlePlayQueue; return singlePlayQueue;
} }