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;
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 {

View file

@ -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

View file

@ -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() {

View file

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

View file

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