1
0
Fork 0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2025-10-03 01:39:38 +02:00

Merge pull request #12612 from Profpatsch/rename-fullscreen-buttons

This commit is contained in:
Stypox 2025-09-07 18:00:47 +02:00 committed by GitHub
commit 759342fa62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 64 additions and 38 deletions

View file

@ -991,7 +991,7 @@ class VideoDetailFragment :
// restored (i.e. bottomSheetState) to STATE_EXPANDED. // restored (i.e. bottomSheetState) to STATE_EXPANDED.
updateBottomSheetState(BottomSheetBehavior.STATE_EXPANDED) updateBottomSheetState(BottomSheetBehavior.STATE_EXPANDED)
// toggle landscape in order to open directly in fullscreen // toggle landscape in order to open directly in fullscreen
onScreenRotationButtonClicked() onFullscreenToggleButtonClicked()
} }
if (PreferenceManager.getDefaultSharedPreferences(activity) if (PreferenceManager.getDefaultSharedPreferences(activity)
@ -1726,7 +1726,7 @@ class VideoDetailFragment :
tryAddVideoPlayerView() tryAddVideoPlayerView()
} }
override fun onScreenRotationButtonClicked() { override fun onFullscreenToggleButtonClicked() {
// 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

View file

@ -10,7 +10,7 @@ public interface PlayerServiceEventListener extends PlayerEventListener {
void onFullscreenStateChanged(boolean fullscreen); void onFullscreenStateChanged(boolean fullscreen);
void onScreenRotationButtonClicked(); void onFullscreenToggleButtonClicked();
void onMoreOptionsLongClicked(); void onMoreOptionsLongClicked();

View file

@ -243,8 +243,8 @@ object PlayerHolder {
listener?.onFullscreenStateChanged(fullscreen) listener?.onFullscreenStateChanged(fullscreen)
} }
override fun onScreenRotationButtonClicked() { override fun onFullscreenToggleButtonClicked() {
listener?.onScreenRotationButtonClicked() listener?.onFullscreenToggleButtonClicked()
} }
override fun onMoreOptionsLongClicked() { override fun onMoreOptionsLongClicked() {

View file

@ -122,7 +122,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
&& DeviceUtils.isTablet(player.getService()) && DeviceUtils.isTablet(player.getService())
&& PlayerHelper.globalScreenOrientationLocked(player.getService())) { && PlayerHelper.globalScreenOrientationLocked(player.getService())) {
player.getFragmentListener().ifPresent( player.getFragmentListener().ifPresent(
PlayerServiceEventListener::onScreenRotationButtonClicked); PlayerServiceEventListener::onFullscreenToggleButtonClicked);
} }
} }
@ -154,12 +154,12 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
protected void initListeners() { protected void initListeners() {
super.initListeners(); super.initListeners();
binding.screenRotationButton.setOnClickListener(makeOnClickListener(() -> { binding.fullscreenToggleButton.setOnClickListener(makeOnClickListener(() -> {
// Only if it's not a vertical video or vertical video but in landscape with locked // Only if it's not a vertical video or vertical video but in landscape with locked
// orientation a screen orientation can be changed automatically // orientation a screen orientation can be changed automatically
if (!isVerticalVideo || (isLandscape() && globalScreenOrientationLocked(context))) { if (!isVerticalVideo || (isLandscape() && globalScreenOrientationLocked(context))) {
player.getFragmentListener() player.getFragmentListener()
.ifPresent(PlayerServiceEventListener::onScreenRotationButtonClicked); .ifPresent(PlayerServiceEventListener::onFullscreenToggleButtonClicked);
} else { } else {
toggleFullscreen(); toggleFullscreen();
} }
@ -233,7 +233,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
// Exit from fullscreen when user closes the player via notification // Exit from fullscreen when user closes the player via notification
if (isFullscreen) { if (isFullscreen) {
toggleFullscreen(); exitFullscreen();
} }
removeViewFromParent(); removeViewFromParent();
@ -270,7 +270,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
closeItemsList(); closeItemsList();
showHideKodiButton(); showHideKodiButton();
binding.fullScreenButton.setVisibility(View.GONE); binding.fullscreenToggleButtonSecondaryMenu.setVisibility(View.GONE);
setupScreenRotationButton(); setupScreenRotationButton();
binding.resizeTextView.setVisibility(View.VISIBLE); binding.resizeTextView.setVisibility(View.VISIBLE);
binding.getRoot().findViewById(R.id.metadataView).setVisibility(View.VISIBLE); binding.getRoot().findViewById(R.id.metadataView).setVisibility(View.VISIBLE);
@ -414,7 +414,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
public void onCompleted() { public void onCompleted() {
super.onCompleted(); super.onCompleted();
if (isFullscreen) { if (isFullscreen) {
toggleFullscreen(); exitFullscreen();
} }
} }
//endregion //endregion
@ -885,10 +885,10 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
//region Video size, orientation, fullscreen //region Video size, orientation, fullscreen
private void setupScreenRotationButton() { private void setupScreenRotationButton() {
binding.screenRotationButton.setVisibility(globalScreenOrientationLocked(context) binding.fullscreenToggleButton.setVisibility(globalScreenOrientationLocked(context)
|| isVerticalVideo || DeviceUtils.isTablet(context) || isVerticalVideo || DeviceUtils.isTablet(context)
? View.VISIBLE : View.GONE); ? View.VISIBLE : View.GONE);
binding.screenRotationButton.setImageDrawable(AppCompatResources.getDrawable(context, binding.fullscreenToggleButton.setImageDrawable(AppCompatResources.getDrawable(context,
isFullscreen ? R.drawable.ic_fullscreen_exit isFullscreen ? R.drawable.ic_fullscreen_exit
: R.drawable.ic_fullscreen)); : R.drawable.ic_fullscreen));
} }
@ -905,7 +905,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
&& !DeviceUtils.isTablet(context)) { && !DeviceUtils.isTablet(context)) {
// set correct orientation // set correct orientation
player.getFragmentListener().ifPresent( player.getFragmentListener().ifPresent(
PlayerServiceEventListener::onScreenRotationButtonClicked); PlayerServiceEventListener::onFullscreenToggleButtonClicked);
} }
setupScreenRotationButton(); setupScreenRotationButton();
@ -915,28 +915,54 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "toggleFullscreen() called"); Log.d(TAG, "toggleFullscreen() called");
} }
if (isFullscreen) {
exitFullscreen();
} else {
enterFullscreen();
}
}
public void enterFullscreen() {
if (DEBUG) {
Log.d(TAG, "enterFullscreen() called");
}
final PlayerServiceEventListener fragmentListener = player.getFragmentListener() final PlayerServiceEventListener fragmentListener = player.getFragmentListener()
.orElse(null); .orElse(null);
if (fragmentListener == null || player.exoPlayerIsNull()) { if (fragmentListener == null || player.exoPlayerIsNull()) {
return; return;
} }
isFullscreen = true;
// Android needs tens milliseconds to send new insets but a user is able to see
// how controls changes it's position from `0` to `nav bar height` padding.
// So just hide the controls to hide this visual inconsistency
hideControls(0, 0);
fragmentListener.onFullscreenStateChanged(true);
setupFullscreenButtons(true);
}
isFullscreen = !isFullscreen; public void exitFullscreen() {
if (isFullscreen) { if (DEBUG) {
// Android needs tens milliseconds to send new insets but a user is able to see Log.d(TAG, "exitFullscreen() called");
// how controls changes it's position from `0` to `nav bar height` padding.
// So just hide the controls to hide this visual inconsistency
hideControls(0, 0);
} else {
// Apply window insets because Android will not do it when orientation changes
// from landscape to portrait (open vertical video to reproduce)
binding.playbackControlRoot.setPadding(0, 0, 0, 0);
} }
fragmentListener.onFullscreenStateChanged(isFullscreen); final PlayerServiceEventListener fragmentListener = player.getFragmentListener()
.orElse(null);
if (fragmentListener == null || player.exoPlayerIsNull()) {
return;
}
isFullscreen = false;
// Apply window insets because Android will not do it when orientation changes
// from landscape to portrait (open vertical video to reproduce)
binding.playbackControlRoot.setPadding(0, 0, 0, 0);
fragmentListener.onFullscreenStateChanged(false);
setupFullscreenButtons(false);
}
binding.titleTextView.setVisibility(isFullscreen ? View.VISIBLE : View.GONE); private void setupFullscreenButtons(final boolean fullscreen) {
binding.channelTextView.setVisibility(isFullscreen ? View.VISIBLE : View.GONE); binding.titleTextView.setVisibility(fullscreen ? View.VISIBLE : View.GONE);
binding.playerCloseButton.setVisibility(isFullscreen ? View.GONE : View.VISIBLE); binding.channelTextView.setVisibility(fullscreen ? View.VISIBLE : View.GONE);
binding.playerCloseButton.setVisibility(fullscreen ? View.GONE : View.VISIBLE);
setupScreenRotationButton(); setupScreenRotationButton();
} }
@ -951,7 +977,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
if (videoInLandscapeButNotInFullscreen if (videoInLandscapeButNotInFullscreen
&& notPaused && notPaused
&& !DeviceUtils.isTablet(context)) { && !DeviceUtils.isTablet(context)) {
toggleFullscreen(); enterFullscreen();
} }
} }
//endregion //endregion

