diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java index 6e4f09ace..1dcf4a89d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -44,6 +44,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.WindowManager; import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.PopupMenu; import android.widget.RemoteViews; import android.widget.SeekBar; @@ -370,6 +371,7 @@ public final class PopupVideoPlayer extends Service { protected class VideoPlayerImpl extends VideoPlayer implements View.OnLayoutChangeListener { private TextView resizingIndicator; private ImageButton fullScreenButton; + private ImageView videoPlayPause; private View extraOptionsView; @@ -391,6 +393,8 @@ public final class PopupVideoPlayer extends Service { resizingIndicator = rootView.findViewById(R.id.resizing_indicator); fullScreenButton = rootView.findViewById(R.id.fullScreenButton); fullScreenButton.setOnClickListener(v -> onFullScreenButtonClicked()); + videoPlayPause = rootView.findViewById(R.id.videoPlayPause); + videoPlayPause.setOnClickListener(this::onPlayPauseButtonPressed); extraOptionsView = rootView.findViewById(R.id.extraOptionsView); rootView.addOnLayoutChangeListener(this); @@ -406,6 +410,10 @@ public final class PopupVideoPlayer extends Service { view.setStyle(captionStyle); } + private void onPlayPauseButtonPressed(View ib) { + onPlayPause(); + } + @Override public void onLayoutChange(final View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { @@ -651,6 +659,7 @@ public final class PopupVideoPlayer extends Service { public void onPlaying() { super.onPlaying(); updateNotification(R.drawable.ic_pause_white); + videoPlayPause.setBackgroundResource(R.drawable.ic_pause_white); lockManager.acquireWifiAndCpu(); hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME); @@ -666,13 +675,14 @@ public final class PopupVideoPlayer extends Service { public void onPaused() { super.onPaused(); updateNotification(R.drawable.ic_play_arrow_white); - showAndAnimateControl(R.drawable.ic_play_arrow_white, false); + videoPlayPause.setBackgroundResource(R.drawable.ic_play_arrow_white); lockManager.releaseWifiAndCpu(); } @Override public void onPausedSeek() { super.onPausedSeek(); + videoPlayPause.setBackgroundResource(R.drawable.ic_pause_white); updateNotification(R.drawable.ic_play_arrow_white); } @@ -680,10 +690,27 @@ public final class PopupVideoPlayer extends Service { public void onCompleted() { super.onCompleted(); updateNotification(R.drawable.ic_replay_white); - showAndAnimateControl(R.drawable.ic_replay_white, false); + videoPlayPause.setBackgroundResource(R.drawable.ic_replay_white); lockManager.releaseWifiAndCpu(); } + @Override + public void showControlsThenHide() { + videoPlayPause.setVisibility(View.VISIBLE); + super.showControlsThenHide(); + } + + public void showControls(long duration) { + videoPlayPause.setVisibility(View.VISIBLE); + super.showControls(duration); + } + + public void hideControls(final long duration, long delay) { + super.hideControlsAndButton(duration, delay, videoPlayPause); + } + + + /*////////////////////////////////////////////////////////////////////////// // Utils //////////////////////////////////////////////////////////////////////////*/ @@ -717,6 +744,8 @@ public final class PopupVideoPlayer extends Service { Log.d(TAG, "onDoubleTap() called with: e = [" + e + "]" + "rawXy = " + e.getRawX() + ", " + e.getRawY() + ", xy = " + e.getX() + ", " + e.getY()); if (playerImpl == null || !playerImpl.isPlaying()) return false; + playerImpl.hideControls(0, 0); + if (e.getX() > popupWidth / 2) { playerImpl.onFastForward(); } else { @@ -730,7 +759,12 @@ public final class PopupVideoPlayer extends Service { public boolean onSingleTapConfirmed(MotionEvent e) { if (DEBUG) Log.d(TAG, "onSingleTapConfirmed() called with: e = [" + e + "]"); if (playerImpl == null || playerImpl.getPlayer() == null) return false; - playerImpl.onPlayPause(); + if (playerImpl.isControlsVisible()) { + playerImpl.hideControls(100, 100); + } else { + playerImpl.showControlsThenHide(); + + } return true; } diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index f81318880..5ea1c74a0 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -887,6 +887,19 @@ public abstract class VideoPlayer extends BasePlayer () -> animateView(controlsRoot, false, duration), delay); } + public void hideControlsAndButton(final long duration, long delay, View button) { + if (DEBUG) Log.d(TAG, "hideControls() called with: delay = [" + delay + "]"); + controlsVisibilityHandler.removeCallbacksAndMessages(null); + controlsVisibilityHandler.postDelayed(hideControlsAndButtonHandler(duration, button), delay); + } + + private Runnable hideControlsAndButtonHandler(long duration, View videoPlayPause) + { + return () -> { + videoPlayPause.setVisibility(View.INVISIBLE); + animateView(controlsRoot, false,duration); + }; + } /*////////////////////////////////////////////////////////////////////////// // Getters and Setters //////////////////////////////////////////////////////////////////////////*/ diff --git a/app/src/main/res/layout/player_popup.xml b/app/src/main/res/layout/player_popup.xml index 5e8ed664e..f866cf002 100644 --- a/app/src/main/res/layout/player_popup.xml +++ b/app/src/main/res/layout/player_popup.xml @@ -53,6 +53,16 @@ android:visibility="gone" tools:visibility="visible"> + + + tools:text="FIT" /> + tools:ignore="ContentDescription,RtlHardcoded" /> +