mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
feat: Include playlist name in toast after succesfully adding video
This commit is contained in:
parent
6bc13c4395
commit
c5497c4f6e
@ -1,5 +1,6 @@
|
||||
package com.github.libretube.ui.dialogs
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
@ -56,23 +57,25 @@ class AddToPlaylistDialog(
|
||||
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
return@repeatOnLifecycle
|
||||
}
|
||||
if (response.isEmpty()) return@repeatOnLifecycle
|
||||
val names = response.mapNotNull { it.name }
|
||||
val arrayAdapter = ArrayAdapter(requireContext(), R.layout.dropdown_item, names)
|
||||
binding.playlistsSpinner.adapter = arrayAdapter
|
||||
|
||||
val playlists = response.filter { !it.name.isNullOrEmpty() }
|
||||
if (playlists.isEmpty()) return@repeatOnLifecycle
|
||||
|
||||
binding.playlistsSpinner.adapter =
|
||||
ArrayAdapter(requireContext(), R.layout.dropdown_item, playlists.map { it.name!! })
|
||||
|
||||
// select the last used playlist
|
||||
viewModel.lastSelectedPlaylistId?.let { id ->
|
||||
binding.playlistsSpinner.setSelection(
|
||||
response.indexOfFirst { it.id == id }.takeIf { it >= 0 } ?: 0
|
||||
)
|
||||
val latestIndex = response.indexOfFirst { it.id == id }.takeIf { it >= 0 } ?: 0
|
||||
binding.playlistsSpinner.setSelection(latestIndex)
|
||||
}
|
||||
binding.addToPlaylist.setOnClickListener {
|
||||
val index = binding.playlistsSpinner.selectedItemPosition
|
||||
viewModel.lastSelectedPlaylistId = response[index].id!!
|
||||
val playlist = playlists[index]
|
||||
viewModel.lastSelectedPlaylistId = playlist.id!!
|
||||
dialog?.hide()
|
||||
lifecycleScope.launch {
|
||||
addToPlaylist(response[index].id!!)
|
||||
addToPlaylist(playlist.id, playlist.name!!)
|
||||
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 streams = when {
|
||||
videoId != null -> listOfNotNull(
|
||||
@ -100,8 +104,8 @@ class AddToPlaylistDialog(
|
||||
appContext.toastFromMainDispatcher(R.string.unknown_error)
|
||||
return
|
||||
}
|
||||
appContext.toastFromMainDispatcher(
|
||||
if (success) R.string.added_to_playlist else R.string.fail
|
||||
)
|
||||
if (success) appContext.toastFromMainDispatcher(
|
||||
appContext.getString(R.string.added_to_playlist, playlistName)
|
||||
) else appContext.toastFromMainDispatcher(R.string.fail)
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +289,7 @@
|
||||
<string name="playlistNameReversed">Oynatma siyahısı adı (əks)</string>
|
||||
<string name="playlists_order">Oynatma siyahısı sırası</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="sb_markers">Göstəricilər</string>
|
||||
<string name="sb_markers_summary">Vaxt çubuğunda bölümləri işarələ.</string>
|
||||
|
@ -289,7 +289,7 @@
|
||||
<string name="playlists_order">Pořadí playlistů</string>
|
||||
<string name="playlistNameReversed">Název playlistu (obráceně)</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="livestreams">Živé přenosy</string>
|
||||
<string name="alternative_videos_layout">Alternativní rozvržení videí</string>
|
||||
|
@ -306,7 +306,7 @@
|
||||
<string name="layout">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="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="audio_track">Tonspur</string>
|
||||
<string name="default_audio_track">Standard</string>
|
||||
|
@ -276,7 +276,7 @@
|
||||
<string name="filename">Όνομα αρχείου</string>
|
||||
<string name="invalid_filename">Άκυρο όνομα αρχείου!</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="confirm_unsubscribe">Είστε βέβαιοι ότι θέλετε να καταργήσετε την εγγραφή %1$s;</string>
|
||||
<string name="confirm_unsubscribing_summary">Εμφάνιση διαλόγου επιβεβαίωσης πριν από την κατάργηση της εγγραφής.</string>
|
||||
|
@ -289,7 +289,7 @@
|
||||
<string name="playlists_order">Orden de las listas de reproducción</string>
|
||||
<string name="playlistNameReversed">Nombre de la lista (Z-A)</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="sb_markers">Señaladores</string>
|
||||
<string name="sb_markers_summary">Señala los segmentos en la barra de tiempo.</string>
|
||||
|
@ -284,7 +284,7 @@
|
||||
<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="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="invalid_filename">Fitxategi izen baliogabea!</string>
|
||||
<string name="playlists_order">Erreprodukzio zerrenden ordena</string>
|
||||
|
@ -289,7 +289,7 @@
|
||||
<string name="playlists_order">Ordre des playlists</string>
|
||||
<string name="playlistNameReversed">Nom de la playlist (inversé)</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_summary">Marquez les segments sur la barre de temps.</string>
|
||||
<string name="alternative_videos_layout">Disposition alternative des vidéos</string>
|
||||
|
@ -284,7 +284,7 @@
|
||||
<string name="playback_pitch">Hangmagasság</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="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="filename">Fájlnév</string>
|
||||
<string name="playlistNameReversed">Lejátszási lista neve (fordított)</string>
|
||||
|
@ -289,7 +289,7 @@
|
||||
<string name="playlists_order">Urutan daftar main</string>
|
||||
<string name="playlistNameReversed">Nama daftar main (dibalik)</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="sb_markers_summary">Tandai segmen pada bilah waktu.</string>
|
||||
<string name="sb_markers">Penanda</string>
|
||||
|
@ -288,7 +288,7 @@
|
||||
<string name="invalid_filename">Nome del file non valido!</string>
|
||||
<string name="playlists_order">Ordine delle playlist</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="sb_markers">Marcatori</string>
|
||||
<string name="sb_markers_summary">Segna i segmenti sulla barra del tempo.</string>
|
||||
|
@ -149,7 +149,7 @@
|
||||
<string name="playlists_order">Grojaraščių tvarka</string>
|
||||
<string name="playlistNameReversed">Grojaraščio pavadinimas (atvirkštinis)</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="download_channel_name">Atsisiuntimo paslauga</string>
|
||||
<string name="download_channel_description">Rodomas pranešimas, kai atsisiunčiama medija.</string>
|
||||
|
@ -300,7 +300,7 @@
|
||||
<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_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="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>
|
||||
|
@ -289,7 +289,7 @@
|
||||
<string name="invalid_filename">Ugyldig filnavn</string>
|
||||
<string name="playlists_order">Spillelisterekkefølge</string>
|
||||
<string name="queue">Kø</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="sb_markers">Markører</string>
|
||||
<string name="sb_markers_summary">Marker segmenter i forløpsindikatoren.</string>
|
||||
|
@ -289,7 +289,7 @@
|
||||
<string name="invalid_filename">Nieprawidłowa nazwa pliku!</string>
|
||||
<string name="playlists_order">Kolejność playlist</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="sb_markers">Oznaczenia</string>
|
||||
<string name="livestreams">Na żywo</string>
|
||||
|
@ -289,7 +289,7 @@
|
||||
<string name="wifi">Wi-Fi</string>
|
||||
<string name="mobile_data">Dados móveis</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="livestreams">Transmissões ao vivo</string>
|
||||
<string name="sb_markers_summary">Marque os segmentos na barra de tempo.</string>
|
||||
|
@ -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="queue">Fila</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="filename">Nome do ficheiro</string>
|
||||
<string name="invalid_filename">Nome de ficheiro inválido!</string>
|
||||
|
@ -333,7 +333,7 @@
|
||||
<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="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_summary">Afișați un dialog de confirmare înainte de a vă dezabona.</string>
|
||||
<string name="start_time">Timpul de începere</string>
|
||||
|
@ -289,7 +289,7 @@
|
||||
<string name="filename">Dosya adı</string>
|
||||
<string name="invalid_filename">Geçersiz dosya adı!</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="sb_markers">İşaretleyiciler</string>
|
||||
<string name="sb_markers_summary">Bölümleri zaman çubuğunda işaretleyin.</string>
|
||||
|
@ -303,7 +303,7 @@
|
||||
<string name="playlists_order">Playlists order</string>
|
||||
<string name="playlistNameReversed">Playlist name (reversed)</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="sb_markers">Markers</string>
|
||||
<string name="sb_markers_summary">Mark the segments on the time bar.</string>
|
||||
|
Loading…
Reference in New Issue
Block a user