forked from mirrors/linphone-iphone
add possibility to add participants + UI fixes
This commit is contained in:
parent
6880f77846
commit
ab6881ce2e
10 changed files with 87 additions and 39 deletions
|
|
@ -25,7 +25,6 @@
|
|||
_allContacts =
|
||||
[[NSDictionary alloc] initWithDictionary:LinphoneManager.instance.fastAddressBook.addressBookMap];
|
||||
if(_notFirstTime) {
|
||||
_notFirstTime = FALSE;
|
||||
for(NSString *addr in _contactsGroup) {
|
||||
[_collectionView registerClass:UIChatCreateCollectionViewCell.class forCellWithReuseIdentifier:addr];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,14 +73,6 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
_tableController.isForEditing = _isForEditing;
|
||||
}
|
||||
|
||||
#pragma mark - searchBar delegate
|
||||
|
||||
- (IBAction)onBackClick:(id)sender {
|
||||
[_tableController.contactsDict removeAllObjects];
|
||||
[_tableController.contactsGroup removeAllObjects];
|
||||
[PhoneMainView.instance popToView:ChatsListView.compositeViewDescription];
|
||||
}
|
||||
|
||||
#pragma mark - Chat room functions
|
||||
|
||||
void create_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) {
|
||||
|
|
@ -117,28 +109,27 @@ void create_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState
|
|||
|
||||
#pragma mark - Buttons signals
|
||||
|
||||
- (IBAction)onBackClick:(id)sender {
|
||||
[_tableController.contactsDict removeAllObjects];
|
||||
[_tableController.contactsGroup removeAllObjects];
|
||||
[PhoneMainView.instance popToView:ChatsListView.compositeViewDescription];
|
||||
}
|
||||
|
||||
- (IBAction)onNextClick:(id)sender {
|
||||
if (_tableController.contactsGroup.count == 1) {
|
||||
if (_tableController.contactsGroup.count == 1 && !_isForEditing) {
|
||||
[self createChatRoom];
|
||||
return;
|
||||
}
|
||||
ChatConversationInfoView *view = VIEW(ChatConversationInfoView);
|
||||
if (!_isForEditing)
|
||||
view.contacts = _tableController.contactsDict;
|
||||
else {
|
||||
for (NSString *uri in _tableController.contactsDict) {
|
||||
[view.contacts setObject:[_tableController.contactsDict objectForKey:uri] forKey:uri];
|
||||
}
|
||||
}
|
||||
|
||||
ChatConversationInfoView *view = VIEW(ChatConversationInfoView);
|
||||
view.contacts = _tableController.contactsDict;
|
||||
view.create = !_isForEditing;
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
}
|
||||
|
||||
- (void)dismissKeyboards {
|
||||
if ([self.tableController.searchBar isFirstResponder]) {
|
||||
if ([self.tableController.searchBar isFirstResponder])
|
||||
[self.tableController.searchBar resignFirstResponder];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Contacts filter
|
||||
|
|
@ -192,7 +183,9 @@ typedef enum { ContactsAll, ContactsLinphone, ContactsMAX } ContactsCategory;
|
|||
UIChatCreateCollectionViewCell *cell = (UIChatCreateCollectionViewCell *)[_collectionView dequeueReusableCellWithReuseIdentifier:uri forIndexPath:indexPath];
|
||||
cell.controller = self;
|
||||
cell.uri = uri;
|
||||
cell = [cell initWithName:_tableController.contactsDict[uri]];
|
||||
LinphoneAddress *addr = linphone_address_new(uri.UTF8String);
|
||||
cell = [cell initWithName:[FastAddressBook displayNameForAddress:addr]];
|
||||
linphone_address_unref(addr);
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
@property(nonatomic, strong) NSMutableDictionary *contacts;
|
||||
@property(nonatomic, strong) NSMutableArray *admins;
|
||||
@property(nonatomic) BOOL create;
|
||||
@property(nonatomic) BOOL imAdmin;
|
||||
@property(nonatomic) NSString *oldSubject;
|
||||
@property(nonatomic, strong) NSMutableDictionary *oldContacts;
|
||||
@property(nonatomic, strong) NSMutableArray *oldAdmins;
|
||||
|
|
@ -23,6 +24,7 @@
|
|||
@property (weak, nonatomic) IBOutlet UIIconButton *nextButton;
|
||||
@property (weak, nonatomic) IBOutlet UIIconButton *backButton;
|
||||
@property (weak, nonatomic) IBOutlet UIRoundBorderedButton *quitButton;
|
||||
@property (weak, nonatomic) IBOutlet UIIconButton *addButton;
|
||||
@property (weak, nonatomic) IBOutlet UITextField *nameLabel;
|
||||
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,9 +58,31 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
if (_room)
|
||||
_nameLabel.text = linphone_chat_room_get_subject(_room)
|
||||
? [NSString stringWithUTF8String:linphone_chat_room_get_subject(_room)]
|
||||
: @"";
|
||||
_nextButton.enabled = _nameLabel.text.length > 0 && _contacts.count > 0;
|
||||
LinphoneParticipant *me = _room ? linphone_chat_room_get_me(_room) : NULL;
|
||||
_imAdmin = me ? linphone_participant_is_admin(me) : false;
|
||||
_quitButton.hidden = _create || (me == NULL);
|
||||
_nameLabel.enabled = _create || _imAdmin;
|
||||
_addButton.hidden = !_create && !_imAdmin;
|
||||
_nextButton.hidden = !_create && !_imAdmin;
|
||||
|
||||
CGFloat height = _quitButton.hidden
|
||||
? self.view.frame.size.height - _tableView.frame.origin.y
|
||||
: _quitButton.frame.origin.y - _tableView.frame.origin.y - 10;
|
||||
|
||||
[_tableView setFrame:CGRectMake(
|
||||
_tableView.frame.origin.x,
|
||||
_tableView.frame.origin.y,
|
||||
_tableView.frame.size.width,
|
||||
height
|
||||
)];
|
||||
|
||||
[_tableView reloadData];
|
||||
_quitButton.hidden = _create;
|
||||
}
|
||||
|
||||
#pragma mark - next functions
|
||||
|
|
@ -95,13 +117,27 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
if (![_oldSubject isEqualToString:_nameLabel.text])
|
||||
linphone_chat_room_set_subject(_room, _nameLabel.text.UTF8String);
|
||||
|
||||
// Add participants if necessary
|
||||
for (NSString *uri in _contacts.allKeys) {
|
||||
if ([_oldContacts objectForKey:uri])
|
||||
continue;
|
||||
|
||||
LinphoneAddress *addr = linphone_address_new(uri.UTF8String);
|
||||
linphone_chat_room_add_participant(_room, addr);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
|
||||
// Remove participants if necessary
|
||||
for (NSString *uri in _oldContacts.allKeys) {
|
||||
if ([_contacts objectForKey:uri])
|
||||
continue;
|
||||
|
||||
LinphoneAddress *addr = linphone_address_new(uri.UTF8String);
|
||||
linphone_chat_room_remove_participant(_room, linphone_chat_room_find_participant(_room, addr));
|
||||
LinphoneParticipant *participant = linphone_chat_room_find_participant(_room, addr);
|
||||
if (!participant)
|
||||
continue;
|
||||
|
||||
linphone_chat_room_remove_participant(_room, participant);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
|
||||
|
|
@ -111,7 +147,11 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
continue;
|
||||
|
||||
LinphoneAddress *addr = linphone_address_new(admin.UTF8String);
|
||||
linphone_chat_room_set_participant_admin_status(_room, linphone_chat_room_find_participant(_room, linphone_address_new(admin.UTF8String)), true);
|
||||
LinphoneParticipant *participant = linphone_chat_room_find_participant(_room, addr);
|
||||
if (!participant)
|
||||
continue;
|
||||
|
||||
linphone_chat_room_set_participant_admin_status(_room, participant, true);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +161,11 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
continue;
|
||||
|
||||
LinphoneAddress *addr = linphone_address_new(admin.UTF8String);
|
||||
linphone_chat_room_set_participant_admin_status(_room, linphone_chat_room_find_participant(_room, linphone_address_new(admin.UTF8String)), false);
|
||||
LinphoneParticipant *participant = linphone_chat_room_find_participant(_room, addr);
|
||||
if (!participant)
|
||||
continue;
|
||||
|
||||
linphone_chat_room_set_participant_admin_status(_room, participant, false);
|
||||
linphone_address_unref(addr);
|
||||
}
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
|
|
@ -161,8 +205,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
ChatConversationCreateView *view = VIEW(ChatConversationCreateView);
|
||||
view.tableController.notFirstTime = TRUE;
|
||||
view.isForEditing = !_create;
|
||||
[view.tableController.contactsDict removeAllObjects];
|
||||
[view.tableController.contactsGroup removeAllObjects];
|
||||
view.tableController.contactsDict = _contacts;
|
||||
view.tableController.contactsGroup = [[_contacts allKeys] mutableCopy];
|
||||
[PhoneMainView.instance popToView:view.compositeViewDescription];
|
||||
}
|
||||
|
||||
|
|
@ -190,8 +234,12 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
cell.adminLabel.enabled = FALSE;
|
||||
cell.adminImage.image = [UIImage imageNamed:@"check_unselected.png"];
|
||||
}
|
||||
cell.adminButton.hidden = _create;
|
||||
cell.adminButton.hidden = _create; // (linphone_chat_room_find_participant(_room, addr) == NULL) ?
|
||||
linphone_address_unref(addr);
|
||||
|
||||
cell.adminButton.hidden = !_imAdmin;
|
||||
cell.removeButton.hidden = !_create && !_imAdmin;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13174"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ChatConversationInfoView">
|
||||
<connections>
|
||||
<outlet property="addButton" destination="XSI-9T-NtW" id="BlB-bn-XWt"/>
|
||||
<outlet property="backButton" destination="HVD-Ql-SJG" id="iHL-Rf-gT2"/>
|
||||
<outlet property="nameLabel" destination="69I-Un-ASz" id="qmU-o2-TmF"/>
|
||||
<outlet property="nextButton" destination="0v1-qv-lPd" id="nPu-w2-iy3"/>
|
||||
<outlet property="quitButton" destination="Hnm-7C-dBQ" id="Kp1-Aw-FQq"/>
|
||||
<outlet property="tableView" destination="pMq-Gv-0uu" id="ELS-RQ-olX"/>
|
||||
<outlet property="view" destination="zgv-a8-72k" id="Gbu-s2-SgQ"/>
|
||||
<outlet property="view" destination="zgv-a8-72k" id="1Cq-i3-h2W"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
|
|
|
|||
|
|
@ -140,7 +140,9 @@ static void chatTable_free_chatrooms(void *data) {
|
|||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:idx inSection:0];
|
||||
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
|
||||
} else if (![self selectFirstRow]) {
|
||||
[PhoneMainView.instance changeCurrentView:ChatConversationCreateView.compositeViewDescription];
|
||||
ChatConversationCreateView *view = VIEW(ChatConversationCreateView);
|
||||
view.tableController.notFirstTime = FALSE;
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
- (IBAction)onAddClick:(id)event {
|
||||
ChatConversationCreateView *view = VIEW(ChatConversationCreateView);
|
||||
view.isForEditing = false;
|
||||
view.tableController.notFirstTime = FALSE;
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
@interface UIChatConversationInfoTableViewCell : UITableViewCell <UIGestureRecognizerDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIIconButton *removeButton;
|
||||
@property (weak, nonatomic) IBOutlet UIView *adminButton;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *adminLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *adminImage;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13174"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
@ -15,11 +15,11 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="John Doe" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rrT-f7-NQO" userLabel="displayNameLabel">
|
||||
<rect key="frame" x="46" y="11" width="184" height="20"/>
|
||||
<rect key="frame" x="46" y="10" width="184" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</imageView>
|
||||
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PbQ-SL-kUk">
|
||||
<rect key="frame" x="213" y="2" width="98" height="39"/>
|
||||
<rect key="frame" x="213" y="1" width="98" height="39"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" fixedFrame="YES" image="check_selected.png" translatesAutoresizingMaskIntoConstraints="NO" id="FOh-C4-1Is" userLabel="adminImage">
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
</accessibility>
|
||||
</view>
|
||||
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JPd-hQ-On6" userLabel="deleteButton" customClass="UIIconButton">
|
||||
<rect key="frame" x="335" y="0.0" width="40" height="44"/>
|
||||
<rect key="frame" x="335" y="0.0" width="40" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES"/>
|
||||
<accessibility key="accessibilityConfiguration" label="Back"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
|
|
@ -75,6 +75,7 @@
|
|||
<outlet property="adminImage" destination="FOh-C4-1Is" id="g51-C3-Ua8"/>
|
||||
<outlet property="adminLabel" destination="DYS-vK-7Ol" id="OCp-Sw-hSc"/>
|
||||
<outlet property="nameLabel" destination="rrT-f7-NQO" id="iwZ-ou-jVQ"/>
|
||||
<outlet property="removeButton" destination="JPd-hQ-On6" id="Kfw-by-wbR"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="61.5" y="52"/>
|
||||
</tableViewCell>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 64802f026b3e2dfb2942db2e530f0e77e1d9dbb6
|
||||
Subproject commit 5c857c2db1d466824f7d1357fdf3177691703fdd
|
||||
Loading…
Add table
Reference in a new issue