Add option to clear profile avatar.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 83a02536a4
commit a748987d72

@ -19,6 +19,14 @@ NS_ASSUME_NONNULL_BEGIN
- (UIViewController *)fromViewController; - (UIViewController *)fromViewController;
- (BOOL)hasClearAvatarAction;
@optional
- (NSString *)clearAvatarActionLabel;
- (void)clearAvatar;
@end @end
#pragma mark - #pragma mark -

@ -53,6 +53,15 @@ NS_ASSUME_NONNULL_BEGIN
}]; }];
[actionSheetController addAction:choosePictureAction]; [actionSheetController addAction:choosePictureAction];
if (self.delegate.hasClearAvatarAction) {
UIAlertAction *clearAction = [UIAlertAction actionWithTitle:self.delegate.clearAvatarActionLabel
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[self.delegate clearAvatar];
}];
[actionSheetController addAction:clearAction];
}
[self.delegate.fromViewController presentViewController:actionSheetController animated:true completion:nil]; [self.delegate.fromViewController presentViewController:actionSheetController animated:true completion:nil];
} }

@ -626,6 +626,11 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
return self; return self;
} }
- (BOOL)hasClearAvatarAction
{
return NO;
}
#pragma mark - AddToGroupViewControllerDelegate #pragma mark - AddToGroupViewControllerDelegate
- (void)recipientIdWasAdded:(NSString *)recipientId - (void)recipientIdWasAdded:(NSString *)recipientId

@ -272,7 +272,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)avatarActionSheetTitle - (NSString *)avatarActionSheetTitle
{ {
return NSLocalizedString( return NSLocalizedString(
@"PROFILE_AVATAR_ACTIONSHEET_TITLE", @"Action Sheet title prompting the user for a profile avatar"); @"PROFILE_VIEW_AVATAR_ACTIONSHEET_TITLE", @"Action Sheet title prompting the user for a profile avatar");
} }
- (void)avatarDidChange:(UIImage *)image - (void)avatarDidChange:(UIImage *)image
@ -289,6 +289,21 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
- (BOOL)hasClearAvatarAction
{
return YES;
}
- (NSString *)clearAvatarActionLabel
{
return NSLocalizedString(@"PROFILE_VIEW_CLEAR_AVATAR", @"Label for action that clear's the user's profile avatar");
}
- (void)clearAvatar
{
self.avatar = nil;
}
#pragma mark - Logging #pragma mark - Logging
+ (NSString *)tag + (NSString *)tag

@ -507,6 +507,11 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
- (BOOL)hasClearAvatarAction
{
return NO;
}
#pragma mark - AddToGroupViewControllerDelegate #pragma mark - AddToGroupViewControllerDelegate
- (void)recipientIdWasAdded:(NSString *)recipientId - (void)recipientIdWasAdded:(NSString *)recipientId

@ -1037,7 +1037,7 @@
"PROCEED_BUTTON" = "Proceed"; "PROCEED_BUTTON" = "Proceed";
/* Action Sheet title prompting the user for a profile avatar */ /* Action Sheet title prompting the user for a profile avatar */
"PROFILE_AVATAR_ACTIONSHEET_TITLE" = "Set Profile Avatar"; "PROFILE_VIEW_AVATAR_ACTIONSHEET_TITLE" = "Set Profile Avatar";
/* Instructions for how to change the profile avatar. */ /* Instructions for how to change the profile avatar. */
"PROFILE_VIEW_AVATAR_INSTRUCTIONS" = "Tap to Select Avatar"; "PROFILE_VIEW_AVATAR_INSTRUCTIONS" = "Tap to Select Avatar";
@ -1045,6 +1045,9 @@
/* Header title for the profile avatar field of the profile view. */ /* Header title for the profile avatar field of the profile view. */
"PROFILE_VIEW_AVATAR_SECTION_HEADER" = "Avatar"; "PROFILE_VIEW_AVATAR_SECTION_HEADER" = "Avatar";
/* Label for action that clear's the user's profile avatar */
"PROFILE_VIEW_CLEAR_AVATAR" = "Clear Avatar";
/* Default text for the profile name field of the profile view. */ /* Default text for the profile name field of the profile view. */
"PROFILE_VIEW_NAME_DEFAULT_TEXT" = "Enter your name."; "PROFILE_VIEW_NAME_DEFAULT_TEXT" = "Enter your name.";

@ -443,6 +443,8 @@ static const NSInteger kProfileKeyLength = 16;
return profileAvatarsDirPath; return profileAvatarsDirPath;
} }
// TODO: We may want to clean up this directory in the "orphan cleanup" logic.
#pragma mark - Notifications #pragma mark - Notifications
- (void)applicationDidBecomeActive:(NSNotification *)notification - (void)applicationDidBecomeActive:(NSNotification *)notification

Loading…
Cancel
Save