diff --git a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m index 1b6ad314b..d6482e6f1 100644 --- a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m @@ -195,6 +195,16 @@ NS_ASSUME_NONNULL_BEGIN } [contents addSection:censorshipSection]; +#ifdef DEBUG + OWSTableSection *themeSection = [OWSTableSection new]; + themeSection.headerTitle = NSLocalizedString(@"THEME_SECTION", nil); + [themeSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_THEME", @"") + isOn:[Environment.preferences isThemeEnabled] + target:weakSelf + selector:@selector(didToggleThemeSwitch:)]]; + [contents addSection:themeSection]; +#endif + self.contents = contents; } @@ -274,6 +284,13 @@ NS_ASSUME_NONNULL_BEGIN [self updateTableContents]; } +- (void)didToggleThemeSwitch:(UISwitch *)sender +{ + [Environment.preferences setIsThemeEnabled:sender.isOn]; + + // TODO: Notify and refresh. +} + @end NS_ASSUME_NONNULL_END diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index d852ebce1..ea18bfff8 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1886,6 +1886,9 @@ /* No comment provided by engineer. */ "SETTINGS_ADVANCED_SUBMIT_DEBUGLOG" = "Submit Debug Log"; +/* No comment provided by engineer. */ +"SETTINGS_ADVANCED_THEME" = "Theme"; + /* No comment provided by engineer. */ "SETTINGS_ADVANCED_TITLE" = "Advanced"; @@ -2132,6 +2135,9 @@ /* Label for button to verify a user's safety number. */ "SYSTEM_MESSAGE_ACTION_VERIFY_SAFETY_NUMBER" = "Verify Safety Number"; +/* No comment provided by engineer. */ +"THEME_SECTION" = "THEME_SECTION"; + /* {{number of days}} embedded in strings, e.g. 'Alice updated disappearing messages expiration to {{5 days}}'. See other *_TIME_AMOUNT strings */ "TIME_AMOUNT_DAYS" = "%@ days"; diff --git a/SignalMessaging/utils/OWSPreferences.h b/SignalMessaging/utils/OWSPreferences.h index fca6588f2..fcd9020da 100644 --- a/SignalMessaging/utils/OWSPreferences.h +++ b/SignalMessaging/utils/OWSPreferences.h @@ -61,7 +61,8 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification; - (BOOL)hasGeneratedThumbnails; - (void)setHasGeneratedThumbnails:(BOOL)value; -#pragma mark - Calling +- (BOOL)isThemeEnabled; +- (void)setIsThemeEnabled:(BOOL)flag; #pragma mark Callkit diff --git a/SignalMessaging/utils/OWSPreferences.m b/SignalMessaging/utils/OWSPreferences.m index b9ef59659..239d76647 100644 --- a/SignalMessaging/utils/OWSPreferences.m +++ b/SignalMessaging/utils/OWSPreferences.m @@ -31,6 +31,7 @@ NSString *const OWSPreferencesKeyHasGeneratedThumbnails = @"OWSPreferencesKeyHas NSString *const OWSPreferencesKeyIOSUpgradeNagDate = @"iOSUpgradeNagDate"; NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExtensions_5"; NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySystemCallLogEnabled"; +NSString *const OWSPreferencesKeyEnableTheme = @"OWSPreferencesKeyEnableTheme"; @implementation OWSPreferences @@ -58,7 +59,7 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste OWSAssert(key != nil); __block id result; - [OWSPrimaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) { + [OWSPrimaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { result = [self tryGetValueForKey:key transaction:transaction]; }]; return result; @@ -72,10 +73,9 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste - (void)setValueForKey:(NSString *)key toValue:(nullable id)value { - [OWSPrimaryStorage.dbReadWriteConnection - readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { - [self setValueForKey:key toValue:value transaction:transaction]; - }]; + [OWSPrimaryStorage.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + [self setValueForKey:key toValue:value transaction:transaction]; + }]; } - (void)setValueForKey:(NSString *)key @@ -414,6 +414,19 @@ NSString *const OWSPreferencesKeySystemCallLogEnabled = @"OWSPreferencesKeySyste } } +- (BOOL)isThemeEnabled +{ + NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyEnableTheme]; + return preference ? [preference boolValue] : NO; +} + +- (void)setIsThemeEnabled:(BOOL)flag +{ + OWSAssert(CurrentAppContext().isMainApp); + + [self setValueForKey:OWSPreferencesKeyEnableTheme toValue:@(flag)]; +} + #pragma mark - Push Tokens - (void)setPushToken:(NSString *)value