From 03a4ebc4d8d10909236c2fb6caed0d5461d834e7 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 1 Aug 2017 16:30:24 -0400 Subject: [PATCH] Respond to CR. // FREEBIE --- Signal/src/AppDelegate.m | 2 +- Signal/src/ViewControllers/AvatarViewHelper.m | 2 +- .../src/ViewControllers/ProfileViewController.m | 6 ++---- .../src/Profiles/OWSProfilesManager.h | 2 ++ .../src/Profiles/OWSProfilesManager.m | 15 ++++++++++----- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index fd6af93c0..79438d5ee 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -161,7 +161,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; DDLogInfo(@"%@ application: didFinishLaunchingWithOptions completed.", self.tag); [OWSAnalytics appLaunchDidBegin]; - [OWSProfilesManager sharedManager]; + [OWSProfilesManager.sharedManager appLaunchDidBegin]; return YES; } diff --git a/Signal/src/ViewControllers/AvatarViewHelper.m b/Signal/src/ViewControllers/AvatarViewHelper.m index 3023a310b..b88b4a00e 100644 --- a/Signal/src/ViewControllers/AvatarViewHelper.m +++ b/Signal/src/ViewControllers/AvatarViewHelper.m @@ -116,7 +116,7 @@ NS_ASSUME_NONNULL_BEGIN if (rawAvatar) { // We resize the avatar to fill a 210x210 square. // - // See: AvatarCreateActivity.java in Signal-Android.java. + // See: GroupCreateActivity.java in Signal-Android.java. UIImage *resizedAvatar = [rawAvatar resizedImageToFillPixelSize:CGSizeMake(210, 210)]; [self.delegate avatarDidChange:resizedAvatar]; } diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m index 552931320..18383a749 100644 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ b/Signal/src/ViewControllers/ProfileViewController.m @@ -60,8 +60,6 @@ NS_ASSUME_NONNULL_BEGIN @"PROFILE_VIEW_NAME_DEFAULT_TEXT", @"Default text for the profile name field of the profile view."); _nameTextField.delegate = self; _nameTextField.text = [OWSProfilesManager.sharedManager localProfileName]; - DDLogError(@"_nameTextField.text: %@", _nameTextField.text); - [DDLog flushLog]; [_nameTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; _avatarView = [AvatarImageView new]; @@ -85,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN __weak ProfileViewController *weakSelf = self; - // Avatar + // Profile Avatar OWSTableSection *avatarSection = [OWSTableSection new]; avatarSection.headerTitle = NSLocalizedString( @"PROFILE_VIEW_AVATAR_SECTION_HEADER", @"Header title for the profile avatar field of the profile view."); @@ -124,7 +122,7 @@ NS_ASSUME_NONNULL_BEGIN actionBlock:nil]]; [contents addSection:avatarSection]; - // Profile + // Profile Name OWSTableSection *nameSection = [OWSTableSection new]; nameSection.headerTitle = NSLocalizedString( @"PROFILE_VIEW_NAME_SECTION_HEADER", @"Label for the profile name field of the profile view."); diff --git a/SignalServiceKit/src/Profiles/OWSProfilesManager.h b/SignalServiceKit/src/Profiles/OWSProfilesManager.h index 5ce661f71..bddbcae48 100644 --- a/SignalServiceKit/src/Profiles/OWSProfilesManager.h +++ b/SignalServiceKit/src/Profiles/OWSProfilesManager.h @@ -24,6 +24,8 @@ extern NSString *const kNSNotificationName_LocalProfileDidChange; success:(void (^)())successBlock failure:(void (^)())failureBlock; +- (void)appLaunchDidBegin; + @end NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Profiles/OWSProfilesManager.m b/SignalServiceKit/src/Profiles/OWSProfilesManager.m index 5558b5a9a..7eda6dd54 100644 --- a/SignalServiceKit/src/Profiles/OWSProfilesManager.m +++ b/SignalServiceKit/src/Profiles/OWSProfilesManager.m @@ -77,7 +77,7 @@ NSString *const kNSNotificationName_LocalProfileDidChange = @"kNSNotificationNam NSString *const kOWSProfilesManager_Collection = @"kOWSProfilesManager_Collection"; // This key is used to persist the local user's profile key. -NSString *const kOWSProfilesManager_LocalProfileKey = @"kOWSProfilesManager_LocalProfileKey"; +NSString *const kOWSProfilesManager_LocalProfileSecretKey = @"kOWSProfilesManager_LocalProfileSecretKey"; NSString *const kOWSProfilesManager_LocalProfileNameKey = @"kOWSProfilesManager_LocalProfileNameKey"; NSString *const kOWSProfilesManager_LocalProfileAvatarMetadataKey = @"kOWSProfilesManager_LocalProfileAvatarMetadataKey"; @@ -146,14 +146,14 @@ static const NSInteger kProfileKeyLength = 16; [messageSender setProfilesManager:self]; // Try to load. - _localProfileKey = [self.storageManager objectForKey:kOWSProfilesManager_LocalProfileKey + _localProfileKey = [self.storageManager objectForKey:kOWSProfilesManager_LocalProfileSecretKey inCollection:kOWSProfilesManager_Collection]; if (!_localProfileKey) { // Generate _localProfileKey = [OWSProfilesManager generateLocalProfileKey]; // Persist [self.storageManager setObject:_localProfileKey - forKey:kOWSProfilesManager_LocalProfileKey + forKey:kOWSProfilesManager_LocalProfileSecretKey inCollection:kOWSProfilesManager_Collection]; } OWSAssert(_localProfileKey.length == kProfileKeyLength); @@ -176,6 +176,11 @@ static const NSInteger kProfileKeyLength = 16; object:nil]; } +- (void)appLaunchDidBegin +{ + // Do nothing; we only want to make sure this singleton is created on startup. +} + #pragma mark - Local Profile Key + (NSData *)generateLocalProfileKey @@ -380,7 +385,7 @@ static const NSInteger kProfileKeyLength = 16; inCollection:kOWSProfilesManager_Collection]; UIImage *_Nullable localProfileAvatarImage = nil; if (localProfileAvatarMetadata) { - localProfileAvatarImage = [self loadProfileAvatarsWithFilename:localProfileAvatarMetadata.fileName]; + localProfileAvatarImage = [self loadProfileAvatarWithFilename:localProfileAvatarMetadata.fileName]; if (!localProfileAvatarImage) { localProfileAvatarMetadata = nil; } @@ -400,7 +405,7 @@ static const NSInteger kProfileKeyLength = 16; #pragma mark - Avatar Disk Cache -- (nullable UIImage *)loadProfileAvatarsWithFilename:(NSString *)fileName +- (nullable UIImage *)loadProfileAvatarWithFilename:(NSString *)fileName { OWSAssert(fileName.length > 0);