diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index 0dea47e56..8daa544ae 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -208,10 +208,17 @@ public final class MainVideoPlayer extends AppCompatActivity protected void onStop() { if (DEBUG) Log.d(TAG, "onStop() called"); super.onStop(); - playerImpl.destroy(); - PlayerHelper.setScreenBrightness(getApplicationContext(), getWindow().getAttributes().screenBrightness); + + isInMultiWindow = false; + + if (playerImpl == null) return; + if (PlayerHelper.isMinimizeOnExitEnabled(this)) { + playerImpl.onFullScreenButtonClicked(); + } else { + playerImpl.destroy(); + } } /*////////////////////////////////////////////////////////////////////////// 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 dbe0e9f46..252a3f708 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 @@ -173,6 +173,10 @@ public class PlayerHelper { return isAutoQueueEnabled(context, false); } + public static boolean isMinimizeOnExitEnabled(@NonNull final Context context) { + return isMinimizeOnExitEnabled(context, false); + } + @NonNull public static SeekParameters getSeekParameters(@NonNull final Context context) { return isUsingInexactSeek(context, false) ? @@ -249,7 +253,6 @@ public class PlayerHelper { * System font scaling: * Very small - 0.25f, Small - 0.5f, Normal - 1.0f, Large - 1.5f, Very Large - 2.0f * */ - @NonNull public static float getCaptionScale(@NonNull final Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return 1f; @@ -322,4 +325,8 @@ public class PlayerHelper { return sp.getFloat(context.getString(R.string.screen_brightness_key), screenBrightness); } } + + private static boolean isMinimizeOnExitEnabled(@NonNull final Context context, final boolean b) { + return getPreferences(context).getBoolean(context.getString(R.string.minimize_on_exit_key), b); + } } diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index fc7cfd1b4..e21697a62 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -24,6 +24,7 @@ auto_queue_key screen_brightness_key screen_brightness_timestamp_key + minimize_on_exit_key default_resolution 360p diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5ee80536f..747b80dcc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -74,6 +74,8 @@ Remember last size and position of popup Use fast inexact seek Inexact seek allows the player to seek to positions faster with reduced precision + Minimize on exit + Experimental. Switch to play on popup player when exiting main video player Load thumbnails Disable to stop all thumbnails from loading and save on data and memory usage. Changing this will clear both in-memory and on-disk image cache. Image cache wiped diff --git a/app/src/main/res/xml/video_audio_settings.xml b/app/src/main/res/xml/video_audio_settings.xml index 6ec0da215..440bce0f2 100644 --- a/app/src/main/res/xml/video_audio_settings.xml +++ b/app/src/main/res/xml/video_audio_settings.xml @@ -113,5 +113,11 @@ android:key="@string/use_inexact_seek_key" android:summary="@string/use_inexact_seek_summary" android:title="@string/use_inexact_seek_title"/> + +