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 cb3c651bd..13978a957 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 @@ -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) } } diff --git a/app/src/main/res/values-az/strings.xml b/app/src/main/res/values-az/strings.xml index 34ec34e6e..ebfe98422 100644 --- a/app/src/main/res/values-az/strings.xml +++ b/app/src/main/res/values-az/strings.xml @@ -289,7 +289,7 @@ Oynatma siyahısı adı (əks) Oynatma siyahısı sırası Vaxt kodu (saniyə) - Oynatma siyahısına əlavə edildi + Oynatma siyahısına əlavə edildi %1$s Növbə Göstəricilər Vaxt çubuğunda bölümləri işarələ. diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index e01ef36cb..7cb04c3f3 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -289,7 +289,7 @@ Pořadí playlistů Název playlistu (obráceně) Čas (sekundy) - Přidáno do playlistu + Přidáno do playlistu %1$s Fronta Živé přenosy Alternativní rozvržení videí diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 213bd460b..2c941cf3e 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -306,7 +306,7 @@ Layout Alternatives Player-Layout Zeige ähnliche Videos über den Kommentaren in einer Reihe an anstatt darunter. - Zur Playlist hinzugefügt + Zur Playlist %1$s hinzugefügt Markierungen Tonspur Standard diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 1e175a77c..43f86c7eb 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -276,7 +276,7 @@ Όνομα αρχείου Άκυρο όνομα αρχείου! Τόνος - Προστέθηκε στη λίστα αναπαραγωγής + Προστέθηκε στη λίστα αναπαραγωγής %1$s Προεπιλεγμένο φως Είστε βέβαιοι ότι θέλετε να καταργήσετε την εγγραφή %1$s; Εμφάνιση διαλόγου επιβεβαίωσης πριν από την κατάργηση της εγγραφής. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index e4b439de1..e93f6d89d 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -289,7 +289,7 @@ Orden de las listas de reproducción Nombre de la lista (Z-A) Código de tiempo (segundos) - Añadido a la lista + Añadido a la lista %1$s Cola Señaladores Señala los segmentos en la barra de tiempo. diff --git a/app/src/main/res/values-eu/strings.xml b/app/src/main/res/values-eu/strings.xml index 204bd0803..f3c63623d 100644 --- a/app/src/main/res/values-eu/strings.xml +++ b/app/src/main/res/values-eu/strings.xml @@ -284,7 +284,7 @@ Datu mugikorrak Badirudi \'Joerak\' ez dagoela eskuragarri eskualde honetan. Mesedez, hautatu beste bat ezarpenetan. Ilara - Gehitu erreprodukzio zerrendara + Gehitu erreprodukzio zerrendara %1$s Fitxategi izena Fitxategi izen baliogabea! Erreprodukzio zerrenden ordena diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 144e56e4e..5729d4abe 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -289,7 +289,7 @@ Ordre des playlists Nom de la playlist (inversé) File - Ajouté à la playlist + Ajouté à la playlist %1$s Marqueurs Marquez les segments sur la barre de temps. Disposition alternative des vidéos diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 5c9d6d33e..495249706 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -284,7 +284,7 @@ Hangmagasság Videófolyam betöltése a háttérben 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. - Hozzáadva a lejátszási listához + Hozzáadva a lejátszási listához %1$s Érvénytelen fájlnév! Fájlnév Lejátszási lista neve (fordított) diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index f0139ffde..e2d294299 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -289,7 +289,7 @@ Urutan daftar main Nama daftar main (dibalik) Kode waktu (detik) - Ditambahkan ke daftar putar + Ditambahkan ke daftar putar %1$s Antrean Tandai segmen pada bilah waktu. Penanda diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 3439b6aef..ab41c4772 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -288,7 +288,7 @@ Nome del file non valido! Ordine delle playlist Nome playlist (invertito) - Aggiunto alla playlist + Aggiunto alla playlist %1$s Coda Marcatori Segna i segmenti sulla barra del tempo. diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index 516a3c414..d39e4be1d 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -149,7 +149,7 @@ Grojaraščių tvarka Grojaraščio pavadinimas (atvirkštinis) Laiko kodas (sekundėmis) - Pridėti į grojaraštį + Pridėti į grojaraštį %1$s Eilė Atsisiuntimo paslauga Rodomas pranešimas, kai atsisiunčiama medija. diff --git a/app/src/main/res/values-lv/strings.xml b/app/src/main/res/values-lv/strings.xml index 823c5ae8e..721c56144 100644 --- a/app/src/main/res/values-lv/strings.xml +++ b/app/src/main/res/values-lv/strings.xml @@ -300,7 +300,7 @@ Jūs esat visu redzējuši Paslēpt noskatītos video no plūsmas Nerādīt video abonomentu cilnē, kurus esat noskatījuši vismaz līdz 90% atzīmei. - Pievienots atskaņošanas sarakstam + Pievienots atskaņošanas sarakstam %1$s Nekas nav izvēlēts! Parādīt 5 sekunžu atskaiti pirms automātiski atskaņo nākamo video. Nākamo atskaņos pēc %1$s diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index 6f68f9155..7489b9e37 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -289,7 +289,7 @@ Ugyldig filnavn Spillelisterekkefølge - Lagt til på spillelisten + Lagt til på spillelisten %1$s Tidskode Markører Marker segmenter i forløpsindikatoren. diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index fe08eaefd..fa633857f 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -289,7 +289,7 @@ Nieprawidłowa nazwa pliku! Kolejność playlist Nazwa playlisty (odwrotnie) - Dodano do playlisty + Dodano do playlisty %1$s Kolejka Oznaczenia Na żywo diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 538a1c299..3eb3eb6f0 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -289,7 +289,7 @@ Wi-Fi Dados móveis Fila - Adicionado à playlist + Adicionado à playlist %1$s Marcadores Transmissões ao vivo Marque os segmentos na barra de tempo. diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index ee221f77c..0ff060a57 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -281,7 +281,7 @@ Informação após o final. Não para conclusões com informações. Fila Passo - Adicionado à lista de reprodução + Adicionado à lista de reprodução %1$s Tangente/Piadas Nome do ficheiro Nome de ficheiro inválido! diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 184ead557..82c6f5029 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -333,7 +333,7 @@ Backup aplicație Importați și exportați abonamente, liste de redare, … Cod de timp (secunde) - Adăugat la playlist + Adăugat la playlist %1$s Confirmați dezabonarea Afișați un dialog de confirmare înainte de a vă dezabona. Timpul de începere diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 5d994b14f..007e45646 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -289,7 +289,7 @@ Dosya adı Geçersiz dosya adı! Zaman kodu (saniye) - Oynatma listesine eklendi + Oynatma listesine eklendi %1$s Sıra İşaretleyiciler Bölümleri zaman çubuğunda işaretleyin. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e81bb4c0d..44008ad86 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -303,7 +303,7 @@ Playlists order Playlist name (reversed) Time code (seconds) - Added to playlist + Added to playlist %1$s Queue Markers Mark the segments on the time bar.