diff --git a/Podfile.lock b/Podfile.lock index e6a59f6aa..47b6951ec 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -124,7 +124,7 @@ EXTERNAL SOURCES: :branch: signal-master :git: https://github.com/WhisperSystems/JSQMessagesViewController.git SignalServiceKit: - :path: "." + :path: . SocketRocket: :git: https://github.com/facebook/SocketRocket.git diff --git a/SignalServiceKit/src/Account/TSPreKeyManager.m b/SignalServiceKit/src/Account/TSPreKeyManager.m index 92a0edcde..45e61699e 100644 --- a/SignalServiceKit/src/Account/TSPreKeyManager.m +++ b/SignalServiceKit/src/Account/TSPreKeyManager.m @@ -350,6 +350,7 @@ static const CGFloat kSignedPreKeyUpdateFailureMaxFailureDuration = 10 * 24 * 60 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.dateStyle = NSDateFormatterMediumStyle; dateFormatter.timeStyle = NSDateFormatterMediumStyle; + dateFormatter.locale = [NSLocale systemLocale]; // Sort the signed prekeys in ascending order of generation time. oldSignedPrekeys = [oldSignedPrekeys sortedArrayUsingComparator:^NSComparisonResult( diff --git a/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration.m b/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration.m index 899b09e97..60a2c6b2e 100644 --- a/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration.m +++ b/SignalServiceKit/src/Contacts/OWSDisappearingMessagesConfiguration.m @@ -70,60 +70,61 @@ const uint32_t OWSDisappearingMessagesConfigurationDefaultExpirationDuration = 6 uint32_t secondsPerWeek = secondsPerDay * 7; if (durationSeconds < secondsPerMinute) { // XX Seconds - amountFormat = NSLocalizedString(@"SECONDS_TIME_AMOUNT", + amountFormat = NSLocalizedString(@"TIME_AMOUNT_SECONDS", @"{{number of seconds}} embedded in strings, e.g. 'Alice updated disappearing messages " @"expiration to {{5 seconds}}'. See other *_TIME_AMOUNT strings"); duration = durationSeconds; } else if (durationSeconds < secondsPerMinute * 1.5) { // 1 Minute - amountFormat = NSLocalizedString(@"SINGLE_MINUTE_TIME_AMOUNT", + amountFormat = NSLocalizedString(@"TIME_AMOUNT_SINGLE_MINUTE", @"{{1 minute}} embedded in strings, e.g. 'Alice updated disappearing messages " @"expiration to {{1 minute}}'. See other *_TIME_AMOUNT strings"); duration = durationSeconds / secondsPerMinute; } else if (durationSeconds < secondsPerHour) { // Multiple Minutes - amountFormat = NSLocalizedString(@"MINUTES_TIME_AMOUNT", + amountFormat = NSLocalizedString(@"TIME_AMOUNT_MINUTES", @"{{number of minutes}} embedded in strings, e.g. 'Alice updated disappearing messages " @"expiration to {{5 minutes}}'. See other *_TIME_AMOUNT strings"); duration = durationSeconds / secondsPerMinute; } else if (durationSeconds < secondsPerHour * 1.5) { // 1 Hour - amountFormat = NSLocalizedString(@"SINGLE_HOUR_TIME_AMOUNT", + amountFormat = NSLocalizedString(@"TIME_AMOUNT_SINGLE_HOUR", @"{{1 hour}} embedded in strings, e.g. 'Alice updated disappearing messages " @"expiration to {{1 hour}}'. See other *_TIME_AMOUNT strings"); duration = durationSeconds / secondsPerHour; } else if (durationSeconds < secondsPerDay) { // Multiple Hours - amountFormat = NSLocalizedString(@"HOURS_TIME_AMOUNT", + amountFormat = NSLocalizedString(@"TIME_AMOUNT_HOURS", @"{{number of hours}} embedded in strings, e.g. 'Alice updated disappearing messages " @"expiration to {{5 hours}}'. See other *_TIME_AMOUNT strings"); duration = durationSeconds / secondsPerHour; } else if (durationSeconds < secondsPerDay * 1.5) { // 1 Day - amountFormat = NSLocalizedString(@"SINGLE_DAY_TIME_AMOUNT", + amountFormat = NSLocalizedString(@"TIME_AMOUNT_SINGLE_DAY", @"{{1 day}} embedded in strings, e.g. 'Alice updated disappearing messages " @"expiration to {{1 day}}'. See other *_TIME_AMOUNT strings"); duration = durationSeconds / secondsPerDay; } else if (durationSeconds < secondsPerWeek) { // Multiple Days - amountFormat = NSLocalizedString(@"DAYS_TIME_AMOUNT", + amountFormat = NSLocalizedString(@"TIME_AMOUNT_DAYS", @"{{number of days}} embedded in strings, e.g. 'Alice updated disappearing messages " @"expiration to {{5 days}}'. See other *_TIME_AMOUNT strings"); duration = durationSeconds / secondsPerDay; } else if (durationSeconds < secondsPerWeek * 1.5) { // 1 Week - amountFormat = NSLocalizedString(@"SINGLE_WEEK_TIME_AMOUNT", + amountFormat = NSLocalizedString(@"TIME_AMOUNT_SINGLE_WEEK", @"{{1 week}} embedded in strings, e.g. 'Alice updated disappearing messages " @"expiration to {{1 week}}'. See other *_TIME_AMOUNT strings"); duration = durationSeconds / secondsPerWeek; } else { // Multiple weeks - amountFormat = NSLocalizedString(@"WEEKS_TIME_AMOUNT", + amountFormat = NSLocalizedString(@"TIME_AMOUNT_WEEKS", @"{{number of weeks}}, embedded in strings, e.g. 'Alice updated disappearing messages " @"expiration to {{5 weeks}}'. See other *_TIME_AMOUNT strings"); duration = durationSeconds / secondsPerWeek; } - return [NSString stringWithFormat:amountFormat, duration]; + return [NSString stringWithFormat:amountFormat, [NSNumberFormatter localizedStringFromNumber:@(duration) + numberStyle:NSNumberFormatterNoStyle]]; } + (NSArray *)validDurationsSeconds diff --git a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m index 47ec187c9..27c5db7bb 100644 --- a/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m +++ b/SignalServiceKit/src/Messages/Attachments/TSAttachmentStream.m @@ -409,10 +409,10 @@ NS_ASSUME_NONNULL_BEGIN // Ignore "invalid audio file" errors. return 0.f; } - OWSAssert(!error); if (!error) { return (CGFloat)[audioPlayer duration]; } else { + OWSFail(@"Could not find audio duration: %@", self.mediaURL); return 0; } } diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h index 2599e6330..8e2991fb5 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.h +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.h @@ -26,9 +26,6 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark Utility Method -+ (NSString *)stringFromTimeStamp:(uint64_t)timestamp; -+ (uint64_t)timeStampFromString:(NSString *)string; - + (instancetype)interactionForTimestamp:(uint64_t)timestamp withTransaction:(YapDatabaseReadWriteTransaction *)transaction; diff --git a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m index 1d72ffdd6..87e8ff3fb 100644 --- a/SignalServiceKit/src/Messages/Interactions/TSInteraction.m +++ b/SignalServiceKit/src/Messages/Interactions/TSInteraction.m @@ -72,17 +72,6 @@ NS_ASSUME_NONNULL_BEGIN return self.timestamp; } -+ (NSString *)stringFromTimeStamp:(uint64_t)timestamp { - return [[NSNumber numberWithUnsignedLongLong:timestamp] stringValue]; -} - -+ (uint64_t)timeStampFromString:(NSString *)string { - NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; - [f setNumberStyle:NSNumberFormatterNoStyle]; - NSNumber *myNumber = [f numberFromString:string]; - return [myNumber unsignedLongLongValue]; -} - - (NSDate *)dateForSorting { return [NSDate ows_dateWithMillisecondsSince1970:self.timestampForSorting]; diff --git a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m index b3aece129..6483fcb95 100644 --- a/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m +++ b/SignalServiceKit/src/Messages/OWSDisappearingMessagesJob.m @@ -327,6 +327,7 @@ NS_ASSUME_NONNULL_BEGIN NSDateFormatter *dateFormatter = [NSDateFormatter new]; dateFormatter.dateStyle = NSDateFormatterNoStyle; dateFormatter.timeStyle = kCFDateFormatterMediumStyle; + dateFormatter.locale = [NSLocale systemLocale]; // Don't run more often than once per second. const NSTimeInterval kMinDelaySeconds = ignoreMinDelay ? 0.f : 1.f;