From 31751997872a07af96145f5083b2e747f880a929 Mon Sep 17 00:00:00 2001 From: TheLastGimbus Date: Tue, 14 Apr 2020 22:05:51 +0200 Subject: [PATCH 1/7] Add fast-rewind/forward buttons in layout --- .../layout/activity_player_queue_control.xml | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/activity_player_queue_control.xml b/app/src/main/res/layout/activity_player_queue_control.xml index d17a7007a..6a8b31f43 100644 --- a/app/src/main/res/layout/activity_player_queue_control.xml +++ b/app/src/main/res/layout/activity_player_queue_control.xml @@ -207,7 +207,7 @@ android:layout_height="40dp" android:layout_centerVertical="true" android:layout_marginLeft="5dp" - android:layout_toLeftOf="@+id/control_play_pause" + android:layout_toLeftOf="@+id/control_fast_rewind" android:background="?attr/selectableItemBackgroundBorderless" android:clickable="true" android:focusable="true" @@ -216,6 +216,20 @@ android:src="@drawable/exo_controls_previous" tools:ignore="ContentDescription"/> + + + + + Date: Tue, 14 Apr 2020 22:06:32 +0200 Subject: [PATCH 2/7] Add listeners in activity --- .../schabi/newpipe/player/ServicePlayerActivity.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 6841389f4..54022c0cb 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -84,7 +84,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity private ImageButton repeatButton; private ImageButton backwardButton; + private ImageButton fastRewindButton; private ImageButton playPauseButton; + private ImageButton fastForwardButton; private ImageButton forwardButton; private ImageButton shuffleButton; private ProgressBar progressBar; @@ -310,7 +312,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity private void buildControls() { repeatButton = rootView.findViewById(R.id.control_repeat); backwardButton = rootView.findViewById(R.id.control_backward); + fastRewindButton = rootView.findViewById(R.id.control_fast_rewind); playPauseButton = rootView.findViewById(R.id.control_play_pause); + fastForwardButton = rootView.findViewById(R.id.control_fast_forward); forwardButton = rootView.findViewById(R.id.control_forward); shuffleButton = rootView.findViewById(R.id.control_shuffle); playbackSpeedButton = rootView.findViewById(R.id.control_playback_speed); @@ -319,7 +323,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity repeatButton.setOnClickListener(this); backwardButton.setOnClickListener(this); + fastRewindButton.setOnClickListener(this); playPauseButton.setOnClickListener(this); + fastForwardButton.setOnClickListener(this); forwardButton.setOnClickListener(this); shuffleButton.setOnClickListener(this); playbackSpeedButton.setOnClickListener(this); @@ -473,8 +479,12 @@ public abstract class ServicePlayerActivity extends AppCompatActivity player.onRepeatClicked(); } else if (view.getId() == backwardButton.getId()) { player.onPlayPrevious(); + } else if (view.getId() == fastRewindButton.getId()) { + player.onFastRewind(); } else if (view.getId() == playPauseButton.getId()) { player.onPlayPause(); + } else if (view.getId() == fastForwardButton.getId()) { + player.onFastForward(); } else if (view.getId() == forwardButton.getId()) { player.onPlayNext(); } else if (view.getId() == shuffleButton.getId()) { From 1975973ff2192e1425a93b7f1e037d0f68833a69 Mon Sep 17 00:00:00 2001 From: TheLastGimbus Date: Sat, 25 Apr 2020 15:46:56 +0200 Subject: [PATCH 3/7] Update progress bar on fast forward/rewind --- app/src/main/java/org/schabi/newpipe/player/BasePlayer.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index ecae13290..2c8de9937 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -1129,6 +1129,7 @@ public abstract class BasePlayer implements Log.d(TAG, "onFastRewind() called"); } seekBy(-getSeekDuration()); + triggerProgressUpdate(); } public void onFastForward() { @@ -1136,6 +1137,7 @@ public abstract class BasePlayer implements Log.d(TAG, "onFastForward() called"); } seekBy(getSeekDuration()); + triggerProgressUpdate(); } private int getSeekDuration() { From 36b4134838b62797ceb34b96948f6f06ba9d39f2 Mon Sep 17 00:00:00 2001 From: TheLastGimbus Date: Sun, 14 Jun 2020 15:15:38 +0200 Subject: [PATCH 4/7] Remove speed buttons from bottom menu --- .../newpipe/player/ServicePlayerActivity.java | 15 +-------- .../layout/activity_player_queue_control.xml | 31 ------------------- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 54022c0cb..0d355d61f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -45,7 +45,6 @@ import org.schabi.newpipe.util.ThemeHelper; import java.util.Collections; import java.util.List; -import static org.schabi.newpipe.player.helper.PlayerHelper.formatPitch; import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed; import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; @@ -91,9 +90,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity private ImageButton shuffleButton; private ProgressBar progressBar; - private TextView playbackSpeedButton; - private TextView playbackPitchButton; - private Menu menu; //////////////////////////////////////////////////////////////////////////// @@ -317,8 +313,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity fastForwardButton = rootView.findViewById(R.id.control_fast_forward); forwardButton = rootView.findViewById(R.id.control_forward); shuffleButton = rootView.findViewById(R.id.control_shuffle); - playbackSpeedButton = rootView.findViewById(R.id.control_playback_speed); - playbackPitchButton = rootView.findViewById(R.id.control_playback_pitch); progressBar = rootView.findViewById(R.id.control_progress_bar); repeatButton.setOnClickListener(this); @@ -328,8 +322,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity fastForwardButton.setOnClickListener(this); forwardButton.setOnClickListener(this); shuffleButton.setOnClickListener(this); - playbackSpeedButton.setOnClickListener(this); - playbackPitchButton.setOnClickListener(this); } private void buildItemPopupMenu(final PlayQueueItem item, final View view) { @@ -489,10 +481,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity player.onPlayNext(); } else if (view.getId() == shuffleButton.getId()) { player.onShuffleClicked(); - } else if (view.getId() == playbackSpeedButton.getId()) { - openPlaybackParameterDialog(); - } else if (view.getId() == playbackPitchButton.getId()) { - openPlaybackParameterDialog(); } else if (view.getId() == metadata.getId()) { scrollToSelected(); } else if (view.getId() == progressLiveSync.getId()) { @@ -700,8 +688,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity private void onPlaybackParameterChanged(final PlaybackParameters parameters) { if (parameters != null) { - playbackSpeedButton.setText(formatSpeed(parameters.speed)); - playbackPitchButton.setText(formatPitch(parameters.pitch)); + Log.d("Dupa", "12"); } } diff --git a/app/src/main/res/layout/activity_player_queue_control.xml b/app/src/main/res/layout/activity_player_queue_control.xml index 6a8b31f43..dbe3d718a 100644 --- a/app/src/main/res/layout/activity_player_queue_control.xml +++ b/app/src/main/res/layout/activity_player_queue_control.xml @@ -169,22 +169,6 @@ android:orientation="horizontal" tools:ignore="RtlHardcoded"> - - - \ No newline at end of file From 72af51fe9d2256aa8bb39d90c58f83bea2a42d94 Mon Sep 17 00:00:00 2001 From: TheLastGimbus Date: Sun, 14 Jun 2020 15:16:04 +0200 Subject: [PATCH 5/7] Add speed button to top bar --- .../org/schabi/newpipe/player/ServicePlayerActivity.java | 8 +++++++- app/src/main/res/menu/menu_play_queue.xml | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 0d355d61f..195f0da95 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -164,6 +164,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity case R.id.action_append_playlist: appendAllToPlaylist(); return true; + case R.id.action_playback_speed: + openPlaybackParameterDialog(); + return true; case R.id.action_mute: player.onMuteUnmuteButtonClicked(); return true; @@ -688,7 +691,10 @@ public abstract class ServicePlayerActivity extends AppCompatActivity private void onPlaybackParameterChanged(final PlaybackParameters parameters) { if (parameters != null) { - Log.d("Dupa", "12"); + if (menu != null && player != null) { + MenuItem item = menu.findItem(R.id.action_playback_speed); + item.setTitle(formatSpeed(parameters.speed)); + } } } diff --git a/app/src/main/res/menu/menu_play_queue.xml b/app/src/main/res/menu/menu_play_queue.xml index fc3fd07a8..76385a140 100644 --- a/app/src/main/res/menu/menu_play_queue.xml +++ b/app/src/main/res/menu/menu_play_queue.xml @@ -10,6 +10,14 @@ android:visible="true" app:showAsAction="ifRoom"/> + + + Date: Sun, 14 Jun 2020 19:52:58 +0200 Subject: [PATCH 6/7] Change to final --- .../java/org/schabi/newpipe/player/ServicePlayerActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 195f0da95..a957eb28d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -692,7 +692,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity private void onPlaybackParameterChanged(final PlaybackParameters parameters) { if (parameters != null) { if (menu != null && player != null) { - MenuItem item = menu.findItem(R.id.action_playback_speed); + final MenuItem item = menu.findItem(R.id.action_playback_speed); item.setTitle(formatSpeed(parameters.speed)); } } From 63e167b38e76122eedfbb0cd5412cb825d68988e Mon Sep 17 00:00:00 2001 From: TheLastGimbus Date: Sun, 14 Jun 2020 23:22:31 +0200 Subject: [PATCH 7/7] Add buttons also in landscape mode --- .../activity_player_queue_control.xml | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/app/src/main/res/layout-land/activity_player_queue_control.xml b/app/src/main/res/layout-land/activity_player_queue_control.xml index 6468c6784..40229e329 100644 --- a/app/src/main/res/layout-land/activity_player_queue_control.xml +++ b/app/src/main/res/layout-land/activity_player_queue_control.xml @@ -111,7 +111,7 @@ tools:ignore="RtlHardcoded"> @@ -161,7 +161,7 @@ android:visibility="invisible"/> @@ -185,8 +185,8 @@ android:orientation="horizontal" tools:ignore="RtlHardcoded"> - + android:background="?attr/selectableItemBackgroundBorderless" + android:clickable="true" + android:focusable="true" + android:scaleType="fitXY" + android:src="@drawable/exo_controls_previous" + android:tint="?attr/colorAccent" + tools:ignore="ContentDescription" /> - + android:background="?attr/selectableItemBackgroundBorderless" + android:clickable="true" + android:focusable="true" + android:scaleType="fitXY" + android:src="@drawable/exo_controls_next" + android:tint="?attr/colorAccent" + tools:ignore="ContentDescription" />