diff --git a/CHANGES.rst b/CHANGES.rst index 3136b496b..ed5e3e35a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,7 @@ Changes to be released in next version 🙌 Improvements * RoomMemberDetailsVC: Enable / disable "Hide all messages from this user" from settings (#4281). * RoomVC: Show / Hide More and Report Content contextual menu from settings (#4285). + * SettingsVC: Show / hide NSFW and decrypted content options from build settings (#4290). 🐛 Bugfix * RoomVC: Avoid navigation to integration management using integration popup with settings set to integration disabled (#4261). diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index 00a7a8123..564475de3 100644 --- a/Config/BuildSettings.swift +++ b/Config/BuildSettings.swift @@ -242,6 +242,8 @@ final class BuildSettings: NSObject { static let settingsScreenShowChangePassword:Bool = true static let settingsScreenShowInviteFriends:Bool = true static let settingsScreenShowEnableStunServerFallback: Bool = true + static let settingsScreenShowNotificationDecodedContentOption: Bool = true + static let settingsScreenShowNsfwRoomsOption: Bool = true static let settingsSecurityScreenShowSessions:Bool = true static let settingsSecurityScreenShowSetupBackup:Bool = true static let settingsSecurityScreenShowRestoreBackup:Bool = true diff --git a/Riot/Managers/Settings/RiotSettings.swift b/Riot/Managers/Settings/RiotSettings.swift index 9d05078f1..bd28f9926 100644 --- a/Riot/Managers/Settings/RiotSettings.swift +++ b/Riot/Managers/Settings/RiotSettings.swift @@ -60,6 +60,8 @@ final class RiotSettings: NSObject { static let roomSettingsScreenShowFlairSettings = "roomSettingsScreenShowFlairSettings" static let roomSettingsScreenShowAdvancedSettings = "roomSettingsScreenShowAdvancedSettings" static let roomSettingsScreenAdvancedShowEncryptToVerifiedOption = "roomSettingsScreenAdvancedShowEncryptToVerifiedOption" + static let settingsScreenShowNotificationDecodedContentOption = "settingsScreenShowNotificationDecodedContentOption" + static let settingsScreenShowNsfwRoomsOption = "settingsScreenShowNsfwRoomsOption" static let roomsAllowToJoinPublicRooms = "roomsAllowToJoinPublicRooms" static let homeScreenShowFavouritesTab = "homeScreenShowFavouritesTab" static let homeScreenShowPeopleTab = "homeScreenShowPeopleTab" @@ -517,6 +519,26 @@ final class RiotSettings: NSObject { defaults.set(newValue, forKey: UserDefaultsKeys.settingsScreenShowEnableStunServerFallback) } } + var settingsScreenShowNotificationDecodedContentOption: Bool { + get { + guard defaults.object(forKey: UserDefaultsKeys.settingsScreenShowNotificationDecodedContentOption) != nil else { + return BuildSettings.settingsScreenShowNotificationDecodedContentOption + } + return defaults.bool(forKey: UserDefaultsKeys.settingsScreenShowNotificationDecodedContentOption) + } set { + defaults.set(newValue, forKey: UserDefaultsKeys.settingsScreenShowNotificationDecodedContentOption) + } + } + var settingsScreenShowNsfwRoomsOption: Bool { + get { + guard defaults.object(forKey: UserDefaultsKeys.settingsScreenShowNsfwRoomsOption) != nil else { + return BuildSettings.settingsScreenShowNsfwRoomsOption + } + return defaults.bool(forKey: UserDefaultsKeys.settingsScreenShowNsfwRoomsOption) + } set { + defaults.set(newValue, forKey: UserDefaultsKeys.settingsScreenShowNsfwRoomsOption) + } + } var settingsSecurityScreenShowSessions: Bool { get { guard defaults.object(forKey: UserDefaultsKeys.settingsSecurityScreenShowSessions) != nil else { diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 12adb0364..115d86be4 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -350,7 +350,10 @@ TableViewSectionsDelegate> Section *sectionNotificationSettings = [Section sectionWithTag:SECTION_TAG_NOTIFICATIONS]; [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_ENABLE_PUSH_INDEX]; - [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_SHOW_DECODED_CONTENT]; + if (RiotSettings.shared.settingsScreenShowNotificationDecodedContentOption) + { + [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_SHOW_DECODED_CONTENT]; + } [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_GLOBAL_SETTINGS_INDEX]; [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_PIN_MISSED_NOTIFICATIONS_INDEX]; [sectionNotificationSettings addRowWithTag:NOTIFICATION_SETTINGS_PIN_UNREAD_INDEX]; @@ -458,7 +461,10 @@ TableViewSectionsDelegate> [sectionOther addRowWithTag:OTHER_PRIVACY_INDEX]; } [sectionOther addRowWithTag:OTHER_THIRD_PARTY_INDEX]; - [sectionOther addRowWithTag:OTHER_SHOW_NSFW_ROOMS_INDEX]; + if (RiotSettings.shared.settingsScreenShowNsfwRoomsOption) + { + [sectionOther addRowWithTag:OTHER_SHOW_NSFW_ROOMS_INDEX]; + } if (BuildSettings.settingsScreenAllowChangingCrashUsageDataSettings) {