|
33 | 33 | import android.provider.Settings; |
34 | 34 | import android.util.DisplayMetrics; |
35 | 35 | import android.util.Log; |
36 | | -import android.util.Rational; |
37 | 36 | import android.util.TypedValue; |
38 | 37 | import android.view.LayoutInflater; |
39 | 38 | import android.view.MotionEvent; |
@@ -439,20 +438,13 @@ public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, |
439 | 438 |
|
440 | 439 | @Override |
441 | 440 | public void onPictureInPictureModeChanged(final boolean isInPictureInPictureMode) { |
442 | | - if (isInPictureInPictureMode) { |
443 | | - binding.overlayLayout.setVisibility(View.GONE); |
444 | | - binding.tabLayout.setVisibility(View.GONE); |
445 | | - binding.detailContentRootLayout.setVisibility(View.GONE); |
446 | | - if (binding.relatedItemsLayout != null) { |
447 | | - binding.relatedItemsLayout.setVisibility(View.GONE); |
448 | | - } |
449 | | - } else { |
450 | | - binding.overlayLayout.setVisibility(View.VISIBLE); |
451 | | - binding.tabLayout.setVisibility(View.VISIBLE); |
452 | | - binding.detailContentRootLayout.setVisibility(View.VISIBLE); |
453 | | - if (binding.relatedItemsLayout != null) { |
454 | | - binding.relatedItemsLayout.setVisibility(View.VISIBLE); |
455 | | - } |
| 441 | + final int visibility = isInPictureInPictureMode ? View.GONE : View.VISIBLE; |
| 442 | + binding.overlayLayout.setVisibility(visibility); |
| 443 | + binding.tabLayout.setVisibility(visibility); |
| 444 | + binding.detailContentRootLayout.setVisibility(visibility); |
| 445 | + binding.viewPager.setVisibility(visibility); |
| 446 | + if (binding.relatedItemsLayout != null) { |
| 447 | + binding.relatedItemsLayout.setVisibility(visibility); |
456 | 448 | } |
457 | 449 | } |
458 | 450 |
|
@@ -1150,16 +1142,16 @@ private void openBackgroundPlayer(final boolean append) { |
1150 | 1142 | } |
1151 | 1143 |
|
1152 | 1144 | private void openPopupPlayer(final boolean append) { |
| 1145 | + final var popupMode = PreferenceManager.getDefaultSharedPreferences(activity) |
| 1146 | + .getString(getString(R.string.popup_configuration_key), |
| 1147 | + getString(R.string.popup_mode_legacy)); |
1153 | 1148 | final var isPipAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N |
1154 | 1149 | && requireContext().getPackageManager() |
1155 | | - .hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE); |
| 1150 | + .hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE) |
| 1151 | + && popupMode.equals(getString(R.string.popup_mode_pip)); |
| 1152 | + |
1156 | 1153 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && isPipAvailable) { |
1157 | | - final var videoPlayerUi = player.UIs().get(VideoPlayerUi.class).orElse(null); |
1158 | 1154 | final var pipParams = new PictureInPictureParams.Builder(); |
1159 | | - if (videoPlayerUi != null) { |
1160 | | - final var videoView = videoPlayerUi.getBinding().getRoot(); |
1161 | | - pipParams.setAspectRatio(new Rational(videoView.getWidth(), videoView.getHeight())); |
1162 | | - } |
1163 | 1155 | requireActivity().enterPictureInPictureMode(pipParams.build()); |
1164 | 1156 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isPipAvailable) { |
1165 | 1157 | requireActivity().enterPictureInPictureMode(); |
|
0 commit comments