mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-06 03:55:06 +01:00
Fix external repo info banner in ExtensionDetailsScreen
This commit is contained in:
parent
3dc2f9a711
commit
4b8fa059d5
@ -11,7 +11,7 @@ class CreateSourceRepo(private val preferences: SourcePreferences) {
|
|||||||
return Result.InvalidUrl
|
return Result.InvalidUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.extensionRepos() += name.substringBeforeLast("/index.min.json")
|
preferences.extensionRepos() += name.removeSuffix("/index.min.json")
|
||||||
|
|
||||||
return Result.Success
|
return Result.Success
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ import eu.kanade.tachiyomi.extension.model.Extension
|
|||||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||||
import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionDetailsScreenModel
|
import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionDetailsScreenModel
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
|
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
|
||||||
@ -138,7 +139,7 @@ fun ExtensionDetailsScreen(
|
|||||||
private fun ExtensionDetails(
|
private fun ExtensionDetails(
|
||||||
contentPadding: PaddingValues,
|
contentPadding: PaddingValues,
|
||||||
extension: Extension.Installed,
|
extension: Extension.Installed,
|
||||||
sources: List<ExtensionSourceItem>,
|
sources: ImmutableList<ExtensionSourceItem>,
|
||||||
onClickSourcePreferences: (sourceId: Long) -> Unit,
|
onClickSourcePreferences: (sourceId: Long) -> Unit,
|
||||||
onClickUninstall: () -> Unit,
|
onClickUninstall: () -> Unit,
|
||||||
onClickSource: (sourceId: Long) -> Unit,
|
onClickSource: (sourceId: Long) -> Unit,
|
||||||
@ -150,18 +151,24 @@ private fun ExtensionDetails(
|
|||||||
contentPadding = contentPadding,
|
contentPadding = contentPadding,
|
||||||
) {
|
) {
|
||||||
when {
|
when {
|
||||||
extension.isRepoSource ->
|
extension.isFromExternalRepo ->
|
||||||
item {
|
item {
|
||||||
val uriHandler = LocalUriHandler.current
|
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(
|
WarningBanner(
|
||||||
MR.strings.repo_extension_message,
|
MR.strings.repo_extension_message,
|
||||||
modifier = Modifier.clickable {
|
modifier = Modifier.clickable {
|
||||||
extension.repoUrl ?: return@clickable
|
url ?: return@clickable
|
||||||
uriHandler.openUri(
|
uriHandler.openUri(url)
|
||||||
extension.repoUrl
|
|
||||||
.replace("https://raw.githubusercontent.com", "https://github.com")
|
|
||||||
.removeSuffix("/repo/"),
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,17 @@ class ExtensionManager(
|
|||||||
val hasUpdate = installedExt.updateExists(availableExt)
|
val hasUpdate = installedExt.updateExists(availableExt)
|
||||||
|
|
||||||
if (installedExt.hasUpdate != hasUpdate) {
|
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
|
changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ internal class ExtensionApi {
|
|||||||
apkName = it.apk,
|
apkName = it.apk,
|
||||||
iconUrl = "$repoUrl/icon/${it.pkg}.png",
|
iconUrl = "$repoUrl/icon/${it.pkg}.png",
|
||||||
repoUrl = repoUrl,
|
repoUrl = repoUrl,
|
||||||
isRepoSource = isRepoSource,
|
isFromExternalRepo = isRepoSource,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ sealed class Extension {
|
|||||||
val isUnofficial: Boolean = false,
|
val isUnofficial: Boolean = false,
|
||||||
val isShared: Boolean,
|
val isShared: Boolean,
|
||||||
val repoUrl: String? = null,
|
val repoUrl: String? = null,
|
||||||
val isRepoSource: Boolean = false,
|
val isFromExternalRepo: Boolean = false,
|
||||||
) : Extension()
|
) : Extension()
|
||||||
|
|
||||||
data class Available(
|
data class Available(
|
||||||
@ -45,7 +45,7 @@ sealed class Extension {
|
|||||||
val apkName: String,
|
val apkName: String,
|
||||||
val iconUrl: String,
|
val iconUrl: String,
|
||||||
val repoUrl: String,
|
val repoUrl: String,
|
||||||
val isRepoSource: Boolean,
|
val isFromExternalRepo: Boolean,
|
||||||
) : Extension() {
|
) : Extension() {
|
||||||
|
|
||||||
data class Source(
|
data class Source(
|
||||||
|
@ -318,8 +318,8 @@
|
|||||||
<string name="untrusted_extension">Untrusted extension</string>
|
<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="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="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="unofficial_extension_message">This extension is not from the official repo.</string>
|
||||||
<string name="extension_api_error">Failed to get extensions list</string>
|
<string name="extension_api_error">Failed to fetch available extensions</string>
|
||||||
<string name="ext_info_version">Version</string>
|
<string name="ext_info_version">Version</string>
|
||||||
<string name="ext_info_language">Language</string>
|
<string name="ext_info_language">Language</string>
|
||||||
<string name="ext_info_age_rating">Age rating</string>
|
<string name="ext_info_age_rating">Age rating</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user