Pārlūkot izejas kodu

Better distinguish between obsolete and unofficial extensions

arkon 4 gadi atpakaļ
vecāks
revīzija
d875d5ef74

+ 2 - 1
app/src/main/java/eu/kanade/tachiyomi/extension/model/Extension.kt

@@ -18,7 +18,8 @@ sealed class Extension {
         val sources: List<Source>,
         override val lang: String,
         val hasUpdate: Boolean = false,
-        val isObsolete: Boolean = false
+        val isObsolete: Boolean = false,
+        val isUnofficial: Boolean = false
     ) : Extension()
 
     data class Available(

+ 7 - 4
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<String>() +
-        Injekt.get<PreferencesHelper>().trustedSignatures().get() +
-        // inorichi's key
-        "7ce04da7773d41b489f4693a366c36bcd0a11fc39b547168553c285bd7348e23"
+        Injekt.get<PreferencesHelper>().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)
     }
 

+ 7 - 1
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() }

+ 4 - 0
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)
                 }

+ 2 - 3
app/src/main/res/layout/extension_detail_controller.xml

@@ -61,7 +61,7 @@
         tools:text="eu.kanade.tachiyomi.extension.en.myext" />
 
     <TextView
-        android:id="@+id/extension_obsolete"
+        android:id="@+id/extension_warning_banner"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="16dp"
@@ -69,7 +69,6 @@
         android:background="@color/red_error"
         android:gravity="center"
         android:padding="16dp"
-        android:text="@string/obsolete_extension_message"
         android:textColor="@android:color/white"
         android:visibility="gone"
         app:layout_constraintEnd_toEndOf="parent"
@@ -87,7 +86,7 @@
         android:text="@string/ext_uninstall"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="@id/guideline"
-        app:layout_constraintTop_toBottomOf="@id/extension_obsolete" />
+        app:layout_constraintTop_toBottomOf="@id/extension_warning_banner" />
 
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/extension_prefs_recycler"

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -206,6 +206,7 @@
     <string name="ext_installing">Installing</string>
     <string name="ext_installed">Installed</string>
     <string name="ext_trust">Trust</string>
+    <string name="ext_unofficial">Unofficial</string>
     <string name="ext_untrusted">Untrusted</string>
     <string name="ext_uninstall">Uninstall</string>
     <string name="ext_preferences">Preferences</string>
@@ -213,6 +214,7 @@
     <string name="untrusted_extension">Untrusted extension</string>
     <string name="untrusted_extension_message">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.</string>
     <string name="obsolete_extension_message">This extension is no longer available.</string>
+    <string name="unofficial_extension_message">This extension is not from the official Tachiyomi extensions list.</string>
     <string name="ext_version_info">Version: %1$s</string>
     <string name="ext_language_info">Language: %1$s</string>
     <string name="ext_empty_preferences">No preferences to edit for this extension</string>