Merge pull request #4234 from Bnyro/master

feat: Include playlist name in toast after succesfully adding video
This commit is contained in:
Bnyro 2023-07-16 16:04:47 +02:00 committed by GitHub
commit 810a733410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 36 additions and 32 deletions

View File

@ -1,5 +1,6 @@
package com.github.libretube.ui.dialogs package com.github.libretube.ui.dialogs
import android.annotation.SuppressLint
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
@ -56,23 +57,25 @@ class AddToPlaylistDialog(
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show() Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
return@repeatOnLifecycle return@repeatOnLifecycle
} }
if (response.isEmpty()) return@repeatOnLifecycle
val names = response.mapNotNull { it.name } val playlists = response.filter { !it.name.isNullOrEmpty() }
val arrayAdapter = ArrayAdapter(requireContext(), R.layout.dropdown_item, names) if (playlists.isEmpty()) return@repeatOnLifecycle
binding.playlistsSpinner.adapter = arrayAdapter
binding.playlistsSpinner.adapter =
ArrayAdapter(requireContext(), R.layout.dropdown_item, playlists.map { it.name!! })
// select the last used playlist // select the last used playlist
viewModel.lastSelectedPlaylistId?.let { id -> viewModel.lastSelectedPlaylistId?.let { id ->
binding.playlistsSpinner.setSelection( val latestIndex = response.indexOfFirst { it.id == id }.takeIf { it >= 0 } ?: 0
response.indexOfFirst { it.id == id }.takeIf { it >= 0 } ?: 0 binding.playlistsSpinner.setSelection(latestIndex)
)
} }
binding.addToPlaylist.setOnClickListener { binding.addToPlaylist.setOnClickListener {
val index = binding.playlistsSpinner.selectedItemPosition val index = binding.playlistsSpinner.selectedItemPosition
viewModel.lastSelectedPlaylistId = response[index].id!! val playlist = playlists[index]
viewModel.lastSelectedPlaylistId = playlist.id!!
dialog?.hide() dialog?.hide()
lifecycleScope.launch { lifecycleScope.launch {
addToPlaylist(response[index].id!!) addToPlaylist(playlist.id, playlist.name!!)
dialog?.dismiss() dialog?.dismiss()
} }
} }
@ -80,7 +83,8 @@ class AddToPlaylistDialog(
} }
} }
private suspend fun addToPlaylist(playlistId: String) { @SuppressLint("StringFormatInvalid")
private suspend fun addToPlaylist(playlistId: String, playlistName: String) {
val appContext = context?.applicationContext ?: return val appContext = context?.applicationContext ?: return
val streams = when { val streams = when {
videoId != null -> listOfNotNull( videoId != null -> listOfNotNull(
@ -100,8 +104,8 @@ class AddToPlaylistDialog(
appContext.toastFromMainDispatcher(R.string.unknown_error) appContext.toastFromMainDispatcher(R.string.unknown_error)
return return
} }
appContext.toastFromMainDispatcher( if (success) appContext.toastFromMainDispatcher(
if (success) R.string.added_to_playlist else R.string.fail appContext.getString(R.string.added_to_playlist, playlistName)
) ) else appContext.toastFromMainDispatcher(R.string.fail)
} }
} }

View File

@ -289,7 +289,7 @@
<string name="playlistNameReversed">Oynatma siyahısı adı (əks)</string> <string name="playlistNameReversed">Oynatma siyahısı adı (əks)</string>
<string name="playlists_order">Oynatma siyahısı sırası</string> <string name="playlists_order">Oynatma siyahısı sırası</string>
<string name="time_code">Vaxt kodu (saniyə)</string> <string name="time_code">Vaxt kodu (saniyə)</string>
<string name="added_to_playlist">Oynatma siyahısına əlavə edildi</string> <string name="added_to_playlist">Oynatma siyahısına əlavə edildi %1$s</string>
<string name="queue">Növbə</string> <string name="queue">Növbə</string>
<string name="sb_markers">Göstəricilər</string> <string name="sb_markers">Göstəricilər</string>
<string name="sb_markers_summary">Vaxt çubuğunda bölümləri işarələ.</string> <string name="sb_markers_summary">Vaxt çubuğunda bölümləri işarələ.</string>

View File

@ -289,7 +289,7 @@
<string name="playlists_order">Pořadí playlistů</string> <string name="playlists_order">Pořadí playlistů</string>
<string name="playlistNameReversed">Název playlistu (obráceně)</string> <string name="playlistNameReversed">Název playlistu (obráceně)</string>
<string name="time_code">Čas (sekundy)</string> <string name="time_code">Čas (sekundy)</string>
<string name="added_to_playlist">Přidáno do playlistu</string> <string name="added_to_playlist">Přidáno do playlistu %1$s</string>
<string name="queue">Fronta</string> <string name="queue">Fronta</string>
<string name="livestreams">Živé přenosy</string> <string name="livestreams">Živé přenosy</string>
<string name="alternative_videos_layout">Alternativní rozvržení videí</string> <string name="alternative_videos_layout">Alternativní rozvržení videí</string>

View File

@ -306,7 +306,7 @@
<string name="layout">Layout</string> <string name="layout">Layout</string>
<string name="alternative_player_layout">Alternatives Player-Layout</string> <string name="alternative_player_layout">Alternatives Player-Layout</string>
<string name="alternative_player_layout_summary">Zeige ähnliche Videos über den Kommentaren in einer Reihe an anstatt darunter.</string> <string name="alternative_player_layout_summary">Zeige ähnliche Videos über den Kommentaren in einer Reihe an anstatt darunter.</string>
<string name="added_to_playlist">Zur Playlist hinzugefügt</string> <string name="added_to_playlist">Zur Playlist %1$s hinzugefügt</string>
<string name="sb_markers">Markierungen</string> <string name="sb_markers">Markierungen</string>
<string name="audio_track">Tonspur</string> <string name="audio_track">Tonspur</string>
<string name="default_audio_track">Standard</string> <string name="default_audio_track">Standard</string>

View File

@ -276,7 +276,7 @@
<string name="filename">Όνομα αρχείου</string> <string name="filename">Όνομα αρχείου</string>
<string name="invalid_filename">Άκυρο όνομα αρχείου!</string> <string name="invalid_filename">Άκυρο όνομα αρχείου!</string>
<string name="playback_pitch">Τόνος</string> <string name="playback_pitch">Τόνος</string>
<string name="added_to_playlist">Προστέθηκε στη λίστα αναπαραγωγής</string> <string name="added_to_playlist">Προστέθηκε στη λίστα αναπαραγωγής %1$s</string>
<string name="defaultIconLight">Προεπιλεγμένο φως</string> <string name="defaultIconLight">Προεπιλεγμένο φως</string>
<string name="confirm_unsubscribe">Είστε βέβαιοι ότι θέλετε να καταργήσετε την εγγραφή %1$s;</string> <string name="confirm_unsubscribe">Είστε βέβαιοι ότι θέλετε να καταργήσετε την εγγραφή %1$s;</string>
<string name="confirm_unsubscribing_summary">Εμφάνιση διαλόγου επιβεβαίωσης πριν από την κατάργηση της εγγραφής.</string> <string name="confirm_unsubscribing_summary">Εμφάνιση διαλόγου επιβεβαίωσης πριν από την κατάργηση της εγγραφής.</string>

View File

@ -289,7 +289,7 @@
<string name="playlists_order">Orden de las listas de reproducción</string> <string name="playlists_order">Orden de las listas de reproducción</string>
<string name="playlistNameReversed">Nombre de la lista (Z-A)</string> <string name="playlistNameReversed">Nombre de la lista (Z-A)</string>
<string name="time_code">Código de tiempo (segundos)</string> <string name="time_code">Código de tiempo (segundos)</string>
<string name="added_to_playlist">Añadido a la lista</string> <string name="added_to_playlist">Añadido a la lista %1$s</string>
<string name="queue">Cola</string> <string name="queue">Cola</string>
<string name="sb_markers">Señaladores</string> <string name="sb_markers">Señaladores</string>
<string name="sb_markers_summary">Señala los segmentos en la barra de tiempo.</string> <string name="sb_markers_summary">Señala los segmentos en la barra de tiempo.</string>

View File

@ -284,7 +284,7 @@
<string name="mobile_data">Datu mugikorrak</string> <string name="mobile_data">Datu mugikorrak</string>
<string name="change_region">Badirudi \'Joerak\' ez dagoela eskuragarri eskualde honetan. Mesedez, hautatu beste bat ezarpenetan.</string> <string name="change_region">Badirudi \'Joerak\' ez dagoela eskuragarri eskualde honetan. Mesedez, hautatu beste bat ezarpenetan.</string>
<string name="queue">Ilara</string> <string name="queue">Ilara</string>
<string name="added_to_playlist">Gehitu erreprodukzio zerrendara</string> <string name="added_to_playlist">Gehitu erreprodukzio zerrendara %1$s</string>
<string name="filename">Fitxategi izena</string> <string name="filename">Fitxategi izena</string>
<string name="invalid_filename">Fitxategi izen baliogabea!</string> <string name="invalid_filename">Fitxategi izen baliogabea!</string>
<string name="playlists_order">Erreprodukzio zerrenden ordena</string> <string name="playlists_order">Erreprodukzio zerrenden ordena</string>

View File

@ -289,7 +289,7 @@
<string name="playlists_order">Ordre des playlists</string> <string name="playlists_order">Ordre des playlists</string>
<string name="playlistNameReversed">Nom de la playlist (inversé)</string> <string name="playlistNameReversed">Nom de la playlist (inversé)</string>
<string name="queue">File</string> <string name="queue">File</string>
<string name="added_to_playlist">Ajouté à la playlist</string> <string name="added_to_playlist">Ajouté à la playlist %1$s</string>
<string name="sb_markers">Marqueurs</string> <string name="sb_markers">Marqueurs</string>
<string name="sb_markers_summary">Marquez les segments sur la barre de temps.</string> <string name="sb_markers_summary">Marquez les segments sur la barre de temps.</string>
<string name="alternative_videos_layout">Disposition alternative des vidéos</string> <string name="alternative_videos_layout">Disposition alternative des vidéos</string>

View File

@ -284,7 +284,7 @@
<string name="playback_pitch">Hangmagasság</string> <string name="playback_pitch">Hangmagasság</string>
<string name="save_feed">Videófolyam betöltése a háttérben</string> <string name="save_feed">Videófolyam betöltése a háttérben</string>
<string name="change_region">A felkapott úgy tűnik, hogy nem elérhető a jelenlegi régió számára. Válasszon egy másikat a beállításokban.</string> <string name="change_region">A felkapott úgy tűnik, hogy nem elérhető a jelenlegi régió számára. Válasszon egy másikat a beállításokban.</string>
<string name="added_to_playlist">Hozzáadva a lejátszási listához</string> <string name="added_to_playlist">Hozzáadva a lejátszási listához %1$s</string>
<string name="invalid_filename">Érvénytelen fájlnév!</string> <string name="invalid_filename">Érvénytelen fájlnév!</string>
<string name="filename">Fájlnév</string> <string name="filename">Fájlnév</string>
<string name="playlistNameReversed">Lejátszási lista neve (fordított)</string> <string name="playlistNameReversed">Lejátszási lista neve (fordított)</string>

View File

@ -289,7 +289,7 @@
<string name="playlists_order">Urutan daftar main</string> <string name="playlists_order">Urutan daftar main</string>
<string name="playlistNameReversed">Nama daftar main (dibalik)</string> <string name="playlistNameReversed">Nama daftar main (dibalik)</string>
<string name="time_code">Kode waktu (detik)</string> <string name="time_code">Kode waktu (detik)</string>
<string name="added_to_playlist">Ditambahkan ke daftar putar</string> <string name="added_to_playlist">Ditambahkan ke daftar putar %1$s</string>
<string name="queue">Antrean</string> <string name="queue">Antrean</string>
<string name="sb_markers_summary">Tandai segmen pada bilah waktu.</string> <string name="sb_markers_summary">Tandai segmen pada bilah waktu.</string>
<string name="sb_markers">Penanda</string> <string name="sb_markers">Penanda</string>

View File

@ -288,7 +288,7 @@
<string name="invalid_filename">Nome del file non valido!</string> <string name="invalid_filename">Nome del file non valido!</string>
<string name="playlists_order">Ordine delle playlist</string> <string name="playlists_order">Ordine delle playlist</string>
<string name="playlistNameReversed">Nome playlist (invertito)</string> <string name="playlistNameReversed">Nome playlist (invertito)</string>
<string name="added_to_playlist">Aggiunto alla playlist</string> <string name="added_to_playlist">Aggiunto alla playlist %1$s</string>
<string name="queue">Coda</string> <string name="queue">Coda</string>
<string name="sb_markers">Marcatori</string> <string name="sb_markers">Marcatori</string>
<string name="sb_markers_summary">Segna i segmenti sulla barra del tempo.</string> <string name="sb_markers_summary">Segna i segmenti sulla barra del tempo.</string>

View File

@ -149,7 +149,7 @@
<string name="playlists_order">Grojaraščių tvarka</string> <string name="playlists_order">Grojaraščių tvarka</string>
<string name="playlistNameReversed">Grojaraščio pavadinimas (atvirkštinis)</string> <string name="playlistNameReversed">Grojaraščio pavadinimas (atvirkštinis)</string>
<string name="time_code">Laiko kodas (sekundėmis)</string> <string name="time_code">Laiko kodas (sekundėmis)</string>
<string name="added_to_playlist">Pridėti į grojaraštį</string> <string name="added_to_playlist">Pridėti į grojaraštį %1$s</string>
<string name="queue">Eilė</string> <string name="queue">Eilė</string>
<string name="download_channel_name">Atsisiuntimo paslauga</string> <string name="download_channel_name">Atsisiuntimo paslauga</string>
<string name="download_channel_description">Rodomas pranešimas, kai atsisiunčiama medija.</string> <string name="download_channel_description">Rodomas pranešimas, kai atsisiunčiama medija.</string>

View File

@ -300,7 +300,7 @@
<string name="all_caught_up">Jūs esat visu redzējuši</string> <string name="all_caught_up">Jūs esat visu redzējuši</string>
<string name="hide_watched_from_feed">Paslēpt noskatītos video no plūsmas</string> <string name="hide_watched_from_feed">Paslēpt noskatītos video no plūsmas</string>
<string name="hide_watched_from_feed_summary">Nerādīt video abonomentu cilnē, kurus esat noskatījuši vismaz līdz 90% atzīmei.</string> <string name="hide_watched_from_feed_summary">Nerādīt video abonomentu cilnē, kurus esat noskatījuši vismaz līdz 90% atzīmei.</string>
<string name="added_to_playlist">Pievienots atskaņošanas sarakstam</string> <string name="added_to_playlist">Pievienots atskaņošanas sarakstam %1$s</string>
<string name="nothing_selected">Nekas nav izvēlēts!</string> <string name="nothing_selected">Nekas nav izvēlēts!</string>
<string name="autoplay_countdown_summary">Parādīt 5 sekunžu atskaiti pirms automātiski atskaņo nākamo video.</string> <string name="autoplay_countdown_summary">Parādīt 5 sekunžu atskaiti pirms automātiski atskaņo nākamo video.</string>
<string name="playing_next">Nākamo atskaņos pēc %1$s</string> <string name="playing_next">Nākamo atskaņos pēc %1$s</string>

View File

@ -289,7 +289,7 @@
<string name="invalid_filename">Ugyldig filnavn</string> <string name="invalid_filename">Ugyldig filnavn</string>
<string name="playlists_order">Spillelisterekkefølge</string> <string name="playlists_order">Spillelisterekkefølge</string>
<string name="queue"></string> <string name="queue"></string>
<string name="added_to_playlist">Lagt til på spillelisten</string> <string name="added_to_playlist">Lagt til på spillelisten %1$s</string>
<string name="time_code">Tidskode</string> <string name="time_code">Tidskode</string>
<string name="sb_markers">Markører</string> <string name="sb_markers">Markører</string>
<string name="sb_markers_summary">Marker segmenter i forløpsindikatoren.</string> <string name="sb_markers_summary">Marker segmenter i forløpsindikatoren.</string>

View File

@ -289,7 +289,7 @@
<string name="invalid_filename">Nieprawidłowa nazwa pliku!</string> <string name="invalid_filename">Nieprawidłowa nazwa pliku!</string>
<string name="playlists_order">Kolejność playlist</string> <string name="playlists_order">Kolejność playlist</string>
<string name="playlistNameReversed">Nazwa playlisty (odwrotnie)</string> <string name="playlistNameReversed">Nazwa playlisty (odwrotnie)</string>
<string name="added_to_playlist">Dodano do playlisty</string> <string name="added_to_playlist">Dodano do playlisty %1$s</string>
<string name="queue">Kolejka</string> <string name="queue">Kolejka</string>
<string name="sb_markers">Oznaczenia</string> <string name="sb_markers">Oznaczenia</string>
<string name="livestreams">Na żywo</string> <string name="livestreams">Na żywo</string>

View File

@ -289,7 +289,7 @@
<string name="wifi">Wi-Fi</string> <string name="wifi">Wi-Fi</string>
<string name="mobile_data">Dados móveis</string> <string name="mobile_data">Dados móveis</string>
<string name="queue">Fila</string> <string name="queue">Fila</string>
<string name="added_to_playlist">Adicionado à playlist</string> <string name="added_to_playlist">Adicionado à playlist %1$s</string>
<string name="sb_markers">Marcadores</string> <string name="sb_markers">Marcadores</string>
<string name="livestreams">Transmissões ao vivo</string> <string name="livestreams">Transmissões ao vivo</string>
<string name="sb_markers_summary">Marque os segmentos na barra de tempo.</string> <string name="sb_markers_summary">Marque os segmentos na barra de tempo.</string>

View File

@ -281,7 +281,7 @@
<string name="category_outro_description">Informação após o final. Não para conclusões com informações.</string> <string name="category_outro_description">Informação após o final. Não para conclusões com informações.</string>
<string name="queue">Fila</string> <string name="queue">Fila</string>
<string name="playback_pitch">Passo</string> <string name="playback_pitch">Passo</string>
<string name="added_to_playlist">Adicionado à lista de reprodução</string> <string name="added_to_playlist">Adicionado à lista de reprodução %1$s</string>
<string name="category_filler">Tangente/Piadas</string> <string name="category_filler">Tangente/Piadas</string>
<string name="filename">Nome do ficheiro</string> <string name="filename">Nome do ficheiro</string>
<string name="invalid_filename">Nome de ficheiro inválido!</string> <string name="invalid_filename">Nome de ficheiro inválido!</string>

View File

@ -333,7 +333,7 @@
<string name="app_backup">Backup aplicație</string> <string name="app_backup">Backup aplicație</string>
<string name="backup_restore_summary">Importați și exportați abonamente, liste de redare, …</string> <string name="backup_restore_summary">Importați și exportați abonamente, liste de redare, …</string>
<string name="time_code">Cod de timp (secunde)</string> <string name="time_code">Cod de timp (secunde)</string>
<string name="added_to_playlist">Adăugat la playlist</string> <string name="added_to_playlist">Adăugat la playlist %1$s</string>
<string name="confirm_unsubscribing">Confirmați dezabonarea</string> <string name="confirm_unsubscribing">Confirmați dezabonarea</string>
<string name="confirm_unsubscribing_summary">Afișați un dialog de confirmare înainte de a vă dezabona.</string> <string name="confirm_unsubscribing_summary">Afișați un dialog de confirmare înainte de a vă dezabona.</string>
<string name="start_time">Timpul de începere</string> <string name="start_time">Timpul de începere</string>

View File

@ -289,7 +289,7 @@
<string name="filename">Dosya adı</string> <string name="filename">Dosya adı</string>
<string name="invalid_filename">Geçersiz dosya adı!</string> <string name="invalid_filename">Geçersiz dosya adı!</string>
<string name="time_code">Zaman kodu (saniye)</string> <string name="time_code">Zaman kodu (saniye)</string>
<string name="added_to_playlist">Oynatma listesine eklendi</string> <string name="added_to_playlist">Oynatma listesine eklendi %1$s</string>
<string name="queue">Sıra</string> <string name="queue">Sıra</string>
<string name="sb_markers">İşaretleyiciler</string> <string name="sb_markers">İşaretleyiciler</string>
<string name="sb_markers_summary">Bölümleri zaman çubuğunda işaretleyin.</string> <string name="sb_markers_summary">Bölümleri zaman çubuğunda işaretleyin.</string>

View File

@ -303,7 +303,7 @@
<string name="playlists_order">Playlists order</string> <string name="playlists_order">Playlists order</string>
<string name="playlistNameReversed">Playlist name (reversed)</string> <string name="playlistNameReversed">Playlist name (reversed)</string>
<string name="time_code">Time code (seconds)</string> <string name="time_code">Time code (seconds)</string>
<string name="added_to_playlist">Added to playlist</string> <string name="added_to_playlist">Added to playlist %1$s</string>
<string name="queue">Queue</string> <string name="queue">Queue</string>
<string name="sb_markers">Markers</string> <string name="sb_markers">Markers</string>
<string name="sb_markers_summary">Mark the segments on the time bar.</string> <string name="sb_markers_summary">Mark the segments on the time bar.</string>