From 186da72c047889faf3f70a68f9388e71094df921 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Wed, 2 Jan 2019 15:33:58 +0100 Subject: [PATCH] new HistoryDetailsView : enable the creation of an encrypted chatroom --- Classes/Base.lproj/HistoryDetailsView.xib | 235 ++++++++++++++-------- Classes/HistoryDetailsView.h | 3 + Classes/HistoryDetailsView.m | 26 ++- 3 files changed, 172 insertions(+), 92 deletions(-) diff --git a/Classes/Base.lproj/HistoryDetailsView.xib b/Classes/Base.lproj/HistoryDetailsView.xib index 9c8838b00..00ae27638 100644 --- a/Classes/Base.lproj/HistoryDetailsView.xib +++ b/Classes/Base.lproj/HistoryDetailsView.xib @@ -1,11 +1,11 @@ - - + + - + @@ -17,9 +17,11 @@ + + @@ -28,23 +30,23 @@ - + - + - + - + - + + + + + + + + + + + + + + + + + + + - + @@ -142,19 +173,19 @@ - - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + - - + - + @@ -331,5 +391,6 @@ + diff --git a/Classes/HistoryDetailsView.h b/Classes/HistoryDetailsView.h index 1e88ed6ca..d109e645d 100644 --- a/Classes/HistoryDetailsView.h +++ b/Classes/HistoryDetailsView.h @@ -40,11 +40,14 @@ @property(weak, nonatomic) IBOutlet UILabel *emptyLabel; @property (weak, nonatomic) IBOutlet UIView *waitView; @property (weak, nonatomic) IBOutlet UIRoundedImageView *linphoneImage; +@property (weak, nonatomic) IBOutlet UIView *optionsView; +@property (weak, nonatomic) IBOutlet UIView *encryptedChatView; - (IBAction)onBackClick:(id)event; - (IBAction)onAddContactClick:(id)event; - (IBAction)onCallClick:(id)event; - (IBAction)onChatClick:(id)event; +- (IBAction)onEncryptedChatClick:(id)sender; - (void)setCallLogId:(NSString *)acallLogId; @end diff --git a/Classes/HistoryDetailsView.m b/Classes/HistoryDetailsView.m index c0cffe96f..9ff1e2df8 100644 --- a/Classes/HistoryDetailsView.m +++ b/Classes/HistoryDetailsView.m @@ -111,9 +111,7 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void) deviceOrientationDidChange:(NSNotification*) notif { - if (IPAD) { - [self update]; - } + [self update]; } #pragma mark - @@ -147,14 +145,28 @@ static UICompositeViewDescription *compositeDescription = nil; [ContactDisplay setDisplayNameLabel:_contactLabel forAddress:addr withAddressLabel:_addressLabel]; [_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES]; Contact *contact = [FastAddressBook getContactWithAddress:addr]; + const LinphonePresenceModel *model = contact.friend ? linphone_friend_get_presence_model(contact.friend) : NULL; _linphoneImage.hidden = - ! ((contact.friend && linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(contact.friend)) == LinphonePresenceBasicStatusOpen) || [FastAddressBook contactHasValidSipDomain:contact]); + ! ((model && linphone_presence_model_get_basic_status(model) == LinphonePresenceBasicStatusOpen) || [FastAddressBook contactHasValidSipDomain:contact]); + [self shouldHideEncryptedChatView:model && linphone_presence_model_has_capability(model, LinphoneFriendCapabilityLimeX3dh)]; char *addrURI = linphone_address_as_string_uri_only(addr); ms_free(addrURI); [_tableView loadDataForAddress:(callLog ? linphone_call_log_get_remote_address(callLog) : NULL)]; } +- (void)shouldHideEncryptedChatView:(BOOL)hasLime { + _encryptedChatView.hidden = !hasLime; + CGRect newFrame = _optionsView.frame; + if (!hasLime) { + newFrame.origin.x = _encryptedChatView.frame.size.width * 2/3; + + } else { + newFrame.origin.x = 0; + } + _optionsView.frame = newFrame; +} + #pragma mark - Action Functions - (IBAction)onBackClick:(id)event { @@ -195,7 +207,11 @@ static UICompositeViewDescription *compositeDescription = nil; - (IBAction)onChatClick:(id)event { const LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); - // TODO one button for chatroom encrypted,another button for chatroom unencrypted + [PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:FALSE]; +} + +- (IBAction)onEncryptedChatClick:(id)sender { + const LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog); [PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:TRUE]; }