diff --git a/Podfile b/Podfile index eebe2abcd..ea5a451cd 100644 --- a/Podfile +++ b/Podfile @@ -3,7 +3,7 @@ source 'https://github.com/CocoaPods/Specs.git' target 'Signal' do pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git' - pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git', branch: 'mkirk/empty-bubble-disappearing-self#1393' + pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' #pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'OpenSSL', '~> 1.0.208' pod 'PastelogKit', '~> 1.3' diff --git a/Podfile.lock b/Podfile.lock index 1c820c041..6710f92e9 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -122,13 +122,12 @@ DEPENDENCIES: - OpenSSL (~> 1.0.208) - PastelogKit (~> 1.3) - SCWaveformView (~> 1.0) - - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`, branch `mkirk/empty-bubble-disappearing-self#1393`) + - SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`) - ZXingObjC EXTERNAL SOURCES: SignalServiceKit: - :branch: mkirk/empty-bubble-disappearing-self#1393 :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :git: https://github.com/facebook/SocketRocket.git @@ -167,6 +166,6 @@ SPEC CHECKSUMS: YapDatabase: b1e43555a34a5298e23a045be96817a5ef0da58f ZXingObjC: bf15b3814f7a105b6d99f47da2333c93a063650a -PODFILE CHECKSUM: e8495fa75a157c62674121b7f0faf30ee7542ec6 +PODFILE CHECKSUM: f5e3e3b84c4c471518f4e3a32746e6a0e13808f6 COCOAPODS: 1.0.1 diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 138f09057..91be3a806 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -21,7 +21,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2.6.1 + 2.6.2 CFBundleSignature ???? CFBundleURLTypes @@ -38,7 +38,7 @@ CFBundleVersion - 2.6.1.3 + 2.6.2.0 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index 8d15e9bd9..c0863d86b 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -664,6 +664,9 @@ typedef enum : NSUInteger { } } +#pragma mark - UICollectionViewDelegate + +// Override JSQMVC - (BOOL)collectionView:(JSQMessagesCollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath { if (indexPath == nil) { @@ -679,6 +682,16 @@ typedef enum : NSUInteger { return YES; } +- (void)collectionView:(UICollectionView *)collectionView + didEndDisplayingCell:(nonnull UICollectionViewCell *)cell + forItemAtIndexPath:(nonnull NSIndexPath *)indexPath +{ + if ([cell conformsToProtocol:@protocol(OWSExpirableMessageView)]) { + id expirableView = (id)cell; + [expirableView stopExpirationTimer]; + } +} + #pragma mark - JSQMessages CollectionView DataSource - (id)collectionView:(JSQMessagesCollectionView *)collectionView diff --git a/Signal/src/views/OWSExpirableMessageView.h b/Signal/src/views/OWSExpirableMessageView.h index ea4ceeb12..ce4bbd87a 100644 --- a/Signal/src/views/OWSExpirableMessageView.h +++ b/Signal/src/views/OWSExpirableMessageView.h @@ -15,6 +15,8 @@ static const CGFloat OWSExpirableMessageViewTimerWidth = 10.0f; - (void)startExpirationTimerWithExpiresAtSeconds:(uint64_t)expiresAtSeconds initialDurationSeconds:(uint32_t)initialDurationSeconds; +- (void)stopExpirationTimer; + @end NS_ASSUME_NONNULL_END diff --git a/Signal/src/views/OWSExpirationTimerView.h b/Signal/src/views/OWSExpirationTimerView.h index 043efdf8a..b7a013ac7 100644 --- a/Signal/src/views/OWSExpirationTimerView.h +++ b/Signal/src/views/OWSExpirationTimerView.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)startTimerWithExpiresAtSeconds:(uint64_t)expiresAtSeconds initialDurationSeconds:(uint32_t)initialDurationSeconds; -- (void)stopBlinking; +- (void)stopTimer; @end diff --git a/Signal/src/views/OWSExpirationTimerView.m b/Signal/src/views/OWSExpirationTimerView.m index bf548a989..8c477855f 100644 --- a/Signal/src/views/OWSExpirationTimerView.m +++ b/Signal/src/views/OWSExpirationTimerView.m @@ -85,9 +85,10 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2; self.fullHourglassImageView.bounds = hourglassFrame; } -- (void)restartAnimation:(NSNotification *)notification +- (void)handleReappearNotification:(NSNotification *)notification { - [self startTimerWithExpiresAtSeconds:self.expiresAtSeconds initialDurationSeconds:self.initialDurationSeconds]; + DDLogVerbose(@"%@ handleReappearNotification", self.logTag); + [self startAnimation]; } - (void)startTimerWithExpiresAtSeconds:(uint64_t)expiresAtSeconds @@ -100,7 +101,7 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2; initialDurationSeconds); } - DDLogVerbose(@"%@ Starting animation timer with expiresAtSeconds: %llu initialDurationSeconds: %d", + DDLogVerbose(@"%@ Starting timer with expiresAtSeconds: %llu initialDurationSeconds: %d", self.logTag, expiresAtSeconds, initialDurationSeconds); @@ -108,9 +109,18 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2; self.expiresAtSeconds = expiresAtSeconds; self.initialDurationSeconds = initialDurationSeconds; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(restartAnimation:) + selector:@selector(handleReappearNotification:) name:OWSMessagesViewControllerDidAppearNotification object:nil]; + [self startAnimation]; +} + +- (void)startAnimation +{ + DDLogVerbose(@"%@ Starting animation with expiresAtSeconds: %llu initialDurationSeconds: %d", + self.logTag, + self.expiresAtSeconds, + self.initialDurationSeconds); double secondsLeft = (double)self.expiresAtSeconds - [NSDate new].timeIntervalSince1970; @@ -154,14 +164,26 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2; [maskLayer addAnimation:revealAnimation forKey:@"revealAnimation"]; maskLayer.position = finalPosition; // don't snap back + __weak typeof(self) wself = self; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (long long)((secondsLeft - OWSExpirationTimerViewBlinkingSeconds) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self startBlinking]; + [wself startBlinking]; }); } +- (void)stopTimer +{ + DDLogVerbose(@"%@ Stopping Timer.", self.logTag); + [[NSNotificationCenter defaultCenter] removeObserver:self + name:OWSMessagesViewControllerDidAppearNotification + object:nil]; + + [self.layer removeAnimationForKey:@"alphaBlink"]; + self.layer.opacity = 1; +} + - (BOOL)itIsTimeToBlink { double secondsLeft = (double)self.expiresAtSeconds - [NSDate new].timeIntervalSince1970; @@ -185,12 +207,6 @@ double const OWSExpirationTimerViewBlinkingSeconds = 2; [self.layer addAnimation:blinkAnimation forKey:@"alphaBlink"]; } -- (void)stopBlinking -{ - [self.layer removeAnimationForKey:@"alphaBlink"]; - self.layer.opacity = 1; -} - #pragma mark - Logging + (NSString *)logTag diff --git a/Signal/src/views/OWSIncomingMessageCollectionViewCell.m b/Signal/src/views/OWSIncomingMessageCollectionViewCell.m index 541fd955d..7a9157051 100644 --- a/Signal/src/views/OWSIncomingMessageCollectionViewCell.m +++ b/Signal/src/views/OWSIncomingMessageCollectionViewCell.m @@ -24,7 +24,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)prepareForReuse { [super prepareForReuse]; - [self.expirationTimerView stopBlinking]; self.expirationTimerViewWidthConstraint.constant = 0.0f; } @@ -38,6 +37,11 @@ NS_ASSUME_NONNULL_BEGIN initialDurationSeconds:initialDurationSeconds]; } +- (void)stopExpirationTimer +{ + [self.expirationTimerView stopTimer]; +} + @end NS_ASSUME_NONNULL_END diff --git a/Signal/src/views/OWSOutgoingMessageCollectionViewCell.m b/Signal/src/views/OWSOutgoingMessageCollectionViewCell.m index 34e32e30e..4ee17be51 100644 --- a/Signal/src/views/OWSOutgoingMessageCollectionViewCell.m +++ b/Signal/src/views/OWSOutgoingMessageCollectionViewCell.m @@ -24,7 +24,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)prepareForReuse { [super prepareForReuse]; - [self.expirationTimerView stopBlinking]; self.expirationTimerViewWidthConstraint.constant = 0.0f; } @@ -38,6 +37,11 @@ NS_ASSUME_NONNULL_BEGIN initialDurationSeconds:initialDurationSeconds]; } +- (void)stopExpirationTimer +{ + [self.expirationTimerView stopTimer]; +} + @end NS_ASSUME_NONNULL_END