diff --git a/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java b/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java index b5c7fc564..3518aa139 100644 --- a/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java +++ b/app/src/main/java/com/google/android/material/appbar/FlingBehavior.java @@ -5,7 +5,6 @@ import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; -import android.view.ViewGroup; import android.widget.OverScroller; import androidx.annotation.NonNull; @@ -14,6 +13,8 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout; import org.schabi.newpipe.R; import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.List; // See https://stackoverflow.com/questions/56849221#57997489 public final class FlingBehavior extends AppBarLayout.Behavior { @@ -25,6 +26,9 @@ public final class FlingBehavior extends AppBarLayout.Behavior { private boolean allowScroll = true; private final Rect globalRect = new Rect(); + private final List skipInterceptionOfElements = Arrays.asList( + R.id.playQueuePanel, R.id.playbackSeekBar, + R.id.playPauseButton, R.id.playPreviousButton, R.id.playNextButton); @Override public boolean onRequestChildRectangleOnScreen( @@ -60,20 +64,14 @@ public final class FlingBehavior extends AppBarLayout.Behavior { public boolean onInterceptTouchEvent(final CoordinatorLayout parent, final AppBarLayout child, final MotionEvent ev) { - final ViewGroup playQueue = child.findViewById(R.id.playQueuePanel); - if (playQueue != null) { - final boolean visible = playQueue.getGlobalVisibleRect(globalRect); - if (visible && globalRect.contains((int) ev.getRawX(), (int) ev.getRawY())) { - allowScroll = false; - return false; - } - } - final View seekBar = child.findViewById(R.id.playbackSeekBar); - if (seekBar != null) { - final boolean visible = seekBar.getGlobalVisibleRect(globalRect); - if (visible && globalRect.contains((int) ev.getRawX(), (int) ev.getRawY())) { - allowScroll = false; - return false; + for (final Integer element : skipInterceptionOfElements) { + final View view = child.findViewById(element); + if (view != null) { + final boolean visible = view.getGlobalVisibleRect(globalRect); + if (visible && globalRect.contains((int) ev.getRawX(), (int) ev.getRawY())) { + allowScroll = false; + return false; + } } } allowScroll = true; diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index e3eb1c9f7..f1bbc7312 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -172,6 +172,8 @@ public class VideoPlayerImpl extends VideoPlayer private RecyclerView itemsList; private ItemTouchHelper itemTouchHelper; + private RelativeLayout playerOverlays; + private boolean queueVisible; private MainPlayer.PlayerType playerType = MainPlayer.PlayerType.VIDEO; @@ -305,6 +307,8 @@ public class VideoPlayerImpl extends VideoPlayer this.itemsListCloseButton = view.findViewById(R.id.playQueueClose); this.itemsList = view.findViewById(R.id.playQueue); + this.playerOverlays = view.findViewById(R.id.player_overlays); + closingOverlayView = view.findViewById(R.id.closingOverlay); titleTextView.setSelected(true); @@ -481,6 +485,16 @@ public class VideoPlayerImpl extends VideoPlayer return windowInsets; }); } + + // PlaybackControlRoot already consumed window insets but we should pass them to + // player_overlays too. Without it they will be off-centered + getControlsRoot().addOnLayoutChangeListener((v, left, top, right, bottom, + oldLeft, oldTop, oldRight, oldBottom) -> + playerOverlays.setPadding( + v.getPaddingLeft(), + v.getPaddingTop(), + v.getPaddingRight(), + v.getPaddingBottom())); } public boolean onKeyDown(final int keyCode) { diff --git a/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java b/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java index 47c0624b8..5405d01c1 100644 --- a/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java +++ b/app/src/main/java/org/schabi/newpipe/player/event/CustomBottomSheetBehavior.java @@ -5,7 +5,6 @@ import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; -import android.view.ViewGroup; import android.widget.FrameLayout; import androidx.annotation.NonNull; import androidx.coordinatorlayout.widget.CoordinatorLayout; @@ -21,12 +20,12 @@ public class CustomBottomSheetBehavior extends BottomSheetBehavior super(context, attrs); } - boolean visible; Rect globalRect = new Rect(); private boolean skippingInterception = false; private final List skipInterceptionOfElements = Arrays.asList( R.id.detail_content_root_layout, R.id.relatedStreamsLayout, - R.id.playQueuePanel, R.id.viewpager, R.id.bottomControls); + R.id.playQueuePanel, R.id.viewpager, R.id.bottomControls, + R.id.playPauseButton, R.id.playPreviousButton, R.id.playNextButton); @Override public boolean onInterceptTouchEvent(@NonNull final CoordinatorLayout parent, @@ -48,9 +47,9 @@ public class CustomBottomSheetBehavior extends BottomSheetBehavior && event.getAction() == MotionEvent.ACTION_DOWN) { // Without overriding scrolling will not work when user touches these elements for (final Integer element : skipInterceptionOfElements) { - final ViewGroup viewGroup = child.findViewById(element); - if (viewGroup != null) { - visible = viewGroup.getGlobalVisibleRect(globalRect); + final View view = child.findViewById(element); + if (view != null) { + final boolean visible = view.getGlobalVisibleRect(globalRect); if (visible && globalRect.contains((int) event.getRawX(), (int) event.getRawY())) { // Makes bottom part of the player draggable in portrait when diff --git a/app/src/main/res/layout-large-land/player.xml b/app/src/main/res/layout-large-land/player.xml index 7e27765a0..c3f2e640c 100644 --- a/app/src/main/res/layout-large-land/player.xml +++ b/app/src/main/res/layout-large-land/player.xml @@ -530,117 +530,123 @@ - - - - - - + android:layout_height="match_parent"> - - - - - - - - + + tools:src="@drawable/ic_fast_rewind_white_24dp" + tools:visibility="visible" /> + + + + + + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + tools:ignore="RtlHardcoded"> - - - + android:background="@drawable/background_oval_black_transparent" + android:visibility="gone" + tools:visibility="visible"> + + + + + + + + + + + + + + - - - - - - - - - + android:layout_height="match_parent"> - - - - - - - - + + tools:src="@drawable/ic_fast_rewind_white_24dp" + tools:visibility="visible" /> + + + + + + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + tools:ignore="RtlHardcoded"> - - - + android:background="@drawable/background_oval_black_transparent" + android:visibility="gone" + tools:visibility="visible"> + + + + + + + + + + + + + + -