Fix external repo info banner in ExtensionDetailsScreen
(cherry picked from commit 4b8fa059d5f9234176680d0c5c9e8e706ddd7e98) # Conflicts: # app/src/main/java/eu/kanade/presentation/browse/ExtensionDetailsScreen.kt # app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt # app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt
This commit is contained in:
parent
27d0ad11bd
commit
a2e121aba1
@ -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.i18n.sy.SYMR
|
||||
@ -139,7 +140,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,
|
||||
@ -157,21 +158,24 @@ private fun ExtensionDetails(
|
||||
WarningBanner(SYMR.strings.redundant_extension_message)
|
||||
}
|
||||
// SY <--
|
||||
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/")
|
||||
// SY -->
|
||||
.removeSuffix("/repo"),
|
||||
// SY <--
|
||||
)
|
||||
url ?: return@clickable
|
||||
uriHandler.openUri(url)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -234,17 +234,22 @@ class ExtensionManager(
|
||||
changed = true
|
||||
// SY <--
|
||||
} else if (availableExt != null) {
|
||||
// SY -->
|
||||
val hasUpdate = installedExt.updateExists(availableExt)
|
||||
|
||||
if (installedExt.hasUpdate != hasUpdate) {
|
||||
mutInstalledExtensions[index] = installedExt.copy(hasUpdate = hasUpdate, isRepoSource = availableExt.isRepoSource, repoUrl = availableExt.repoUrl)
|
||||
mutInstalledExtensions[index] = installedExt.copy(
|
||||
hasUpdate = hasUpdate,
|
||||
isFromExternalRepo = availableExt.isFromExternalRepo,
|
||||
repoUrl = availableExt.repoUrl,
|
||||
)
|
||||
changed = true
|
||||
} else if (availableExt.isRepoSource) {
|
||||
mutInstalledExtensions[index] = installedExt.copy(isRepoSource = true, repoUrl = availableExt.repoUrl)
|
||||
} else if (availableExt.isFromExternalRepo) {
|
||||
mutInstalledExtensions[index] = installedExt.copy(
|
||||
isFromExternalRepo = true,
|
||||
repoUrl = availableExt.repoUrl,
|
||||
)
|
||||
changed = true
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
|
@ -141,7 +141,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,
|
||||
// SY -->
|
||||
val isRedundant: Boolean = false,
|
||||
// SY <--
|
||||
@ -48,7 +48,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…
x
Reference in New Issue
Block a user