new ChatConversationCreateView : filter data with capabilities

This commit is contained in:
Danmei Chen 2019-01-03 10:40:19 +01:00
parent 186da72c04
commit 3d07968904
5 changed files with 49 additions and 22 deletions

View file

@ -125,12 +125,12 @@
<rect key="frame" x="56" y="24" width="36" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="security_toogle_background_green.png" translatesAutoresizingMaskIntoConstraints="NO" id="jIQ-qM-GVG" userLabel="chiffreImage">
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="security_toogle_background_grey.png" translatesAutoresizingMaskIntoConstraints="NO" id="jIQ-qM-GVG" userLabel="chiffreImage">
<rect key="frame" x="0.0" y="0.0" width="36" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uUN-bl-g4c" userLabel="chiffreButton">
<rect key="frame" x="20" y="2" width="14" height="14"/>
<rect key="frame" x="0.0" y="2" width="14" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" image="security_toogle_button.png"/>
<connections>
@ -237,7 +237,7 @@
<image name="contacts_sip_selected.png" width="39" height="39"/>
<image name="next_default.png" width="24" height="22"/>
<image name="next_disabled.png" width="24" height="22"/>
<image name="security_toogle_background_green.png" width="52" height="27"/>
<image name="security_toogle_background_grey.png" width="52" height="27"/>
<image name="security_toogle_button.png" width="21" height="21"/>
<image name="security_toogle_icon_green.png" width="21" height="24"/>
<image name="security_toogle_icon_grey.png" width="21" height="24"/>

View file

@ -94,7 +94,15 @@
char *uri = linphone_address_as_string_uri_only(addr);
NSString *address = [NSString stringWithUTF8String:uri];
ms_free(uri);
ms_free(uri);
Contact *contact = [LinphoneManager.instance.fastAddressBook.addressBookMap objectForKey:address];
const LinphonePresenceModel *model = contact.friend ? linphone_friend_get_presence_model(contact.friend) : NULL;
if (_isGroupChat && !(model && linphone_presence_model_has_capability(model, LinphoneFriendCapabilityGroupChat))) {
results = results->next;
continue;
}
[_addresses addObject:address];
[_phoneOrAddr addObject:phoneNumber ? [NSString stringWithUTF8String:phoneNumber] : address];
@ -127,13 +135,16 @@
NSString *key = [_addresses objectAtIndex:indexPath.row];
NSString *phoneOrAddr = [_phoneOrAddr objectAtIndex:indexPath.row];
Contact *contact = [LinphoneManager.instance.fastAddressBook.addressBookMap objectForKey:key];
const LinphonePresenceModel *model = contact.friend ? linphone_friend_get_presence_model(contact.friend) : NULL;
Boolean linphoneContact = [FastAddressBook contactHasValidSipDomain:contact]
|| (contact.friend && linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(contact.friend)) == LinphonePresenceBasicStatusOpen);
|| (model && linphone_presence_model_get_basic_status(model) == LinphonePresenceBasicStatusOpen);
LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:key];
if (!addr)
return cell;
cell.linphoneImage.hidden = !linphoneContact;
cell.securityImage.hidden = !(model && linphone_presence_model_has_capability(model, LinphoneFriendCapabilityLimeX3dh));
cell.userInteractionEnabled = cell.greyView.hidden = _isEncrypted ? !cell.securityImage.hidden : TRUE;
cell.displayNameLabel.text = [FastAddressBook displayNameForAddress:addr];
cell.addressLabel.text = linphoneContact ? [NSString stringWithUTF8String:linphone_address_as_string(addr)] : phoneOrAddr;
cell.selectedImage.hidden = ![_contactsGroup containsObject:cell.addressLabel.text];
@ -143,13 +154,13 @@
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIChatCreateCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (!cell.userInteractionEnabled)
return;
if (!linphone_proxy_config_get_conference_factory_uri(linphone_core_get_default_proxy_config(LC)) || !_isGroupChat) {
// Create directly a basic chat room if there's no factory uri
bctbx_list_t *addresses = NULL;
LinphoneAddress *addr = linphone_address_new(cell.addressLabel.text.UTF8String);
addresses = bctbx_list_append(addresses, addr);
[PhoneMainView.instance createChatRoomWithSubject:NULL addresses:addresses andWaitView:NULL isEncrypted:_isEncrypted];
[PhoneMainView.instance getOrCreateOneToOneChatRoom:addr waitView:_waitView isEncrypted:_isEncrypted];
linphone_address_unref(addr);
return;
}

View file

