Merge branch 'charlesmchen/tweakAppearance'

pull/1/head
Matthew Chen 6 years ago
commit 343faed8b7

@ -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

@ -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";

@ -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

@ -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 <SignalServiceKit/Cryptography.h>
#import <SignalServiceKit/OWSPrimaryStorage.h>
#import <SignalServiceKit/YapDatabaseConnection+OWS.h>
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

@ -61,8 +61,6 @@ extern NSString *const OWSPreferencesCallLoggingDidChangeNotification;
- (BOOL)hasGeneratedThumbnails;
- (void)setHasGeneratedThumbnails:(BOOL)value;
#pragma mark - Calling
#pragma mark Callkit
- (BOOL)isSystemCallLogEnabled;

@ -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

Loading…
Cancel
Save