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)
|
showToast(R.string.error_invalid_data, Toast.LENGTH_SHORT)
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
val fixedName = if (!name.isNullOrBlank()) name
|
||||||
else RepositoryManager.parseRepository(url)?.name ?: "No name"
|
else repository.name
|
||||||
|
|
||||||
val newRepo = RepositoryData(fixedName, url)
|
val newRepo = RepositoryData(fixedName, url)
|
||||||
RepositoryManager.addRepository(newRepo)
|
RepositoryManager.addRepository(newRepo)
|
||||||
extensionViewModel.loadStats()
|
extensionViewModel.loadStats()
|
||||||
extensionViewModel.loadRepositories()
|
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)
|
dialog.dismissSafe(activity)
|
||||||
|
|
|
@ -86,13 +86,17 @@ class PluginsViewModel : ViewModel() {
|
||||||
}.also { list ->
|
}.also { list ->
|
||||||
main {
|
main {
|
||||||
showToast(
|
showToast(
|
||||||
if (list.isEmpty()) {
|
when {
|
||||||
txt(
|
// 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,
|
R.string.batch_download_nothing_to_download_format,
|
||||||
txt(R.string.plugin)
|
txt(R.string.plugin)
|
||||||
)
|
)
|
||||||
} else {
|
else -> txt(
|
||||||
txt(
|
|
||||||
R.string.batch_download_start_format,
|
R.string.batch_download_start_format,
|
||||||
list.size,
|
list.size,
|
||||||
txt(if (list.size == 1) R.string.plugin_singular else R.string.plugin)
|
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_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_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="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="batch_download">Batch download</string>
|
||||||
<string name="plugin_singular">plugin</string>
|
<string name="plugin_singular">plugin</string>
|
||||||
<string name="plugin">plugins</string>
|
<string name="plugin">plugins</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue