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
|
||||
}
|
||||
|
||||
@@ -268,6 +268,8 @@
|
||||
|
||||
<string name="pref_category_extensions">Extensions</string>
|
||||
<string name="pref_allowed_content_warnings">Allowed content warnings</string>
|
||||
<string name="pref_apply_content_warnings_to_installed">Also apply to installed extensions</string>
|
||||
<string name="pref_apply_content_warnings_to_installed_summary">When off, extensions you already installed keep loading and updating regardless of their warning</string>
|
||||
<string name="content_warnings_info">Requires app restart to take effect. Extensions that aren\'t loaded won\'t provide their sources anywhere in the app. This does not prevent unofficial or potentially incorrectly flagged extensions from surfacing 18+ content within the app.</string>
|
||||
|
||||
<string name="relative_time_today">Today</string>
|
||||
|
||||
Reference in New Issue
Block a user