diff --git a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m index 1b6ad314b..73d2902d5 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 THEME_ENABLED + OWSTableSection *themeSection = [OWSTableSection new]; + themeSection.headerTitle = NSLocalizedString(@"THEME_SECTION", nil); + [themeSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_THEME", @"") + isOn:[UIColor 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 +{ + [UIColor 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..376104bab 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"; + /* {{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/categories/UIColor+OWS.h b/SignalMessaging/categories/UIColor+OWS.h index 419b20bc5..c51cf85b7 100644 --- a/SignalMessaging/categories/UIColor+OWS.h +++ b/SignalMessaging/categories/UIColor+OWS.h @@ -6,6 +6,10 @@ NS_ASSUME_NONNULL_BEGIN +#ifdef DEBUG +#define THEME_ENABLED +#endif + @interface UIColor (OWS) #pragma mark - Global App Colors @@ -77,6 +81,13 @@ NS_ASSUME_NONNULL_BEGIN @property (class, readonly, nonatomic) UIColor *ows_grey600Color; @property (class, readonly, nonatomic) UIColor *ows_darkSkyBlueColor; +#pragma mark - Theme + +#ifdef THEME_ENABLED ++ (BOOL)isThemeEnabled; ++ (void)setIsThemeEnabled:(BOOL)value; +#endif + @end NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/categories/UIColor+OWS.m b/SignalMessaging/categories/UIColor+OWS.m index 3c979ad8c..3b6e0e7da 100644 --- a/SignalMessaging/categories/UIColor+OWS.m +++ b/SignalMessaging/categories/UIColor+OWS.m @@ -2,12 +2,17 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "UIColor+OWS.h" #import "OWSMath.h" +#import "UIColor+OWS.h" #import +#import +#import NS_ASSUME_NONNULL_BEGIN +NSString *const UIColorCollection = @"UIColorCollection"; +NSString *const UIColorKeyThemeEnabled = @"UIColorKeyThemeEnabled"; + @implementation UIColor (OWS) #pragma mark - Global App Colors @@ -338,6 +343,26 @@ NS_ASSUME_NONNULL_BEGIN return [self.ows_conversationColorMap allKeysForObject:color].firstObject; } +#pragma mark - Theme + ++ (BOOL)isThemeEnabled +{ + OWSAssertIsOnMainThread(); + + return [OWSPrimaryStorage.sharedManager.dbReadConnection boolForKey:UIColorKeyThemeEnabled + inCollection:UIColorCollection + defaultValue:NO]; +} + ++ (void)setIsThemeEnabled:(BOOL)value +{ + OWSAssertIsOnMainThread(); + + [OWSPrimaryStorage.sharedManager.dbReadWriteConnection setBool:value + forKey:UIColorKeyThemeEnabled + inCollection:UIColorCollection]; +} + @end NS_ASSUME_NONNULL_END diff --git a/SignalMessaging/utils/OWSPreferences.h b/SignalMessaging/utils/OWSPreferences.h index fca6588f2..15c653f38 100644 --- a/SignalMessaging/utils/OWSPreferences.h +++ b/SignalMessaging/utils/OWSPreferences.h @@ -61,8 +61,6 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification; - (BOOL)hasGeneratedThumbnails; - (void)setHasGeneratedThumbnails:(BOOL)value; -#pragma mark - Calling - #pragma mark Callkit - (BOOL)isSystemCallLogEnabled; diff --git a/SignalMessaging/utils/OWSPreferences.m b/SignalMessaging/utils/OWSPreferences.m index b9ef59659..9484812df 100644 --- a/SignalMessaging/utils/OWSPreferences.m +++ b/SignalMessaging/utils/OWSPreferences.m @@ -58,7 +58,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 +72,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