Better distinguish between obsolete and unofficial extensions

This commit is contained in:
arkon
2020-05-13 22:47:44 -04:00
parent fc4e290c49
commit d875d5ef74
6 changed files with 24 additions and 9 deletions

View File

@ -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(

View File

@ -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)
}

View File

@ -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() }

View File

@ -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)
}