@@ -219,7 +219,7 @@ public void onServiceConnected(final Player connectedPlayer,
219
219
return ;
220
220
}
221
221
222
- if (isLandscape ()) {
222
+ if (DeviceUtils . isLandscape (requireContext () )) {
223
223
// If the video is playing but orientation changed
224
224
// let's make the video in fullscreen again
225
225
checkLandscape ();
@@ -494,7 +494,7 @@ public void onClick(final View v) {
494
494
autoPlayEnabled = true ; // forcefully start playing
495
495
if (PlayerHelper .getAutoplayType (requireContext ())
496
496
== PlayerHelper .AutoplayType .AUTOPLAY_TYPE_NEVER_AND_START_IN_FULLSCREEN
497
- && !isLandscape ()
497
+ && !DeviceUtils . isLandscape (requireContext () )
498
498
&& PlayerHelper .globalScreenOrientationLocked (requireContext ())) {
499
499
// open directly in fullscreen TODO does it work for large-land layouts?
500
500
onScreenRotationButtonClicked ();
@@ -1257,7 +1257,7 @@ public boolean onPreDraw() {
1257
1257
final DisplayMetrics metrics = getResources ().getDisplayMetrics ();
1258
1258
1259
1259
if (getView () != null ) {
1260
- final int height = (isInMultiWindow ()
1260
+ final int height = (DeviceUtils . isInMultiWindow (activity )
1261
1261
? requireView ()
1262
1262
: activity .getWindow ().getDecorView ()).getHeight ();
1263
1263
setHeightThumbnail (height , metrics );
@@ -1280,7 +1280,7 @@ private void setHeightThumbnail() {
1280
1280
requireView ().getViewTreeObserver ().removeOnPreDrawListener (preDrawListener );
1281
1281
1282
1282
if (player != null && player .isFullscreen ()) {
1283
- final int height = (isInMultiWindow ()
1283
+ final int height = (DeviceUtils . isInMultiWindow (activity )
1284
1284
? requireView ()
1285
1285
: activity .getWindow ().getDecorView ()).getHeight ();
1286
1286
// Height is zero when the view is not yet displayed like after orientation change
@@ -1871,13 +1871,14 @@ public void onScreenRotationButtonClicked() {
1871
1871
// from landscape to portrait every time.
1872
1872
// Just turn on fullscreen mode in landscape orientation
1873
1873
// or portrait & unlocked global orientation
1874
+ final boolean isLandscape = DeviceUtils .isLandscape (requireContext ());
1874
1875
if (DeviceUtils .isTablet (activity )
1875
- && (!globalScreenOrientationLocked (activity ) || isLandscape () )) {
1876
+ && (!globalScreenOrientationLocked (activity ) || isLandscape )) {
1876
1877
player .toggleFullscreen ();
1877
1878
return ;
1878
1879
}
1879
1880
1880
- final int newOrientation = isLandscape ()
1881
+ final int newOrientation = isLandscape
1881
1882
? ActivityInfo .SCREEN_ORIENTATION_PORTRAIT
1882
1883
: ActivityInfo .SCREEN_ORIENTATION_SENSOR_LANDSCAPE ;
1883
1884
@@ -1949,15 +1950,17 @@ private void hideSystemUi() {
1949
1950
| View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
1950
1951
| View .SYSTEM_UI_FLAG_HIDE_NAVIGATION
1951
1952
| View .SYSTEM_UI_FLAG_IMMERSIVE_STICKY ;
1953
+
1952
1954
// In multiWindow mode status bar is not transparent for devices with cutout
1953
1955
// if I include this flag. So without it is better in this case
1954
- if (!isInMultiWindow ()) {
1956
+ final boolean isInMultiWindow = DeviceUtils .isInMultiWindow (activity );
1957
+ if (!isInMultiWindow ) {
1955
1958
visibility |= View .SYSTEM_UI_FLAG_FULLSCREEN ;
1956
1959
}
1957
1960
activity .getWindow ().getDecorView ().setSystemUiVisibility (visibility );
1958
1961
1959
1962
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP
1960
- && (isInMultiWindow () || (player != null && player .isFullscreen ()))) {
1963
+ && (isInMultiWindow || (player != null && player .isFullscreen ()))) {
1961
1964
activity .getWindow ().setStatusBarColor (Color .TRANSPARENT );
1962
1965
activity .getWindow ().setNavigationBarColor (Color .TRANSPARENT );
1963
1966
}
@@ -2029,15 +2032,6 @@ private void checkLandscape() {
2029
2032
}
2030
2033
}
2031
2034
2032
- public boolean isLandscape () {
2033
- return getResources ().getDisplayMetrics ().heightPixels < getResources ()
2034
- .getDisplayMetrics ().widthPixels ;
2035
- }
2036
-
2037
- private boolean isInMultiWindow () {
2038
- return Build .VERSION .SDK_INT >= Build .VERSION_CODES .N && activity .isInMultiWindowMode ();
2039
- }
2040
-
2041
2035
/*
2042
2036
* Means that the player fragment was swiped away via BottomSheetLayout
2043
2037
* and is empty but ready for any new actions. See cleanUp()
@@ -2220,7 +2214,7 @@ public void onStateChanged(@NonNull final View bottomSheet, final int newState)
2220
2214
setOverlayElementsClickable (false );
2221
2215
hideSystemUiIfNeeded ();
2222
2216
// Conditions when the player should be expanded to fullscreen
2223
- if (isLandscape ()
2217
+ if (DeviceUtils . isLandscape (requireContext () )
2224
2218
&& player != null
2225
2219
&& player .isPlaying ()
2226
2220
&& !player .isFullscreen ()
0 commit comments