From d28e80d68ead847bbdd081099ee3e43f1e00bb72 Mon Sep 17 00:00:00 2001 From: Cd16d <98320806+cd16b@users.noreply.github.com> Date: Mon, 14 Aug 2023 22:47:42 +0200 Subject: [PATCH] feat: picture-in-picture (#277) * add pip * fixed OnResume() OnStop() add picture in picture button add pip settings * fixed sourceRectHint add aspectRatio * fix import * improve hide playerControls * add onNewIntent() * Home button/gesture settings * add summary * add GESTURE_EXCLUSION_AREA_SIDE * remove if else in sourceRectHint fix onStop() behavior * fix behavior when using pip button, now go home * test * fix onStop() * fix: mpv aspect ratio * fix when in PiP mode and starting new playback * refactor: pip implementation Remove option to disable pip button, always show the button when pip is supported Remove the option to completely disable pip Format using ktlint * fix when in pip mode and play a new video * fix recent app behavior * lint * Some adjustments * fix: Aspect ratio is too extreme * fix: Activity recreation * fix merge issues * fix merge issues * ktlintFormat * Add Picture in Picture * fix * fix sourceRectHint, updateZoomMode before entering pip * lint * fix: disable pip when player is locked * lint * lint * fix: sourceRectHint * fix: replace media items in mpv * fix: don't show skip intro button in pip * chore: remove `android:resizeableActivity` from manifest since the default is already `true` * refactor: remove option to force 16:9 aspect ratio * refactor: update strings --------- Co-authored-by: Jarne Demeulemeester --- app/phone/src/main/AndroidManifest.xml | 3 + .../dev/jdtech/jellyfin/BasePlayerActivity.kt | 19 +++- .../dev/jdtech/jellyfin/PlayerActivity.kt | 104 +++++++++++++++++- .../src/main/res/layout/exo_main_controls.xml | 15 +++ .../res/drawable/ic_picture_in_picture.xml | 14 +++ core/src/main/res/values/strings.xml | 3 + .../main/res/xml/fragment_settings_player.xml | 9 +- .../java/dev/jdtech/jellyfin/mpv/MPVPlayer.kt | 10 +- .../viewmodels/PlayerActivityViewModel.kt | 4 - player/video/src/main/res/values/strings.xml | 3 +- .../dev/jdtech/jellyfin/AppPreferences.kt | 2 + .../java/dev/jdtech/jellyfin/Constants.kt | 3 + 12 files changed, 175 insertions(+), 14 deletions(-) create mode 100644 core/src/main/res/drawable/ic_picture_in_picture.xml diff --git a/app/phone/src/main/AndroidManifest.xml b/app/phone/src/main/AndroidManifest.xml index 0ac39b0f..2917fcbe 100644 --- a/app/phone/src/main/AndroidManifest.xml +++ b/app/phone/src/main/AndroidManifest.xml @@ -26,6 +26,9 @@ android:name=".PlayerActivity" android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" android:screenOrientation="sensorLandscape" + android:launchMode="singleTask" + android:supportsPictureInPicture="true" + android:autoRemoveFromRecents="true" android:theme="@style/Theme.Findroid.Player" /> (R.id.btn_subtitle) val speedButton = binding.playerView.findViewById(R.id.btn_speed) val skipIntroButton = binding.playerView.findViewById