Changes for tablets and device's orientation behavior
- the app will not rotate the screen to portrait after video completes, it will just exit from fullscreen mode - ability to rotate the orientation via fullscreen button from landscape to portrait when device has locked orientation in landscape - ability to enter/exit to/from fullscreen on tablets with unlocked global orientation in portrait mode
This commit is contained in:
parent
3add24b8aa
commit
df9823988e
|
@ -125,6 +125,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
|
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
|
||||||
import static org.schabi.newpipe.extractor.stream.StreamExtractor.NO_AGE_LIMIT;
|
import static org.schabi.newpipe.extractor.stream.StreamExtractor.NO_AGE_LIMIT;
|
||||||
|
import static org.schabi.newpipe.player.helper.PlayerHelper.globalScreenOrientationLocked;
|
||||||
import static org.schabi.newpipe.player.helper.PlayerHelper.isClearingQueueConfirmationRequired;
|
import static org.schabi.newpipe.player.helper.PlayerHelper.isClearingQueueConfirmationRequired;
|
||||||
import static org.schabi.newpipe.player.playqueue.PlayQueueItem.RECOVERY_UNSET;
|
import static org.schabi.newpipe.player.playqueue.PlayQueueItem.RECOVERY_UNSET;
|
||||||
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
import static org.schabi.newpipe.util.AnimationUtils.animateView;
|
||||||
|
@ -404,7 +405,7 @@ public class VideoDetailFragment
|
||||||
settingsContentObserver = new ContentObserver(new Handler()) {
|
settingsContentObserver = new ContentObserver(new Handler()) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(final boolean selfChange) {
|
public void onChange(final boolean selfChange) {
|
||||||
if (activity != null && !PlayerHelper.globalScreenOrientationLocked(activity)) {
|
if (activity != null && !globalScreenOrientationLocked(activity)) {
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1844,9 +1845,6 @@ public class VideoDetailFragment
|
||||||
setOverlayPlayPauseImage();
|
setOverlayPlayPauseImage();
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case BasePlayer.STATE_COMPLETED:
|
|
||||||
restoreDefaultOrientation();
|
|
||||||
break;
|
|
||||||
case BasePlayer.STATE_PLAYING:
|
case BasePlayer.STATE_PLAYING:
|
||||||
if (positionView.getAlpha() != 1.0f
|
if (positionView.getAlpha() != 1.0f
|
||||||
&& player.getPlayQueue() != null
|
&& player.getPlayQueue() != null
|
||||||
|
@ -1956,13 +1954,15 @@ public class VideoDetailFragment
|
||||||
// In tablet user experience will be better if screen will not be rotated
|
// In tablet user experience will be better if screen will not be rotated
|
||||||
// from landscape to portrait every time.
|
// from landscape to portrait every time.
|
||||||
// Just turn on fullscreen mode in landscape orientation
|
// Just turn on fullscreen mode in landscape orientation
|
||||||
if (isLandscape() && DeviceUtils.isTablet(activity)) {
|
// or portrait & unlocked global orientation
|
||||||
|
if (DeviceUtils.isTablet(activity)
|
||||||
|
&& (!globalScreenOrientationLocked(activity) || isLandscape())) {
|
||||||
player.toggleFullscreen();
|
player.toggleFullscreen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int newOrientation = isLandscape()
|
final int newOrientation = isLandscape()
|
||||||
? ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
||||||
|
|
||||||
activity.setRequestedOrientation(newOrientation);
|
activity.setRequestedOrientation(newOrientation);
|
||||||
|
@ -2105,9 +2105,8 @@ public class VideoDetailFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
player.checkLandscape();
|
player.checkLandscape();
|
||||||
final boolean orientationLocked = PlayerHelper.globalScreenOrientationLocked(activity);
|
|
||||||
// Let's give a user time to look at video information page if video is not playing
|
// Let's give a user time to look at video information page if video is not playing
|
||||||
if (orientationLocked && !player.isPlaying()) {
|
if (globalScreenOrientationLocked(activity) && !player.isPlaying()) {
|
||||||
player.onPlay();
|
player.onPlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -822,7 +822,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
showHideShadow(true, DEFAULT_CONTROLS_DURATION, 0);
|
showHideShadow(true, DEFAULT_CONTROLS_DURATION, 0);
|
||||||
animateView(getControlsRoot(), true, DEFAULT_CONTROLS_DURATION, 0, () -> {
|
animateView(getControlsRoot(), true, DEFAULT_CONTROLS_DURATION, 0, () -> {
|
||||||
if (getCurrentState() == STATE_PLAYING && !isSomePopupMenuVisible()) {
|
if (getCurrentState() == STATE_PLAYING && !isSomePopupMenuVisible()) {
|
||||||
if (v.getId() == playPauseButton.getId()) {
|
if (v.getId() == playPauseButton.getId()
|
||||||
|
// Hide controls in fullscreen immediately
|
||||||
|
|| (v.getId() == screenRotationButton.getId() && isFullscreen)) {
|
||||||
hideControls(0, 0);
|
hideControls(0, 0);
|
||||||
} else {
|
} else {
|
||||||
hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME);
|
hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME);
|
||||||
|
@ -941,9 +943,8 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
|
|
||||||
private void setupScreenRotationButton() {
|
private void setupScreenRotationButton() {
|
||||||
final boolean orientationLocked = PlayerHelper.globalScreenOrientationLocked(service);
|
final boolean orientationLocked = PlayerHelper.globalScreenOrientationLocked(service);
|
||||||
final boolean tabletInLandscape = DeviceUtils.isTablet(service) && service.isLandscape();
|
|
||||||
final boolean showButton = videoPlayerSelected()
|
final boolean showButton = videoPlayerSelected()
|
||||||
&& (orientationLocked || isVerticalVideo || tabletInLandscape);
|
&& (orientationLocked || isVerticalVideo || DeviceUtils.isTablet(service));
|
||||||
screenRotationButton.setVisibility(showButton ? View.VISIBLE : View.GONE);
|
screenRotationButton.setVisibility(showButton ? View.VISIBLE : View.GONE);
|
||||||
screenRotationButton.setImageDrawable(AppCompatResources.getDrawable(service, isFullscreen()
|
screenRotationButton.setImageDrawable(AppCompatResources.getDrawable(service, isFullscreen()
|
||||||
? R.drawable.ic_fullscreen_exit_white_24dp
|
? R.drawable.ic_fullscreen_exit_white_24dp
|
||||||
|
@ -1176,6 +1177,9 @@ public class VideoPlayerImpl extends VideoPlayer
|
||||||
|
|
||||||
service.resetNotification();
|
service.resetNotification();
|
||||||
service.updateNotification(R.drawable.ic_replay_white_24dp);
|
service.updateNotification(R.drawable.ic_replay_white_24dp);
|
||||||
|
if (isFullscreen) {
|
||||||
|
toggleFullscreen();
|
||||||
|
}
|
||||||
|
|
||||||
super.onCompleted();
|
super.onCompleted();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue