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:
Avently 2019-12-31 19:06:39 +03:00
parent fc9b63298c
commit bc2dc8d933
7 changed files with 109 additions and 84 deletions

View File

@ -1,12 +1,17 @@
package com.google.android.material.appbar; package com.google.android.material.appbar;
import android.content.Context; import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.OverScroller; import android.widget.OverScroller;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import org.jetbrains.annotations.NotNull;
import org.schabi.newpipe.R;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -17,21 +22,40 @@ public final class FlingBehavior extends AppBarLayout.Behavior {
super(context, attrs); super(context, attrs);
} }
private boolean allowScroll = true;
private Rect playQueueRect = new Rect();
@Override @Override
public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) { public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) {
switch (ev.getActionMasked()) { ViewGroup playQueue = child.findViewById(R.id.playQueue);
case MotionEvent.ACTION_DOWN: if (playQueue != null) {
// remove reference to old nested scrolling child playQueue.getGlobalVisibleRect(playQueueRect);
resetNestedScrollingChild(); if (playQueueRect.contains((int) ev.getX(), (int) ev.getY())) {
// Stop fling when your finger touches the screen allowScroll = false;
stopAppBarLayoutFling(); return false;
break; }
default: }
break; 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); 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 @Nullable
private OverScroller getScrollerField() { private OverScroller getScrollerField() {
try { try {

View File

@ -311,7 +311,6 @@ public class VideoDetailFragment
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setHasOptionsMenu(true); setHasOptionsMenu(true);
ThemeHelper.setTheme(getContext());
// Let's play all streams automatically // Let's play all streams automatically
setAutoplay(true); setAutoplay(true);
@ -953,14 +952,14 @@ public class VideoDetailFragment
showLoading(); showLoading();
initTabs(); initTabs();
if (scrollToTop) appBarLayout.setExpanded(true, true); if (scrollToTop) scrollToTop();
handleResult(info); handleResult(info);
showContent(); showContent();
} }
protected void prepareAndLoadInfo() { protected void prepareAndLoadInfo() {
appBarLayout.setExpanded(true, true); scrollToTop();
startLoading(false); startLoading(false);
} }
@ -1029,6 +1028,10 @@ public class VideoDetailFragment
} }
} }
public void scrollToTop() {
appBarLayout.setExpanded(true, true);
}
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Play Utils // Play Utils
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@ -1862,6 +1865,8 @@ public class VideoDetailFragment
// Disable click because overlay buttons located on top of buttons from the player // Disable click because overlay buttons located on top of buttons from the player
setOverlayElementsClickable(false); setOverlayElementsClickable(false);
hideSystemUIIfNeeded(); hideSystemUIIfNeeded();
if (isLandscape() && player != null && player.isPlaying() && !player.isInFullscreen())
player.toggleFullscreen();
break; break;
case BottomSheetBehavior.STATE_COLLAPSED: case BottomSheetBehavior.STATE_COLLAPSED:
// Re-enable clicks // Re-enable clicks

View File

@ -346,7 +346,8 @@ public class VideoPlayerImpl extends VideoPlayer
// Use smaller value to be consistent between screen orientations // Use smaller value to be consistent between screen orientations
// (and to make usage easier) // (and to make usage easier)
int width = r - l, height = b - t; 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); if (DEBUG) Log.d(TAG, "maxGestureLength = " + maxGestureLength);
@ -354,6 +355,7 @@ public class VideoPlayerImpl extends VideoPlayer
brightnessProgressBar.setMax(maxGestureLength); brightnessProgressBar.setMax(maxGestureLength);
setInitialGestureValues(); setInitialGestureValues();
queueLayout.getLayoutParams().height = min - queueLayout.getTop();
} }
}); });
} }
@ -620,8 +622,6 @@ public class VideoPlayerImpl extends VideoPlayer
DEFAULT_CONTROLS_DURATION); DEFAULT_CONTROLS_DURATION);
itemsList.scrollToPosition(playQueue.getIndex()); itemsList.scrollToPosition(playQueue.getIndex());
if (playQueue.getStreams().size() > 4 && !isInFullscreen()) toggleFullscreen();
} }
private void onQueueClosed() { private void onQueueClosed() {

View File

@ -292,7 +292,6 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen
playerImpl.showControlsThenHide(); playerImpl.showControlsThenHide();
} }
playerImpl.onPlayPause();
return true; return true;
} }

View File

@ -301,6 +301,7 @@ public class NavigationHelper {
VideoDetailFragment detailFragment = (VideoDetailFragment) fragment; VideoDetailFragment detailFragment = (VideoDetailFragment) fragment;
detailFragment.setAutoplay(autoPlay); detailFragment.setAutoplay(autoPlay);
detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue); detailFragment.selectAndLoadVideo(serviceId, url, title, playQueue);
detailFragment.scrollToTop();
return; return;
} }

View File

@ -149,6 +149,7 @@
android:background="@drawable/player_top_controls_bg" android:background="@drawable/player_top_controls_bg"
android:orientation="vertical" android:orientation="vertical"
android:gravity="top" android:gravity="top"
android:paddingTop="4dp"
android:baselineAligned="false" android:baselineAligned="false"
android:layout_toStartOf="@id/fullScreenButton"> android:layout_toStartOf="@id/fullScreenButton">
@ -158,7 +159,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:baselineAligned="false" android:baselineAligned="false"
android:gravity="top" android:gravity="top"
android:paddingTop="4dp"
android:paddingBottom="7dp" android:paddingBottom="7dp"
android:paddingLeft="2dp" android:paddingLeft="2dp"
android:paddingRight="6dp" android:paddingRight="6dp"
@ -170,7 +170,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="top" android:gravity="top"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="8dp" android:paddingTop="6dp"
android:paddingLeft="16dp"
android:paddingRight="8dp" android:paddingRight="8dp"
tools:ignore="RtlHardcoded" tools:ignore="RtlHardcoded"
android:layout_weight="1"> android:layout_weight="1">
@ -212,8 +213,9 @@
android:id="@+id/qualityTextView" android:id="@+id/qualityTextView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginLeft="2dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginStart="5dp"
android:layout_marginEnd="8dp"
android:gravity="center" android:gravity="center"
android:minWidth="50dp" android:minWidth="50dp"
android:text="720p" android:text="720p"
@ -227,7 +229,8 @@
android:id="@+id/playbackSpeed" android:id="@+id/playbackSpeed"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="2dp" android:padding="6dp"
android:layout_marginEnd="8dp"
android:gravity="center" android:gravity="center"
android:minHeight="35dp" android:minHeight="35dp"
android:minWidth="40dp" android:minWidth="40dp"
@ -241,11 +244,10 @@
android:id="@+id/queueButton" android:id="@+id/queueButton"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginLeft="2dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="5dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_list_white_24dp" android:src="@drawable/ic_list_white_24dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -256,8 +258,8 @@
android:id="@+id/moreOptionsButton" android:id="@+id/moreOptionsButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="2dp" android:padding="8dp"
android:padding="5dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:scaleType="fitXY" android:scaleType="fitXY"
@ -272,9 +274,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="top" android:gravity="top"
android:paddingTop="4dp" android:paddingStart="16dp"
android:paddingBottom="7dp"
android:paddingStart="6dp"
android:paddingEnd="6dp" android:paddingEnd="6dp"
android:visibility="invisible" android:visibility="invisible"
tools:ignore="RtlHardcoded" tools:ignore="RtlHardcoded"
@ -284,7 +284,8 @@
android:id="@+id/resizeTextView" android:id="@+id/resizeTextView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginRight="8dp" android:padding="6dp"
android:layout_marginEnd="8dp"
android:gravity="center" android:gravity="center"
android:minWidth="50dp" android:minWidth="50dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
@ -297,8 +298,8 @@
android:id="@+id/captionTextView" android:id="@+id/captionTextView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="8dp" android:padding="6dp"
android:layout_marginRight="8dp" android:layout_marginEnd="8dp"
android:gravity="center|left" android:gravity="center|left"
android:minHeight="35dp" android:minHeight="35dp"
android:minWidth="50dp" android:minWidth="50dp"
@ -316,13 +317,12 @@
<ImageButton <ImageButton
android:id="@+id/playWithKodi" android:id="@+id/playWithKodi"
android:layout_width="30dp" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="35dp"
android:layout_marginLeft="4dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="5dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_channel_white_24dp" android:src="@drawable/ic_channel_white_24dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -331,13 +331,12 @@
<ImageButton <ImageButton
android:id="@+id/openInBrowser" android:id="@+id/openInBrowser"
android:layout_width="30dp" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="35dp"
android:layout_marginLeft="4dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="5dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_language_white_24dp" android:src="@drawable/ic_language_white_24dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -346,13 +345,12 @@
<ImageButton <ImageButton
android:id="@+id/share" android:id="@+id/share"
android:layout_width="30dp" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="35dp"
android:layout_marginLeft="4dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="5dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_share_white_24dp" android:src="@drawable/ic_share_white_24dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -367,8 +365,8 @@
android:id="@+id/fullScreenButton" android:id="@+id/fullScreenButton"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_marginRight="4dp" android:paddingEnd="8dp"
android:padding="4dp" android:paddingTop="8dp"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:background="@drawable/player_top_controls_bg" android:background="@drawable/player_top_controls_bg"
android:clickable="true" android:clickable="true"
@ -387,7 +385,7 @@
android:background="@drawable/player_controls_bg" android:background="@drawable/player_controls_bg"
android:gravity="center" android:gravity="center"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingBottom="2dp" android:paddingBottom="6dp"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp"> android:paddingRight="16dp">

View File

@ -147,6 +147,7 @@
android:background="@drawable/player_top_controls_bg" android:background="@drawable/player_top_controls_bg"
android:orientation="vertical" android:orientation="vertical"
android:gravity="top" android:gravity="top"
android:paddingTop="4dp"
android:baselineAligned="false" android:baselineAligned="false"
android:layout_toStartOf="@id/fullScreenButton"> android:layout_toStartOf="@id/fullScreenButton">
@ -156,7 +157,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:baselineAligned="false" android:baselineAligned="false"
android:gravity="top" android:gravity="top"
android:paddingTop="4dp"
android:paddingBottom="7dp" android:paddingBottom="7dp"
android:paddingLeft="2dp" android:paddingLeft="2dp"
android:paddingRight="6dp" android:paddingRight="6dp"
@ -168,7 +168,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="top" android:gravity="top"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="8dp" android:paddingTop="6dp"
android:paddingLeft="16dp"
android:paddingRight="8dp" android:paddingRight="8dp"
tools:ignore="RtlHardcoded" tools:ignore="RtlHardcoded"
android:layout_weight="1"> android:layout_weight="1">
@ -210,8 +211,9 @@
android:id="@+id/qualityTextView" android:id="@+id/qualityTextView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginLeft="2dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginStart="5dp"
android:layout_marginEnd="8dp"
android:gravity="center" android:gravity="center"
android:minWidth="50dp" android:minWidth="50dp"
android:text="720p" android:text="720p"
@ -225,7 +227,8 @@
android:id="@+id/playbackSpeed" android:id="@+id/playbackSpeed"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="2dp" android:padding="6dp"
android:layout_marginEnd="8dp"
android:gravity="center" android:gravity="center"
android:minHeight="35dp" android:minHeight="35dp"
android:minWidth="40dp" android:minWidth="40dp"
@ -239,11 +242,10 @@
android:id="@+id/queueButton" android:id="@+id/queueButton"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginLeft="2dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="5dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_list_white_24dp" android:src="@drawable/ic_list_white_24dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -254,8 +256,8 @@
android:id="@+id/moreOptionsButton" android:id="@+id/moreOptionsButton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="2dp" android:padding="8dp"
android:padding="5dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:scaleType="fitXY" android:scaleType="fitXY"
@ -270,9 +272,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="top" android:gravity="top"
android:paddingTop="4dp" android:paddingStart="16dp"
android:paddingBottom="7dp"
android:paddingStart="6dp"
android:paddingEnd="6dp" android:paddingEnd="6dp"
android:visibility="invisible" android:visibility="invisible"
tools:ignore="RtlHardcoded" tools:ignore="RtlHardcoded"
@ -282,7 +282,8 @@
android:id="@+id/resizeTextView" android:id="@+id/resizeTextView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="35dp" android:layout_height="35dp"
android:layout_marginRight="8dp" android:padding="6dp"
android:layout_marginEnd="8dp"
android:gravity="center" android:gravity="center"
android:minWidth="50dp" android:minWidth="50dp"
android:textColor="@android:color/white" android:textColor="@android:color/white"
@ -295,8 +296,8 @@
android:id="@+id/captionTextView" android:id="@+id/captionTextView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="8dp" android:padding="6dp"
android:layout_marginRight="8dp" android:layout_marginEnd="8dp"
android:gravity="center|left" android:gravity="center|left"
android:minHeight="35dp" android:minHeight="35dp"
android:minWidth="50dp" android:minWidth="50dp"
@ -314,13 +315,12 @@
<ImageButton <ImageButton
android:id="@+id/playWithKodi" android:id="@+id/playWithKodi"
android:layout_width="30dp" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="35dp"
android:layout_marginLeft="4dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="5dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_channel_white_24dp" android:src="@drawable/ic_channel_white_24dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -329,13 +329,12 @@
<ImageButton <ImageButton
android:id="@+id/openInBrowser" android:id="@+id/openInBrowser"
android:layout_width="30dp" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="35dp"
android:layout_marginLeft="4dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="5dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_language_white_24dp" android:src="@drawable/ic_language_white_24dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -344,13 +343,12 @@
<ImageButton <ImageButton
android:id="@+id/share" android:id="@+id/share"
android:layout_width="30dp" android:layout_width="wrap_content"
android:layout_height="30dp" android:layout_height="35dp"
android:layout_marginLeft="4dp" android:padding="6dp"
android:layout_marginRight="2dp" android:layout_marginEnd="8dp"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:padding="5dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@drawable/ic_share_white_24dp" android:src="@drawable/ic_share_white_24dp"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -365,8 +363,8 @@
android:id="@+id/fullScreenButton" android:id="@+id/fullScreenButton"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_marginRight="4dp" android:paddingEnd="8dp"
android:padding="4dp" android:paddingTop="8dp"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:background="@drawable/player_top_controls_bg" android:background="@drawable/player_top_controls_bg"
android:clickable="true" android:clickable="true"
@ -385,7 +383,7 @@
android:background="@drawable/player_controls_bg" android:background="@drawable/player_controls_bg"
android:gravity="center" android:gravity="center"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingBottom="2dp" android:paddingBottom="6dp"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp"> android:paddingRight="16dp">