4.1 new liste devices view 2

This commit is contained in:
Danmei Chen 2018-11-07 17:41:32 +01:00
parent a8e393ba16
commit a388334f01
13 changed files with 164 additions and 34 deletions

View file

@ -69,7 +69,6 @@
@property (weak, nonatomic) IBOutlet UIButton *encryptedButton;
+ (void)markAsRead:(LinphoneChatRoom *)chatRoom;
+ (UIImage *)getSecurityImageForChatRoom:(LinphoneChatRoom *)chatRoom;
- (void)configureForRoom:(BOOL)editing;
- (IBAction)onBackClick:(id)event;

View file

@ -84,24 +84,6 @@ static UICompositeViewDescription *compositeDescription = nil;
[PhoneMainView.instance updateApplicationBadgeNumber];
}
+ (UIImage *)getSecurityImageForChatRoom:(LinphoneChatRoom *)chatRoom {
if (!chatRoom)
return nil;
LinphoneChatRoomSecurityLevel securityLevel = linphone_chat_room_get_security_level(chatRoom);
switch (securityLevel) {
case LinphoneChatRoomSecurityLevelUnsafe:
return [UIImage imageNamed:@"security_alert_indicator.png"];
case LinphoneChatRoomSecurityLevelEncrypted:
return [UIImage imageNamed:@"security_1_indicator.png.png"];
case LinphoneChatRoomSecurityLevelSafe:
return [UIImage imageNamed:@"security_2_indicator.png.png"];
default:
return nil;
}
}
#pragma mark - ViewController Functions
- (void)viewDidLoad {

View file

@ -8,6 +8,7 @@
#import "DevicesListView.h"
#import "PhoneMainView.h"
#import "UIDevicesDetails.h"
#import "UIDeviceCell.h"
@implementation DevicesMenuEntry
@ -50,7 +51,7 @@ static UICompositeViewDescription *compositeDescription = nil;
_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];
_devicesMenuEntries = [NSMutableArray array];
if (_isOneToOne) {
LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL;
@ -73,10 +74,6 @@ static UICompositeViewDescription *compositeDescription = nil;
[_tableView reloadData];
}
- (void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
#pragma mark - Action Functions
- (IBAction)onBackClick:(id)sender {
ChatConversationView *view = VIEW(ChatConversationView);
@ -107,10 +104,16 @@ static UICompositeViewDescription *compositeDescription = nil;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (_isOneToOne) {
UITableViewCell *cell = [[UITableViewCell alloc] init];
NSString *kCellId = NSStringFromClass(UIDeviceCell.class);
UIDeviceCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId];
if (cell == nil) {
cell = [[UIDeviceCell alloc] initWithIdentifier:kCellId];
}
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;
cell.device = device;
cell.isOneToOne = TRUE;
[cell update];
return cell;
}
@ -121,6 +124,7 @@ static UICompositeViewDescription *compositeDescription = nil;
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)];

View file

@ -82,7 +82,7 @@
[_avatarImage setImage:[UIImage imageNamed:@"chat_group_avatar.png"] bordered:NO withRoundedRadius:YES];
}
// TODO update security image when security level changed
[_securityImage setImage:[ChatConversationView getSecurityImageForChatRoom:chatRoom]];
[_securityImage setImage:[FastAddressBook imageForSecurityLevel:linphone_chat_room_get_security_level(chatRoom)]];
_chatLatestTimeLabel.text = [LinphoneUtils timeToString:linphone_chat_room_get_last_update_time(chatRoom) withFormat:LinphoneDateChatList];

View file

@ -0,0 +1,19 @@
//
// UIDeviceCell.h
// linphone
//
// Created by Danmei Chen on 07/11/2018.
//
#import <UIKit/UIKit.h>
@interface UIDeviceCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *deviceLabel;
@property (weak, nonatomic) IBOutlet UIImageView *securityImage;
@property LinphoneParticipantDevice *device;
@property BOOL isOneToOne;
- (id)initWithIdentifier:(NSString *)identifier;
- (void)update;
@end

View file

@ -0,0 +1,40 @@
//
// UIDeviceCell.m
// linphone
//
// Created by Danmei Chen on 07/11/2018.
//
#import "UIDeviceCell.h"
@implementation UIDeviceCell
#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];
}
return self;
}
- (void)update {
[_securityImage setImage:[FastAddressBook imageForSecurityLevel:linphone_participant_device_get_security_level(_device)]];
_deviceLabel.text = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(linphone_participant_device_get_address(_device))];
if (_isOneToOne) {
CGRect frame =_deviceLabel.frame;
frame.origin.x = 30;
_deviceLabel.frame = frame;
}
self.selectionStyle =UITableViewCellSelectionStyleNone;
}
@end

