This commit is contained in:
deniscerri 2025-04-05 20:27:49 +02:00
parent 71988fa246
commit 5b31612462
No known key found for this signature in database
GPG key ID: 95C43D517D830350
5 changed files with 22 additions and 16 deletions

View file

@ -286,11 +286,8 @@ class GeneralSettingsFragment : BaseSettingsFragment() {
"${s}\n[${entries[entryValues.indexOf(newValue)]}]" "${s}\n[${entries[entryValues.indexOf(newValue)]}]"
} }
if (newValue == "yt_api") { findPreference<EditTextPreference>("api_key")?.isVisible = newValue == "yt_api"
findPreference<EditTextPreference>("api_key")?.isVisible = true findPreference<EditTextPreference>("custom_home_recommendation_url")?.isVisible = newValue == "custom"
}else if (newValue == "custom") {
findPreference<EditTextPreference>("custom_home_recommendation_url")?.isVisible = true
}
true true
} }
} }

View file

@ -225,6 +225,9 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
addCategory(Intent.CATEGORY_OPENABLE) addCategory(Intent.CATEGORY_OPENABLE)
type = "*/*" type = "*/*"
} }
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
appRestoreResultLauncher.launch(intent) appRestoreResultLauncher.launch(intent)
true true
} }
@ -448,7 +451,7 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
}.onFailure { }.onFailure {
it.printStackTrace() it.printStackTrace()
Snackbar.make(requireView(), getString(R.string.couldnt_parse_file), Snackbar.LENGTH_LONG).show() Snackbar.make(requireView(), it.message.toString(), Snackbar.LENGTH_INDEFINITE).show()
} }
} }

View file

@ -76,8 +76,10 @@ class YoutubePlayerClientFragment : Fragment(), YoutubePlayerClientAdapter.OnIte
recyclerView.layoutManager = LinearLayoutManager(context) recyclerView.layoutManager = LinearLayoutManager(context)
recyclerView.adapter = listAdapter recyclerView.adapter = listAdapter
itemTouchHelper.attachToRecyclerView(recyclerView) itemTouchHelper.attachToRecyclerView(recyclerView)
currentListRaw = preferences.getString("youtube_player_clients", "[]")!! currentListRaw = preferences.getString("youtube_player_clients", "[]")!!.ifEmpty { "[]" }
currentList = Gson().fromJson(currentListRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList() currentList = kotlin.runCatching {
Gson().fromJson(currentListRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList()
}.getOrElse { mutableListOf() }
listAdapter.submitList(currentList.toList()) listAdapter.submitList(currentList.toList())
val newClient = view.findViewById<Chip>(R.id.newClient) val newClient = view.findViewById<Chip>(R.id.newClient)
@ -146,8 +148,10 @@ class YoutubePlayerClientFragment : Fragment(), YoutubePlayerClientAdapter.OnIte
} }
}) })
val existingConfigsRaw = preferences.getString("youtube_player_clients", "[]") val existingConfigsRaw = preferences.getString("youtube_player_clients", "[]")!!.ifEmpty { "[]" }
val existingConfigs = Gson().fromJson(existingConfigsRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList() val existingConfigs = kotlin.runCatching {
Gson().fromJson(existingConfigsRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList()
}.getOrElse { mutableListOf() }
defaultChips.filter { it.isNotBlank() }.forEach { defaultChips.filter { it.isNotBlank() }.forEach {
if (!existingConfigs.any { it2 -> it2.playerClient == it }) { if (!existingConfigs.any { it2 -> it2.playerClient == it }) {

View file

@ -64,10 +64,12 @@ class GenerateYoutubePoTokensFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
configuration = Gson().fromJson( configuration = kotlin.runCatching {
preferences.getString("youtube_generated_po_tokens", "[]"), Gson().fromJson(
Array<YoutubeGeneratePoTokenItem>::class.java preferences.getString("youtube_generated_po_tokens", "[]")!!.ifEmpty { "[]" },
).toMutableList() Array<YoutubeGeneratePoTokenItem>::class.java
).toMutableList()
}.getOrDefault(mutableListOf())
initWeb() initWeb()
} }

View file

@ -1282,7 +1282,7 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
val playerClients = mutableSetOf<String>() val playerClients = mutableSetOf<String>()
val poTokens = mutableListOf<String>() val poTokens = mutableListOf<String>()
val configuredPlayerClientsRaw = sharedPreferences.getString("youtube_player_clients", "[]")!! val configuredPlayerClientsRaw = sharedPreferences.getString("youtube_player_clients", "[]")!!.ifEmpty { "[]" }
kotlin.runCatching { kotlin.runCatching {
val configuredPlayerClients = Gson().fromJson(configuredPlayerClientsRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList() val configuredPlayerClients = Gson().fromJson(configuredPlayerClientsRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList()
@ -1312,7 +1312,7 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
extractorArgs.add("data_sync_id=${dataSyncID}") extractorArgs.add("data_sync_id=${dataSyncID}")
} }
val generatedPoTokensRaw = sharedPreferences.getString("youtube_generated_po_tokens", "[]") val generatedPoTokensRaw = sharedPreferences.getString("youtube_generated_po_tokens", "[]")!!.ifEmpty { "[]" }
kotlin.runCatching { kotlin.runCatching {
val generatedPoTokens = Gson().fromJson(generatedPoTokensRaw,Array<YoutubeGeneratePoTokenItem>::class.java).toMutableList() val generatedPoTokens = Gson().fromJson(generatedPoTokensRaw,Array<YoutubeGeneratePoTokenItem>::class.java).toMutableList()
if (generatedPoTokens.isNotEmpty()) { if (generatedPoTokens.isNotEmpty()) {