From fc2704cf8828c9e2d06a9975d934a5bd3b370109 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 11 Apr 2018 11:47:33 -0400 Subject: [PATCH 1/2] Label quoted replies to yourself as such. --- .../Cells/OWSQuotedMessageView.m | 21 ++++++++++++------- .../translations/en.lproj/Localizable.strings | 3 +++ SignalMessaging/Models/OWSQuotedReplyModel.m | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index f1bf3cbe5..ce290c2b6 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -301,13 +301,20 @@ NS_ASSUME_NONNULL_BEGIN - (UILabel *)createQuotedAuthorLabel { - OWSContactsManager *contactsManager = Environment.current.contactsManager; - NSString *quotedAuthor = [contactsManager displayNameForPhoneIdentifier:self.quotedMessage.authorId]; - NSString *quotedAuthorText = - [NSString stringWithFormat: - NSLocalizedString(@"QUOTED_REPLY_AUTHOR_INDICATOR_FORMAT", - @"Indicates the author of a quoted message. Embeds {{the author's name or phone number}}."), - quotedAuthor]; + NSString *_Nullable localNumber = [TSAccountManager localNumber]; + NSString *quotedAuthorText; + if ([localNumber isEqualToString:self.quotedMessage.authorId]) { + quotedAuthorText = NSLocalizedString( + @"QUOTED_REPLY_AUTHOR_INDICATOR_YOURSELF", @"Indicates the author of a quoted message is yourself."); + } else { + OWSContactsManager *contactsManager = Environment.current.contactsManager; + NSString *quotedAuthor = [contactsManager displayNameForPhoneIdentifier:self.quotedMessage.authorId]; + quotedAuthorText = [NSString + stringWithFormat: + NSLocalizedString(@"QUOTED_REPLY_AUTHOR_INDICATOR_FORMAT", + @"Indicates the author of a quoted message. Embeds {{the author's name or phone number}}."), + quotedAuthor]; + } UILabel *quotedAuthorLabel = [UILabel new]; quotedAuthorLabel.text = quotedAuthorText; diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index e3735813e..fadb47e96 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1411,6 +1411,9 @@ /* Indicates the author of a quoted message. Embeds {{the author's name or phone number}}. */ "QUOTED_REPLY_AUTHOR_INDICATOR_FORMAT" = "Replying to %@"; +/* Indicates the author of a quoted message is yourself. */ +"QUOTED_REPLY_AUTHOR_INDICATOR_YOURSELF" = "Yourself"; + /* Indicates this message is a quoted reply to an attachment of unknown type. */ "QUOTED_REPLY_TYPE_ATTACHMENT" = "Attachment"; diff --git a/SignalMessaging/Models/OWSQuotedReplyModel.m b/SignalMessaging/Models/OWSQuotedReplyModel.m index 06e2ad124..18356df83 100644 --- a/SignalMessaging/Models/OWSQuotedReplyModel.m +++ b/SignalMessaging/Models/OWSQuotedReplyModel.m @@ -154,7 +154,7 @@ // The search will always converge since in the worst case (namely // a single character which in utf-8 is >= 1024 bytes) the loop will // exit when the string is empty. - truncatedText = [truncatedText substringToIndex:oversizeText.length / 2]; + truncatedText = [truncatedText substringToIndex:truncatedText.length / 2]; } if ([truncatedText dataUsingEncoding:NSUTF8StringEncoding].length < kOversizeTextMessageSizeThreshold) { quotedText = truncatedText; From c152a41342c268f76eabb332c115701ea9e02cee Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 11 Apr 2018 14:41:07 -0400 Subject: [PATCH 2/2] Respond to CR. --- Signal/translations/en.lproj/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index fadb47e96..fc89353b0 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1412,7 +1412,7 @@ "QUOTED_REPLY_AUTHOR_INDICATOR_FORMAT" = "Replying to %@"; /* Indicates the author of a quoted message is yourself. */ -"QUOTED_REPLY_AUTHOR_INDICATOR_YOURSELF" = "Yourself"; +"QUOTED_REPLY_AUTHOR_INDICATOR_YOURSELF" = "Replying to Yourself"; /* Indicates this message is a quoted reply to an attachment of unknown type. */ "QUOTED_REPLY_TYPE_ATTACHMENT" = "Attachment";