Allow user to load installed extensions regardless of content warning (#3952)
This commit is contained in:
@@ -48,6 +48,11 @@ class SourcePreferences(
|
||||
setOf(ContentWarning.SAFE, ContentWarning.MIXED, ContentWarning.NSFW),
|
||||
)
|
||||
|
||||
val applyContentWarningsToInstalled: Preference<Boolean> = preferenceStore.getBoolean(
|
||||
"apply_content_warnings_to_installed",
|
||||
true,
|
||||
)
|
||||
|
||||
val migrationSortingMode: Preference<SetMigrateSorting.Mode> = preferenceStore.getEnum(
|
||||
"pref_migration_sorting",
|
||||
SetMigrateSorting.Mode.ALPHABETICAL,
|
||||
|
||||
@@ -81,6 +81,22 @@ object SettingsBrowseScreen : SearchableSettings {
|
||||
}
|
||||
},
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = sourcePreferences.applyContentWarningsToInstalled,
|
||||
title = stringResource(MR.strings.pref_apply_content_warnings_to_installed),
|
||||
subtitle = stringResource(MR.strings.pref_apply_content_warnings_to_installed_summary),
|
||||
onValueChanged = { newValue ->
|
||||
if (newValue) {
|
||||
true
|
||||
} else {
|
||||
(context as FragmentActivity).authenticate(
|
||||
title = context.stringResource(
|
||||
MR.strings.pref_apply_content_warnings_to_installed,
|
||||
),
|
||||
)
|
||||
}
|
||||
},
|
||||
),
|
||||
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.content_warnings_info)),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -223,7 +223,9 @@ internal object ExtensionLoader {
|
||||
*/
|
||||
private suspend fun loadExtension(context: Context, extensionInfo: ExtensionInfo): LoadResult {
|
||||
val trustExtension: TrustExtension = context.appGraph.trustExtension
|
||||
val enabledContentWarnings = context.appGraph.sourcePreferences.enabledContentWarnings.get()
|
||||
val sourcePreferences = context.appGraph.sourcePreferences
|
||||
val enabledContentWarnings = sourcePreferences.enabledContentWarnings.get()
|
||||
val applyContentWarningsToInstalled = sourcePreferences.applyContentWarningsToInstalled.get()
|
||||
|
||||
val pkgManager = context.packageManager
|
||||
val pkgInfo = extensionInfo.packageInfo
|
||||
@@ -281,7 +283,7 @@ internal object ExtensionLoader {
|
||||
appInfo.metaData.getInt(METADATA_NSFW) == 1 -> ContentWarning.NSFW
|
||||
else -> ContentWarning.SAFE
|
||||
}
|
||||
if (contentWarning !in enabledContentWarnings) {
|
||||
if (applyContentWarningsToInstalled && contentWarning !in enabledContentWarnings) {
|
||||
logcat(LogPriority.WARN) { "Extension $pkgName with $contentWarning not allowed" }
|
||||
return LoadResult.Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user