From bff238774ec3a92fe84289d300e7c476b0e9daab Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Mon, 13 Jul 2020 23:28:39 +0300 Subject: [PATCH] Small fixes of issues --- .../fragments/detail/VideoDetailFragment.java | 9 ++------- .../schabi/newpipe/player/VideoPlayerImpl.java | 17 +++++++++-------- .../player/event/PlayerGestureListener.java | 8 ++++++-- .../layout-large-land/activity_main_player.xml | 18 +++++++----------- .../main/res/layout/activity_main_player.xml | 4 ++-- 5 files changed, 26 insertions(+), 30 deletions(-) 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 ce6bd72f5..396363d31 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 @@ -470,11 +470,6 @@ public class VideoDetailFragment @Override public void onSaveInstanceState(final Bundle outState) { super.onSaveInstanceState(outState); - - // Check if the next video label and video is visible, - // if it is, include the two elements in the next check - int nextCount = currentInfo != null && currentInfo.getNextVideo() != null ? 2 : 0; - if (!isLoading.get() && currentInfo != null && isVisible()) { outState.putSerializable(INFO_KEY, currentInfo); } @@ -947,12 +942,12 @@ public class VideoDetailFragment getString(R.string.show_age_restricted_content), false)) { hideAgeRestrictedContent(); } else { - currentInfo = result; handleResult(result); showContent(); if (addToBackStack) { if (playQueue == null) playQueue = new SinglePlayQueue(result); - stack.push(new StackItem(serviceId, url, name, playQueue)); + if (stack.isEmpty() || !stack.peek().getPlayQueue().equals(playQueue)) + stack.push(new StackItem(serviceId, url, name, playQueue)); } if (isAutoplayEnabled()) openVideoPlayer(); } 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 1b72d7a96..d102a93ec 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -351,6 +351,7 @@ public class VideoPlayerImpl extends VideoPlayer titleTextView.setVisibility(View.VISIBLE); channelTextView.setVisibility(View.VISIBLE); } + setMuteButton(muteButton, isMuted()); animateRotation(moreOptionsButton, DEFAULT_CONTROLS_DURATION, 0); } @@ -960,12 +961,12 @@ public class VideoPlayerImpl extends VideoPlayer @Override public void onBlocked() { super.onBlocked(); - playPauseButton.setImageResource(R.drawable.exo_controls_play); + playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp); animatePlayButtons(false, 100); getRootView().setKeepScreenOn(false); service.resetNotification(); - service.updateNotification(R.drawable.exo_controls_play); + service.updateNotification(R.drawable.ic_play_arrow_white_24dp); } @Override @@ -974,14 +975,14 @@ public class VideoPlayerImpl extends VideoPlayer getRootView().setKeepScreenOn(true); service.resetNotification(); - service.updateNotification(R.drawable.exo_controls_play); + service.updateNotification(R.drawable.ic_play_arrow_white_24dp); } @Override public void onPlaying() { super.onPlaying(); animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, () -> { - playPauseButton.setImageResource(R.drawable.exo_controls_pause); + playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp); animatePlayButtons(true, 200); playPauseButton.requestFocus(); }); @@ -991,7 +992,7 @@ public class VideoPlayerImpl extends VideoPlayer getRootView().setKeepScreenOn(true); service.resetNotification(); - service.updateNotification(R.drawable.exo_controls_pause); + service.updateNotification(R.drawable.ic_pause_white_24dp); service.startForeground(NOTIFICATION_ID, service.getNotBuilder().build()); } @@ -1000,7 +1001,7 @@ public class VideoPlayerImpl extends VideoPlayer public void onPaused() { super.onPaused(); animateView(playPauseButton, AnimationUtils.Type.SCALE_AND_ALPHA, false, 80, 0, () -> { - playPauseButton.setImageResource(R.drawable.exo_controls_play); + playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp); animatePlayButtons(true, 200); playPauseButton.requestFocus(); }); @@ -1008,7 +1009,7 @@ public class VideoPlayerImpl extends VideoPlayer updateWindowFlags(IDLE_WINDOW_FLAGS); service.resetNotification(); - service.updateNotification(R.drawable.exo_controls_play); + service.updateNotification(R.drawable.ic_play_arrow_white_24dp); // Remove running notification when user don't want music (or video in popup) to be played in background if (!minimizeOnPopupEnabled() && !backgroundPlaybackEnabled() && videoPlayerSelected()) @@ -1024,7 +1025,7 @@ public class VideoPlayerImpl extends VideoPlayer getRootView().setKeepScreenOn(true); service.resetNotification(); - service.updateNotification(R.drawable.exo_controls_play); + service.updateNotification(R.drawable.ic_play_arrow_white_24dp); } 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 d7bc3a6a0..559a4d02b 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 @@ -175,7 +175,11 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen isMovingInMain = true; - if (isVolumeGestureEnabled && initialEvent.getX() > playerImpl.getRootView().getWidth() / 2.0) { + boolean acceptAnyArea = isVolumeGestureEnabled != isBrightnessGestureEnabled; + boolean acceptVolumeArea = acceptAnyArea + || initialEvent.getX() > playerImpl.getRootView().getWidth() / 2.0; + + if (isVolumeGestureEnabled && acceptVolumeArea) { playerImpl.getVolumeProgressBar().incrementProgressBy((int) distanceY); final float currentProgressPercent = (float) playerImpl.getVolumeProgressBar().getProgress() / playerImpl.getMaxGestureLength(); @@ -197,7 +201,7 @@ public class PlayerGestureListener extends GestureDetector.SimpleOnGestureListen if (playerImpl.getBrightnessRelativeLayout().getVisibility() == View.VISIBLE) { playerImpl.getBrightnessRelativeLayout().setVisibility(View.GONE); } - } else if (isBrightnessGestureEnabled && initialEvent.getX() <= playerImpl.getRootView().getWidth() / 2.0) { + } else { final Activity parent = playerImpl.getParentActivity(); if (parent == null) return true; 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 1ee2538c0..1a4e6b4e4 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 @@ -42,7 +42,6 @@ android:id="@+id/playQueuePanel" android:layout_width="380dp" android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" android:layout_height="match_parent" android:visibility="gone" android:background="?attr/queue_background_color" @@ -58,9 +57,7 @@ android:layout_width="50dp" android:layout_height="50dp" android:layout_centerVertical="true" - android:layout_alignParentRight="true" android:layout_alignParentEnd="true" - android:layout_marginRight="40dp" android:layout_marginEnd="40dp" android:padding="10dp" android:clickable="true" @@ -88,7 +85,6 @@ android:src="@drawable/exo_controls_repeat_off" android:background="?android:selectableItemBackground" tools:ignore="ContentDescription,RtlHardcoded"/> - @@ -223,9 +218,10 @@