From a8e393ba1662f24fc147e33acdf3d70b2907ad01 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Wed, 7 Nov 2018 15:43:08 +0100 Subject: [PATCH] 4.1 create liste devices view --- Classes/Base.lproj/ChatConversationView.xib | 6 +- Classes/ChatConversationView.h | 2 + Classes/ChatConversationView.m | 8 ++ Classes/DevicesListView.h | 29 ++++ Classes/DevicesListView.m | 143 ++++++++++++++++++++ Classes/DevicesListView.xib | 86 ++++++++++++ Classes/LinphoneUI/UIDevicesDetails.h | 18 +++ Classes/LinphoneUI/UIDevicesDetails.m | 62 +++++++++ Classes/LinphoneUI/UIDevicesDetails.xib | 69 ++++++++++ Resources/images/chevron_list_close.png | Bin 0 -> 437 bytes Resources/images/chevron_list_close@2x.png | Bin 0 -> 809 bytes Resources/images/chevron_list_open.png | Bin 0 -> 440 bytes Resources/images/chevron_list_open@2x.png | Bin 0 -> 841 bytes linphone.xcodeproj/project.pbxproj | 36 +++++ 14 files changed, 458 insertions(+), 1 deletion(-) create mode 100644 Classes/DevicesListView.h create mode 100644 Classes/DevicesListView.m create mode 100644 Classes/DevicesListView.xib create mode 100644 Classes/LinphoneUI/UIDevicesDetails.h create mode 100644 Classes/LinphoneUI/UIDevicesDetails.m create mode 100644 Classes/LinphoneUI/UIDevicesDetails.xib create mode 100644 Resources/images/chevron_list_close.png create mode 100644 Resources/images/chevron_list_close@2x.png create mode 100644 Resources/images/chevron_list_open.png create mode 100644 Resources/images/chevron_list_open@2x.png diff --git a/Classes/Base.lproj/ChatConversationView.xib b/Classes/Base.lproj/ChatConversationView.xib index 20b3a1ded..8ada88f0c 100644 --- a/Classes/Base.lproj/ChatConversationView.xib +++ b/Classes/Base.lproj/ChatConversationView.xib @@ -18,6 +18,7 @@ + @@ -293,10 +294,13 @@ - diff --git a/Classes/ChatConversationView.h b/Classes/ChatConversationView.h index f63f3cf7c..55fe33cc7 100644 --- a/Classes/ChatConversationView.h +++ b/Classes/ChatConversationView.h @@ -66,6 +66,7 @@ @property NSMutableArray *qualitySettingsArray; @property (weak, nonatomic) IBOutlet UICollectionView *imagesCollectionView; @property (weak, nonatomic) IBOutlet UIView *imagesView; +@property (weak, nonatomic) IBOutlet UIButton *encryptedButton; + (void)markAsRead:(LinphoneChatRoom *)chatRoom; + (UIImage *)getSecurityImageForChatRoom:(LinphoneChatRoom *)chatRoom; @@ -80,6 +81,7 @@ - (IBAction)onCallClick:(id)sender; - (IBAction)onDeleteClick:(id)sender; - (IBAction)onEditionChangeClick:(id)sender; +- (IBAction)onEncryptedDevicesClick:(id)sender; - (void)update; - (void)openFile:(NSString *) filePath; - (void)clearMessageView; diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 1a9ef5e6e..4a3f0e126 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -24,6 +24,7 @@ #import "Utils.h" #import "FileTransferDelegate.h" #import "UIChatBubbleTextCell.h" +#import "DevicesListView.h" @implementation ChatConversationView static NSString* groupName = @"group.belledonne-communications.linphone"; @@ -588,6 +589,13 @@ static UICompositeViewDescription *compositeDescription = nil; [self updateSuperposedButtons]; } +- (IBAction)onEncryptedDevicesClick:(id)sender { + DevicesListView *view = VIEW(DevicesListView); + view.room = _chatRoom; + + [PhoneMainView.instance popToView:view.compositeViewDescription]; +} + - (IBAction)onCallClick:(id)sender { bctbx_list_t *participants = linphone_chat_room_get_participants(_chatRoom); LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL; diff --git a/Classes/DevicesListView.h b/Classes/DevicesListView.h new file mode 100644 index 000000000..c2a6776d8 --- /dev/null +++ b/Classes/DevicesListView.h @@ -0,0 +1,29 @@ +// +// DevicesListView.h +// linphone +// +// Created by Danmei Chen on 06/11/2018. +// +#import +#import "UICompositeView.h" + +@interface DevicesMenuEntry : NSObject { +@public + LinphoneParticipant *participant; + NSInteger numberOfDevices; +}; +@end + +@interface DevicesListView : UIViewController + +@property (weak, nonatomic) IBOutlet UILabel *addressLabel; +@property (weak, nonatomic) IBOutlet UITableView *tableView; + +@property(nonatomic) LinphoneChatRoom *room; +@property bctbx_list_t *devices; +@property NSMutableArray *devicesMenuEntries; +@property BOOL isOneToOne; + +- (IBAction)onBackClick:(id)sender; + +@end diff --git a/Classes/DevicesListView.m b/Classes/DevicesListView.m new file mode 100644 index 000000000..cd4c5de69 --- /dev/null +++ b/Classes/DevicesListView.m @@ -0,0 +1,143 @@ +// +// DevicesListView.m +// linphone +// +// Created by Danmei Chen on 06/11/2018. +// + +#import "DevicesListView.h" +#import "PhoneMainView.h" +#import "UIDevicesDetails.h" + +@implementation DevicesMenuEntry + +- (id)initWithTitle:(LinphoneParticipant *)par number:(NSInteger)num { + if ((self = [super init])) { + participant = par; + numberOfDevices = num; + } + return self; +} + +@end + +@implementation DevicesListView +#pragma mark - UICompositeViewDelegate Functions + +static UICompositeViewDescription *compositeDescription = nil; + ++ (UICompositeViewDescription *)compositeViewDescription { + if (compositeDescription == nil) { + compositeDescription = [[UICompositeViewDescription alloc] init:self.class + statusBar:StatusBarView.class + tabBar:TabBarView.class + sideMenu:SideMenuView.class + fullscreen:false + isLeftFragment:NO + fragmentWith:ChatsListView.class]; + } + return compositeDescription; +} + +- (UICompositeViewDescription *)compositeViewDescription { + return self.class.compositeViewDescription; +} + +#pragma mark - ViewController Functions +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + _tableView.dataSource = self; + _tableView.delegate = self; + _isOneToOne = linphone_chat_room_get_capabilities(_room) & LinphoneChatRoomCapabilitiesOneToOne; + bctbx_list_t *participants = linphone_chat_room_get_participants(_room); + _devicesMenuEntries = [[NSMutableArray alloc] init]; + + if (_isOneToOne) { + LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL; + const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(_room); + [ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr]; + _devices = linphone_participant_get_devices(firstParticipant); + } else { + LinphoneParticipant *participant; + for (int i=0; inumberOfDevices + 1) * 56.0; + + } + return 56.0; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (_isOneToOne) { + UITableViewCell *cell = [[UITableViewCell alloc] init]; + LinphoneParticipantDevice *device = (LinphoneParticipantDevice *)bctbx_list_nth_data(_devices, (int)[indexPath row]); + cell.textLabel.text = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(linphone_participant_device_get_address(device))]; + cell.selectionStyle =UITableViewCellSelectionStyleNone; + + return cell; + } + + NSString *kCellId = NSStringFromClass(UIDevicesDetails.class); + UIDevicesDetails *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; + + if (cell == nil) { + cell = [[UIDevicesDetails alloc] initWithIdentifier:kCellId]; + } + DevicesMenuEntry *entry = [_devicesMenuEntries objectAtIndex:indexPath.row]; + + [ContactDisplay setDisplayNameLabel:cell.addressLabel forAddress:linphone_participant_get_address(entry->participant)]; + cell.devices = linphone_participant_get_devices(entry->participant); + UIImage *image = (entry->numberOfDevices != 0) ? [UIImage imageNamed:@"chevron_list_open"] : [UIImage imageNamed:@"chevron_list_close"]; + [cell.dropMenuButton setImage:image forState:UIControlStateNormal]; + + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if (!_isOneToOne) { + DevicesMenuEntry *entry = [_devicesMenuEntries objectAtIndex:indexPath.row]; + NSInteger num = (entry->numberOfDevices != 0) ? 0: bctbx_list_size(linphone_participant_get_devices(entry->participant)); + [_devicesMenuEntries replaceObjectAtIndex:indexPath.row withObject:[[DevicesMenuEntry alloc] initWithTitle:entry->participant number:num]]; + [_tableView reloadData]; + } +} + +@end diff --git a/Classes/DevicesListView.xib b/Classes/DevicesListView.xib new file mode 100644 index 000000000..7c5736d12 --- /dev/null +++ b/Classes/DevicesListView.xib @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Classes/LinphoneUI/UIDevicesDetails.h b/Classes/LinphoneUI/UIDevicesDetails.h new file mode 100644 index 000000000..a7e23fea9 --- /dev/null +++ b/Classes/LinphoneUI/UIDevicesDetails.h @@ -0,0 +1,18 @@ +// +// UIDevicesDetails.h +// linphone +// +// Created by Danmei Chen on 06/11/2018. +// + +#import + +@interface UIDevicesDetails : UITableViewCell + +@property (weak, nonatomic) IBOutlet UIButton *dropMenuButton; +@property (weak, nonatomic) IBOutlet UILabel *addressLabel; +@property (weak, nonatomic) IBOutlet UITableView *devicesTable; +@property bctbx_list_t *devices; + +- (id)initWithIdentifier:(NSString *)identifier; +@end diff --git a/Classes/LinphoneUI/UIDevicesDetails.m b/Classes/LinphoneUI/UIDevicesDetails.m new file mode 100644 index 000000000..5c4437e8c --- /dev/null +++ b/Classes/LinphoneUI/UIDevicesDetails.m @@ -0,0 +1,62 @@ +// +// UIDevicesDetails.m +// linphone +// +// Created by Danmei Chen on 06/11/2018. +// + +#import "UIDevicesDetails.h" + +@implementation UIDevicesDetails +#pragma mark - Lifecycle Functions +- (id)initWithIdentifier:(NSString *)identifier { + if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]) != nil) { + NSArray *arrayOfViews = + [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self.class) owner:self options:nil]; + + // resize cell to match .nib size. It is needed when resized the cell to + // correctly adapt its height too + UIView *sub = ((UIView *)[arrayOfViews objectAtIndex:0]); + [self setFrame:CGRectMake(0, 0, sub.frame.size.width, sub.frame.size.height)]; + [self addSubview:sub]; + _devicesTable.dataSource = self; + _devicesTable.delegate = self; + } + return self; +} + + +#pragma mark - TableView + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return bctbx_list_size(_devices); +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath { + return 56.0; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + + UITableViewCell *cell = [[UITableViewCell alloc] init]; + LinphoneParticipantDevice *device = (LinphoneParticipantDevice *)bctbx_list_nth_data(_devices, (int)[indexPath row]); + + cell.textLabel.text = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(linphone_participant_device_get_address(device))]; + + return cell; +} + +- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath + +{ + cell.backgroundColor = [UIColor colorWithRed:(245 / 255.0) green:(245 / 255.0) blue:(245 / 255.0) alpha:1.0]; + +} + + +@end diff --git a/Classes/LinphoneUI/UIDevicesDetails.xib b/Classes/LinphoneUI/UIDevicesDetails.xib new file mode 100644 index 000000000..78b336fb8 --- /dev/null +++ b/Classes/LinphoneUI/UIDevicesDetails.xib @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Resources/images/chevron_list_close.png b/Resources/images/chevron_list_close.png new file mode 100644 index 0000000000000000000000000000000000000000..a82d1d38b33b1ca6114cbd1db1a0647000c4b4b7 GIT binary patch literal 437 zcmV;m0ZRUfP)~yw(5!0YXVc zK~yNum65?qR8bU%zuz6E#Bpy?I|&JwVzi0jz5Ct_BC`l#pnp+C(So+5Q51bM ztAG{Y%FKFoU4K#ocn(D1F>nhELkP!BNuKB1&bdQi3HWVhMU3$)fSW=ggzwI|95@3W z0DEOwzHThqX-IwnekuXbZ1pV5)?2Ms1fBqQz#B8Wk#qn&1kO`Rel!|=YvwfPn9qRP z%$`b`n3(}B;HR1S7~^<0qj^Wo^L))Y_x?{afFF~|q+8eZ>EC$$>&^Xse>cAR>5>(2}<5DJm2d(k3=td(cC3P*LzI=s)9C@C^iO zX*{)TG<6VSg^F(n-$;6minfZFT4uW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