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)]}]"
}
if (newValue == "yt_api") {
findPreference<EditTextPreference>("api_key")?.isVisible = true
}else if (newValue == "custom") {
findPreference<EditTextPreference>("custom_home_recommendation_url")?.isVisible = true
}
findPreference<EditTextPreference>("api_key")?.isVisible = newValue == "yt_api"
findPreference<EditTextPreference>("custom_home_recommendation_url")?.isVisible = newValue == "custom"
true
}
}

View file

@ -225,6 +225,9 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
addCategory(Intent.CATEGORY_OPENABLE)
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)
true
}
@ -448,7 +451,7 @@ class MainSettingsFragment : PreferenceFragmentCompat() {
}.onFailure {
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.adapter = listAdapter
itemTouchHelper.attachToRecyclerView(recyclerView)
currentListRaw = preferences.getString("youtube_player_clients", "[]")!!
currentList = Gson().fromJson(currentListRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList()
currentListRaw = preferences.getString("youtube_player_clients", "[]")!!.ifEmpty { "[]" }
currentList = kotlin.runCatching {
Gson().fromJson(currentListRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList()
}.getOrElse { mutableListOf() }
listAdapter.submitList(currentList.toList())
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 existingConfigs = Gson().fromJson(existingConfigsRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList()
val existingConfigsRaw = preferences.getString("youtube_player_clients", "[]")!!.ifEmpty { "[]" }
val existingConfigs = kotlin.runCatching {
Gson().fromJson(existingConfigsRaw, Array<YoutubePlayerClientItem>::class.java).toMutableList()
}.getOrElse { mutableListOf() }
defaultChips.filter { it.isNotBlank() }.forEach {
if (!existingConfigs.any { it2 -> it2.playerClient == it }) {

View file

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

View file

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