From 75ead2ac0904ea601f654f53b9ca09573df09b70 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 20 Aug 2018 14:58:34 -0600 Subject: [PATCH 1/3] quoted reply: distinguish "not found" vs. "no longer available" --- .../ConversationViewController.m | 26 ++++++++++++++++--- .../translations/en.lproj/Localizable.strings | 13 ++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 92af522d9..b7d77bf78 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2370,6 +2370,11 @@ typedef enum : NSUInteger { __block NSUInteger threadInteractionCount = 0; __block NSNumber *_Nullable groupIndex = nil; + if (quotedReply.isRemotelySourced) { + [self presentRemotelySourcedQuotedReplyToast]; + return; + } + [self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { quotedInteraction = [ThreadUtil findInteractionInThreadByTimestamp:quotedReply.timestamp authorId:quotedReply.authorId @@ -5317,9 +5322,24 @@ typedef enum : NSUInteger { { DDLogInfo(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__); - NSString *toastText = NSLocalizedString(@"QUOTED_REPLY_MISSING_ORIGINAL_MESSAGE", - @"Toast alert text shown when tapping on a quoted message which we cannot scroll to, because the local copy of " - @"the message doesn't exist."); + NSString *toastText = NSLocalizedString(@"QUOTED_REPLY_ORIGINAL_MESSAGE_DELETED", + @"Toast alert text shown when tapping on a quoted message which we cannot scroll to because the local copy of " + @"the message was since deleted."); + + ToastController *toastController = [[ToastController alloc] initWithText:toastText]; + + CGFloat bottomInset = 10 + self.collectionView.contentInset.bottom + self.view.layoutMargins.bottom; + + [toastController presentToastViewFromBottomOfView:self.view inset:bottomInset]; +} + +- (void)presentRemotelySourcedQuotedReplyToast +{ + DDLogInfo(@"%@ in %s", self.logTag, __PRETTY_FUNCTION__); + + NSString *toastText = NSLocalizedString(@"QUOTED_REPLY_ORIGINAL_MESSAGE_REMOTELY_SOURCED", + @"Toast alert text shown when tapping on a quoted message which we cannot scroll to because the local copy of " + @"the message didn't exist when the quote was received."); ToastController *toastController = [[ToastController alloc] initWithText:toastText]; diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 3e527c118..91bd09d94 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1263,12 +1263,6 @@ /* Indicates that this 1:1 conversation is no longer verified. Embeds {{user's name or phone number}}. */ "MESSAGES_VIEW_CONTACT_NO_LONGER_VERIFIED_FORMAT" = "%@ is no longer marked as verified. Tap for options."; -/* Action sheet title after tapping on failed download. */ -"MESSAGES_VIEW_FAILED_DOWNLOAD_ACTIONSHEET_TITLE" = "Download Failed."; - -/* Action sheet button text */ -"MESSAGES_VIEW_FAILED_DOWNLOAD_RETRY_ACTION" = "Download Again"; - /* Indicates that a single member of this group has been blocked. */ "MESSAGES_VIEW_GROUP_1_MEMBER_BLOCKED" = "You Blocked 1 Member of this Group"; @@ -1610,8 +1604,11 @@ /* Footer label that appears below quoted messages when the quoted content was note derived locally. When the local user doesn't have a copy of the message being quoted, e.g. if it had since been deleted, we instead show the content specified by the sender. */ "QUOTED_REPLY_CONTENT_FROM_REMOTE_SOURCE" = "Original message not found."; -/* Toast alert text shown when tapping on a quoted message which we cannot scroll to, because the local copy of the message doesn't exist. */ -"QUOTED_REPLY_MISSING_ORIGINAL_MESSAGE" = "Original message not found."; +/* Toast alert text shown when tapping on a quoted message which we cannot scroll to because the local copy of the message was since deleted. */ +"QUOTED_REPLY_ORIGINAL_MESSAGE_DELETED" = "Original message no longer available."; + +/* Toast alert text shown when tapping on a quoted message which we cannot scroll to because the local copy of the message didn't exist when the quote was received. */ +"QUOTED_REPLY_ORIGINAL_MESSAGE_REMOTELY_SOURCED" = "Original message not found."; /* Indicates this message is a quoted reply to an attachment of unknown type. */ "QUOTED_REPLY_TYPE_ATTACHMENT" = "Attachment"; From 06a8bffa66f0a69ce6f2d52fa895b5a59e4ce836 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 21 Aug 2018 10:05:34 -0600 Subject: [PATCH 2/3] Never show more than one toast view --- Signal/src/views/Toast.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Signal/src/views/Toast.swift b/Signal/src/views/Toast.swift index c9fa543c7..bd75343df 100644 --- a/Signal/src/views/Toast.swift +++ b/Signal/src/views/Toast.swift @@ -67,6 +67,8 @@ class ToastView: UIView { @objc class ToastController: NSObject, ToastViewDelegate { + static var currentToastController: ToastController? + private let toastView: ToastView private var isDismissing: Bool @@ -98,6 +100,12 @@ class ToastController: NSObject, ToastViewDelegate { toastView.autoPinEdge(.bottom, to: .bottom, of: view, withOffset: -inset) toastView.autoPinWidthToSuperview(withMargin: 24) + if let currentToastController = type(of: self).currentToastController { + currentToastController.dismissToastView() + type(of: self).currentToastController = nil + } + type(of: self).currentToastController = self + UIView.animate(withDuration: 0.1) { self.toastView.alpha = 1 } @@ -131,6 +139,11 @@ class ToastController: NSObject, ToastViewDelegate { return } isDismissing = true + + if type(of: self).currentToastController == self { + type(of: self).currentToastController = nil + } + UIView.animate(withDuration: 0.1, animations: { self.toastView.alpha = 0 From 93cb378f7a293f4bc29518d7c64ef9819a9f9467 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 21 Aug 2018 10:18:13 -0600 Subject: [PATCH 3/3] constantize toast inset --- .../ConversationView/ConversationViewController.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index b7d77bf78..79c8d49f0 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -110,6 +110,8 @@ static const int kYapDatabaseRangeMinLength = 0; static const CGFloat kLoadMoreHeaderHeight = 60.f; +static const CGFloat kToastInset = 10; + typedef enum : NSUInteger { kMediaTypePicture, kMediaTypeVideo, @@ -5328,7 +5330,7 @@ typedef enum : NSUInteger { ToastController *toastController = [[ToastController alloc] initWithText:toastText]; - CGFloat bottomInset = 10 + self.collectionView.contentInset.bottom + self.view.layoutMargins.bottom; + CGFloat bottomInset = kToastInset + self.collectionView.contentInset.bottom + self.view.layoutMargins.bottom; [toastController presentToastViewFromBottomOfView:self.view inset:bottomInset]; } @@ -5343,7 +5345,7 @@ typedef enum : NSUInteger { ToastController *toastController = [[ToastController alloc] initWithText:toastText]; - CGFloat bottomInset = 10 + self.collectionView.contentInset.bottom + self.view.layoutMargins.bottom; + CGFloat bottomInset = kToastInset + self.collectionView.contentInset.bottom + self.view.layoutMargins.bottom; [toastController presentToastViewFromBottomOfView:self.view inset:bottomInset]; }