mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
More meaningful errors when adding repositories (#537)
* More meaningful errors when adding repositories
This commit is contained in:
parent
5103ad09dc
commit
ca6700e28d
3 changed files with 29 additions and 6 deletions
|
@ -224,14 +224,31 @@ class ExtensionsFragment : Fragment() {
|
|||
showToast(R.string.error_invalid_data, Toast.LENGTH_SHORT)
|
||||
}
|
||||
} else {
|
||||
val repository = RepositoryManager.parseRepository(url)
|
||||
|
||||
// Exit if wrong repository
|
||||
if (repository == null) {
|
||||
showToast(R.string.no_repository_found_error, Toast.LENGTH_LONG)
|
||||
return@ioSafe
|
||||
}
|
||||
|
||||
val fixedName = if (!name.isNullOrBlank()) name
|
||||
else RepositoryManager.parseRepository(url)?.name ?: "No name"
|
||||
else repository.name
|
||||
|
||||
val newRepo = RepositoryData(fixedName, url)
|
||||
RepositoryManager.addRepository(newRepo)
|
||||
extensionViewModel.loadStats()
|
||||
extensionViewModel.loadRepositories()
|
||||
this@ExtensionsFragment.activity?.downloadAllPluginsDialog(url, fixedName)
|
||||
|
||||
val plugins = RepositoryManager.getRepoPlugins(url)
|
||||
if (plugins.isNullOrEmpty()) {
|
||||
showToast(R.string.no_plugins_found_error, Toast.LENGTH_LONG)
|
||||
} else {
|
||||
this@ExtensionsFragment.activity?.downloadAllPluginsDialog(
|
||||
url,
|
||||
fixedName
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
dialog.dismissSafe(activity)
|
||||
|
|
|
@ -86,13 +86,17 @@ class PluginsViewModel : ViewModel() {
|
|||
}.also { list ->
|
||||
main {
|
||||
showToast(
|
||||
if (list.isEmpty()) {
|
||||
txt(
|
||||
when {
|
||||
// No plugins at all
|
||||
plugins.isEmpty() -> txt(
|
||||
R.string.no_plugins_found_error,
|
||||
)
|
||||
// All plugins downloaded
|
||||
list.isEmpty() -> txt(
|
||||
R.string.batch_download_nothing_to_download_format,
|
||||
txt(R.string.plugin)
|
||||
)
|
||||
} else {
|
||||
txt(
|
||||
else -> txt(
|
||||
R.string.batch_download_start_format,
|
||||
list.size,
|
||||
txt(if (list.size == 1) R.string.plugin_singular else R.string.plugin)
|
||||
|
|
|
@ -572,6 +572,8 @@
|
|||
<string name="batch_download_start_format" formatted="true">Started downloading %d %s…</string>
|
||||
<string name="batch_download_finish_format" formatted="true">Downloaded %d %s</string>
|
||||
<string name="batch_download_nothing_to_download_format" formatted="true">All %s already downloaded</string>
|
||||
<string name="no_plugins_found_error">No plugins found in repository</string>
|
||||
<string name="no_repository_found_error">Repository not found, check the URL and try VPN</string>
|
||||
<string name="batch_download">Batch download</string>
|
||||
<string name="plugin_singular">plugin</string>
|
||||
<string name="plugin">plugins</string>
|
||||
|
|
Loading…
Reference in a new issue