mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 03:31:58 +01:00
Fix external repo info banner in ExtensionDetailsScreen
This commit is contained in:
parent
3dc2f9a711
commit
4b8fa059d5
6 changed files with 32 additions and 15 deletions
|
@ -11,7 +11,7 @@ class CreateSourceRepo(private val preferences: SourcePreferences) {
|
|||
return Result.InvalidUrl
|
||||
}
|
||||
|
||||
preferences.extensionRepos() += name.substringBeforeLast("/index.min.json")
|
||||
preferences.extensionRepos() += name.removeSuffix("/index.min.json")
|
||||
|
||||
return Result.Success
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ import eu.kanade.tachiyomi.extension.model.Extension
|
|||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionDetailsScreenModel
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
|
||||
|
@ -138,7 +139,7 @@ fun ExtensionDetailsScreen(
|
|||
private fun ExtensionDetails(
|
||||
contentPadding: PaddingValues,
|
||||
extension: Extension.Installed,
|
||||
sources: List<ExtensionSourceItem>,
|
||||
sources: ImmutableList<ExtensionSourceItem>,
|
||||
onClickSourcePreferences: (sourceId: Long) -> Unit,
|
||||
onClickUninstall: () -> Unit,
|
||||
onClickSource: (sourceId: Long) -> Unit,
|
||||
|
@ -150,18 +151,24 @@ private fun ExtensionDetails(
|
|||
contentPadding = contentPadding,
|
||||
) {
|
||||
when {
|
||||
extension.isRepoSource ->
|
||||
extension.isFromExternalRepo ->
|
||||
item {
|
||||
val uriHandler = LocalUriHandler.current
|
||||
val url = remember(extension) {
|
||||
val regex = """https://raw.githubusercontent.com/(.+?)/(.+?)/.+""".toRegex()
|
||||
regex.find(extension.repoUrl.orEmpty())
|
||||
?.let {
|
||||
val (user, repo) = it.destructured
|
||||
"https://github.com/$user/$repo"
|
||||
}
|
||||
?: extension.repoUrl
|
||||
}
|
||||
|
||||
WarningBanner(
|
||||
MR.strings.repo_extension_message,
|
||||
modifier = Modifier.clickable {
|
||||
extension.repoUrl ?: return@clickable
|
||||
uriHandler.openUri(
|
||||
extension.repoUrl
|
||||
.replace("https://raw.githubusercontent.com", "https://github.com")
|
||||
.removeSuffix("/repo/"),
|
||||
)
|
||||
url ?: return@clickable
|
||||
uriHandler.openUri(url)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -185,7 +185,17 @@ class ExtensionManager(
|
|||
val hasUpdate = installedExt.updateExists(availableExt)
|
||||
|
||||
if (installedExt.hasUpdate != hasUpdate) {
|
||||
mutInstalledExtensions[index] = installedExt.copy(hasUpdate = hasUpdate)
|
||||
mutInstalledExtensions[index] = installedExt.copy(
|
||||
hasUpdate = hasUpdate,
|
||||
isFromExternalRepo = availableExt.isFromExternalRepo,
|
||||
repoUrl = availableExt.repoUrl,
|
||||
)
|
||||
changed = true
|
||||
} else if (availableExt.isFromExternalRepo) {
|
||||
mutInstalledExtensions[index] = installedExt.copy(
|
||||
isFromExternalRepo = true,
|
||||
repoUrl = availableExt.repoUrl,
|
||||
)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ internal class ExtensionApi {
|
|||
apkName = it.apk,
|
||||
iconUrl = "$repoUrl/icon/${it.pkg}.png",
|
||||
repoUrl = repoUrl,
|
||||
isRepoSource = isRepoSource,
|
||||
isFromExternalRepo = isRepoSource,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ sealed class Extension {
|
|||
val isUnofficial: Boolean = false,
|
||||
val isShared: Boolean,
|
||||
val repoUrl: String? = null,
|
||||
val isRepoSource: Boolean = false,
|
||||
val isFromExternalRepo: Boolean = false,
|
||||
) : Extension()
|
||||
|
||||
data class Available(
|
||||
|
@ -45,7 +45,7 @@ sealed class Extension {
|
|||
val apkName: String,
|
||||
val iconUrl: String,
|
||||
val repoUrl: String,
|
||||
val isRepoSource: Boolean,
|
||||
val isFromExternalRepo: Boolean,
|
||||
) : Extension() {
|
||||
|
||||
data class Source(
|
||||
|
|
|
@ -318,8 +318,8 @@
|
|||
<string name="untrusted_extension">Untrusted extension</string>
|
||||
<string name="untrusted_extension_message">This extension was signed by any unknown author and wasn\'t loaded.\n\nMalicious extensions can read any stored login credentials or execute arbitrary code.\n\nBy trusting this extension\'s certificate, you accept these risks.</string>
|
||||
<string name="obsolete_extension_message">This extension is no longer available. It may not function properly and can cause issues with the app. Uninstalling it is recommended.</string>
|
||||
<string name="unofficial_extension_message">This extension is not from the official list.</string>
|
||||
<string name="extension_api_error">Failed to get extensions list</string>
|
||||
<string name="unofficial_extension_message">This extension is not from the official repo.</string>
|
||||
<string name="extension_api_error">Failed to fetch available extensions</string>
|
||||
<string name="ext_info_version">Version</string>
|
||||
<string name="ext_info_language">Language</string>
|
||||
<string name="ext_info_age_rating">Age rating</string>
|
||||
|
|
Loading…
Reference in a new issue