-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1255 from WhisperSystems/update-jsqmvc
Unfork/Update JSQMessagesViewController
- Loading branch information
Showing
36 changed files
with
1,117 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Created by Dylan Bourgeois on 20/11/14. | ||
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved. | ||
|
||
#import "TSMessageAdapter.h" | ||
#import <Foundation/Foundation.h> | ||
#import <JSQMessagesViewController/JSQMessageData.h> | ||
|
||
typedef enum : NSUInteger { | ||
kCallOutgoing = 1, | ||
kCallIncoming = 2, | ||
kCallMissed = 3, | ||
kGroupUpdateJoin = 4, | ||
kGroupUpdateLeft = 5, | ||
kGroupUpdate = 6 | ||
} CallStatus; | ||
|
||
@interface OWSCall : NSObject <JSQMessageData, NSCoding, NSCopying> | ||
|
||
/* | ||
* Returns the string Id of the user who initiated the call | ||
*/ | ||
@property (copy, nonatomic, readonly) NSString *senderId; | ||
|
||
/* | ||
* Returns the display name for user who initiated the call | ||
*/ | ||
@property (copy, nonatomic, readonly) NSString *senderDisplayName; | ||
|
||
/* | ||
* Returns date of the call | ||
*/ | ||
@property (copy, nonatomic, readonly) NSDate *date; | ||
|
||
/* | ||
* Returns the call status | ||
* @see CallStatus | ||
*/ | ||
@property (nonatomic) CallStatus status; | ||
|
||
/* | ||
* Returns message type for adapter | ||
*/ | ||
@property (nonatomic) TSMessageAdapterType messageType; | ||
|
||
/** | ||
* String to be displayed | ||
*/ | ||
@property (nonatomic, copy) NSString *detailString; | ||
|
||
#pragma mark - Initialization | ||
|
||
- (instancetype)initWithCallerId:(NSString *)callerId | ||
callerDisplayName:(NSString *)callerDisplayName | ||
date:(NSDate *)date | ||
status:(CallStatus)status | ||
displayString:(NSString *)detailString NS_DESIGNATED_INITIALIZER; | ||
|
||
- (NSString *)dateText; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
// Created by Dylan Bourgeois on 20/11/14. | ||
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved. | ||
|
||
#import "OWSCall.h" | ||
#import <JSQMessagesViewController/JSQMessagesTimestampFormatter.h> | ||
#import <JSQMessagesViewController/UIImage+JSQMessages.h> | ||
|
||
@implementation OWSCall | ||
|
||
#pragma mark - Initialzation | ||
|
||
- (id)init | ||
{ | ||
NSAssert(NO, | ||
@"%s is not a valid initializer for %@. Use %@ instead", | ||
__PRETTY_FUNCTION__, | ||
[self class], | ||
NSStringFromSelector(@selector(initWithCallerId:callerDisplayName:date:status:displayString:))); | ||
return [self initWithCallerId:nil callerDisplayName:nil date:nil status:0 displayString:nil]; | ||
} | ||
|
||
- (instancetype)initWithCallerId:(NSString *)senderId | ||
callerDisplayName:(NSString *)senderDisplayName | ||
date:(NSDate *)date | ||
status:(CallStatus)status | ||
displayString:(NSString *)detailString | ||
{ | ||
NSParameterAssert(senderId != nil); | ||
NSParameterAssert(senderDisplayName != nil); | ||
|
||
self = [super init]; | ||
if (!self) { | ||
return self; | ||
} | ||
|
||
_senderId = [senderId copy]; | ||
_senderDisplayName = [senderDisplayName copy]; | ||
_date = [date copy]; | ||
_status = status; | ||
_messageType = TSCallAdapter; | ||
|
||
// TODO interpret detailString from status. make sure it works for calls and | ||
// our re-use of calls as group update display | ||
_detailString = [detailString stringByAppendingFormat:@" "]; | ||
|
||
return self; | ||
} | ||
|
||
- (NSString *)dateText | ||
{ | ||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | ||
dateFormatter.timeStyle = NSDateFormatterShortStyle; | ||
dateFormatter.dateStyle = NSDateFormatterMediumStyle; | ||
dateFormatter.doesRelativeDateFormatting = YES; | ||
return [dateFormatter stringFromDate:_date]; | ||
} | ||
|
||
#pragma mark - NSObject | ||
|
||
- (BOOL)isEqual:(id)object | ||
{ | ||
if (self == object) { | ||
return YES; | ||
} | ||
|
||
if (![object isKindOfClass:[self class]]) { | ||
return NO; | ||
} | ||
|
||
OWSCall *aCall = (OWSCall *)object; | ||
|
||
return [self.senderId isEqualToString:aCall.senderId] && | ||
[self.senderDisplayName isEqualToString:aCall.senderDisplayName] | ||
&& ([self.date compare:aCall.date] == NSOrderedSame) && self.status == aCall.status; | ||
} | ||
|
||
- (NSUInteger)hash | ||
{ | ||
return self.senderId.hash ^ self.date.hash; | ||
} | ||
|
||
- (NSString *)description | ||
{ | ||
return [NSString stringWithFormat:@"<%@: senderId=%@, senderDisplayName=%@, date=%@>", | ||
[self class], | ||
self.senderId, | ||
self.senderDisplayName, | ||
self.date]; | ||
} | ||
|
||
#pragma mark - JSQMessageData | ||
|
||
- (BOOL)isMediaMessage | ||
{ | ||
return NO; | ||
} | ||
|
||
#pragma mark - NSCoding | ||
|
||
- (instancetype)initWithCoder:(NSCoder *)aDecoder | ||
{ | ||
NSString *senderId = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(senderId))]; | ||
NSString *senderDisplayName = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(senderDisplayName))]; | ||
NSDate *date = [aDecoder decodeObjectForKey:NSStringFromSelector(@selector(date))]; | ||
CallStatus status = (CallStatus)[aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(status))]; | ||
NSString *displayString = @""; // FIXME what should this be? | ||
|
||
return [self initWithCallerId:senderId | ||
callerDisplayName:senderDisplayName | ||
date:date | ||
status:status | ||
displayString:displayString]; | ||
} | ||
|
||
- (void)encodeWithCoder:(NSCoder *)aCoder | ||
{ | ||
[aCoder encodeObject:self.senderId forKey:NSStringFromSelector(@selector(senderId))]; | ||
[aCoder encodeObject:self.senderDisplayName forKey:NSStringFromSelector(@selector(senderDisplayName))]; | ||
[aCoder encodeObject:self.date forKey:NSStringFromSelector(@selector(date))]; | ||
[aCoder encodeDouble:self.status forKey:NSStringFromSelector(@selector(status))]; | ||
} | ||
|
||
#pragma mark - NSCopying | ||
|
||
- (instancetype)copyWithZone:(NSZone *)zone | ||
{ | ||
return [[[self class] allocWithZone:zone] initWithCallerId:self.senderId | ||
callerDisplayName:self.senderDisplayName | ||
date:self.date | ||
status:self.status | ||
displayString:self.detailString]; | ||
} | ||
|
||
- (NSUInteger)messageHash | ||
{ | ||
return self.hash; | ||
} | ||
|
||
- (NSString *)text | ||
{ | ||
return _detailString; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Created by Dylan Bourgeois on 29/11/14. | ||
// Copyright (c) 2014 Hexed Bits. All rights reserved. | ||
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved. | ||
|
||
#import "JSQMessageData.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
/* OWSDisplayedMessage message is the parent class for displaying information to the user | ||
* from within the conversation view. Do not use directly : | ||
* | ||
* @see OWSInfoMessage | ||
* @see OWSErrorMessage | ||
* | ||
*/ | ||
@interface OWSDisplayedMessage : NSObject <JSQMessageData> | ||
|
||
/* | ||
* Returns the unique identifier of the person affected by the displayed message | ||
*/ | ||
@property (copy, nonatomic, readonly) NSString *senderId; | ||
|
||
/* | ||
* Returns the name of the person affected by the displayed message | ||
*/ | ||
@property (copy, nonatomic, readonly) NSString *senderDisplayName; | ||
|
||
/* | ||
* Returns date of the displayed message | ||
*/ | ||
@property (copy, nonatomic, readonly) NSDate *date; | ||
|
||
#pragma mark - Initializer | ||
|
||
- (instancetype)initWithSenderId:(NSString *)senderId | ||
senderDisplayName:(NSString *)senderDisplayName | ||
date:(NSDate *)date; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Created by Dylan Bourgeois on 29/11/14. | ||
// Copyright (c) 2014 Hexed Bits. All rights reserved. | ||
// Portions Copyright (c) 2016 Open Whisper Systems. All rights reserved. | ||
|
||
#import "OWSDisplayedMessage.h" | ||
|
||
@implementation OWSDisplayedMessage | ||
|
||
- (id)init | ||
{ | ||
NSAssert(NO, | ||
@"%s is not a valid initializer for %@. Use %@ instead", | ||
__PRETTY_FUNCTION__, | ||
[self class], | ||
NSStringFromSelector(@selector(initWithSenderId:senderDisplayName:date:))); | ||
return nil; | ||
} | ||
|
||
- (instancetype)initWithSenderId:(NSString *)senderId | ||
senderDisplayName:(NSString *)senderDisplayName | ||
date:(NSDate *)date | ||
{ | ||
self = [super init]; | ||
if (!self) { | ||
return self; | ||
} | ||
|
||
_senderId = [senderId copy]; | ||
_senderDisplayName = [senderDisplayName copy]; | ||
_date = [date copy]; | ||
|
||
return self; | ||
} | ||
|
||
- (NSUInteger)messageHash | ||
{ | ||
return self.date.hash ^ self.senderId.hash; | ||
} | ||
|
||
- (BOOL)isMediaMessage | ||
{ | ||
return NO; | ||
} | ||
|
||
@end |
Oops, something went wrong.