123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825 |
- // _____ _
- // |_ _| |_ _ _ ___ ___ _ __ __ _
- // | | | ' \| '_/ -_) -_) ' \/ _` |_
- // |_| |_||_|_| \___\___|_|_|_\__,_(_)
- //
- // Threema iOS Client
- // Copyright (c) 2012-2020 Threema GmbH
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU Affero General Public License, version 3,
- // as published by the Free Software Foundation.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU Affero General Public License for more details.
- //
- // You should have received a copy of the GNU Affero General Public License
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
- #import "UserSettings.h"
- #import "AppGroup.h"
- #import "LicenseStore.h"
- #import "DatabaseManager.h"
- #import "ServerConnector.h"
- #import "MyIdentityStore.h"
- #import "AvatarMaker.h"
- #import "ValidationLogger.h"
- #import "PushSetting.h"
- #import "EntityManager.h"
- #import "EntityFetcher.h"
- #import "NSString+Hex.h"
- #import "Conversation.h"
- #import "Contact.h"
- @implementation UserSettings {
- NSUserDefaults *defaults;
- }
- @synthesize sendReadReceipts;
- @synthesize syncContacts;
- @synthesize syncExclusionList;
- @synthesize blacklist;
- @synthesize workIdentities;
- @synthesize pushSettingsList;
- @synthesize sendTypingIndicator;
- @synthesize blockUnknown;
- @synthesize enablePoi;
- @synthesize hideStaleContacts;
- @synthesize inAppSounds;
- @synthesize inAppVibrate;
- @synthesize inAppPreview;
- @synthesize pushSound;
- @synthesize pushGroupGenerated;
- @synthesize pushGroupSound;
- @synthesize pushDecrypt;
- @synthesize pushShowNickname;
- @synthesize imageSize;
- @synthesize videoQuality;
- @synthesize autoSaveMedia;
- @synthesize chatFontSize;
- @synthesize useDynamicFontSize;
- @synthesize disableBigEmojis;
- @synthesize wallpaper;
- @synthesize showReceivedTimestamps;
- @synthesize returnToSend;
- @synthesize darkTheme;
- @synthesize useSystemTheme;
- @synthesize showProfilePictures;
- @synthesize sortOrderFirstName;
- @synthesize displayOrderFirstName;
- @synthesize validationLogging;
- @synthesize enableIPv6;
- @synthesize companyDirectory;
- @synthesize askedForPushDecryption;
- @synthesize sendProfilePicture;
- @synthesize profilePictureContactList;
- @synthesize profilePictureRequestList;
- @synthesize showGalleryPreview;
- @synthesize disableProximityMonitoring;
- @synthesize enableThreemaCall;
- @synthesize alwaysRelayCalls;
- @synthesize enableCallKit;
- @synthesize previewLimit;
- @synthesize acceptedPrivacyPolicyDate;
- @synthesize acceptedPrivacyPolicyVariant;
- @synthesize voIPSound;
- @synthesize threemaWeb;
- @synthesize openPlusIconInChat;
- @synthesize safeConfig;
- @synthesize safeIntroShown;
- @synthesize workInfoShown;
- @synthesize videoCallInChatInfoShown;
- @synthesize videoCallInfoShown;
- @synthesize videoCallSpeakerInfoShown;
- @synthesize sentryAppDevice;
- @synthesize enableMasterDnd;
- @synthesize masterDndWorkingDays;
- @synthesize masterDndStartTime;
- @synthesize masterDndEndTime;
- @synthesize enableVideoCall;
- @synthesize threemaVideoCallQualitySetting;
- @synthesize quoteV2Active;
- static UserSettings *instance;
- + (UserSettings*)sharedUserSettings {
-
- @synchronized (self) {
- if (!instance)
- instance = [[UserSettings alloc] init];
- }
-
- return instance;
- }
- + (void)resetSharedInstance {
- [instance initFromUserDefaults];
- }
- - (id)init
- {
- self = [super init];
- if (self) {
- defaults = [AppGroup userDefaults];
-
- /* Push group sound migration */
- if ([defaults stringForKey:@"PushGroupSound"] == nil) {
- [self setPushGroupSound:[defaults stringForKey:@"PushSound"]];
- }
-
- if ([defaults stringForKey:@"VoIPSound"] == nil) {
- [self setVoIPSound:@"threema_best"];
- }
-
- NSMutableOrderedSet *tmpNoPushIdentities = [NSMutableOrderedSet orderedSetWithArray:[defaults arrayForKey:@"NoPushIdentities"]];
- if (tmpNoPushIdentities.array.count > 0) {
- [self pushSettingsMigration:tmpNoPushIdentities];
- }
-
- BOOL defaultDarkTheme = NO;
- BOOL defaultUseSystemTheme = true;
- BOOL defaultWorkInfoShown = false;
- if ([LicenseStore requiresLicenseKey]) {
- defaultDarkTheme = YES;
- defaultUseSystemTheme = false;
- defaultWorkInfoShown = true;
- }
-
- NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:YES], @"SendReadReceipts",
- [NSNumber numberWithBool:NO], @"SyncContacts",
- [NSArray array], @"SyncExclusionList",
- [NSArray array], @"Blacklist",
- [NSArray array], @"WorkIdentities",
- [NSArray array], @"PushSettingsList",
- [NSNumber numberWithBool:YES], @"SendTypingIndicator",
- [NSNumber numberWithBool:YES], @"InAppSounds",
- [NSNumber numberWithBool:YES], @"InAppVibrate",
- [NSNumber numberWithBool:YES], @"InAppPreview",
- [NSNumber numberWithBool:NO], @"BlockUnknown",
- [NSNumber numberWithBool:YES], @"EnablePOI",
- [NSNumber numberWithBool:NO], @"HideStaleContacts",
- @"large", @"ImageSize",
- @"high", @"VideoQuality",
- [NSNumber numberWithBool:NO], @"AutoSaveMedia",
- [NSNumber numberWithFloat:16.0f], @"ChatFontSize",
- [NSNumber numberWithBool:YES], @"UseDynamicFontSize",
- [NSNumber numberWithBool:NO], @"DisableBigEmojis",
- [NSNumber numberWithBool:YES], @"ShowReceivedTimestamps",
- [NSNumber numberWithBool:NO], @"ReturnToSend",
- [NSNumber numberWithBool:defaultDarkTheme], @"DarkTheme",
- [NSNumber numberWithBool:defaultUseSystemTheme], @"UseSystemTheme",
- [NSNumber numberWithBool:YES], @"ShowProfilePictures",
- [NSNumber numberWithBool:NO], @"SortOrderFirstName",
- [NSNumber numberWithBool:YES], @"DisplayOrderFirstName",
- @"default", @"PushSound",
- [NSNumber numberWithBool:NO], @"PushGroupGenerated",
- @"default", @"PushGroupSound",
- [NSNumber numberWithBool:NO], @"PushDecrypt",
- [NSNumber numberWithBool:NO], @"PushShowNickname",
- [NSNumber numberWithBool:NO], @"ValidationLogging",
- [NSNumber numberWithBool:YES], @"EnableIPv6",
- [NSNumber numberWithBool:NO], @"CompanyDirectory",
- [NSNumber numberWithBool:NO], @"AskedForPushDecryption",
- [NSNumber numberWithInt:SendProfilePictureNone], @"SendProfilePicture",
- [NSArray array], @"ProfilePictureContactList",
- [NSArray array], @"ProfilePictureRequestList",
- [NSNumber numberWithBool:YES], @"ShowGalleryPreview",
- [NSNumber numberWithBool:NO], @"DisableProximityMonitoring",
- [NSNumber numberWithBool:YES], @"EnableThreemaCall",
- [NSNumber numberWithBool:NO], @"AlwaysRelayCalls",
- [NSNumber numberWithBool:YES], @"EnableCallKit",
- [NSNumber numberWithFloat:50.0], @"PreviewLimit",
- [NSNumber numberWithBool:YES], @"ThreemaWeb",
- [NSNumber numberWithBool:NO], @"OpenPlusIconInChat",
- [NSData data], @"SafeConfig",
- [NSNumber numberWithBool:NO], @"SafeIntroShown",
- [NSNumber numberWithBool:defaultWorkInfoShown], @"WorkInfoShown",
- [NSNumber numberWithBool:NO], @"VideoCallInChatInfoShown",
- [NSNumber numberWithBool:NO], @"VideoCallInfoShown",
- [NSNumber numberWithBool:NO], @"VideoCallSpeakerInfoShown",
- [NSNumber numberWithBool:NO], @"EnableMasterDnd",
- [NSArray array], @"MasterDNDWorkingDays",
- @"08:00", @"MasterDNDStartTime",
- @"17:00", @"MasterDNDEndTime",
- [NSNumber numberWithBool:YES], @"EnableVideoCall",
- [NSNumber numberWithBool:NO], @"QuoteV2Active",
- [NSNumber numberWithInt:ThreemaVideoCallQualitySettingAuto], @"ThreemaVideoCallQualitySetting",
- @"", @"SentryAppDevice",
- nil];
- [defaults registerDefaults:appDefaults];
-
-
- [self initFromUserDefaults];
- }
- return self;
- }
- - (void)initFromUserDefaults {
- sendReadReceipts = [defaults boolForKey:@"SendReadReceipts"];
- syncContacts = [defaults boolForKey:@"SyncContacts"];
- syncExclusionList = [defaults arrayForKey:@"SyncExclusionList"];
- blacklist = [NSOrderedSet orderedSetWithArray:[defaults arrayForKey:@"Blacklist"]];
- workIdentities = [NSOrderedSet orderedSetWithArray:[defaults arrayForKey:@"WorkIdentities"]];
- pushSettingsList = [NSOrderedSet orderedSetWithArray:[defaults arrayForKey:@"PushSettingsList"]];
- sendTypingIndicator = [defaults boolForKey:@"SendTypingIndicator"];
- blockUnknown = [defaults boolForKey:@"BlockUnknown"];
- enablePoi = [defaults boolForKey:@"EnablePOI"];
- hideStaleContacts = [defaults boolForKey:@"HideStaleContacts"];
-
- inAppSounds = [defaults boolForKey:@"InAppSounds"];
- inAppVibrate = [defaults boolForKey:@"InAppVibrate"];
- inAppPreview = [defaults boolForKey:@"InAppPreview"];
- pushSound = [defaults stringForKey:@"PushSound"];
- pushGroupGenerated = [defaults boolForKey:@"PushGroupGenerated"];
- pushGroupSound = [defaults stringForKey:@"PushGroupSound"];
- pushDecrypt = [defaults boolForKey:@"PushDecrypt"];
- pushShowNickname = [defaults boolForKey:@"PushShowNickname"];
-
- imageSize = [defaults stringForKey:@"ImageSize"];
- videoQuality = [defaults stringForKey:@"VideoQuality"];
- autoSaveMedia = [defaults boolForKey:@"AutoSaveMedia"];
-
- chatFontSize = [defaults floatForKey:@"ChatFontSize"];
- useDynamicFontSize = [defaults boolForKey:@"UseDynamicFontSize"];
- disableBigEmojis = [defaults boolForKey:@"DisableBigEmojis"];
- showReceivedTimestamps = [defaults boolForKey:@"ShowReceivedTimestamps"];
- returnToSend = [defaults boolForKey:@"ReturnToSend"];
- darkTheme = [defaults boolForKey:@"DarkTheme"];
- useSystemTheme = [defaults boolForKey:@"UseSystemTheme"];
- showProfilePictures = [defaults boolForKey:@"ShowProfilePictures"];
- NSString *wallpaperPath = [self wallpaperPath];
- if ([[NSFileManager defaultManager] fileExistsAtPath:wallpaperPath]) {
- wallpaper = [UIImage imageWithContentsOfFile:wallpaperPath];
- }
-
- sortOrderFirstName = [defaults boolForKey:@"SortOrderFirstName"];
- displayOrderFirstName = [defaults boolForKey:@"DisplayOrderFirstName"];
-
- validationLogging = [defaults boolForKey:@"ValidationLogging"];
- enableIPv6 = [defaults boolForKey:@"EnableIPv6"];
- companyDirectory = [defaults boolForKey:@"CompanyDirectory"];
-
- askedForPushDecryption = [defaults boolForKey:@"AskedForPushDecryption"];
-
- sendProfilePicture = [[defaults objectForKey:@"SendProfilePicture"] intValue];
-
- profilePictureContactList = [defaults arrayForKey:@"ProfilePictureContactList"];
- profilePictureRequestList = [defaults arrayForKey:@"ProfilePictureRequestList"];
-
- showGalleryPreview = [defaults boolForKey:@"ShowGalleryPreview"];
- disableProximityMonitoring = [defaults boolForKey:@"DisableProximityMonitoring"];
-
- enableThreemaCall = [defaults boolForKey:@"EnableThreemaCall"];
- alwaysRelayCalls = [defaults boolForKey:@"AlwaysRelayCalls"];
- enableCallKit = [defaults boolForKey:@"EnableCallKit"];
-
- previewLimit = [defaults floatForKey:@"PreviewLimit"];
-
- acceptedPrivacyPolicyDate = [defaults objectForKey:@"AcceptedPrivacyPolicyDate"];
- acceptedPrivacyPolicyVariant = [[defaults objectForKey:@"AcceptedPrivacyPolicyVariant"] intValue];
-
- voIPSound = [defaults stringForKey:@"VoIPSound"];
-
- threemaWeb = [defaults boolForKey:@"ThreemaWeb"];
-
- openPlusIconInChat = [defaults boolForKey:@"OpenPlusIconInChat"];
-
- safeConfig = [defaults dataForKey:@"SafeConfig"];
- safeIntroShown = [defaults boolForKey:@"SafeIntroShown"];
-
- workInfoShown = [defaults boolForKey:@"WorkInfoShown"];
- videoCallInChatInfoShown = [defaults boolForKey:@"VideoCallInChatInfoShown"];
- videoCallInfoShown = [defaults boolForKey:@"VideoCallInfoShown"];
- videoCallSpeakerInfoShown = [defaults boolForKey:@"VideoCallSpeakerInfoShown"];
-
- NSString *tmpSentryAppDevice = [defaults stringForKey:@"SentryAppDevice"];
- if (tmpSentryAppDevice != nil) {
- if ([tmpSentryAppDevice isEqualToString:@""]) {
- sentryAppDevice = nil;
- } else {
- sentryAppDevice = [defaults stringForKey:@"SentryAppDevice"];
- }
- } else {
- sentryAppDevice = nil;
- }
- enableMasterDnd = [defaults boolForKey:@"EnableMasterDnd"];
- masterDndWorkingDays = [NSOrderedSet orderedSetWithArray:[defaults arrayForKey:@"MasterDNDWorkingDays"]];
- masterDndStartTime = [defaults objectForKey:@"MasterDNDStartTime"];
- masterDndEndTime = [defaults objectForKey:@"MasterDNDEndTime"];
-
- enableVideoCall = [defaults boolForKey:@"EnableVideoCall"];
- threemaVideoCallQualitySetting = [[defaults objectForKey:@"ThreemaVideoCallQualitySetting"] intValue];
-
- #ifdef DEBUG
- quoteV2Active = [defaults boolForKey:@"QuoteV2Active"];
- #else
- quoteV2Active = false;
- #endif
- }
- - (void)pushSettingsMigration:(NSOrderedSet *)tmpNoPushIdentities {
- NSMutableOrderedSet *pushSettings = [NSMutableOrderedSet new];
- for (NSString *identity in tmpNoPushIdentities.array) {
- PushSetting *tmpPushSetting = [PushSetting new];
- tmpPushSetting.identity = identity;
- tmpPushSetting.type = kPushSettingTypeOff;
- tmpPushSetting.periodOffTime = 0;
- tmpPushSetting.periodOffTillDate = nil;
- tmpPushSetting.silent = false;
- tmpPushSetting.mentions = false;
- [pushSettings addObject:tmpPushSetting.buildDict];
- }
- [self setPushSettingsList:pushSettings];
- [defaults removeObjectForKey:@"NoPushIdentities"];
- [defaults synchronize];
- }
- - (void)setSendReadReceipts:(BOOL)newSendReadReceipts {
- sendReadReceipts = newSendReadReceipts;
- [[ValidationLogger sharedValidationLogger] logString:[NSString stringWithFormat:@"Read receipts bug: set flag to %@", newSendReadReceipts ? @"true" : @"false"]];
- [defaults setBool:sendReadReceipts forKey:@"SendReadReceipts"];
- [defaults synchronize];
- [[ValidationLogger sharedValidationLogger] logString:[NSString stringWithFormat:@"Read receipts bug: It's now set to %@", [defaults boolForKey:@"SendReadReceipts"] ? @"true" : @"false"]];
- }
- - (void)setSyncContacts:(BOOL)newSyncContacts {
- syncContacts = newSyncContacts;
- [defaults setBool:syncContacts forKey:@"SyncContacts"];
- [defaults synchronize];
- }
- - (void)setSyncExclusionList:(NSArray *)newSyncExclusionList {
- syncExclusionList = newSyncExclusionList;
- [defaults setObject:syncExclusionList forKey:@"SyncExclusionList"];
- [defaults synchronize];
- }
- - (void)setBlacklist:(NSOrderedSet *)newBlacklist {
- blacklist = newBlacklist;
- [defaults setObject:blacklist.array forKey:@"Blacklist"];
- [defaults synchronize];
- }
- - (void)setWorkIdentities:(NSOrderedSet *)newWorkIdentities {
- workIdentities = newWorkIdentities;
- [defaults setObject:workIdentities.array forKey:@"WorkIdentities"];
- [defaults synchronize];
- }
- - (void)setPushSettingsList:(NSOrderedSet *)newPushSettingsList {
- pushSettingsList = newPushSettingsList;
- [defaults setObject:pushSettingsList.array forKey:@"PushSettingsList"];
- [defaults synchronize];
- }
- - (void)setSendTypingIndicator:(BOOL)newSendTypingIndicator {
- sendTypingIndicator = newSendTypingIndicator;
- [defaults setBool:sendTypingIndicator forKey:@"SendTypingIndicator"];
- [defaults synchronize];
- }
- - (void)setBlockUnknown:(BOOL)newBlockUnknown {
- blockUnknown = newBlockUnknown;
- [defaults setBool:blockUnknown forKey:@"BlockUnknown"];
- [defaults synchronize];
- }
- - (void)setEnablePoi:(BOOL)newEnablePoi {
- enablePoi = newEnablePoi;
- [defaults setBool:enablePoi forKey:@"EnablePOI"];
- [defaults synchronize];
- }
- - (void)setHideStaleContacts:(BOOL)newHideStaleContacts {
- hideStaleContacts = newHideStaleContacts;
- [defaults setBool:hideStaleContacts forKey:@"HideStaleContacts"];
- [defaults synchronize];
- }
- - (void)setInAppSounds:(BOOL)newInAppSounds {
- inAppSounds = newInAppSounds;
- [defaults setBool:inAppSounds forKey:@"InAppSounds"];
- [defaults synchronize];
- }
- - (void)setInAppVibrate:(BOOL)newInAppVibrate {
- inAppVibrate = newInAppVibrate;
- [defaults setBool:inAppVibrate forKey:@"InAppVibrate"];
- [defaults synchronize];
- }
- - (void)setInAppPreview:(BOOL)newInAppPreview {
- inAppPreview = newInAppPreview;
- [defaults setBool:inAppPreview forKey:@"InAppPreview"];
- [defaults synchronize];
- }
- - (void)setPushSound:(NSString *)newPushSound {
- pushSound = newPushSound;
- [defaults setObject:pushSound forKey:@"PushSound"];
- [defaults synchronize];
- }
- - (void)setPushGroupGenerated:(BOOL)newPushGroupGenerated {
- pushGroupGenerated = newPushGroupGenerated;
- [defaults setBool:newPushGroupGenerated forKey:@"PushGroupGenerated"];
- [defaults synchronize];
- }
- - (void)setPushGroupSound:(NSString *)newPushGroupSound {
- pushGroupSound = newPushGroupSound;
- [defaults setObject:pushGroupSound forKey:@"PushGroupSound"];
- [defaults synchronize];
- }
- - (void)setPushDecrypt:(BOOL)newPushDecrypt {
- pushDecrypt = newPushDecrypt;
- [defaults setBool:pushDecrypt forKey:@"PushDecrypt"];
- [defaults synchronize];
- }
- - (void)setPushShowNickname:(BOOL)newPushShowNickname {
- pushShowNickname = newPushShowNickname;
- [defaults setBool:pushShowNickname forKey:@"PushShowNickname"];
- [defaults synchronize];
- }
- - (void)setImageSize:(NSString *)newImageSize {
- imageSize = newImageSize;
- [defaults setObject:imageSize forKey:@"ImageSize"];
- [defaults synchronize];
- }
- - (void)setVideoQuality:(NSString *)newVideoQuality {
- videoQuality = newVideoQuality;
- [defaults setObject:videoQuality forKey:@"VideoQuality"];
- [defaults synchronize];
- }
- - (void)setAutoSaveMedia:(BOOL)newAutoSaveMedia {
- autoSaveMedia = newAutoSaveMedia;
- [defaults setBool:autoSaveMedia forKey:@"AutoSaveMedia"];
- [defaults synchronize];
- }
- - (void)setChatFontSize:(float)newChatFontSize {
- chatFontSize = newChatFontSize;
- [defaults setFloat:chatFontSize forKey:@"ChatFontSize"];
- [defaults synchronize];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationFontSizeChanged object:nil];
- }
- - (float)chatFontSize {
- if (useDynamicFontSize) {
- UIFontDescriptor *fontDescriptor = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleBody];
- CGFloat size = fontDescriptor.pointSize;
- return size;
- } else {
- return chatFontSize;
- }
- }
- - (void)setUseDynamicFontSize:(BOOL)newUseDynamicFontSize {
- useDynamicFontSize = newUseDynamicFontSize;
- [defaults setBool:useDynamicFontSize forKey:@"UseDynamicFontSize"];
- [defaults synchronize];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationFontSizeChanged object:nil];
- }
- - (void)setShowReceivedTimestamps:(BOOL)newShowReceivedTimestamps {
- showReceivedTimestamps = newShowReceivedTimestamps;
- [defaults setBool:showReceivedTimestamps forKey:@"ShowReceivedTimestamps"];
- [defaults synchronize];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationShowTimestampSettingsChanged object:nil];
- }
- - (void)setReturnToSend:(BOOL)newReturnToSend {
- returnToSend = newReturnToSend;
- [defaults setBool:returnToSend forKey:@"ReturnToSend"];
- [defaults synchronize];
- }
- - (void)setDarkTheme:(BOOL)newDarkTheme {
- darkTheme = newDarkTheme;
- [defaults setBool:darkTheme forKey:@"DarkTheme"];
- [defaults synchronize];
-
- [StyleKit resetThemedCache];
- [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationColorThemeChanged object:nil];
- }
- - (void)setUseSystemTheme:(BOOL)newUseSystemTheme {
- useSystemTheme = newUseSystemTheme;
- [defaults setBool:useSystemTheme forKey:@"UseSystemTheme"];
- [defaults synchronize];
- }
- - (void)setShowProfilePictures:(BOOL)newShowProfilePictures {
- showProfilePictures = newShowProfilePictures;
- [defaults setBool:showProfilePictures forKey:@"ShowProfilePictures"];
- [defaults synchronize];
- [[AvatarMaker sharedAvatarMaker] clearCacheForProfilePicture];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationShowProfilePictureChanged object:nil];
- }
- - (void)setWallpaper:(UIImage *)_wallpaper {
- wallpaper = _wallpaper;
-
- if (_wallpaper != nil) {
- NSData *wallpaperData = UIImagePNGRepresentation(wallpaper);
- [wallpaperData writeToFile:[self wallpaperPath] atomically:NO];
- [[ValidationLogger sharedValidationLogger] logString:@"Wallpaper: Set wallpaper"];
- } else {
- [[NSFileManager defaultManager] removeItemAtPath:[self wallpaperPath] error:nil];
- [[ValidationLogger sharedValidationLogger] logString:@"Wallpaper: Removed wallpaper"];
- }
-
- [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationWallpaperChanged object:nil];
- }
- - (void)checkWallpaper {
- if (wallpaper == nil) {
- NSString *wallpaperPath = [self wallpaperPath];
- if ([[NSFileManager defaultManager] fileExistsAtPath:wallpaperPath]) {
- wallpaper = [UIImage imageWithContentsOfFile:wallpaperPath];
- }
- }
- }
- - (void)setSortOrderFirstName:(BOOL)newSortOrderFirstName displayOrderFirstName:(BOOL)newDisplayOrderFirstName {
- if (sortOrderFirstName == newSortOrderFirstName && displayOrderFirstName == newDisplayOrderFirstName)
- return;
-
- sortOrderFirstName = newSortOrderFirstName;
- displayOrderFirstName = newDisplayOrderFirstName;
- [defaults setBool:sortOrderFirstName forKey:@"SortOrderFirstName"];
- [defaults setBool:displayOrderFirstName forKey:@"DisplayOrderFirstName"];
- [defaults synchronize];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:@"ThreemaContactsOrderChanged" object:nil];
- }
- - (void)setSortOrderFirstName:(BOOL)newSortOrderFirstName {
- if (sortOrderFirstName == newSortOrderFirstName)
- return;
-
- sortOrderFirstName = newSortOrderFirstName;
- [defaults setBool:sortOrderFirstName forKey:@"SortOrderFirstName"];
- [defaults synchronize];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:@"ThreemaContactsOrderChanged" object:nil];
- }
- - (void)setDisplayOrderFirstName:(BOOL)newDisplayOrderFirstName {
- if (displayOrderFirstName == newDisplayOrderFirstName)
- return;
-
- displayOrderFirstName = newDisplayOrderFirstName;
- [defaults setBool:displayOrderFirstName forKey:@"DisplayOrderFirstName"];
- [defaults synchronize];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:@"ThreemaContactsOrderChanged" object:nil];
- }
- - (NSString*)wallpaperPath {
- NSString *documentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
- return [documentsDir stringByAppendingPathComponent:@"wallpaper"];
- }
- - (void)setValidationLogging:(BOOL)newValidationLogging {
- validationLogging = newValidationLogging;
- [defaults setBool:validationLogging forKey:@"ValidationLogging"];
- [defaults synchronize];
- }
- - (void)setEnableIPv6:(BOOL)newEnableIPv6 {
- enableIPv6 = newEnableIPv6;
- [defaults setBool:enableIPv6 forKey:@"EnableIPv6"];
- [defaults synchronize];
- }
- - (void)setCompanyDirectory:(BOOL)newCompanyDirectory {
- companyDirectory = newCompanyDirectory;
- [defaults setBool:companyDirectory forKey:@"CompanyDirectory"];
- [defaults synchronize];
- }
- - (void)setDisableBigEmojis:(BOOL)newDisableBigEmojis {
- disableBigEmojis = newDisableBigEmojis;
- [defaults setBool:disableBigEmojis forKey:@"DisableBigEmojis"];
- [defaults synchronize];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationFontSizeChanged object:nil];
- }
- - (void)setAskedForPushDecryption:(BOOL)newAskedForPushDecryption {
- askedForPushDecryption = newAskedForPushDecryption;
- [defaults setBool:askedForPushDecryption forKey:@"AskedForPushDecryption"];
- [defaults synchronize];
- }
- - (void)setSendProfilePicture:(enum SendProfilePicture)newSendProfilePicture {
- sendProfilePicture = newSendProfilePicture;
- [defaults setObject:[NSNumber numberWithInt:newSendProfilePicture] forKey:@"SendProfilePicture"];
- [defaults synchronize];
- }
- - (void)setProfilePictureContactList:(NSArray *)newProfilePictureContactList {
- profilePictureContactList = newProfilePictureContactList;
- [defaults setObject:profilePictureContactList forKey:@"ProfilePictureContactList"];
- [defaults synchronize];
- }
- - (void)setProfilePictureRequestList:(NSArray *)newProfilePictureRequestList {
- profilePictureRequestList = newProfilePictureRequestList;
- [defaults setObject:profilePictureRequestList forKey:@"ProfilePictureRequestList"];
- [defaults synchronize];
- }
- - (void)setShowGalleryPreview:(BOOL)newShowGalleryPreview {
- showGalleryPreview = newShowGalleryPreview;
- [defaults setBool:showGalleryPreview forKey:@"ShowGalleryPreview"];
- [defaults synchronize];
- }
- - (void)setDisableProximityMonitoring:(BOOL)newDisableProximityMonitoring {
- disableProximityMonitoring = newDisableProximityMonitoring;
- [defaults setBool:disableProximityMonitoring forKey:@"DisableProximityMonitoring"];
- [defaults synchronize];
- }
-
- - (void)setEnableThreemaCall:(BOOL)newEnableThreemaCall {
- enableThreemaCall = newEnableThreemaCall;
- [defaults setBool:enableThreemaCall forKey:@"EnableThreemaCall"];
- [defaults synchronize];
- }
- - (void)setAlwaysRelayCalls:(BOOL)newAlwaysRelayCalls {
- alwaysRelayCalls = newAlwaysRelayCalls;
- [defaults setBool:alwaysRelayCalls forKey:@"AlwaysRelayCalls"];
- [defaults synchronize];
- }
-
- - (void)setEnableCallKit:(BOOL)newEnableCallKit {
- enableCallKit = newEnableCallKit;
- [defaults setBool:enableCallKit forKey:@"EnableCallKit"];
- [defaults synchronize];
- }
- - (void)setPreviewLimit:(float)newPreviewLimit {
- previewLimit = newPreviewLimit;
- [defaults setFloat:previewLimit forKey:@"PreviewLimit"];
- [defaults synchronize];
- }
- - (void)setAcceptedPrivacyPolicyDate:(NSDate *)newAcceptedPrivacyPolicyDate {
- acceptedPrivacyPolicyDate = newAcceptedPrivacyPolicyDate;
- [defaults setObject:acceptedPrivacyPolicyDate forKey:@"AcceptedPrivacyPolicyDate"];
- [defaults synchronize];
- }
- - (void)setAcceptedPrivacyPolicyVariant:(enum AcceptPrivacyPolicyVariant)newAcceptedPrivacyPolicyVariant {
- acceptedPrivacyPolicyVariant = newAcceptedPrivacyPolicyVariant;
- [defaults setObject:[NSNumber numberWithInt:acceptedPrivacyPolicyVariant] forKey:@"AcceptedPrivacyPolicyVariant"];
- [defaults synchronize];
- }
- - (void)setVoIPSound:(NSString *)newVoIPSound {
- voIPSound = newVoIPSound;
- [defaults setObject:voIPSound forKey:@"VoIPSound"];
- [defaults synchronize];
- }
- - (NSInteger)largeTitleDisplayMode {
- return UINavigationItemLargeTitleDisplayModeAlways;
- }
- - (void)setThreemaWeb:(BOOL)newThreemaWeb {
- threemaWeb = newThreemaWeb;
- [defaults setBool:threemaWeb forKey:@"ThreemaWeb"];
- [defaults synchronize];
- }
- - (void)setOpenPlusIconInChat:(BOOL)newOpenPlusIconInChat {
- openPlusIconInChat = newOpenPlusIconInChat;
- [defaults setBool:openPlusIconInChat forKey:@"OpenPlusIconInChat"];
- [defaults synchronize];
- }
- - (void)setSafeConfig:(NSData *)newSafeConfig {
- safeConfig = newSafeConfig;
- [defaults setObject:safeConfig forKey:@"SafeConfig"];
- [defaults synchronize];
- }
- - (void)setSafeIntroShown:(BOOL)newSafeIntroShown {
- safeIntroShown = newSafeIntroShown;
- [defaults setBool:safeIntroShown forKey:@"SafeIntroShown"];
- [defaults synchronize];
- }
- - (void)setWorkInfoShown:(BOOL)newWorkInfoShown {
- workInfoShown = newWorkInfoShown;
- [defaults setBool:workInfoShown forKey:@"WorkInfoShown"];
- [defaults synchronize];
- }
- - (void)setVideoCallInChatInfoShown:(BOOL)newVideoCallInChatInfoShown {
- videoCallInChatInfoShown = newVideoCallInChatInfoShown;
- [defaults setBool:videoCallInChatInfoShown forKey:@"VideoCallInChatInfoShown"];
- [defaults synchronize];
- }
- - (void)setVideoCallInfoShown:(BOOL)newVideoCallInfoShown {
- videoCallInfoShown = newVideoCallInfoShown;
- [defaults setBool:videoCallInfoShown forKey:@"VideoCallInfoShown"];
- [defaults synchronize];
- }
- - (void)setVideoCallSpeakerInfoShown:(BOOL)newVideoCallSpeakerInfoShown {
- videoCallSpeakerInfoShown = newVideoCallSpeakerInfoShown;
- [defaults setBool:videoCallSpeakerInfoShown forKey:@"VideoCallSpeakerInfoShown"];
- [defaults synchronize];
- }
- - (void)setSentryAppDevice:(NSString *)newSentryAppDevice {
- sentryAppDevice = newSentryAppDevice;
- [defaults setObject:sentryAppDevice forKey:@"SentryAppDevice"];
- [defaults synchronize];
- }
- - (void)setEnableMasterDnd:(BOOL)newEnableMasterDnd {
- enableMasterDnd = newEnableMasterDnd;
- [defaults setBool:enableMasterDnd forKey:@"EnableMasterDnd"];
- [defaults synchronize];
- }
- - (void)setMasterDndWorkingDays:(NSOrderedSet *)newMasterDndWorkingDays {
- masterDndWorkingDays = newMasterDndWorkingDays;
- [defaults setObject:masterDndWorkingDays.array forKey:@"MasterDNDWorkingDays"];
- [defaults synchronize];
- }
- - (void)setMasterDndStartTime:(NSString *)newMasterDndStartTime {
- masterDndStartTime = newMasterDndStartTime;
- [defaults setObject:masterDndStartTime forKey:@"MasterDNDStartTime"];
- [defaults synchronize];
- }
- - (void)setMasterDndEndTime:(NSString *)newMasterDndEndTime {
- masterDndEndTime = newMasterDndEndTime;
- [defaults setObject:masterDndEndTime forKey:@"MasterDNDEndTime"];
- [defaults synchronize];
- }
- - (void)setEnableVideoCall:(BOOL)newEnableVideoCall {
- enableVideoCall = newEnableVideoCall;
- [defaults setBool:enableVideoCall forKey:@"EnableVideoCall"];
- [defaults synchronize];
- }
- - (void)setThreemaVideoCallQualitySetting:(enum ThreemaVideoCallQualitySetting)newThreemaVideoCallQualitySetting {
- threemaVideoCallQualitySetting = newThreemaVideoCallQualitySetting;
- [defaults setObject:[NSNumber numberWithInt:threemaVideoCallQualitySetting] forKey:@"ThreemaVideoCallQualitySetting"];
- [defaults synchronize];
- }
- - (void)setQuoteV2Active:(BOOL)newQuoteV2Active {
- quoteV2Active = newQuoteV2Active;
- [defaults setBool:quoteV2Active forKey:@"QuoteV2Active"];
- [defaults synchronize];
- }
- @end
|