From 4ef4cf33d5bc4f857ba14c81a0d7443850153c83 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 14 Aug 2023 15:21:36 +0200 Subject: [PATCH 1/8] feat:(queue): add tooltips --- .../github/libretube/ui/sheets/PlayingQueueSheet.kt | 13 +++++++++++++ app/src/main/res/layout/queue_bottom_sheet.xml | 1 + app/src/main/res/values/strings.xml | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index 9b4724c00..8f5cdc7f8 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -1,6 +1,7 @@ package com.github.libretube.ui.sheets import android.annotation.SuppressLint +import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -49,6 +50,18 @@ class PlayingQueueSheet : ExpandedBottomSheet() { val currentPlayingIndex = PlayingQueue.currentIndex() if (currentPlayingIndex != -1) binding.optionsRecycler.scrollToPosition(currentPlayingIndex) + // tooltips are only supported since API 26 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + binding.repeat.tooltipText = getString(R.string.repeat) + binding.shuffle.tooltipText = getString(R.string.shuffle) + binding.reverse.tooltipText = getString(R.string.reverse) + binding.addToPlaylist.tooltipText = getString(R.string.addToPlaylist) + binding.sort.tooltipText = getString(R.string.sort) + binding.watchPositionsOptions.tooltipText = getString(R.string.watch_position) + binding.clearQueue.tooltipText = getString(R.string.clear_queue) + binding.dismiss?.tooltipText = getString(R.string.dismiss) + } + binding.shuffle.setOnClickListener { val streams = PlayingQueue.getStreams().toMutableList() val currentIndex = PlayingQueue.currentIndex() diff --git a/app/src/main/res/layout/queue_bottom_sheet.xml b/app/src/main/res/layout/queue_bottom_sheet.xml index 63f94d7d0..4761258e9 100644 --- a/app/src/main/res/layout/queue_bottom_sheet.xml +++ b/app/src/main/res/layout/queue_bottom_sheet.xml @@ -73,6 +73,7 @@ android:src="@drawable/ic_close" /> %d new stream %d new streams + + + Repeat + Reverse + Sort + Watch position + Clear queue + Dismiss \ No newline at end of file From 7052c621bcc16ae8f9f873eb09032909ae3d6530 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 14 Aug 2023 15:49:49 +0200 Subject: [PATCH 2/8] feat(player): add tooltips player buttons --- .../libretube/ui/sheets/PlayingQueueSheet.kt | 13 --- .../libretube/ui/views/CustomExoPlayerView.kt | 13 ++- .../res/layout-v26/queue_bottom_sheet.xml | 88 +++++++++++++++++++ .../layout/exo_styled_player_control_view.xml | 6 ++ app/src/main/res/layout/fragment_player.xml | 2 + .../main/res/layout/queue_bottom_sheet.xml | 8 ++ app/src/main/res/values/strings.xml | 22 +++-- 7 files changed, 126 insertions(+), 26 deletions(-) create mode 100644 app/src/main/res/layout-v26/queue_bottom_sheet.xml diff --git a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt index 8f5cdc7f8..9b4724c00 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/PlayingQueueSheet.kt @@ -1,7 +1,6 @@ package com.github.libretube.ui.sheets import android.annotation.SuppressLint -import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -50,18 +49,6 @@ class PlayingQueueSheet : ExpandedBottomSheet() { val currentPlayingIndex = PlayingQueue.currentIndex() if (currentPlayingIndex != -1) binding.optionsRecycler.scrollToPosition(currentPlayingIndex) - // tooltips are only supported since API 26 - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - binding.repeat.tooltipText = getString(R.string.repeat) - binding.shuffle.tooltipText = getString(R.string.shuffle) - binding.reverse.tooltipText = getString(R.string.reverse) - binding.addToPlaylist.tooltipText = getString(R.string.addToPlaylist) - binding.sort.tooltipText = getString(R.string.sort) - binding.watchPositionsOptions.tooltipText = getString(R.string.watch_position) - binding.clearQueue.tooltipText = getString(R.string.clear_queue) - binding.dismiss?.tooltipText = getString(R.string.dismiss) - } - binding.shuffle.setOnClickListener { val streams = PlayingQueue.getStreams().toMutableList() val currentIndex = PlayingQueue.currentIndex() diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index ed33c0a59..4080717a4 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -5,6 +5,7 @@ import android.app.Activity import android.content.Context import android.content.res.Configuration import android.graphics.Color +import android.os.Build import android.os.Handler import android.os.Looper import android.text.format.DateUtils @@ -127,13 +128,11 @@ open class CustomExoPlayerView( // locking the player binding.lockPlayer.setOnClickListener { // change the locked/unlocked icon - binding.lockPlayer.setImageResource( - if (!isPlayerLocked) { - R.drawable.ic_locked - } else { - R.drawable.ic_unlocked - } - ) + val icon = if (!isPlayerLocked) R.drawable.ic_locked else R.drawable.ic_unlocked; + val tooltip = if (!isPlayerLocked) R.string.tooltip_unlocked else R.string.tooltip_locked; + binding.lockPlayer.setImageResource(icon) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) + binding.lockPlayer.tooltipText = context.getString(tooltip) // show/hide all the controls lockPlayer(isPlayerLocked) diff --git a/app/src/main/res/layout-v26/queue_bottom_sheet.xml b/app/src/main/res/layout-v26/queue_bottom_sheet.xml new file mode 100644 index 000000000..c739db968 --- /dev/null +++ b/app/src/main/res/layout-v26/queue_bottom_sheet.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/exo_styled_player_control_view.xml b/app/src/main/res/layout/exo_styled_player_control_view.xml index 59af57a25..8fd0f3b3c 100644 --- a/app/src/main/res/layout/exo_styled_player_control_view.xml +++ b/app/src/main/res/layout/exo_styled_player_control_view.xml @@ -32,6 +32,7 @@ @@ -311,6 +316,7 @@ diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index c35ce684d..ce02638df 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -367,6 +367,7 @@ - Repeat - Reverse - Sort - Watch position - Clear queue - Dismiss + Repeat + Reverse + Sort + Watch position + Clear queue + Dismiss + + + Lock player + Unlock player + Toggle Sponsorblock + Options + Minimze + Fullscreen + Close + Play \ No newline at end of file From ca9990d700692ed0c2409450f8c6fd576e3f5894 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 14 Aug 2023 18:15:02 +0200 Subject: [PATCH 3/8] feat: add tooltips channels --- app/src/main/res/layout/fragment_channel.xml | 2 ++ app/src/main/res/values/strings.xml | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout/fragment_channel.xml b/app/src/main/res/layout/fragment_channel.xml index 7ad2cf94f..bde329a77 100644 --- a/app/src/main/res/layout/fragment_channel.xml +++ b/app/src/main/res/layout/fragment_channel.xml @@ -72,12 +72,14 @@ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 44951c874..23005827b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -487,15 +487,13 @@ %d new streams - + Repeat Reverse Sort Watch position Clear queue Dismiss - - Lock player Unlock player Toggle Sponsorblock From f506a75a2abe11029f6830b8d3d42cdfd642f985 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 14 Aug 2023 18:19:59 +0200 Subject: [PATCH 4/8] feat: add tooltips to subscription fragment --- app/src/main/res/layout/exo_styled_player_control_view.xml | 2 +- app/src/main/res/layout/fragment_subscriptions.xml | 3 +++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/exo_styled_player_control_view.xml b/app/src/main/res/layout/exo_styled_player_control_view.xml index 8fd0f3b3c..be215a963 100644 --- a/app/src/main/res/layout/exo_styled_player_control_view.xml +++ b/app/src/main/res/layout/exo_styled_player_control_view.xml @@ -69,7 +69,7 @@ Fullscreen Close Play + Filter + Edit groups \ No newline at end of file From 432c88bc4cebc9d2cef25dafec2c49eec703d71b Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 14 Aug 2023 18:22:10 +0200 Subject: [PATCH 5/8] feat: add tooltips to library --- app/src/main/res/layout/fragment_library.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 3 insertions(+) diff --git a/app/src/main/res/layout/fragment_library.xml b/app/src/main/res/layout/fragment_library.xml index 20e4c903d..53a2df5ba 100644 --- a/app/src/main/res/layout/fragment_library.xml +++ b/app/src/main/res/layout/fragment_library.xml @@ -96,6 +96,7 @@ Play Filter Edit groups + Create playlist \ No newline at end of file From bfa99d2b7ef66e722cb9d18648d0c9639b3bc92b Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 14 Aug 2023 18:23:15 +0200 Subject: [PATCH 6/8] feat: add tooltip to channel subscription --- app/src/main/res/layout/channel_subscription_row.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/res/layout/channel_subscription_row.xml b/app/src/main/res/layout/channel_subscription_row.xml index 068b52d2d..4c1114279 100644 --- a/app/src/main/res/layout/channel_subscription_row.xml +++ b/app/src/main/res/layout/channel_subscription_row.xml @@ -30,6 +30,7 @@ Date: Mon, 14 Aug 2023 18:27:47 +0200 Subject: [PATCH 7/8] feat: add tooltips to commentsheet --- app/src/main/res/layout/comments_sheet.xml | 2 ++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 3 insertions(+) diff --git a/app/src/main/res/layout/comments_sheet.xml b/app/src/main/res/layout/comments_sheet.xml index d17114b65..840def92e 100644 --- a/app/src/main/res/layout/comments_sheet.xml +++ b/app/src/main/res/layout/comments_sheet.xml @@ -54,6 +54,7 @@ Filter Edit groups Create playlist + Scroll to top \ No newline at end of file From e5efe97693da5120cb319d6ab55702ea2ea5a0f5 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Mon, 14 Aug 2023 18:40:52 +0200 Subject: [PATCH 8/8] feat: add tooltips to playback sheet --- .../github/libretube/helpers/ImportHelper.kt | 2 +- .../ui/dialogs/AddToPlaylistDialog.kt | 6 +- .../libretube/ui/extensions/TrySetTooltip.kt | 15 ++++ .../libretube/ui/views/CustomExoPlayerView.kt | 14 +-- .../res/layout-v26/queue_bottom_sheet.xml | 88 ------------------- .../main/res/layout/playback_bottom_sheet.xml | 2 + 6 files changed, 32 insertions(+), 95 deletions(-) create mode 100644 app/src/main/java/com/github/libretube/ui/extensions/TrySetTooltip.kt delete mode 100644 app/src/main/res/layout-v26/queue_bottom_sheet.xml diff --git a/app/src/main/java/com/github/libretube/helpers/ImportHelper.kt b/app/src/main/java/com/github/libretube/helpers/ImportHelper.kt index f6a1d2b32..3294ac40c 100644 --- a/app/src/main/java/com/github/libretube/helpers/ImportHelper.kt +++ b/app/src/main/java/com/github/libretube/helpers/ImportHelper.kt @@ -19,11 +19,11 @@ import com.github.libretube.obj.NewPipeSubscription import com.github.libretube.obj.NewPipeSubscriptions import com.github.libretube.obj.PipedImportPlaylist import com.github.libretube.obj.PipedImportPlaylistFile +import java.util.stream.Collectors import kotlin.streams.toList import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.decodeFromStream import kotlinx.serialization.json.encodeToStream -import java.util.stream.Collectors object ImportHelper { /** diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt index 42452f6cc..079c7a2bb 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt @@ -62,7 +62,11 @@ class AddToPlaylistDialog( if (playlists.isEmpty()) return@repeatOnLifecycle binding.playlistsSpinner.adapter = - ArrayAdapter(requireContext(), R.layout.dropdown_item, playlists.map { it.name!! }) + ArrayAdapter( + requireContext(), + R.layout.dropdown_item, + playlists.map { it.name!! } + ) // select the last used playlist viewModel.lastSelectedPlaylistId?.let { id -> diff --git a/app/src/main/java/com/github/libretube/ui/extensions/TrySetTooltip.kt b/app/src/main/java/com/github/libretube/ui/extensions/TrySetTooltip.kt new file mode 100644 index 000000000..f5860cfe4 --- /dev/null +++ b/app/src/main/java/com/github/libretube/ui/extensions/TrySetTooltip.kt @@ -0,0 +1,15 @@ +package com.github.libretube.ui.extensions + +import android.os.Build +import android.widget.ImageView + +/** + * Attempts to set the tooltip for the ImageView. + * If the OS does not support tooltips, this function will have no effect. + * @param tooltip The tooltip of the image + */ +fun ImageView.trySetTooltip(tooltip: String) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + tooltipText = tooltip + } +} diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index 4080717a4..01250cdbd 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -5,7 +5,6 @@ import android.app.Activity import android.content.Context import android.content.res.Configuration import android.graphics.Color -import android.os.Build import android.os.Handler import android.os.Looper import android.text.format.DateUtils @@ -50,6 +49,7 @@ import com.github.libretube.helpers.PreferenceHelper import com.github.libretube.obj.BottomSheetItem import com.github.libretube.ui.base.BaseActivity import com.github.libretube.ui.extensions.toggleSystemBars +import com.github.libretube.ui.extensions.trySetTooltip import com.github.libretube.ui.interfaces.PlayerGestureOptions import com.github.libretube.ui.interfaces.PlayerOptions import com.github.libretube.ui.listeners.PlayerGestureController @@ -128,11 +128,15 @@ open class CustomExoPlayerView( // locking the player binding.lockPlayer.setOnClickListener { // change the locked/unlocked icon - val icon = if (!isPlayerLocked) R.drawable.ic_locked else R.drawable.ic_unlocked; - val tooltip = if (!isPlayerLocked) R.string.tooltip_unlocked else R.string.tooltip_locked; + val icon = if (!isPlayerLocked) R.drawable.ic_locked else R.drawable.ic_unlocked + val tooltip = if (!isPlayerLocked) { + R.string.tooltip_unlocked + } else { + R.string.tooltip_locked + } + binding.lockPlayer.setImageResource(icon) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) - binding.lockPlayer.tooltipText = context.getString(tooltip) + binding.lockPlayer.trySetTooltip(context.getString(tooltip)) // show/hide all the controls lockPlayer(isPlayerLocked) diff --git a/app/src/main/res/layout-v26/queue_bottom_sheet.xml b/app/src/main/res/layout-v26/queue_bottom_sheet.xml deleted file mode 100644 index c739db968..000000000 --- a/app/src/main/res/layout-v26/queue_bottom_sheet.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/playback_bottom_sheet.xml b/app/src/main/res/layout/playback_bottom_sheet.xml index 1d6c3c50b..063ba4e2d 100644 --- a/app/src/main/res/layout/playback_bottom_sheet.xml +++ b/app/src/main/res/layout/playback_bottom_sheet.xml @@ -57,6 +57,7 @@