View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="UIDeviceCell">
<connections>
<outlet property="deviceLabel" destination="7tu-QT-9B2" id="HXh-Cw-5Lo"/>
<outlet property="securityImage" destination="W00-d7-5Mq" id="3DW-zg-aZT"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="Sro-AN-vkC">
<rect key="frame" x="0.0" y="0.0" width="375" height="56"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="color_F.png" translatesAutoresizingMaskIntoConstraints="NO" id="GKq-qB-nT7" userLabel="selectedButtonImage">
<rect key="frame" x="0.0" y="55" width="375" height="1"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" fixedFrame="YES" image="security_1_indicator.png" translatesAutoresizingMaskIntoConstraints="NO" id="W00-d7-5Mq" userLabel="securityImage">
<rect key="frame" x="336" y="17" width="18" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="2" contentMode="left" fixedFrame="YES" text="John Doe" lineBreakMode="tailTruncation" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7tu-QT-9B2" userLabel="deviceLabel">
<rect key="frame" x="69" y="16" width="220" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Contact name"/>
<fontDescription key="fontDescription" name=".SFNSDisplay" family=".SF NS Display" pointSize="21"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="Yad-Bp-jOq"/>
<point key="canvasLocation" x="250.40000000000001" y="215.8920539730135"/>
</view>
</objects>
<resources>
<image name="color_F.png" width="2" height="2"/>
<image name="security_1_indicator.png" width="27" height="32"/>
</resources>
</document>

View file

@ -11,6 +11,8 @@
@property (weak, nonatomic) IBOutlet UIButton *dropMenuButton;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
@property (weak, nonatomic) IBOutlet UIImageView *securityImage;
@property (weak, nonatomic) IBOutlet UITableView *devicesTable;
@property bctbx_list_t *devices;

View file

@ -6,6 +6,7 @@
//
#import "UIDevicesDetails.h"
#import "UIDeviceCell.h"
@implementation UIDevicesDetails
#pragma mark - Lifecycle Functions
@ -43,12 +44,18 @@
- (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))];
NSString *kCellId = NSStringFromClass(UIDeviceCell.class);
UIDeviceCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId];
if (cell == nil) {
cell = [[UIDeviceCell alloc] initWithIdentifier:kCellId];
}
LinphoneParticipantDevice *device = (LinphoneParticipantDevice *)bctbx_list_nth_data(_devices, (int)[indexPath row]);
cell.device = device;
cell.isOneToOne = FALSE;
[cell update];
return cell;
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
@ -58,5 +65,4 @@
}
@end

View file

@ -13,8 +13,10 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="UIDevicesDetails">
<connections>
<outlet property="addressLabel" destination="X0O-yd-2qT" id="QJ7-lu-E5n"/>
<outlet property="avatarImage" destination="gUM-dT-1wZ" id="WPF-6b-5Hv"/>
<outlet property="devicesTable" destination="Bhw-SW-cbz" id="Fc6-BV-RrV"/>
<outlet property="dropMenuButton" destination="fqu-53-vFp" id="qwN-sh-50p"/>
<outlet property="securityImage" destination="kEm-qC-OwR" id="SYs-Vr-JdZ"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>

View file

@ -44,6 +44,7 @@
+ (UIImage *)imageForContact:(Contact *)contact;
+ (UIImage *)imageForAddress:(const LinphoneAddress *)addr;
+ (UIImage *)imageForSecurityLevel:(LinphoneChatRoomSecurityLevel)level;
+ (BOOL)contactHasValidSipDomain:(Contact *)person;
+ (BOOL)isSipURIValid:(NSString*)addr;

View file

