From b0a6153d6b5df54d610b2f730f5fd740e065127d Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Wed, 30 Oct 2019 20:52:52 +0800 Subject: [PATCH 01/22] Add customization for time label's color --- ChatSDKCore/Classes/Defines/BCoreDefines.h | 1 + ChatSDKCore/Classes/Session/BConfiguration.h | 3 +++ ChatSDKCore/Classes/Session/BConfiguration.m | 1 + ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m | 6 +++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChatSDKCore/Classes/Defines/BCoreDefines.h b/ChatSDKCore/Classes/Defines/BCoreDefines.h index cb6e9479..36a41190 100755 --- a/ChatSDKCore/Classes/Defines/BCoreDefines.h +++ b/ChatSDKCore/Classes/Defines/BCoreDefines.h @@ -18,6 +18,7 @@ #define bDefaultMessageColorMe @"abcff4" #define bDefaultMessageColorReply @"d7d4d3" +#define bDefaultMessageColorTime @"aaaaaa" #define bDefaultProfileImage @"icn_100_anonymous.png" #define bDefaultPublicGroupImage @"icn_100_anonymous_group.png" diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index 8d6a31dc..2294339e 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -165,6 +165,9 @@ typedef enum { @property (nonatomic, readwrite) UIFont * messageTimeFont; @property (nonatomic, readwrite) UIFont * messageNameFont; +/// Set the custom color of the time label. If not set, it will use the default color of time label. +@property (nonatomic, readwrite) NSString * messageTimeColor; + @property (nonatomic, readwrite) UIFont * threadTitleFont; @property (nonatomic, readwrite) UIFont * threadTimeFont; @property (nonatomic, readwrite) UIFont * threadSubtitleFont; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index bf9d3fb7..5aacfa74 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -13,6 +13,7 @@ @implementation BConfiguration @synthesize messageColorMe; @synthesize messageColorReply; +@synthesize messageTimeColor; @synthesize rootPath; @synthesize appBadgeEnabled; @synthesize defaultUserNamePrefix; diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m index ccc94a03..5a30970c 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m @@ -49,7 +49,11 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr _timeLabel.font = BChatSDK.config.messageTimeFont; } - _timeLabel.textColor = [UIColor lightGrayColor]; + _timeLabel.textColor = [BCoreUtilities colorWithHexString:bDefaultMessageColorTime]; + if(BChatSDK.config.messageTimeColor) { + _timeLabel.textColor = [BCoreUtilities colorWithHexString:BChatSDK.config.messageTimeColor]; + } + _timeLabel.userInteractionEnabled = NO; [self.contentView addSubview:_timeLabel]; From a1d1664d8c2f19f7a67b0e36e199764587b1eab9 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Wed, 30 Oct 2019 21:11:09 +0800 Subject: [PATCH 02/22] Add customization for chat screen's background color --- ChatSDKCore/Classes/Defines/BCoreDefines.h | 2 ++ ChatSDKCore/Classes/Session/BConfiguration.h | 4 ++++ ChatSDKCore/Classes/Session/BConfiguration.m | 1 + ChatSDKUI/Classes/Components/Chat View/BChatViewController.m | 5 +++++ ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m | 4 ++++ 5 files changed, 16 insertions(+) diff --git a/ChatSDKCore/Classes/Defines/BCoreDefines.h b/ChatSDKCore/Classes/Defines/BCoreDefines.h index 36a41190..0cac6e7e 100755 --- a/ChatSDKCore/Classes/Defines/BCoreDefines.h +++ b/ChatSDKCore/Classes/Defines/BCoreDefines.h @@ -16,6 +16,8 @@ #define bTypingTimeout 5.0 #define bLocationDefaultArea 1000 +#define bDefaultChatBgColor @"ffffff" + #define bDefaultMessageColorMe @"abcff4" #define bDefaultMessageColorReply @"d7d4d3" #define bDefaultMessageColorTime @"aaaaaa" diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index 2294339e..f4cee207 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -31,6 +31,10 @@ typedef enum { // Should we ask the user to allow notifications when the app initially loads up? @property (nonatomic, readwrite) BOOL shouldAskForNotificationsPermission; + +/// Custom background color of BChatViewController's main view. +@property (nonatomic, readwrite) NSString * chatBgColor; + // Background color of messages: hex value like "FFFFFF" @property (nonatomic, readwrite) NSString * messageColorMe; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 5aacfa74..8db147db 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -11,6 +11,7 @@ @implementation BConfiguration +@synthesize chatBgColor; @synthesize messageColorMe; @synthesize messageColorReply; @synthesize messageTimeColor; diff --git a/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m b/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m index e485c4eb..c49df9fd 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m +++ b/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m @@ -30,6 +30,11 @@ -(instancetype) initWithThread: (id) thread -(void) viewDidLoad { [super viewDidLoad]; + self.view.backgroundColor = [BCoreUtilities colorWithHexString:bDefaultChatBgColor]; + if(BChatSDK.config.chatBgColor) { + self.view.backgroundColor = [BCoreUtilities colorWithHexString:BChatSDK.config.chatBgColor]; + } + [_sendBarView setMaxLines:BChatSDK.config.textInputViewMaxLines]; [_sendBarView setMaxCharacters:BChatSDK.config.textInputViewMaxCharacters]; diff --git a/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m b/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m index 78717148..d565075e 100755 --- a/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m +++ b/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m @@ -46,6 +46,10 @@ -(instancetype) initWithDelegate: (id) delegate_ _tapRecognizer.enabled = NO; [self.view addGestureRecognizer:_tapRecognizer]; + if (BChatSDK.config.chatBgColor) { + self.tableView.backgroundColor = [BCoreUtilities colorWithHexString:BChatSDK.config.chatBgColor]; + } + // When a user taps the title bar we want to know to show the options screen if (BChatSDK.config.userChatInfoEnabled) { UITapGestureRecognizer * titleTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(navigationBarTapped)]; From 7de76d6c8fdc7758b366bd2d3ac03a9da7428b68 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Wed, 30 Oct 2019 21:15:34 +0800 Subject: [PATCH 03/22] Allow adding of shadow on message bubble --- ChatSDKCore/Classes/Session/BConfiguration.h | 2 ++ ChatSDKCore/Classes/Session/BConfiguration.m | 1 + .../Components/Message Cells/BTextMessageCell.m | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index f4cee207..ae223b70 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -35,6 +35,8 @@ typedef enum { /// Custom background color of BChatViewController's main view. @property (nonatomic, readwrite) NSString * chatBgColor; +/// Add a shadow to the message bubble using a default shadow configuration. +@property (nonatomic, readwrite) BOOL addShadowOnMessageBubble; // Background color of messages: hex value like "FFFFFF" @property (nonatomic, readwrite) NSString * messageColorMe; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 8db147db..598f70d5 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -12,6 +12,7 @@ @implementation BConfiguration @synthesize chatBgColor; +@synthesize addShadowOnMessageBubble; @synthesize messageColorMe; @synthesize messageColorReply; @synthesize messageTimeColor; diff --git a/ChatSDKUI/Classes/Components/Message Cells/BTextMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BTextMessageCell.m index 60e32d65..72473665 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BTextMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BTextMessageCell.m @@ -44,6 +44,16 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr // textView.contentInset = UIEdgeInsetsMake(-9.0, -5.0, 0.0, 0.0); + if(BChatSDK.config.addShadowOnMessageBubble) { + if(BChatSDK.config.addShadowOnMessageBubble == YES) { + self.bubbleImageView.layer.shadowColor = UIColor.blackColor.CGColor; + self.bubbleImageView.layer.shadowOffset = CGSizeMake(0, 1.0); + self.bubbleImageView.layer.shadowRadius = 1.0; + self.bubbleImageView.layer.shadowOpacity = 0.2; + self.bubbleImageView.layer.cornerRadius = 10.0; + } + } + [self.bubbleImageView addSubview:textView]; } From 7cd18e8c65108c0d1f7d53d6b7794015e55194c3 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Wed, 30 Oct 2019 21:16:59 +0800 Subject: [PATCH 04/22] Add customization for chat screen's textview placeholder and font --- ChatSDKCore/Classes/Session/BConfiguration.h | 5 +++++ ChatSDKCore/Classes/Session/BConfiguration.m | 2 ++ .../Classes/Components/Chat View/BTextInputView.m | 13 +++++++++++++ 3 files changed, 20 insertions(+) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index ae223b70..fb23490a 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -42,6 +42,11 @@ typedef enum { @property (nonatomic, readwrite) NSString * messageColorMe; @property (nonatomic, readwrite) NSString * messageColorReply; +/// Custom placeholder for chat screen's textview. +@property (nonatomic, readwrite) NSString * chatTextViewPlaceholder; +/// Custom font for chat screen's textview. +@property (nonatomic, readwrite) UIFont * chatTextViewFont; + // The Firebase root path. Data will be added to Firebase root/rootPath... // this allows you to run multiple chat instances on one Firebase database @property (nonatomic, readwrite) NSString * rootPath; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 598f70d5..b221a2a6 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -16,6 +16,8 @@ @implementation BConfiguration @synthesize messageColorMe; @synthesize messageColorReply; @synthesize messageTimeColor; +@synthesize chatTextViewPlaceholder; +@synthesize chatTextViewFont; @synthesize rootPath; @synthesize appBadgeEnabled; @synthesize defaultUserNamePrefix; diff --git a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m index ea2a4a4c..eb8a6767 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m +++ b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m @@ -36,6 +36,10 @@ -(instancetype) initWithFrame:(CGRect)frame { // self.barTintColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.7]; self.backgroundColor = [UIColor whiteColor]; + if(BChatSDK.config.chatTextViewFont) { + _placeholderLabel.font = BChatSDK.config.chatTextViewFont; + } + // Decide how many lines the message should have minLines = bMinLines; maxLines = bMaxLines; @@ -125,6 +129,9 @@ -(instancetype) initWithFrame:(CGRect)frame { [_placeholderLabel setTextColor:_placeholderColor]; [_placeholderLabel setText:[NSBundle t:bWriteSomething]]; + if(BChatSDK.config.chatTextViewPlaceholder) { + [_placeholderLabel setText:BChatSDK.config.chatTextViewPlaceholder]; + } [self setFont:[UIFont systemFontOfSize:bFontSize]]; @@ -270,6 +277,9 @@ -(void) stopRecording { [[BAudioManager sharedManager] finishRecording]; [_sendBarDelegate.view hideAllToasts]; [_placeholderLabel setText:[NSBundle t:bWriteSomething]]; + if(BChatSDK.config.chatTextViewPlaceholder) { + [_placeholderLabel setText:BChatSDK.config.chatTextViewPlaceholder]; + } [self cancelRecordingToastTimer]; } @@ -305,6 +315,9 @@ -(void) cancelRecordingToastTimer { - (void)sendButtonCancelled { [_sendBarDelegate.view hideAllToasts]; [_placeholderLabel setText:[NSBundle t:bWriteSomething]]; + if(BChatSDK.config.chatTextViewPlaceholder) { + [_placeholderLabel setText:BChatSDK.config.chatTextViewPlaceholder]; + } CSToastStyle * style = [[CSToastStyle alloc] initWithDefaultStyle]; style.backgroundColor = [UIColor redColor]; [_sendBarDelegate.view makeToast:[NSBundle t:bCancelled] From 98442c270f3956572ad972799c0de1b4d3dc777f Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Wed, 30 Oct 2019 21:18:06 +0800 Subject: [PATCH 05/22] Allow hiding of user's name for each message bubble --- ChatSDKCore/Classes/Session/BConfiguration.h | 2 ++ ChatSDKCore/Classes/Session/BConfiguration.m | 1 + .../Classes/Components/Message Cells/BMessageCell.m | 11 +++++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index fb23490a..be0908be 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -151,6 +151,8 @@ typedef enum { @property(nonatomic, readwrite) NSString * messageBubbleMaskLast; @property(nonatomic, readwrite) NSString * messageBubbleMaskSingle; +/// Hide the name label for each message bubble. +@property(nonatomic, readwrite) BOOL hideNameLabel; @property(nonatomic, readwrite) bNameLabelPosition nameLabelPosition; @property(nonatomic, readwrite) BOOL combineTimeWithNameLabel; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index b221a2a6..2c4f1330 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -73,6 +73,7 @@ @implementation BConfiguration @synthesize messageBubbleMaskMiddle; @synthesize messageBubbleMaskLast; @synthesize messageBubbleMaskSingle; +@synthesize hideNameLabel; @synthesize nameLabelPosition; @synthesize combineTimeWithNameLabel; diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m index 5a30970c..072c265e 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m @@ -48,7 +48,7 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr if(BChatSDK.config.messageTimeFont) { _timeLabel.font = BChatSDK.config.messageTimeFont; } - + _timeLabel.textColor = [BCoreUtilities colorWithHexString:bDefaultMessageColorTime]; if(BChatSDK.config.messageTimeColor) { _timeLabel.textColor = [BCoreUtilities colorWithHexString:BChatSDK.config.messageTimeColor]; @@ -57,7 +57,7 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr _timeLabel.userInteractionEnabled = NO; [self.contentView addSubview:_timeLabel]; - + _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(bTimeLabelPadding, 0, 0, 0)]; _nameLabel.userInteractionEnabled = NO; @@ -66,7 +66,7 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr _nameLabel.font = BChatSDK.config.messageNameFont; } [self.contentView addSubview:_nameLabel]; - + _readMessageImageView = [[UIImageView alloc] initWithFrame:CGRectMake(bTimeLabelPadding, 0, 0, 0)]; [self setReadStatus:bMessageReadStatusNone]; [self.contentView addSubview:_readMessageImageView]; @@ -188,12 +188,15 @@ -(void) setMessage: (id) message withColorWeight: (float) colorWeig _nameLabel.text = _message.userModel.name; -// // // We only want to show the name label if the previous message was posted by someone else and if this is enabled in the thread // // Or if the message is mine... _nameLabel.hidden = ![BMessageCell showUserNameLabelForMessage:message atPosition:@(position)]; + if(BChatSDK.config.hideNameLabel) { + _nameLabel.hidden = BChatSDK.config.hideNameLabel; + } + // Hide the read receipt view if this is a public thread or if read receipts are disabled _readMessageImageView.hidden = _message.thread.type.intValue & bThreadFilterPublic || !BChatSDK.readReceipt; From faecb7ff9a9cea37fd026073dcc03fee2beed251 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Wed, 30 Oct 2019 21:19:16 +0800 Subject: [PATCH 06/22] Add customization for chat screen's attach/options icon --- ChatSDKCore/Classes/Session/BConfiguration.h | 2 ++ ChatSDKCore/Classes/Session/BConfiguration.m | 1 + ChatSDKUI/Classes/Components/Chat View/BTextInputView.m | 9 +++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index be0908be..da74400f 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -256,6 +256,8 @@ typedef enum { // How much distance must be moved to update the server with our new location @property (nonatomic, readwrite) int nearbyUsersMinimumLocationChangeToUpdateServer; +/// Custom icon for the options/attachment button. +@property (nonatomic, readwrite) NSString * optionsButtonIcon; // XMPP Auth type used which can be: // default, scramsha1, digestmd5, plain @property (nonatomic, readwrite) NSString * xmppAuthType; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 2c4f1330..697601f7 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -98,6 +98,7 @@ @implementation BConfiguration @synthesize publicChatRoomLifetimeMinutes; @synthesize nearbyUsersMinimumLocationChangeToUpdateServer; +@synthesize optionsButtonIcon; -(instancetype) init { if((self = [super init])) { diff --git a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m index eb8a6767..71bb8186 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m +++ b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m @@ -64,8 +64,13 @@ -(instancetype) initWithFrame:(CGRect)frame { _sendButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [self addSubview: _sendButton]; - [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_options.png"] forState:UIControlStateNormal]; - [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_keyboard.png"] forState:UIControlStateSelected]; + if(BChatSDK.config.optionsButtonIcon) { + [_optionsButton setImage:[UIImage imageNamed:BChatSDK.config.optionsButtonIcon] forState:UIControlStateNormal]; + [_optionsButton setImage:[UIImage imageNamed:BChatSDK.config.optionsButtonIcon] forState:UIControlStateSelected]; + } else { + [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_options.png"] forState:UIControlStateNormal]; + [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_keyboard.png"] forState:UIControlStateSelected]; + } [_optionsButton addTarget:self action:@selector(optionsButtonPressed) forControlEvents:UIControlEventTouchUpInside]; From 34e58926b637588b95b2ae8853e14e71c536380c Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Wed, 30 Oct 2019 21:19:34 +0800 Subject: [PATCH 07/22] Add customization for chat screen's send icon --- ChatSDKCore/Classes/Session/BConfiguration.h | 3 +++ ChatSDKCore/Classes/Session/BConfiguration.m | 2 ++ .../Components/Chat View/BTextInputView.m | 21 +++++++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index da74400f..c1378e2e 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -258,6 +258,9 @@ typedef enum { /// Custom icon for the options/attachment button. @property (nonatomic, readwrite) NSString * optionsButtonIcon; +/// Custom icon for the send message button. +@property (nonatomic, readwrite) NSString * sendButtonIcon; + // XMPP Auth type used which can be: // default, scramsha1, digestmd5, plain @property (nonatomic, readwrite) NSString * xmppAuthType; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 697601f7..67cd84fd 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -99,6 +99,8 @@ @implementation BConfiguration @synthesize nearbyUsersMinimumLocationChangeToUpdateServer; @synthesize optionsButtonIcon; +@synthesize sendButtonIcon; + -(instancetype) init { if((self = [super init])) { diff --git a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m index 71bb8186..3e09c193 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m +++ b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m @@ -74,8 +74,15 @@ -(instancetype) initWithFrame:(CGRect)frame { [_optionsButton addTarget:self action:@selector(optionsButtonPressed) forControlEvents:UIControlEventTouchUpInside]; - NSString * sendButtonTitle = [NSBundle t:bSend]; - [_sendButton setTitle:sendButtonTitle forState:UIControlStateNormal]; + if(BChatSDK.config.sendButtonIcon) { + [_sendButton setTitle:Nil forState:UIControlStateNormal]; + [_sendButton setImage:[UIImage imageNamed:BChatSDK.config.sendButtonIcon] forState:UIControlStateNormal]; + [_sendButton setImage:[UIImage imageNamed:BChatSDK.config.sendButtonIcon] forState:UIControlStateSelected]; + } else { + NSString * sendButtonTitle = [NSBundle t:bSend]; + [_sendButton setImage:Nil forState:UIControlStateNormal]; + [_sendButton setTitle:sendButtonTitle forState:UIControlStateNormal]; + } [_sendButton addTarget:self action:@selector(sendButtonPressed) forControlEvents:UIControlEventTouchUpInside]; [_sendButton addTarget:self action:@selector(sendButtonHeld) forControlEvents:UIControlEventTouchDown]; @@ -188,8 +195,14 @@ -(void) setMicButtonEnabled: (BOOL) enabled sendButtonEnabled: (BOOL) sendButton forState:UIControlStateNormal]; } else { - [_sendButton setTitle:[NSBundle t:bSend] forState:UIControlStateNormal]; - [_sendButton setImage:Nil forState:UIControlStateNormal]; + if(BChatSDK.config.sendButtonIcon) { + [_sendButton setTitle:Nil forState:UIControlStateNormal]; + [_sendButton setImage:[UIImage imageNamed:BChatSDK.config.sendButtonIcon] forState:UIControlStateNormal]; + [_sendButton setImage:[UIImage imageNamed:BChatSDK.config.sendButtonIcon] forState:UIControlStateSelected]; + } else { + [_sendButton setTitle:[NSBundle t:bSend] forState:UIControlStateNormal]; + [_sendButton setImage:Nil forState:UIControlStateNormal]; + } } } From bb1a1ba74bd87e11775edd904db1a12e8b7b438d Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Sun, 3 Nov 2019 12:10:47 +0800 Subject: [PATCH 08/22] Fix customization of options button icon --- ChatSDKUI/Classes/Components/Chat View/BTextInputView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m index 3e09c193..c7656edd 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m +++ b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m @@ -65,8 +65,8 @@ -(instancetype) initWithFrame:(CGRect)frame { [self addSubview: _sendButton]; if(BChatSDK.config.optionsButtonIcon) { - [_optionsButton setImage:[UIImage imageNamed:BChatSDK.config.optionsButtonIcon] forState:UIControlStateNormal]; - [_optionsButton setImage:[UIImage imageNamed:BChatSDK.config.optionsButtonIcon] forState:UIControlStateSelected]; + [_optionsButton setImage:[NSBundle uiImageNamed:BChatSDK.config.optionsButtonIcon] forState:UIControlStateNormal]; + [_optionsButton setImage:[NSBundle uiImageNamed:BChatSDK.config.optionsButtonIcon] forState:UIControlStateSelected]; } else { [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_options.png"] forState:UIControlStateNormal]; [_optionsButton setImage:[NSBundle uiImageNamed:@"icn_24_keyboard.png"] forState:UIControlStateSelected]; From d5a79f5aec380eceee4fe9413a0bdab11d7343ab Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Sun, 3 Nov 2019 13:14:48 +0800 Subject: [PATCH 09/22] Center align options button if a custom icon has been set --- .../Classes/Components/Chat View/BTextInputView.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m index c7656edd..827da72c 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m +++ b/ChatSDKUI/Classes/Components/Chat View/BTextInputView.m @@ -107,9 +107,15 @@ -(instancetype) initWithFrame:(CGRect)frame { // Constrain the elements _optionsButton.keepLeftInset.equal = bMargin +keepRequired; - - _optionsButton.keepBottomInset.equal = 8.0; - _optionsButton.keepHeight.equal = 24; + + /// If a custom options button icon has been set, then center align it. + if(BChatSDK.config.optionsButtonIcon) { + _optionsButton.keepBottomInset.equal = bMargin; + _optionsButton.keepTopInset.equal = bMargin; + } else { + _optionsButton.keepBottomInset.equal = 8.0; + _optionsButton.keepHeight.equal = 24; + } // If the user has no chat options available then remove the chat option button width _optionsButton.keepWidth.equal = BChatSDK.ui.chatOptions.count ? 24 : 0; From cf7b6c5368f26ec53375d7b0b9de6f44babcdb54 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Mon, 4 Nov 2019 11:12:09 +0800 Subject: [PATCH 10/22] Add a temporary solution for showing message status icon --- ChatSDKCore/Classes/Session/BConfiguration.h | 1 + ChatSDKCore/Classes/Session/BConfiguration.m | 1 + .../Classes/Components/Message Cells/BMessageCell.m | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index c1378e2e..997f9247 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -37,6 +37,7 @@ typedef enum { /// Add a shadow to the message bubble using a default shadow configuration. @property (nonatomic, readwrite) BOOL addShadowOnMessageBubble; +@property (nonatomic, readwrite) BOOL showReadStatus; // Background color of messages: hex value like "FFFFFF" @property (nonatomic, readwrite) NSString * messageColorMe; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 67cd84fd..a6d22225 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -13,6 +13,7 @@ @implementation BConfiguration @synthesize chatBgColor; @synthesize addShadowOnMessageBubble; +@synthesize showReadStatus; @synthesize messageColorMe; @synthesize messageColorReply; @synthesize messageTimeColor; diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m index 072c265e..889aae78 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m @@ -197,8 +197,13 @@ -(void) setMessage: (id) message withColorWeight: (float) colorWeig _nameLabel.hidden = BChatSDK.config.hideNameLabel; } - // Hide the read receipt view if this is a public thread or if read receipts are disabled - _readMessageImageView.hidden = _message.thread.type.intValue & bThreadFilterPublic || !BChatSDK.readReceipt; + if(BChatSDK.config.showReadStatus) { + // TODO: Find actual way to show the message status. This is temp solution only. + _readMessageImageView.hidden = NO; + } else { + // Hide the read receipt view if this is a public thread or if read receipts are disabled + _readMessageImageView.hidden = _message.thread.type.intValue & bThreadFilterPublic || !BChatSDK.readReceipt; + } _timeLabel.hidden = BChatSDK.config.combineTimeWithNameLabel; From 0ee5211a1484a84d2f0bbfb89d0be8913171961b Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Mon, 4 Nov 2019 11:12:39 +0800 Subject: [PATCH 11/22] Add filtering of messages according to a given date --- ChatSDKCore/Classes/Session/BConfiguration.h | 5 +++++ ChatSDKCore/Classes/Session/BConfiguration.m | 2 ++ .../Classes/Components/Chat View/BChatViewController.m | 6 ++++++ ChatSDKUI/Classes/Components/Chat View/BLazyReloadManager.m | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index 997f9247..921f648b 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -38,6 +38,11 @@ typedef enum { /// Add a shadow to the message bubble using a default shadow configuration. @property (nonatomic, readwrite) BOOL addShadowOnMessageBubble; @property (nonatomic, readwrite) BOOL showReadStatus; +/// Format to be used for NSPredicate. +@property (nonatomic, readwrite) NSString * dateFilterFormat; +/// An NSDate filter used to filter thread messages to show only the messages that are greater than or equal +/// the set dateFilter. +@property (nonatomic, readwrite) NSDate * dateFilter; // Background color of messages: hex value like "FFFFFF" @property (nonatomic, readwrite) NSString * messageColorMe; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index a6d22225..622aca5e 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -14,6 +14,8 @@ @implementation BConfiguration @synthesize chatBgColor; @synthesize addShadowOnMessageBubble; @synthesize showReadStatus; +@synthesize dateFilterFormat; +@synthesize dateFilter; @synthesize messageColorMe; @synthesize messageColorReply; @synthesize messageTimeColor; diff --git a/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m b/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m index c49df9fd..c3159f33 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m +++ b/ChatSDKUI/Classes/Components/Chat View/BChatViewController.m @@ -49,6 +49,12 @@ -(void) viewDidLoad { // Add the initial batch of messages NSArray * messages = [BChatSDK.db loadMessagesForThread:_thread newest:BChatSDK.config.messagesToLoadPerBatch]; messages = [messages sortedArrayUsingComparator:[BMessageSorter oldestFirst]]; + + if(BChatSDK.config.dateFilter && BChatSDK.config.dateFilterFormat) { + NSPredicate *dateFilterPredicate = [NSPredicate predicateWithFormat:BChatSDK.config.dateFilterFormat, BChatSDK.config.dateFilter]; + messages = (NSArray *)[messages filteredArrayUsingPredicate:dateFilterPredicate]; + } + [self setMessages:messages scrollToBottom:NO animate:NO force: YES]; } diff --git a/ChatSDKUI/Classes/Components/Chat View/BLazyReloadManager.m b/ChatSDKUI/Classes/Components/Chat View/BLazyReloadManager.m index dfab29fc..86d7c004 100755 --- a/ChatSDKUI/Classes/Components/Chat View/BLazyReloadManager.m +++ b/ChatSDKUI/Classes/Components/Chat View/BLazyReloadManager.m @@ -44,6 +44,11 @@ -(void) loadMessages: (UIScrollView *) scrollView { float height = scrollView.contentSize.height; float offsetY = scrollView.contentOffset.y; + if(BChatSDK.config.dateFilter && BChatSDK.config.dateFilterFormat) { + NSPredicate *dateFilterPredicate = [NSPredicate predicateWithFormat:BChatSDK.config.dateFilterFormat, BChatSDK.config.dateFilter]; + messages = (NSArray *)[messages filteredArrayUsingPredicate:dateFilterPredicate]; + } + [self.messageManager addMessages: messages]; [self.tableView reloadData]; From ef955a2d2276baa9b1c550c39ca1d1a3c3149215 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Mon, 4 Nov 2019 12:13:58 +0800 Subject: [PATCH 12/22] Update SDWebImage to 5.0 --- ChatSDK.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChatSDK.podspec b/ChatSDK.podspec index c018ef81..61c7acd8 100755 --- a/ChatSDK.podspec +++ b/ChatSDK.podspec @@ -65,7 +65,7 @@ Pod::Spec.new do |s| ui.dependency 'MBProgressHUD', '~> 1.0' ui.dependency 'VENTokenField', '~> 2.0' - ui.dependency 'SDWebImage', '~> 4.0' + ui.dependency 'SDWebImage', '~> 5.0' ui.dependency 'StaticDataTableViewController', '~> 2.0' ui.dependency 'CountryPicker', '~> 1.0' ui.dependency 'TOCropViewController', '~> 2.0' From 61b780c1b1dfdc9ed5ef0a641d65a9fabff79a71 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Mon, 4 Nov 2019 15:07:05 +0800 Subject: [PATCH 13/22] Add boolean to keeps online status on did resign active --- ChatSDKCore/Classes/Session/BChatSDK.m | 4 +++- ChatSDKCore/Classes/Session/BConfiguration.h | 3 +++ ChatSDKCore/Classes/Session/BConfiguration.m | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChatSDKCore/Classes/Session/BChatSDK.m b/ChatSDKCore/Classes/Session/BChatSDK.m index ffe64809..ff7b397c 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.m +++ b/ChatSDKCore/Classes/Session/BChatSDK.m @@ -77,7 +77,9 @@ +(void) initialize: (BConfiguration *) config app:(UIApplication *)application o } -(void) appDidResignActive { - if(self.networkAdapter) { + if(self.config.keepAliveOnDidResignActive) { + + } else if(self.networkAdapter) { [self.networkAdapter.core save]; [self.networkAdapter.core goOffline]; } diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index 921f648b..c617d02a 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -32,6 +32,9 @@ typedef enum { // Should we ask the user to allow notifications when the app initially loads up? @property (nonatomic, readwrite) BOOL shouldAskForNotificationsPermission; +/// Keep the online status even when app resigns from an active state. +@property (nonatomic, readwrite) BOOL keepAliveOnDidResignActive; + /// Custom background color of BChatViewController's main view. @property (nonatomic, readwrite) NSString * chatBgColor; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 622aca5e..22b4dde8 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -11,6 +11,7 @@ @implementation BConfiguration +@synthesize keepAliveOnDidResignActive; @synthesize chatBgColor; @synthesize addShadowOnMessageBubble; @synthesize showReadStatus; From c6fe7648d3141940da82a79b12a132a4a3b6916d Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Mon, 4 Nov 2019 15:19:42 +0800 Subject: [PATCH 14/22] Fix wrong variable used for config --- ChatSDKCore/Classes/Session/BChatSDK.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChatSDKCore/Classes/Session/BChatSDK.m b/ChatSDKCore/Classes/Session/BChatSDK.m index ff7b397c..100c7fe9 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.m +++ b/ChatSDKCore/Classes/Session/BChatSDK.m @@ -77,7 +77,7 @@ +(void) initialize: (BConfiguration *) config app:(UIApplication *)application o } -(void) appDidResignActive { - if(self.config.keepAliveOnDidResignActive) { + if(self.configuration.keepAliveOnDidResignActive) { } else if(self.networkAdapter) { [self.networkAdapter.core save]; From 7395ff9ff7f0e6b697bb19827139755013cc09ee Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Mon, 4 Nov 2019 15:41:13 +0800 Subject: [PATCH 15/22] Revert "Fix wrong variable used for config" This reverts commit c6fe7648d3141940da82a79b12a132a4a3b6916d. --- ChatSDKCore/Classes/Session/BChatSDK.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChatSDKCore/Classes/Session/BChatSDK.m b/ChatSDKCore/Classes/Session/BChatSDK.m index 100c7fe9..ff7b397c 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.m +++ b/ChatSDKCore/Classes/Session/BChatSDK.m @@ -77,7 +77,7 @@ +(void) initialize: (BConfiguration *) config app:(UIApplication *)application o } -(void) appDidResignActive { - if(self.configuration.keepAliveOnDidResignActive) { + if(self.config.keepAliveOnDidResignActive) { } else if(self.networkAdapter) { [self.networkAdapter.core save]; From ff2124262d3eca20853e94332240faddd2055933 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Mon, 4 Nov 2019 15:42:13 +0800 Subject: [PATCH 16/22] Fix implementation of keepAliveOnDidResignActive condition --- ChatSDKCore/Classes/Session/BChatSDK.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChatSDKCore/Classes/Session/BChatSDK.m b/ChatSDKCore/Classes/Session/BChatSDK.m index ff7b397c..8b114046 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.m +++ b/ChatSDKCore/Classes/Session/BChatSDK.m @@ -77,7 +77,7 @@ +(void) initialize: (BConfiguration *) config app:(UIApplication *)application o } -(void) appDidResignActive { - if(self.config.keepAliveOnDidResignActive) { + if([BChatSDK config].keepAliveOnDidResignActive) { } else if(self.networkAdapter) { [self.networkAdapter.core save]; From 42d22f56df1277820e88213acde1b3e80e31bd32 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Mon, 4 Nov 2019 16:23:25 +0800 Subject: [PATCH 17/22] Another fix for crashing unrecognized setKeepAliveOnDidResignActive --- ChatSDKCore/Classes/Session/BChatSDK.h | 1 + ChatSDKCore/Classes/Session/BChatSDK.m | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChatSDKCore/Classes/Session/BChatSDK.h b/ChatSDKCore/Classes/Session/BChatSDK.h index 096fe1d7..095b51b3 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.h +++ b/ChatSDKCore/Classes/Session/BChatSDK.h @@ -31,6 +31,7 @@ @property (nonatomic, readwrite) id interfaceAdapter; @property (nonatomic, readwrite) id storageAdapter; @property (nonatomic, readwrite) id networkAdapter; +@property (nonatomic, readwrite) BOOL keepAliveOnDidResignActive; +(BChatSDK *) shared; +(BConfiguration *) config; diff --git a/ChatSDKCore/Classes/Session/BChatSDK.m b/ChatSDKCore/Classes/Session/BChatSDK.m index 8b114046..e8b55aa5 100755 --- a/ChatSDKCore/Classes/Session/BChatSDK.m +++ b/ChatSDKCore/Classes/Session/BChatSDK.m @@ -18,6 +18,7 @@ @implementation BChatSDK @synthesize interfaceAdapter = _interfaceAdapter; @synthesize storageAdapter = _storageAdapter; @synthesize networkAdapter = _networkAdapter; +@synthesize keepAliveOnDidResignActive = _keepAliveOnDidResignActive; static BChatSDK * instance; @@ -77,9 +78,7 @@ +(void) initialize: (BConfiguration *) config app:(UIApplication *)application o } -(void) appDidResignActive { - if([BChatSDK config].keepAliveOnDidResignActive) { - - } else if(self.networkAdapter) { + if(self.networkAdapter && self.keepAliveOnDidResignActive == NO) { [self.networkAdapter.core save]; [self.networkAdapter.core goOffline]; } From 13615ffa6173a68cb3f593eecd824ddb3d4f14e4 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Tue, 5 Nov 2019 11:18:17 +0800 Subject: [PATCH 18/22] Remove unused variable on BConfig --- ChatSDKCore/Classes/Session/BConfiguration.h | 3 --- ChatSDKCore/Classes/Session/BConfiguration.m | 1 - 2 files changed, 4 deletions(-) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index c617d02a..921f648b 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -32,9 +32,6 @@ typedef enum { // Should we ask the user to allow notifications when the app initially loads up? @property (nonatomic, readwrite) BOOL shouldAskForNotificationsPermission; -/// Keep the online status even when app resigns from an active state. -@property (nonatomic, readwrite) BOOL keepAliveOnDidResignActive; - /// Custom background color of BChatViewController's main view. @property (nonatomic, readwrite) NSString * chatBgColor; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 22b4dde8..622aca5e 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -11,7 +11,6 @@ @implementation BConfiguration -@synthesize keepAliveOnDidResignActive; @synthesize chatBgColor; @synthesize addShadowOnMessageBubble; @synthesize showReadStatus; From d36d3813f29e52d6b32290b6d4babca92ca73c7a Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Tue, 5 Nov 2019 11:18:44 +0800 Subject: [PATCH 19/22] Allow hiding of chat section header --- ChatSDKCore/Classes/Session/BConfiguration.h | 2 ++ ChatSDKCore/Classes/Session/BConfiguration.m | 1 + ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index 921f648b..7ddb8913 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -35,6 +35,8 @@ typedef enum { /// Custom background color of BChatViewController's main view. @property (nonatomic, readwrite) NSString * chatBgColor; +/// Hide the section that shows "Today", "Yesterday", etc. +@property (nonatomic, readwrite) BOOL hideDayOfTheWeekSection; /// Add a shadow to the message bubble using a default shadow configuration. @property (nonatomic, readwrite) BOOL addShadowOnMessageBubble; @property (nonatomic, readwrite) BOOL showReadStatus; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 622aca5e..4109df2f 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -12,6 +12,7 @@ @implementation BConfiguration @synthesize chatBgColor; +@synthesize hideDayOfTheWeekSection; @synthesize addShadowOnMessageBubble; @synthesize showReadStatus; @synthesize dateFilterFormat; diff --git a/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m b/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m index d565075e..6f3687ca 100755 --- a/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m +++ b/ChatSDKUI/Classes/Components/SDK/ElmChatViewController.m @@ -408,6 +408,14 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger return [_messageManager messageForIndexPath:path]; } +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + if(BChatSDK.config.hideDayOfTheWeekSection) { + return 0.01; + } + + return UITableViewAutomaticDimension; +} + - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return [_messageManager headerForSection:section]; } From 767bae8a85bb728d92d95cba486c102611e36817 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Tue, 5 Nov 2019 13:33:49 +0800 Subject: [PATCH 20/22] Allow showing of profile picture on every cell --- ChatSDKCore/Classes/Session/BConfiguration.h | 3 +++ ChatSDKCore/Classes/Session/BConfiguration.m | 1 + .../Components/Message Cells/BMessageCell.m | 26 +++++++++++-------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index 7ddb8913..4daaf1ad 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -74,6 +74,9 @@ typedef enum { // Should empty chats be shown in the threads view? @property (nonatomic, readwrite) BOOL showEmptyChats; +/// Show profile picture on every message cell. +@property (nonatomic, readwrite) BOOL showProfilePictureOnEveryCell; + // User profile image @property (nonatomic, readwrite) NSString * defaultAvatarURL; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 4109df2f..5ee1836c 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -35,6 +35,7 @@ @implementation BConfiguration @synthesize defaultServer; @synthesize shouldOpenChatWhenPushNotificationClicked; @synthesize loginUsernamePlaceholder; +@synthesize showProfilePictureOnEveryCell; @synthesize defaultAvatarURL; @synthesize defaultBlankAvatar; @synthesize timeFormat; diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m index 889aae78..df68fc3c 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m @@ -28,12 +28,12 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr // Make sure the selected color is white self.selectedBackgroundView = [[UIView alloc] init]; - + // Bubble view bubbleImageView = [[UIImageView alloc] init]; bubbleImageView.contentMode = UIViewContentModeScaleToFill; bubbleImageView.userInteractionEnabled = YES; - + [self.contentView addSubview:bubbleImageView]; _profilePicture = [[UIImageView alloc] init]; @@ -76,14 +76,14 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr [_profilePicture addGestureRecognizer:profileTouched]; _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - + } return self; } -(void) setReadStatus: (bMessageReadStatus) status { NSString * imageName = Nil; - + switch (status) { case bMessageReadStatusNone: imageName = @"icn_message_received.png"; @@ -142,12 +142,16 @@ -(void) setMessage: (id) message withColorWeight: (float) colorWeig // Set the bubble to be the correct color bubbleImageView.image = [[BMessageCache sharedCache] bubbleForMessage:message withColorWeight:colorWeight]; - + // Hide profile pictures for 1-to-1 threads _profilePicture.hidden = self.profilePictureHidden; // We only want to show the user picture if it is the latest message from the user - if (position & BChatSDK.config.showMessageAvatarAtPosition) { + // + // 11/05/2019 + // Or we can also show a profile picture beside each message cell by setting a value to + // BChatSDK.config.showProfilePictureOnEveryCell, depends on the project requirements. + if ((position & BChatSDK.config.showMessageAvatarAtPosition) || BChatSDK.config.showProfilePictureOnEveryCell) { if (message.userModel) { [_profilePicture loadAvatar:message.userModel]; @@ -175,7 +179,7 @@ -(void) setMessage: (id) message withColorWeight: (float) colorWeig if (message.flagged.intValue) { _timeLabel.text = [NSBundle t:bFlagged]; } - + _timeLabel.text = _message.date.messageTimeAt; // We use 10 here because if the messages are less than 10 minutes apart, then we // can just compare the minute figures. If they were hours apart they could have @@ -237,7 +241,7 @@ -(void) willDisplayCell { else { float ppDiameter = [BMessageCell profilePictureDiameter]; float ppPadding = self.profilePicturePadding; - + [_profilePicture setFrame:CGRectMake(ppPadding, (self.cellHeight - ppDiameter - self.nameHeight)/2.0, ppDiameter, @@ -574,7 +578,7 @@ +(UIEdgeInsets) bubbleMargin: (id) message { } Class cellType = [BChatSDK.ui cellTypeForMessageType:message.type]; - + SEL selector = @selector(messageBubbleMargin:); if ([cellType respondsToSelector:selector]) { return [[cellType performSelector:selector withObject:message] UIEdgeInsetsValue]; @@ -595,12 +599,12 @@ +(UIEdgeInsets) bubblePadding: (id) message { } Class cellType = [BChatSDK.ui cellTypeForMessageType:message.type]; - + SEL selector = @selector(messageBubblePadding:); if ([cellType respondsToSelector:selector]) { return [[cellType performSelector:selector withObject:message] UIEdgeInsetsValue]; } - + return [self messageBubblePadding:message].UIEdgeInsetsValue; } From 0cbec2bb6191683bc6d31ad28edca72835d852fc Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Tue, 5 Nov 2019 14:12:26 +0800 Subject: [PATCH 21/22] Fix overlapping image on time label --- ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m index df68fc3c..84030167 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m @@ -654,7 +654,7 @@ +(NSNumber *) messageContentHeight: (id) message maxWidth: (float) } +(NSNumber *) messageContentWidth: (id) message maxWidth: (float) maxWidth { - return @(bMaxMessageWidth); + return @(maxWidth); } +(NSValue *) messageBubblePadding: (id) message { From 032d18d6e8ac52cefa4696a855d4f72a9dde0cd3 Mon Sep 17 00:00:00 2001 From: Failyn Kaye Sedik Date: Wed, 13 Nov 2019 11:49:56 +0800 Subject: [PATCH 22/22] ADD: Flag for tap action on message cell's profile picture --- ChatSDKCore/Classes/Session/BConfiguration.h | 3 +++ ChatSDKCore/Classes/Session/BConfiguration.m | 3 +++ .../Classes/Components/Message Cells/BMessageCell.m | 9 ++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChatSDKCore/Classes/Session/BConfiguration.h b/ChatSDKCore/Classes/Session/BConfiguration.h index 4daaf1ad..7d9d0de5 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.h +++ b/ChatSDKCore/Classes/Session/BConfiguration.h @@ -77,6 +77,9 @@ typedef enum { /// Show profile picture on every message cell. @property (nonatomic, readwrite) BOOL showProfilePictureOnEveryCell; +/// Value of profilePictureOnCellTapEnabled is enabled by default to follow previous implementation. +@property (nonatomic, readwrite) BOOL profilePictureOnCellTapEnabled; + // User profile image @property (nonatomic, readwrite) NSString * defaultAvatarURL; diff --git a/ChatSDKCore/Classes/Session/BConfiguration.m b/ChatSDKCore/Classes/Session/BConfiguration.m index 5ee1836c..51828291 100755 --- a/ChatSDKCore/Classes/Session/BConfiguration.m +++ b/ChatSDKCore/Classes/Session/BConfiguration.m @@ -36,6 +36,7 @@ @implementation BConfiguration @synthesize shouldOpenChatWhenPushNotificationClicked; @synthesize loginUsernamePlaceholder; @synthesize showProfilePictureOnEveryCell; +@synthesize profilePictureOnCellTapEnabled; @synthesize defaultAvatarURL; @synthesize defaultBlankAvatar; @synthesize timeFormat; @@ -164,6 +165,8 @@ -(instancetype) init { shouldAskForNotificationsPermission = YES; + profilePictureOnCellTapEnabled = YES; + defaultBlankAvatar = [NSBundle imageNamed:bDefaultProfileImage bundle:bCoreBundleName]; defaultGroupChatAvatar = [NSBundle imageNamed:bDefaultPublicGroupImage bundle:bCoreBundleName]; diff --git a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m index 84030167..d532a832 100755 --- a/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m +++ b/ChatSDKUI/Classes/Components/Message Cells/BMessageCell.m @@ -71,9 +71,12 @@ -(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSStr [self setReadStatus:bMessageReadStatusNone]; [self.contentView addSubview:_readMessageImageView]; - UITapGestureRecognizer * profileTouched = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showProfileView)]; - _profilePicture.userInteractionEnabled = YES; - [_profilePicture addGestureRecognizer:profileTouched]; + // Value of profilePictureOnCellTapEnabled is enabled by default to follow previous implementation. + if (BChatSDK.config.profilePictureOnCellTapEnabled) { + UITapGestureRecognizer * profileTouched = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showProfileView)]; + _profilePicture.userInteractionEnabled = YES; + [_profilePicture addGestureRecognizer:profileTouched]; + } _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];