Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfork/Update JSQMessagesViewController #1255

Merged
merged 9 commits into from
Jul 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
---
BasedOnStyle: Chromium
AlignTrailingComments: true
AlignConsecutiveAssignments: true
AllowShortIfStatementsOnASingleLine: false
BreakBeforeBraces: Attach
BasedOnStyle: WebKit
AllowShortFunctionsOnASingleLine: false
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 120
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
IndentCaseLabels: true
MaxEmptyLinesToKeep: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ target 'Signal' do
pod 'FFCircularProgressView', '~> 0.5'
pod 'SCWaveformView', '~> 1.0'
pod 'DJWActionSheet'
pod 'JSQMessagesViewController', :git => 'https://github.com/WhisperSystems/JSQMessagesViewController', :branch => 'JSignalQ'
pod 'JSQMessagesViewController'
target 'SignalTests' do
inherit! :search_paths
end
Expand Down
14 changes: 4 additions & 10 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ PODS:
- DJWActionSheet (1.0.4)
- FFCircularProgressView (0.5)
- HKDFKit (0.0.3)
- JSQMessagesViewController (7.1.0):
- JSQMessagesViewController (7.3.3):
- JSQSystemSoundPlayer (~> 2.0.1)
- JSQSystemSoundPlayer (2.0.1)
- libPhoneNumber-iOS (0.8.14)
Expand Down Expand Up @@ -115,26 +115,20 @@ PODS:
DEPENDENCIES:
- DJWActionSheet
- FFCircularProgressView (~> 0.5)
- JSQMessagesViewController (from `https://github.com/WhisperSystems/JSQMessagesViewController`, branch `JSignalQ`)
- JSQMessagesViewController
- OpenSSL (~> 1.0.208)
- PastelogKit (~> 1.3)
- SCWaveformView (~> 1.0)
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`)
- SocketRocket (from `https://github.com/facebook/SocketRocket.git`)

EXTERNAL SOURCES:
JSQMessagesViewController:
:branch: JSignalQ
:git: https://github.com/WhisperSystems/JSQMessagesViewController
SignalServiceKit:
:git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket:
:git: https://github.com/facebook/SocketRocket.git

CHECKOUT OPTIONS:
JSQMessagesViewController:
:commit: 225b1baa11125ea84d4b960d700834b5b0a40ee1
:git: https://github.com/WhisperSystems/JSQMessagesViewController
SignalServiceKit:
:commit: f537b6f19265b0f0845f15b3155cdac4f1913dc6
:git: https://github.com/WhisperSystems/SignalServiceKit.git
Expand All @@ -150,7 +144,7 @@ SPEC CHECKSUMS:
DJWActionSheet: 2fe54b1298a7f0fe44462233752c76a530e0cd80
FFCircularProgressView: 683a4ab1e1bd613246a3dffa61503ffdebcde8d8
HKDFKit: c058305d6f64b84f28c50bd7aa89574625bcb62a
JSQMessagesViewController: ca11f86fa68ca70835f05e169df9244147c1dc40
JSQMessagesViewController: 0ee3f80237268192a3e8337fd0d787f1a1bf5a7a
JSQSystemSoundPlayer: c5850e77a4363ffd374cd851154b9af93264ed8d
libPhoneNumber-iOS: fb165271ebe7fb32e55da97b83219382f2f9d409
Mantle: bc40bb061d8c2c6fb48d5083e04d928c3b7f73d9
Expand All @@ -167,6 +161,6 @@ SPEC CHECKSUMS:
UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d
YapDatabase: 713d4018cfacbd6e77dd430710ca84730e450980

PODFILE CHECKSUM: 860bce87f11d7ce3a8a80c10f8d35ef83699531e
PODFILE CHECKSUM: 060ff4edf8b7a110984cb2c1ffef3f6e19a6b8b6

COCOAPODS: 1.0.1
70 changes: 62 additions & 8 deletions Signal.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions Signal/src/Models/OWSCall.h
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
144 changes: 144 additions & 0 deletions Signal/src/Models/OWSCall.m
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
38 changes: 38 additions & 0 deletions Signal/src/Models/OWSDisplayedMessage.h
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
45 changes: 45 additions & 0 deletions Signal/src/Models/OWSDisplayedMessage.m
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
Loading