@ -48,6 +48,20 @@
return [FastAddressBook imageForContact:[FastAddressBook getContactWithAddress:addr]];
}
+ (UIImage *)imageForSecurityLevel:(LinphoneChatRoomSecurityLevel)level {
switch (level) {
case LinphoneChatRoomSecurityLevelUnsafe:
return [UIImage imageNamed:@"security_alert_indicator.png"];
case LinphoneChatRoomSecurityLevelEncrypted:
return [UIImage imageNamed:@"security_1_indicator.png.png"];
case LinphoneChatRoomSecurityLevelSafe:
return [UIImage imageNamed:@"security_2_indicator.png.png"];
default:
return nil;
}
}
+ (Contact *)getContact:(NSString *)address {
if (LinphoneManager.instance.fastAddressBook != nil) {
@synchronized(LinphoneManager.instance.fastAddressBook.addressBookMap) {

View file

@ -132,6 +132,8 @@
61AEBEC82191E48400F35E7F /* chevron_list_close@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 61AEBEC72191E48400F35E7F /* chevron_list_close@2x.png */; };
61AEBECA2191E49300F35E7F /* chevron_list_open.png in Resources */ = {isa = PBXBuildFile; fileRef = 61AEBEC92191E49200F35E7F /* chevron_list_open.png */; };
61AEBECC2191E4A300F35E7F /* chevron_list_open@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 61AEBECB2191E4A300F35E7F /* chevron_list_open@2x.png */; };
61CCC3DF21933B580060EDEA /* UIDeviceCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 61CCC3DE21933B580060EDEA /* UIDeviceCell.m */; };
61CCC3E121933B660060EDEA /* UIDeviceCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 61CCC3E021933B660060EDEA /* UIDeviceCell.xib */; };
61F1997520C6B1D5006B069A /* AVKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61F1996E20C6B1D5006B069A /* AVKit.framework */; };
630589E71B4E810900EFAE36 /* ChatTester.m in Sources */ = {isa = PBXBuildFile; fileRef = 630589DF1B4E810900EFAE36 /* ChatTester.m */; };
630589E81B4E810900EFAE36 /* ContactsTester.m in Sources */ = {isa = PBXBuildFile; fileRef = 630589E11B4E810900EFAE36 /* ContactsTester.m */; };
@ -1211,6 +1213,9 @@
61AEBEC72191E48400F35E7F /* chevron_list_close@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "chevron_list_close@2x.png"; sourceTree = "<group>"; };
61AEBEC92191E49200F35E7F /* chevron_list_open.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chevron_list_open.png; sourceTree = "<group>"; };
61AEBECB2191E4A300F35E7F /* chevron_list_open@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "chevron_list_open@2x.png"; sourceTree = "<group>"; };
61CCC3D721933B380060EDEA /* UIDeviceCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIDeviceCell.h; sourceTree = "<group>"; };
61CCC3DE21933B580060EDEA /* UIDeviceCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIDeviceCell.m; sourceTree = "<group>"; };
61CCC3E021933B660060EDEA /* UIDeviceCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = UIDeviceCell.xib; sourceTree = "<group>"; };
61F1996E20C6B1D5006B069A /* AVKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVKit.framework; path = System/Library/Frameworks/AVKit.framework; sourceTree = SDKROOT; };
630589DE1B4E810900EFAE36 /* ChatTester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatTester.h; sourceTree = "<group>"; };
630589DF1B4E810900EFAE36 /* ChatTester.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatTester.m; sourceTree = "<group>"; };
@ -2507,6 +2512,9 @@
639E9CAE1C0DB80300019A75 /* UIContactDetailsCell.xib */,
2248E90C12F7E4CF00220D9C /* UIDigitButton.h */,
2248E90D12F7E4CF00220D9C /* UIDigitButton.m */,
61CCC3D721933B380060EDEA /* UIDeviceCell.h */,
61CCC3DE21933B580060EDEA /* UIDeviceCell.m */,
61CCC3E021933B660060EDEA /* UIDeviceCell.xib */,
61AEBEC02191D7B400F35E7F /* UIDevicesDetails.h */,
61AEBEC12191D7C800F35E7F /* UIDevicesDetails.m */,
61AEBEC32191D7D900F35E7F /* UIDevicesDetails.xib */,
@ -3906,6 +3914,7 @@
633FEF0B1D3CD55A0014B822 /* options_transfer_call_default@2x.png in Resources */,
633FEDE81D3CD5590014B822 /* call_status_missed~ipad.png in Resources */,
63AADBFF1B6A0FF200AA16FD /* assistant_external_sip.rc in Resources */,
61CCC3E121933B660060EDEA /* UIDeviceCell.xib in Resources */,
633FEE9E1D3CD55A0014B822 /* numpad_0_over@2x.png in Resources */,
634610121B6140A500548952 /* CallOutgoingView.xib in Resources */,
8CE24F581F8268850077AC0A /* conference_delete@2x.png in Resources */,
@ -4666,6 +4675,7 @@
D3F7998115BD32370018C273 /* TPMultiLayoutViewController.m in Sources */,
D3807FBF15C28940005BE9BC /* DCRoundSwitch.m in Sources */,
D3807FC115C28940005BE9BC /* DCRoundSwitchKnobLayer.m in Sources */,
61CCC3DF21933B580060EDEA /* UIDeviceCell.m in Sources */,
6306440E1BECB08500134C72 /* FirstLoginView.m in Sources */,
D3807FC315C28940005BE9BC /* DCRoundSwitchOutlineLayer.m in Sources */,
CF7602E221086EB200749F76 /* RecordingsListTableView.m in Sources */,