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 4a2662f53..ff2860558 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 @@ -1,12 +1,17 @@ package com.google.android.material.appbar; import android.content.Context; +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.Nullable; import androidx.coordinatorlayout.widget.CoordinatorLayout; +import org.jetbrains.annotations.NotNull; +import org.schabi.newpipe.R; import java.lang.reflect.Field; @@ -17,21 +22,40 @@ public final class FlingBehavior extends AppBarLayout.Behavior { super(context, attrs); } + private boolean allowScroll = true; + private Rect playQueueRect = new Rect(); + @Override public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) { - switch (ev.getActionMasked()) { - case MotionEvent.ACTION_DOWN: - // remove reference to old nested scrolling child - resetNestedScrollingChild(); - // Stop fling when your finger touches the screen - stopAppBarLayoutFling(); - break; - default: - break; + ViewGroup playQueue = child.findViewById(R.id.playQueue); + if (playQueue != null) { + playQueue.getGlobalVisibleRect(playQueueRect); + if (playQueueRect.contains((int) ev.getX(), (int) ev.getY())) { + allowScroll = false; + return false; + } + } + allowScroll = true; + + if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) { + // remove reference to old nested scrolling child + resetNestedScrollingChild(); + // Stop fling when your finger touches the screen + stopAppBarLayoutFling(); } return super.onInterceptTouchEvent(parent, child, ev); } + @Override + public boolean onStartNestedScroll(CoordinatorLayout parent, AppBarLayout child, View directTargetChild, View target, int nestedScrollAxes, int type) { + return allowScroll && super.onStartNestedScroll(parent, child, directTargetChild, target, nestedScrollAxes, type); + } + + @Override + public boolean onNestedFling(@NotNull CoordinatorLayout coordinatorLayout, @NotNull AppBarLayout child, @NotNull View target, float velocityX, float velocityY, boolean consumed) { + return allowScroll && super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed); + } + @Nullable private OverScroller getScrollerField() { try { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 245a9a495..d0ca95d6b 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -311,7 +311,6 @@ public class VideoDetailFragment super.onCreate(savedInstanceState); setHasOptionsMenu(true); - ThemeHelper.setTheme(getContext()); // Let's play all streams automatically setAutoplay(true); @@ -953,14 +952,14 @@ public class VideoDetailFragment showLoading(); initTabs(); - if (scrollToTop) appBarLayout.setExpanded(true, true); + if (scrollToTop) scrollToTop(); handleResult(info); showContent(); } protected void prepareAndLoadInfo() { - appBarLayout.setExpanded(true, true); + scrollToTop(); startLoading(false); } @@ -1029,6 +1028,10 @@ public class VideoDetailFragment } } + public void scrollToTop() { + appBarLayout.setExpanded(true, true); + } + /*////////////////////////////////////////////////////////////////////////// // Play Utils //////////////////////////////////////////////////////////////////////////*/ @@ -1862,6 +1865,8 @@ public class VideoDetailFragment // Disable click because overlay buttons located on top of buttons from the player setOverlayElementsClickable(false); hideSystemUIIfNeeded(); + if (isLandscape() && player != null && player.isPlaying() && !player.isInFullscreen()) + player.toggleFullscreen(); break; case BottomSheetBehavior.STATE_COLLAPSED: // Re-enable clicks 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 492fd9ac5..71fe21b6d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -346,7 +346,8 @@ public class VideoPlayerImpl extends VideoPlayer // Use smaller value to be consistent between screen orientations // (and to make usage easier) int width = r - l, height = b - t; - maxGestureLength = (int) (Math.min(width, height) * MAX_GESTURE_LENGTH); + int min = Math.min(width, height); + maxGestureLength = (int) (min * MAX_GESTURE_LENGTH); if (DEBUG) Log.d(TAG, "maxGestureLength = " + maxGestureLength); @@ -354,6 +355,7 @@ public class VideoPlayerImpl extends VideoPlayer brightnessProgressBar.setMax(maxGestureLength); setInitialGestureValues(); + queueLayout.getLayoutParams().height = min - queueLayout.getTop(); } }); } @@ -620,8 +622,6 @@ public class VideoPlayerImpl extends VideoPlayer DEFAULT_CONTROLS_DURATION); itemsList.scrollToPosition(playQueue.getIndex()); - - if (playQueue.getStreams().size() > 4 && !isInFullscreen()) toggleFullscreen(); } private void onQueueClosed() { diff --git a/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java b/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java index 398cf9534..00a511ca3 100644 --- a/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java +++ b/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java @@ -292,7 +292,6 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen playerImpl.showControlsThenHide(); } - playerImpl.onPlayPause(); return true; } diff --git a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java index 07ef0b6ac..648894cc1 100644 --- a/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/NavigationHelper.java @@ -301,6 +301,7 @@ public class NavigationHelper { VideoDetailFragment detailFragment = (VideoDetailFragment) fragment; detailFragment.setAutoplay(autoPlay); detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue); + detailFragment.scrollToTop(); return; } diff --git a/app/src/main/res/layout-large-land/activity_main_player.xml b/app/src/main/res/layout-large-land/activity_main_player.xml index 0e2011910..8d7d9b639 100644 --- a/app/src/main/res/layout-large-land/activity_main_player.xml +++ b/app/src/main/res/layout-large-land/activity_main_player.xml @@ -149,6 +149,7 @@ android:background="@drawable/player_top_controls_bg" android:orientation="vertical" android:gravity="top" + android:paddingTop="4dp" android:baselineAligned="false" android:layout_toStartOf="@id/fullScreenButton"> @@ -158,7 +159,6 @@ android:layout_height="wrap_content" android:baselineAligned="false" android:gravity="top" - android:paddingTop="4dp" android:paddingBottom="7dp" android:paddingLeft="2dp" android:paddingRight="6dp" @@ -170,7 +170,8 @@ android:layout_height="wrap_content" android:gravity="top" android:orientation="vertical" - android:paddingLeft="8dp" + android:paddingTop="6dp" + android:paddingLeft="16dp" android:paddingRight="8dp" tools:ignore="RtlHardcoded" android:layout_weight="1"> @@ -212,8 +213,9 @@ android:id="@+id/qualityTextView" android:layout_width="wrap_content" android:layout_height="35dp" - android:layout_marginLeft="2dp" - android:layout_marginRight="2dp" + android:padding="6dp" + android:layout_marginStart="5dp" + android:layout_marginEnd="8dp" android:gravity="center" android:minWidth="50dp" android:text="720p" @@ -227,7 +229,8 @@ android:id="@+id/playbackSpeed" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="2dp" + android:padding="6dp" + android:layout_marginEnd="8dp" android:gravity="center" android:minHeight="35dp" android:minWidth="40dp" @@ -241,11 +244,10 @@ android:id="@+id/queueButton" android:layout_width="30dp" android:layout_height="35dp" - android:layout_marginLeft="2dp" - android:layout_marginRight="2dp" + android:padding="6dp" + android:layout_marginEnd="8dp" android:clickable="true" android:focusable="true" - android:padding="5dp" android:scaleType="fitXY" android:src="@drawable/ic_list_white_24dp" android:background="?attr/selectableItemBackground" @@ -256,8 +258,8 @@ android:id="@+id/moreOptionsButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="2dp" - android:padding="5dp" + android:padding="8dp" + android:layout_marginEnd="8dp" android:clickable="true" android:focusable="true" android:scaleType="fitXY" @@ -272,9 +274,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top" - android:paddingTop="4dp" - android:paddingBottom="7dp" - android:paddingStart="6dp" + android:paddingStart="16dp" android:paddingEnd="6dp" android:visibility="invisible" tools:ignore="RtlHardcoded" @@ -284,7 +284,8 @@ android:id="@+id/resizeTextView" android:layout_width="wrap_content" android:layout_height="35dp" - android:layout_marginRight="8dp" + android:padding="6dp" + android:layout_marginEnd="8dp" android:gravity="center" android:minWidth="50dp" android:textColor="@android:color/white" @@ -297,8 +298,8 @@ android:id="@+id/captionTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="8dp" - android:layout_marginRight="8dp" + android:padding="6dp" + android:layout_marginEnd="8dp" android:gravity="center|left" android:minHeight="35dp" android:minWidth="50dp" @@ -316,13 +317,12 @@ diff --git a/app/src/main/res/layout/activity_main_player.xml b/app/src/main/res/layout/activity_main_player.xml index 39c3f4410..8d00142a8 100644 --- a/app/src/main/res/layout/activity_main_player.xml +++ b/app/src/main/res/layout/activity_main_player.xml @@ -147,6 +147,7 @@ android:background="@drawable/player_top_controls_bg" android:orientation="vertical" android:gravity="top" + android:paddingTop="4dp" android:baselineAligned="false" android:layout_toStartOf="@id/fullScreenButton"> @@ -156,7 +157,6 @@ android:layout_height="wrap_content" android:baselineAligned="false" android:gravity="top" - android:paddingTop="4dp" android:paddingBottom="7dp" android:paddingLeft="2dp" android:paddingRight="6dp" @@ -168,7 +168,8 @@ android:layout_height="wrap_content" android:gravity="top" android:orientation="vertical" - android:paddingLeft="8dp" + android:paddingTop="6dp" + android:paddingLeft="16dp" android:paddingRight="8dp" tools:ignore="RtlHardcoded" android:layout_weight="1"> @@ -210,8 +211,9 @@ android:id="@+id/qualityTextView" android:layout_width="wrap_content" android:layout_height="35dp" - android:layout_marginLeft="2dp" - android:layout_marginRight="2dp" + android:padding="6dp" + android:layout_marginStart="5dp" + android:layout_marginEnd="8dp" android:gravity="center" android:minWidth="50dp" android:text="720p" @@ -225,7 +227,8 @@ android:id="@+id/playbackSpeed" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="2dp" + android:padding="6dp" + android:layout_marginEnd="8dp" android:gravity="center" android:minHeight="35dp" android:minWidth="40dp" @@ -239,11 +242,10 @@ android:id="@+id/queueButton" android:layout_width="30dp" android:layout_height="35dp" - android:layout_marginLeft="2dp" - android:layout_marginRight="2dp" + android:padding="6dp" + android:layout_marginEnd="8dp" android:clickable="true" android:focusable="true" - android:padding="5dp" android:scaleType="fitXY" android:src="@drawable/ic_list_white_24dp" android:background="?attr/selectableItemBackground" @@ -254,8 +256,8 @@ android:id="@+id/moreOptionsButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="2dp" - android:padding="5dp" + android:padding="8dp" + android:layout_marginEnd="8dp" android:clickable="true" android:focusable="true" android:scaleType="fitXY" @@ -270,9 +272,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top" - android:paddingTop="4dp" - android:paddingBottom="7dp" - android:paddingStart="6dp" + android:paddingStart="16dp" android:paddingEnd="6dp" android:visibility="invisible" tools:ignore="RtlHardcoded" @@ -282,7 +282,8 @@ android:id="@+id/resizeTextView" android:layout_width="wrap_content" android:layout_height="35dp" - android:layout_marginRight="8dp" + android:padding="6dp" + android:layout_marginEnd="8dp" android:gravity="center" android:minWidth="50dp" android:textColor="@android:color/white" @@ -295,8 +296,8 @@ android:id="@+id/captionTextView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="8dp" - android:layout_marginRight="8dp" + android:padding="6dp" + android:layout_marginEnd="8dp" android:gravity="center|left" android:minHeight="35dp" android:minWidth="50dp" @@ -314,13 +315,12 @@