mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-26 10:00:39 +00:00
First block of fixes for review
- popup player click event changed to show/hide buttons - queue panel WORKS. Finally - removed theme overriding in fragment - added scroll to top after stream selection - adjusted padding/margin of buttons in player - player will itself in fullscreen after user hides it in fullscreen mode and then expands it again while video still playing
This commit is contained in:
parent
fc9b63298c
commit
bc2dc8d933
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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() {
|
||||
|
@ -292,7 +292,6 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen
|
||||
playerImpl.showControlsThenHide();
|
||||
|
||||
}
|
||||
playerImpl.onPlayPause();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -301,6 +301,7 @@ public class NavigationHelper {
|
||||
VideoDetailFragment detailFragment = (VideoDetailFragment) fragment;
|
||||
detailFragment.setAutoplay(autoPlay);
|
||||
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
|
||||
detailFragment.scrollToTop();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/playWithKodi"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:padding="6dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_channel_white_24dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
@ -331,13 +331,12 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/openInBrowser"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:padding="6dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_language_white_24dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
@ -346,13 +345,12 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/share"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:padding="6dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_share_white_24dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
@ -367,8 +365,8 @@
|
||||
android:id="@+id/fullScreenButton"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:padding="4dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/player_top_controls_bg"
|
||||
android:clickable="true"
|
||||
@ -387,7 +385,7 @@
|
||||
android:background="@drawable/player_controls_bg"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
|
@ -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 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/playWithKodi"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:padding="6dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_channel_white_24dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
@ -329,13 +329,12 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/openInBrowser"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:padding="6dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_language_white_24dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
@ -344,13 +343,12 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/share"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="35dp"
|
||||
android:padding="6dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_share_white_24dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
@ -365,8 +363,8 @@
|
||||
android:id="@+id/fullScreenButton"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:padding="4dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:background="@drawable/player_top_controls_bg"
|
||||
android:clickable="true"
|
||||
@ -385,7 +383,7 @@
|
||||
android:background="@drawable/player_controls_bg"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user