@ -49,8 +49,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[_collectionView setCollectionViewLayout:layout];
_tableController.collectionView = _collectionView;
_tableController.controllerNextButton = _nextButton;
_isForEditing = FALSE;
_isEncrypted = TRUE;
_isForEditing = FALSE;
}
- (void)viewWillAppear:(BOOL)animated {
@ -67,6 +66,14 @@ static UICompositeViewDescription *compositeDescription = nil;
frame.origin.x = self.view.frame.size.width * 0.192;
}
_chiffreOptionView.frame = frame;
_isEncrypted = FALSE;
CGRect buttonFrame = _chiffreButton.frame;
_tableController.isEncrypted = _isEncrypted;
// no encrypted by default
buttonFrame.origin.x = 2;
[_chiffreImage setImage:[UIImage imageNamed:@"security_toogle_background_grey.png"]];
_chiffreButton.frame = buttonFrame;
_waitView.hidden = YES;
_backButton.hidden = IPAD;
@ -127,7 +134,6 @@ static UICompositeViewDescription *compositeDescription = nil;
CGRect frame = _chiffreButton.frame;
_isEncrypted = !_isEncrypted;
_tableController.isEncrypted = _isEncrypted;
// TODO show encrypted contacts
if (_isEncrypted) {
// encrypted
frame.origin.x = 20;
@ -138,6 +144,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[_chiffreImage setImage:[UIImage imageNamed:@"security_toogle_background_grey.png"]];
}
_chiffreButton.frame = frame;
[_tableController.tableView reloadData];
}
- (void)dismissKeyboards {

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -14,51 +14,58 @@
<outlet property="addressLabel" destination="Bjy-H9-VyJ" id="YFi-IY-Omd"/>
<outlet property="avatarImage" destination="ktO-jm-Ra6" id="IFH-3K-TdW"/>
<outlet property="displayNameLabel" destination="Hrt-Iz-T2j" id="0tY-FY-dFe"/>
<outlet property="greyView" destination="THU-mJ-O0r" id="2Gs-TQ-tNh"/>
<outlet property="linphoneImage" destination="vhd-fK-M2m" id="hO8-lY-0Hh"/>
<outlet property="securityImage" destination="ioo-eB-vvQ" id="WXu-ej-Nfi"/>
<outlet property="selectedImage" destination="qMd-eD-DOW" id="m79-nU-deW"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" misplaced="YES" id="WTc-GF-a0y">
<view contentMode="scaleToFill" id="WTc-GF-a0y">
<rect key="frame" x="0.0" y="0.0" width="375" height="60"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="john.doe@linphone.org" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Bjy-H9-VyJ" userLabel="addressLabel">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="john.doe@linphone.org" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Bjy-H9-VyJ" userLabel="addressLabel">
<rect key="frame" x="65" y="30" width="238" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.98766469955444336" green="0.27512490749359131" blue="0.029739789664745331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="John Doe" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Hrt-Iz-T2j" userLabel="displayNameLabel">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="John Doe" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Hrt-Iz-T2j" userLabel="displayNameLabel">
<rect key="frame" x="65" y="6" width="238" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" image="check_selected.png" id="qMd-eD-DOW" userLabel="selectedImage">
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="check_selected.png" id="qMd-eD-DOW" userLabel="selectedImage">
<rect key="frame" x="347" y="21" width="21" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" image="linphone_user.png" id="vhd-fK-M2m" userLabel="linphoneImage">
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="linphone_user.png" id="vhd-fK-M2m" userLabel="linphoneImage">
<rect key="frame" x="314" y="21" width="21" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Linphone"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" misplaced="YES" image="avatar.png" id="ktO-jm-Ra6" userLabel="avatarImage" customClass="UIRoundedImageView">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" image="avatar.png" id="ktO-jm-Ra6" userLabel="avatarImage" customClass="UIRoundedImageView">
<rect key="frame" x="10" y="10" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" misplaced="YES" image="security_toogle_icon_green.png" id="ioo-eB-vvQ" userLabel="securityImage">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" image="security_toogle_icon_green.png" id="ioo-eB-vvQ" userLabel="securityImage">
<rect key="frame" x="40" y="11" width="18" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<view hidden="YES" contentMode="scaleToFill" id="THU-mJ-O0r" userLabel="greyView">
<rect key="frame" x="0.0" y="0.0" width="375" height="60"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.7032625440140845" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="556.5" y="214"/>
<point key="canvasLocation" x="890.39999999999998" y="192.50374812593705"/>
</view>
</objects>
<resources>

View file

@ -14,6 +14,8 @@
@property (weak, nonatomic) IBOutlet UIImageView *selectedImage;
@property (weak, nonatomic) IBOutlet UIImageView *linphoneImage;
@property (weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage;
@property (weak, nonatomic) IBOutlet UIImageView *securityImage;
@property (weak, nonatomic) IBOutlet UIView *greyView;
- (id)initWithIdentifier:(NSString *)identifier;