fixes
This commit is contained in:
parent
71988fa246
commit
5b31612462
5 changed files with 22 additions and 16 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 }) {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue