From d875d5ef746f1a70bd9dba7f72da9a83ed7a8a08 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 13 May 2020 22:47:44 -0400 Subject: [PATCH] Better distinguish between obsolete and unofficial extensions --- .../eu/kanade/tachiyomi/extension/model/Extension.kt | 3 ++- .../tachiyomi/extension/util/ExtensionLoader.kt | 11 +++++++---- .../ui/browse/extension/ExtensionDetailsController.kt | 8 +++++++- .../tachiyomi/ui/browse/extension/ExtensionHolder.kt | 4 ++++ .../main/res/layout/extension_detail_controller.xml | 5 ++--- app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt index 7fb384cc0..c8f8626da 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt @@ -18,7 +18,8 @@ sealed class Extension { val sources: List, override val lang: String, val hasUpdate: Boolean = false, - val isObsolete: Boolean = false + val isObsolete: Boolean = false, + val isUnofficial: Boolean = false ) : Extension() data class Available( diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt index 0ff9b6e61..7bbd84695 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt @@ -31,13 +31,13 @@ internal object ExtensionLoader { private const val PACKAGE_FLAGS = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES + // inorichi's key + val officialSignature = "7ce04da7773d41b489f4693a366c36bcd0a11fc39b547168553c285bd7348e23" /** * List of the trusted signatures. */ var trustedSignatures = mutableSetOf() + - Injekt.get().trustedSignatures().get() + - // inorichi's key - "7ce04da7773d41b489f4693a366c36bcd0a11fc39b547168553c285bd7348e23" + Injekt.get().trustedSignatures().get() + officialSignature /** * Return a list of all the installed extensions initialized concurrently. @@ -159,7 +159,10 @@ internal object ExtensionLoader { else -> "all" } - val extension = Extension.Installed(extName, pkgName, versionName, versionCode, sources, lang) + val extension = Extension.Installed( + extName, pkgName, versionName, versionCode, sources, lang, + isUnofficial = signatureHash != officialSignature + ) return LoadResult.Success(extension) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionDetailsController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionDetailsController.kt index e73e4f945..bdd3db428 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionDetailsController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionDetailsController.kt @@ -84,7 +84,13 @@ class ExtensionDetailsController(bundle: Bundle? = null) : .launchIn(scope) if (extension.isObsolete) { - binding.extensionObsolete.visible() + binding.extensionWarningBanner.visible() + binding.extensionWarningBanner.setText(R.string.obsolete_extension_message) + } + + if (extension.isUnofficial) { + binding.extensionWarningBanner.visible() + binding.extensionWarningBanner.setText(R.string.unofficial_extension_message) } val themedContext by lazy { getPreferenceThemeContext() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt index 456806b38..00645722c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/extension/ExtensionHolder.kt @@ -91,6 +91,10 @@ class ExtensionHolder(view: View, override val adapter: ExtensionAdapter) : setTextColor(context.getResourceColor(R.attr.colorError)) setText(R.string.ext_obsolete) } + extension.isUnofficial -> { + setTextColor(context.getResourceColor(R.attr.colorError)) + setText(R.string.ext_unofficial) + } else -> { setText(R.string.ext_details) } diff --git a/app/src/main/res/layout/extension_detail_controller.xml b/app/src/main/res/layout/extension_detail_controller.xml index f920ae17e..743f17257 100644 --- a/app/src/main/res/layout/extension_detail_controller.xml +++ b/app/src/main/res/layout/extension_detail_controller.xml @@ -61,7 +61,7 @@ tools:text="eu.kanade.tachiyomi.extension.en.myext" /> + app:layout_constraintTop_toBottomOf="@id/extension_warning_banner" /> Installing Installed Trust + Unofficial Untrusted Uninstall Preferences @@ -213,6 +214,7 @@ Untrusted extension This extension was signed with an untrusted certificate and wasn\'t activated.\n\nA malicious extension could read any login credentials stored in Tachiyomi or execute arbitrary code.\n\nBy trusting this certificate you accept these risks. This extension is no longer available. + This extension is not from the official Tachiyomi extensions list. Version: %1$s Language: %1$s No preferences to edit for this extension