Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ public final class VideoDetailFragment
int lastStableBottomSheetState = BottomSheetBehavior.STATE_EXPANDED;
@State
protected boolean autoPlayEnabled = true;
@State
protected int originalOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

@Nullable
private StreamInfo currentInfo = null;
Expand Down Expand Up @@ -1900,23 +1902,29 @@ public void onFullscreenStateChanged(final boolean fullscreen) {

@Override
public void onScreenRotationButtonClicked() {
// On Android TV screen rotation is not supported
// In tablet user experience will be better if screen will not be rotated
// from landscape to portrait every time.
// Just turn on fullscreen mode in landscape orientation
// or portrait & unlocked global orientation
final boolean isLandscape = DeviceUtils.isLandscape(requireContext());
if (DeviceUtils.isTv(activity) || DeviceUtils.isTablet(activity)
&& (!globalScreenOrientationLocked(activity) || isLandscape)) {
player.UIs().get(MainPlayerUi.class).ifPresent(MainPlayerUi::toggleFullscreen);
final Optional<MainPlayerUi> playerUi = player != null
? player.UIs().get(MainPlayerUi.class)
: Optional.empty();
if (playerUi.isEmpty()) {
return;
}

final int newOrientation = isLandscape
? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
// On tablets and TVs, just toggle fullscreen UI without orientation change.
if (DeviceUtils.isTablet(activity) || DeviceUtils.isTv(activity)) {
playerUi.get().toggleFullscreen();
return;
}

activity.setRequestedOrientation(newOrientation);
if (playerUi.get().isFullscreen()) {
// EXITING FULLSCREEN
playerUi.get().toggleFullscreen();
activity.setRequestedOrientation(originalOrientation);
} else {
// ENTERING FULLSCREEN
originalOrientation = activity.getRequestedOrientation();
playerUi.get().toggleFullscreen();
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
}

/*
Expand Down