View file

@ -153,8 +153,8 @@ public final class PopupPlayerUi extends VideoPlayerUi {
@Override @Override
protected void setupElementsVisibility() { protected void setupElementsVisibility() {
binding.fullScreenButton.setVisibility(View.VISIBLE); binding.fullscreenToggleButtonSecondaryMenu.setVisibility(View.VISIBLE);
binding.screenRotationButton.setVisibility(View.GONE); binding.fullscreenToggleButton.setVisibility(View.GONE);
binding.resizeTextView.setVisibility(View.GONE); binding.resizeTextView.setVisibility(View.GONE);
binding.getRoot().findViewById(R.id.metadataView).setVisibility(View.GONE); binding.getRoot().findViewById(R.id.metadataView).setVisibility(View.GONE);
binding.queueButton.setVisibility(View.GONE); binding.queueButton.setVisibility(View.GONE);

View file

@ -234,7 +234,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
ShareUtils.copyToClipboard(context, player.getVideoUrlAtCurrentTime()); ShareUtils.copyToClipboard(context, player.getVideoUrlAtCurrentTime());
return true; return true;
}); });
binding.fullScreenButton.setOnClickListener(makeOnClickListener(() -> { binding.fullscreenToggleButtonSecondaryMenu.setOnClickListener(makeOnClickListener(() -> {
player.setRecovery(); player.setRecovery();
NavigationHelper.playOnMainPlayer(context, NavigationHelper.playOnMainPlayer(context,
Objects.requireNonNull(player.getPlayQueue()), true); Objects.requireNonNull(player.getPlayQueue()), true);
@ -301,8 +301,8 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
binding.moreOptionsButton.setOnLongClickListener(null); binding.moreOptionsButton.setOnLongClickListener(null);
binding.share.setOnClickListener(null); binding.share.setOnClickListener(null);
binding.share.setOnLongClickListener(null); binding.share.setOnLongClickListener(null);
binding.fullScreenButton.setOnClickListener(null); binding.fullscreenToggleButtonSecondaryMenu.setOnClickListener(null);
binding.screenRotationButton.setOnClickListener(null); binding.fullscreenToggleButton.setOnClickListener(null);
binding.playWithKodi.setOnClickListener(null); binding.playWithKodi.setOnClickListener(null);
binding.openInBrowser.setOnClickListener(null); binding.openInBrowser.setOnClickListener(null);
binding.playerCloseButton.setOnClickListener(null); binding.playerCloseButton.setOnClickListener(null);
@ -1455,7 +1455,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
if (player.getCurrentState() == STATE_PLAYING && !isSomePopupMenuVisible) { if (player.getCurrentState() == STATE_PLAYING && !isSomePopupMenuVisible) {
if (v == binding.playPauseButton if (v == binding.playPauseButton
// Hide controls in fullscreen immediately // Hide controls in fullscreen immediately
|| (v == binding.screenRotationButton && isFullscreen())) { || (v == binding.fullscreenToggleButton && 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);

View file

@ -363,7 +363,7 @@
tools:ignore="RtlHardcoded" /> tools:ignore="RtlHardcoded" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/fullScreenButton" android:id="@+id/fullscreenToggleButtonSecondaryMenu"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
@ -457,7 +457,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:layout_weight="1" android:layout_weight="1"
android:nextFocusDown="@id/screenRotationButton" android:nextFocusDown="@id/fullscreenToggleButton"
tools:progress="25" tools:progress="25"
tools:secondaryProgress="50" /> tools:secondaryProgress="50" />
@ -486,7 +486,7 @@
tools:ignore="HardcodedText,RtlHardcoded,RtlSymmetry" /> tools:ignore="HardcodedText,RtlHardcoded,RtlSymmetry" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/screenRotationButton" android:id="@+id/fullscreenToggleButton"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"