From 88c72a45f785891ad632daed874563708821c9d0 Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sat, 12 Nov 2022 16:31:44 +0000 Subject: [PATCH 1/6] Added restart icon and change miniplayer to it when video is finished. --- .../libretube/ui/fragments/PlayerFragment.kt | 21 ++++++++++++------- app/src/main/res/drawable/ic_restart.xml | 10 +++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/ic_restart.xml diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index df0195ffe..c157a0913 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -816,13 +816,20 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { if (binding.player.autoplayEnabled) playNextVideo() } - if (playbackState == Player.STATE_READY) { - // media actually playing - transitioning = false - binding.playImageView.setImageResource(R.drawable.ic_pause) - } else { - // player paused in any state - binding.playImageView.setImageResource(R.drawable.ic_play) + when (playbackState) { + Player.STATE_READY -> { + // media actually playing + transitioning = false + binding.playImageView.setImageResource(R.drawable.ic_pause) + } + Player.STATE_ENDED -> { + // video has finished + binding.playImageView.setImageResource(R.drawable.ic_restart) + } + else -> { + // player in any other state + binding.playImageView.setImageResource(R.drawable.ic_play) + } } // save the watch position when paused diff --git a/app/src/main/res/drawable/ic_restart.xml b/app/src/main/res/drawable/ic_restart.xml new file mode 100644 index 000000000..4acff846b --- /dev/null +++ b/app/src/main/res/drawable/ic_restart.xml @@ -0,0 +1,10 @@ + + + From cf8288b538d7bc70f01c3cd7d6a0e89074c69afd Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sat, 12 Nov 2022 16:45:52 +0000 Subject: [PATCH 2/6] Miniplayer can now restart video if autoplay is not set. --- .../java/com/github/libretube/ui/fragments/PlayerFragment.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index c157a0913..64289add2 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -306,6 +306,10 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { if (!exoPlayer.isPlaying) { // start or go on playing binding.playImageView.setImageResource(R.drawable.ic_pause) + if (exoPlayer.playbackState == Player.STATE_ENDED) { + // restart video if finished + exoPlayer.seekTo(0); + } exoPlayer.play() } else { // pause the video From 5b5d5b8bab4be02a6a58e6c9ca6d905ad1159dce Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sat, 12 Nov 2022 17:27:39 +0000 Subject: [PATCH 3/6] Added LibreTube icon to notification. --- .../main/res/drawable/ic_launcher_lockscreen.xml | 13 +++++++++++++ app/src/main/res/values/drawables.xml | 1 + 2 files changed, 14 insertions(+) create mode 100644 app/src/main/res/drawable/ic_launcher_lockscreen.xml diff --git a/app/src/main/res/drawable/ic_launcher_lockscreen.xml b/app/src/main/res/drawable/ic_launcher_lockscreen.xml new file mode 100644 index 000000000..1c2eb3863 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_lockscreen.xml @@ -0,0 +1,13 @@ + + + + diff --git a/app/src/main/res/values/drawables.xml b/app/src/main/res/values/drawables.xml index ba8b31ed0..6f99af375 100644 --- a/app/src/main/res/values/drawables.xml +++ b/app/src/main/res/values/drawables.xml @@ -3,5 +3,6 @@ @drawable/ic_play @drawable/ic_pause + @drawable/ic_launcher_lockscreen \ No newline at end of file From b42846de6c76d6b3413b583b8e327257b053c31a Mon Sep 17 00:00:00 2001 From: GilesMunn Date: Sat, 12 Nov 2022 17:38:58 +0000 Subject: [PATCH 4/6] Miniplayer now shows proper replay button. Partially solves #1811. --- .../java/com/github/libretube/ui/fragments/PlayerFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index 64289add2..1a41f6441 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -308,7 +308,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { binding.playImageView.setImageResource(R.drawable.ic_pause) if (exoPlayer.playbackState == Player.STATE_ENDED) { // restart video if finished - exoPlayer.seekTo(0); + exoPlayer.seekTo(0) } exoPlayer.play() } else { From 11ec5bef68c68bef17548a4bdd8c541e6735b277 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 12 Nov 2022 19:25:43 +0100 Subject: [PATCH 5/6] some visual changes --- app/src/main/res/drawable/ic_forward.xml | 4 ++-- app/src/main/res/drawable/ic_restart.xml | 2 ++ app/src/main/res/drawable/ic_rewind.xml | 4 ++-- app/src/main/res/layout/double_tap_overlay.xml | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/drawable/ic_forward.xml b/app/src/main/res/drawable/ic_forward.xml index 1f165a420..580ecf823 100644 --- a/app/src/main/res/drawable/ic_forward.xml +++ b/app/src/main/res/drawable/ic_forward.xml @@ -1,6 +1,6 @@ diff --git a/app/src/main/res/drawable/ic_restart.xml b/app/src/main/res/drawable/ic_restart.xml index 4acff846b..576fccffe 100644 --- a/app/src/main/res/drawable/ic_restart.xml +++ b/app/src/main/res/drawable/ic_restart.xml @@ -6,5 +6,7 @@ android:viewportHeight="24"> diff --git a/app/src/main/res/drawable/ic_rewind.xml b/app/src/main/res/drawable/ic_rewind.xml index 843bba82b..abb2576c5 100644 --- a/app/src/main/res/drawable/ic_rewind.xml +++ b/app/src/main/res/drawable/ic_rewind.xml @@ -1,6 +1,6 @@ diff --git a/app/src/main/res/layout/double_tap_overlay.xml b/app/src/main/res/layout/double_tap_overlay.xml index 717b05544..3f9cab4d3 100644 --- a/app/src/main/res/layout/double_tap_overlay.xml +++ b/app/src/main/res/layout/double_tap_overlay.xml @@ -34,7 +34,7 @@ android:layout_gravity="center" android:layout_marginTop="2dp" android:textColor="@android:color/white" - android:textSize="11sp" /> + android:textSize="12sp" /> @@ -75,7 +75,7 @@ android:layout_gravity="center" android:layout_marginTop="2dp" android:textColor="@android:color/white" - android:textSize="11sp" /> + android:textSize="12sp" /> From ce95a33fe18d2dea106b4e3f5c68f2ae2cab8807 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 12 Nov 2022 19:26:59 +0100 Subject: [PATCH 6/6] use the lockscreen icon for all notifications --- .../java/com/github/libretube/workers/NotificationWorker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt b/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt index 5320780e5..1c4c85466 100644 --- a/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt +++ b/app/src/main/java/com/github/libretube/workers/NotificationWorker.kt @@ -177,7 +177,7 @@ class NotificationWorker(appContext: Context, parameters: WorkerParameters) : val builder = NotificationCompat.Builder(applicationContext, PUSH_CHANNEL_ID) .setContentTitle(title) .setGroup(group) - .setSmallIcon(R.drawable.ic_notification) + .setSmallIcon(R.drawable.ic_launcher_lockscreen) .setPriority(NotificationCompat.PRIORITY_DEFAULT) // Set the intent that will fire when the user taps the notification .setContentIntent(pendingIntent)