contact rework

This commit is contained in:
Gautier Pelloux-Prayer 2015-07-23 16:51:04 +02:00
parent a06c78e8f5
commit 96a0c6cf80
13 changed files with 421 additions and 353 deletions

View file

@ -14,8 +14,7 @@
<outlet property="composeLabel" destination="fpY-Fv-ht2" id="4L6-ik-ZAe"/>
<outlet property="editButton" destination="10" id="35"/>
<outlet property="headerView" destination="39" id="45"/>
<outlet property="messageBackgroundImage" destination="66" id="90"/>
<outlet property="messageField" destination="63" id="64"/>
<outlet property="messageField" destination="CPp-ts-xy0" id="wPX-Uo-vZQ"/>
<outlet property="messageView" destination="14" id="89"/>
<outlet property="pictureButton" destination="73" id="84"/>
<outlet property="sendButton" destination="15" id="27"/>
@ -28,6 +27,43 @@
<rect key="frame" x="0.0" y="0.0" width="360" height="537"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" id="7" userLabel="toolsView">
<rect key="frame" x="0.0" y="0.0" width="360" height="40"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" id="9" userLabel="backButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="0.0" width="72" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="deviceRGB"/>
<accessibility key="accessibilityConfiguration" label="Back"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="back.png" backgroundImage="color_F.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted" backgroundImage="color_E.png"/>
<connections>
<action selector="onBackClick:" destination="-1" eventType="touchUpInside" id="12"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" id="10" userLabel="editButton" customClass="UIToggleButton">
<rect key="frame" x="288" y="0.0" width="72" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.35686274509999999" green="0.39607843139999999" blue="0.43529411759999997" alpha="1" colorSpace="deviceRGB"/>
<accessibility key="accessibilityConfiguration" label="Edit"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="edit_list.png" backgroundImage="color_F.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted" backgroundImage="color_E.png"/>
<connections>
<action selector="onEditClick:" destination="-1" eventType="touchUpInside" id="13"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.76862745099999996" green="0.76862745099999996" blue="0.76862745099999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
<view contentMode="scaleToFill" id="49" userLabel="chatView">
<rect key="frame" x="0.0" y="44" width="360" height="493"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
@ -36,11 +72,7 @@
<rect key="frame" x="0.0" y="0.0" width="360" height="80"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="avatar_shadow_small.png" id="42" userLabel="avatarShadowBackground">
<rect key="frame" x="-13" y="-5" width="131" height="107"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="avatar_unknown_small.png" id="41" userLabel="avatarImage">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" image="avatar.png" id="41" userLabel="avatarImage" customClass="UIRoundedImageView">
<rect key="frame" x="20" y="6" width="65" height="65"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Contact avatar">
@ -49,7 +81,7 @@
</accessibility>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Contact1" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="40" userLabel="addressLabel">
<rect key="frame" x="101" y="37" width="239" height="43"/>
<rect key="frame" x="93" y="17" width="174" height="43"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Contact name">
<accessibilityTraits key="traits" none="YES"/>
@ -58,11 +90,18 @@
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Wzg-i0-spp" userLabel="callButton" customClass="UIIconButton">
<rect key="frame" x="287" y="6" width="65" height="65"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" image="start_call_body_default.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="8" userLabel="tableView">
<rect key="frame" x="0.0" y="80" width="360" height="334"/>
<rect key="frame" x="0.0" y="80" width="360" height="319"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
@ -72,7 +111,7 @@
</connections>
</tableView>
<view contentMode="scaleToFill" id="fx4-ao-53M" userLabel="composeIndicatorView">
<rect key="frame" x="0.0" y="414" width="360" height="22"/>
<rect key="frame" x="0.0" y="407" width="360" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="%@ is composing..." lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="fpY-Fv-ht2" userLabel="composeLabel">
@ -86,115 +125,50 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" id="14" userLabel="messageView">
<rect key="frame" x="0.0" y="436" width="360" height="57"/>
<rect key="frame" x="0.0" y="430" width="360" height="63"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" id="66" userLabel="messageBackgroundImage">
<rect key="frame" x="0.0" y="0.0" width="360" height="57"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" adjustsImageWhenDisabled="NO" lineBreakMode="middleTruncation" id="15" userLabel="sendButton">
<rect key="frame" x="302" y="0.0" width="58" height="57"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Send"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="titleEdgeInsets" minX="0.0" minY="30" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Send" backgroundImage="chat_send_default.png">
<color key="titleColor" red="0.35686275360000003" green="0.3960784376" blue="0.43529412150000002" alpha="1" colorSpace="deviceRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="disabled" backgroundImage="chat_send_disabled.png">
<color key="titleColor" red="0.80784313730000001" green="0.81568627449999997" blue="0.82352941180000006" alpha="1" colorSpace="deviceRGB"/>
</state>
<state key="highlighted" backgroundImage="chat_send_over.png">
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="deviceRGB"/>
</state>
<connections>
<action selector="onSendClick:" destination="-1" eventType="touchUpInside" id="25"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" adjustsImageWhenDisabled="NO" lineBreakMode="middleTruncation" id="73" userLabel="pictureButton">
<rect key="frame" x="0.0" y="0.0" width="35" height="57"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="73" userLabel="pictureButton">
<rect key="frame" x="0.0" y="0.0" width="72" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Send picture"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" backgroundImage="chat_photo_default.png">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<state key="normal" image="chat_photo.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="disabled" backgroundImage="chat_photo_disabled.png"/>
<state key="highlighted" backgroundImage="chat_photo_over.png">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onPictureClick:" destination="-1" eventType="touchUpInside" id="87"/>
</connections>
</button>
<view contentMode="scaleToFill" id="63" userLabel="messageField" customClass="HPGrowingTextView">
<rect key="frame" x="39" y="12" width="258" height="33"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<accessibility key="accessibilityConfiguration" label="Message field">
<bool key="isElement" value="YES"/>
</accessibility>
</view>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="CPp-ts-xy0" userLabel="messageField">
<rect key="frame" x="80" y="12" width="200" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<accessibility key="accessibilityConfiguration" hint="" label=""/>
<fontDescription key="fontDescription" type="system" pointSize="26"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences" autocorrectionType="yes" spellCheckingType="yes" keyboardAppearance="alert" returnKeyType="send"/>
<dataDetectorType key="dataDetectorTypes" phoneNumber="YES" link="YES" address="YES"/>
<connections>
<outlet property="delegate" destination="-1" id="RVG-F4-M9q"/>
</connections>
</textView>
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="15" userLabel="sendButton">
<rect key="frame" x="288" y="0.0" width="72" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Send"/>
<inset key="titleEdgeInsets" minX="0.0" minY="30" maxX="0.0" maxY="0.0"/>
<state key="normal" image="chat_send.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onSendClick:" destination="-1" eventType="touchUpInside" id="25"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" id="7" userLabel="toolsView">
<rect key="frame" x="0.0" y="0.0" width="360" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="toolsbar_background.png" id="47" userLabel="background">
<rect key="frame" x="0.0" y="0.0" width="360" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" id="9" userLabel="backButton">
<rect key="frame" x="0.0" y="0.0" width="160" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="deviceRGB"/>
<accessibility key="accessibilityConfiguration" label="Back"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Back" backgroundImage="chat_back_default.png">
<color key="titleColor" red="0.35686274509999999" green="0.39607843139999999" blue="0.43529411759999997" alpha="1" colorSpace="deviceRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted" backgroundImage="chat_back_over.png">
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="deviceRGB"/>
</state>
<connections>
<action selector="onBackClick:" destination="-1" eventType="touchUpInside" id="12"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" id="10" userLabel="editButton" customClass="UIToggleButton">
<rect key="frame" x="200" y="0.0" width="160" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.35686274509999999" green="0.39607843139999999" blue="0.43529411759999997" alpha="1" colorSpace="deviceRGB"/>
<accessibility key="accessibilityConfiguration" label="Edit"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Edit" backgroundImage="chat_edit_default.png">
<color key="titleColor" red="0.35686274509999999" green="0.39607843139999999" blue="0.43529411759999997" alpha="1" colorSpace="deviceRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" title="Ok" backgroundImage="chat_ok_default.png">
<color key="titleColor" red="0.35686274509999999" green="0.39607843139999999" blue="0.43529411759999997" alpha="1" colorSpace="deviceRGB"/>
</state>
<state key="highlighted" backgroundImage="chat_edit_over.png">
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="deviceRGB"/>
</state>
<connections>
<action selector="onEditClick:" destination="-1" eventType="touchUpInside" id="13"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
@ -207,23 +181,18 @@
<connections>
<outlet property="view" destination="8" id="33"/>
</connections>
<point key="canvasLocation" x="758" y="347"/>
</tableViewController>
</objects>
<resources>
<image name="avatar_shadow_small.png" width="262" height="214"/>
<image name="avatar_unknown_small.png" width="131" height="131"/>
<image name="chat_back_default.png" width="320" height="88"/>
<image name="chat_back_over.png" width="320" height="88"/>
<image name="chat_edit_default.png" width="320" height="88"/>
<image name="chat_edit_over.png" width="320" height="88"/>
<image name="chat_ok_default.png" width="320" height="88"/>
<image name="chat_photo_default.png" width="71" height="115"/>
<image name="chat_photo_disabled.png" width="71" height="115"/>
<image name="chat_photo_over.png" width="71" height="115"/>
<image name="chat_send_default.png" width="117" height="115"/>
<image name="chat_send_disabled.png" width="117" height="115"/>
<image name="chat_send_over.png" width="117" height="115"/>
<image name="toolsbar_background.png" width="5" height="88"/>
<image name="avatar.png" width="751" height="751"/>
<image name="back.png" width="71" height="64"/>
<image name="chat_photo.png" width="72" height="56"/>
<image name="chat_send.png" width="71" height="71"/>
<image name="color_E.png" width="1" height="1"/>
<image name="color_F.png" width="1" height="1"/>
<image name="edit_list.png" width="88" height="85"/>
<image name="start_call_body_default.png" width="151" height="151"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>

View file

@ -22,30 +22,28 @@
#import "UIToggleButton.h"
#import "UICompositeViewController.h"
#import "ChatRoomTableViewController.h"
#import "HPGrowingTextView.h"
#import "ImagePickerViewController.h"
#import "OrderedDictionary.h"
#include "linphone/linphonecore.h"
@interface ChatRoomViewController : UIViewController<HPGrowingTextViewDelegate, UICompositeViewDelegate, ImagePickerDelegate, ChatRoomDelegate> {
LinphoneChatRoom *chatRoom;
OrderedDictionary *imageQualities;
BOOL scrollOnGrowingEnabled;
BOOL composingVisible;
@interface ChatRoomViewController
: UIViewController <UITextViewDelegate, UICompositeViewDelegate, ImagePickerDelegate, ChatRoomDelegate> {
LinphoneChatRoom *chatRoom;
OrderedDictionary *imageQualities;
BOOL scrollOnGrowingEnabled;
BOOL composingVisible;
}
@property (nonatomic, strong) IBOutlet ChatRoomTableViewController* tableController;
@property (nonatomic, strong) IBOutlet UIToggleButton *editButton;
@property (nonatomic, strong) IBOutlet HPGrowingTextView* messageField;
@property(weak, nonatomic) IBOutlet UITextView *messageField;
@property (nonatomic, strong) IBOutlet UIButton* sendButton;
@property (nonatomic, strong) IBOutlet UILabel *addressLabel;
@property (nonatomic, strong) IBOutlet UIImageView *avatarImage;
@property (nonatomic, strong) IBOutlet UIView *headerView;
@property (nonatomic, strong) IBOutlet UIView *chatView;
@property (nonatomic, strong) IBOutlet UIView *messageView;
@property (nonatomic, strong) IBOutlet UIImageView *messageBackgroundImage;
@property (nonatomic, strong) IBOutlet UIImageView *transferBackgroundImage;
@property (nonatomic, strong) IBOutlet UITapGestureRecognizer *listTapGestureRecognizer;
@property (nonatomic, strong) IBOutlet UISwipeGestureRecognizer *listSwipeGestureRecognizer;
@property (strong, nonatomic) IBOutlet UILabel *composeLabel;

View file

@ -30,9 +30,9 @@
@implementation ChatRoomViewController
@synthesize messageField;
@synthesize tableController;
@synthesize sendButton;
@synthesize messageField;
@synthesize editButton;
@synthesize addressLabel;
@synthesize composeLabel;
@ -41,8 +41,6 @@
@synthesize headerView;
@synthesize chatView;
@synthesize messageView;
@synthesize messageBackgroundImage;
@synthesize transferBackgroundImage;
@synthesize listTapGestureRecognizer;
@synthesize listSwipeGestureRecognizer;
@synthesize pictureButton;
@ -94,21 +92,6 @@ static UICompositeViewDescription *compositeDescription = nil;
[super viewDidLoad];
[tableController setChatRoomDelegate:self];
// Set selected+over background: IB lack !
[editButton setBackgroundImage:[UIImage imageNamed:@"chat_ok_over.png"]
forState:(UIControlStateHighlighted | UIControlStateSelected)];
[LinphoneUtils buttonFixStates:editButton];
messageField.minNumberOfLines = 1;
messageField.maxNumberOfLines = ([LinphoneManager runningOnIpad]) ? 10 : 3;
messageField.delegate = self;
messageField.font = [UIFont systemFontOfSize:18.0f];
messageField.contentInset = UIEdgeInsetsMake(0, -5, -2, -5);
messageField.internalTextView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, 10);
messageField.backgroundColor = [UIColor clearColor];
[sendButton setEnabled:FALSE];
[tableController.tableView addGestureRecognizer:listTapGestureRecognizer];
[listTapGestureRecognizer setEnabled:FALSE];
@ -152,9 +135,6 @@ static UICompositeViewDescription *compositeDescription = nil;
[editButton setOff];
[[tableController tableView] reloadData];
[messageBackgroundImage setImage:[TUNinePatchCache imageOfSize:[messageBackgroundImage bounds].size
forNinePatchNamed:@"chat_message_background"]];
BOOL fileSharingEnabled =
[[LinphoneManager instance] lpConfigStringForKey:@"sharing_server_preference"] != NULL &&
[[[LinphoneManager instance] lpConfigStringForKey:@"sharing_server_preference"] length] > 0;
@ -173,8 +153,6 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[messageBackgroundImage setImage:[TUNinePatchCache imageOfSize:[messageBackgroundImage bounds].size
forNinePatchNamed:@"chat_message_background"]];
[tableController scrollToBottom:true];
}
@ -411,7 +389,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
#pragma mark - UITextFieldDelegate Functions
- (BOOL)growingTextViewShouldBeginEditing:(HPGrowingTextView *)growingTextView {
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
if (editButton.selected) {
[tableController setEditing:FALSE animated:TRUE];
[editButton setOff];
@ -420,17 +398,34 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
return TRUE;
}
- (BOOL)growingTextViewShouldEndEditing:(HPGrowingTextView *)growingTextView {
- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
[listTapGestureRecognizer setEnabled:FALSE];
return TRUE;
}
- (void)growingTextChanged:(HPGrowingTextView *)growingTextView text:(NSString *)text {
if ([text length] > 0 && chatRoom)
linphone_chat_room_compose(chatRoom);
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if ([text isEqualToString:@"\n"]) {
[listTapGestureRecognizer setEnabled:FALSE];
[self onSendClick:nil];
textView.text = @"";
return NO;
}
return YES;
}
- (void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height {
- (void)textViewDidChange:(UITextView *)textView {
if ([textView.text length] > 0) {
linphone_chat_room_compose(chatRoom);
}
}
- (void)textViewDidEndEditing:(UITextView *)textView {
[listTapGestureRecognizer setEnabled:FALSE];
[textView resignFirstResponder];
}
/*
- (void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height {
int diff = height - growingTextView.bounds.size.height;
if (diff != 0) {
@ -453,8 +448,6 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
tableRect.size.height -= diff;
[tableController.view setFrame:tableRect];
[messageBackgroundImage setImage:[TUNinePatchCache imageOfSize:[messageBackgroundImage bounds].size
forNinePatchNamed:@"chat_message_background"]];
// if we're showing the compose message, update it position
if (![composeLabel isHidden]) {
CGRect frame = [composeLabel frame];
@ -462,7 +455,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
[composeLabel setFrame:frame];
}
}
}
}*/
#pragma mark - Action Functions

View file

@ -63,45 +63,6 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info
#pragma mark -
- (BOOL)contactHasValidSipDomain:(ABRecordRef)person {
// Check if one of the contact' sip URI matches the expected SIP filter
ABMultiValueRef personSipAddresses = ABRecordCopyValue(person, kABPersonInstantMessageProperty);
BOOL match = false;
NSString *filter = [ContactSelection getSipFilter];
for (int i = 0; i < ABMultiValueGetCount(personSipAddresses) && !match; ++i) {
CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(personSipAddresses, i);
if (CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) {
CFStringRef serviceKey = CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey);
if (CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, serviceKey,
kCFCompareCaseInsensitive) == 0) {
match = true;
}
} else {
// check domain
LinphoneAddress *address = linphone_address_new(
[(NSString *)CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey) UTF8String]);
if (address) {
const char *dom = linphone_address_get_domain(address);
if (dom != NULL) {
NSString *domain = [NSString stringWithCString:dom encoding:[NSString defaultCStringEncoding]];
if (([filter compare:@"*" options:NSCaseInsensitiveSearch] == NSOrderedSame) ||
([filter compare:domain options:NSCaseInsensitiveSearch] == NSOrderedSame)) {
match = true;
}
}
linphone_address_destroy(address);
}
}
CFRelease(lDict);
}
CFRelease(personSipAddresses);
return match;
}
static int ms_strcmpfuz(const char *fuzzy_word, const char *sentence) {
if (!fuzzy_word || !sentence) {
return fuzzy_word == sentence;
@ -138,7 +99,7 @@ static int ms_strcmpfuz(const char *fuzzy_word, const char *sentence) {
if ([ContactSelection getSipFilter] || [ContactSelection emailFilterEnabled]) {
add = false;
}
if ([ContactSelection getSipFilter] && [self contactHasValidSipDomain:person]) {
if ([FastAddressBook contactHasValidSipDomain:person]) {
add = true;
}
if (!add && [ContactSelection emailFilterEnabled]) {
@ -175,8 +136,7 @@ static int ms_strcmpfuz(const char *fuzzy_word, const char *sentence) {
[[name lowercaseString] UTF8String]) == 0)) {
// Sort contacts by first letter. We need to translate the name to ASCII first, because of UTF-8
// issues. For instance
// we expect order: Alberta(A tilde) before ASylvano.
// issues. For instance expected order would be: Alberta(A tilde) before ASylvano.
NSData *name2ASCIIdata =
[name dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *name2ASCII =

View file

@ -175,34 +175,9 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self changeView:History_All];
[linphoneButton.titleLabel setAdjustsFontSizeToFitWidth:TRUE];
// Set selected+over background: IB lack !
[linphoneButton setBackgroundImage:[UIImage imageNamed:@"contacts_linphone_selected.png"]
forState:(UIControlStateHighlighted | UIControlStateSelected)];
[linphoneButton setTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]
forState:UIControlStateNormal];
[LinphoneUtils buttonFixStates:linphoneButton];
// Set selected+over background: IB lack !
[allButton setBackgroundImage:[UIImage imageNamed:@"contacts_all_selected.png"]
forState:(UIControlStateHighlighted | UIControlStateSelected)];
[LinphoneUtils buttonFixStates:allButton];
// [tableController.tableView setBackgroundColor:[UIColor clearColor]]; // Can't do it in Xib: issue with ios4
// [tableController.tableView setBackgroundView:nil]; // Can't do it in Xib: issue with ios4
}
#pragma mark -

View file

@ -33,7 +33,7 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="675878782">
<nil key="NSNextResponder"/>
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUIImageView" id="275930832">
@ -41,17 +41,23 @@
<int key="NSvFlags">300</int>
<string key="NSFrame">{{6, 6}, {32, 32}}</string>
<reference key="NSSuperview" ref="675878782"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="505648338"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">avatar.png</string>
</object>
</object>
<object class="IBUILabel" id="505648338">
<reference key="NSNextResponder" ref="675878782"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{46, 0}, {95, 44}}</string>
<string key="NSFrame">{{46, 0}, {261, 44}}</string>
<reference key="NSSuperview" ref="675878782"/>
<reference key="NSNextKeyView" ref="261477247"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="647977481"/>
<string key="NSReuseIdentifierKey">_NS:328</string>
<object class="NSColor" key="IBUIBackgroundColor" id="497796648">
<int key="NSColorSpace">3</int>
@ -66,52 +72,63 @@
<string key="IBUIAccessibilityLabel">Firstname</string>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">John</string>
<bool key="IBUIUsesAttributedText">YES</bool>
<object class="NSAttributedString" key="IBUIAttributedText">
<string key="NSString">John Doe</string>
<array class="NSMutableArray" key="NSAttributes">
<dictionary>
<object class="NSColor" key="NSColor" id="281940989">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
<object class="NSFont" key="NSFont">
<string key="NSName">HelveticaNeue</string>
<double key="NSSize">25</double>
<int key="NSfFlags">16</int>
</object>
<object class="NSMutableParagraphStyle" key="NSParagraphStyle" id="148133502">
<int key="NSLineBreakMode">4</int>
<nil key="NSTabStops"/>
</object>
</dictionary>
<dictionary>
<reference key="NSColor" ref="281940989"/>
<object class="NSFont" key="NSFont">
<string key="NSName">HelveticaNeue-Bold</string>
<double key="NSSize">25</double>
<int key="NSfFlags">16</int>
</object>
<reference key="NSParagraphStyle" ref="148133502"/>
</dictionary>
</array>
<object class="NSMutableData" key="NSAttributeInfo">
<bytes key="NS.bytes">BQADAQ</bytes>
</object>
</object>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">10</float>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">1</int>
<int key="weightCategory">0</int>
<double key="pointSize">25</double>
</object>
<object class="NSFont" key="IBUIFont" id="808316515">
<string key="NSName">HelveticaNeue</string>
<double key="NSSize">25</double>
<int key="NSfFlags">16</int>
</object>
<bool key="useAutomaticPreferredMaxLayoutWidth">YES</bool>
</object>
<object class="IBUILabel" id="261477247">
<object class="IBUIImageView" id="647977481">
<reference key="NSNextResponder" ref="675878782"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{111, 0}, {240, 44}}</string>
<int key="NSvFlags">300</int>
<string key="NSFrame">{{315, 12}, {37, 20}}</string>
<reference key="NSSuperview" ref="675878782"/>
<string key="NSReuseIdentifierKey">_NS:328</string>
<reference key="IBUIBackgroundColor" ref="497796648"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<int key="IBUIContentMode">7</int>
<int key="IBUITag">2</int>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIUserInteractionEnabled">NO</bool>
<object class="IBUIAccessibilityConfiguration" key="IBUIAccessibilityConfiguration">
<string key="IBUIAccessibilityLabel">Lastname</string>
</object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<string key="IBUIText">Doe</string>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">10</float>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<int key="type">2</int>
<int key="weightCategory">30</int>
<double key="pointSize">25</double>
<object class="NSCustomResource" key="IBUIImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">incoming_call_icon.png</string>
</object>
<reference key="IBUIFont" ref="808316515"/>
<bool key="useAutomaticPreferredMaxLayoutWidth">YES</bool>
</object>
</array>
<string key="NSFrameSize">{360, 44}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="275930832"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<reference key="IBUIBackgroundColor" ref="497796648"/>
@ -124,22 +141,6 @@
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">firstNameLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="505648338"/>
</object>
<int key="connectionID">17</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">lastNameLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="261477247"/>
</object>
<int key="connectionID">18</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">avatarImage</string>
@ -148,6 +149,22 @@
</object>
<int key="connectionID">24</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">nameLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="505648338"/>
</object>
<int key="connectionID">26</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">linphoneImage</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="647977481"/>
</object>
<int key="connectionID">27</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@ -174,7 +191,7 @@
<array class="NSMutableArray" key="children">
<reference ref="275930832"/>
<reference ref="505648338"/>
<reference ref="261477247"/>
<reference ref="647977481"/>
</array>
<reference key="parent" ref="0"/>
</object>
@ -182,13 +199,7 @@
<int key="objectID">6</int>
<reference key="object" ref="505648338"/>
<reference key="parent" ref="675878782"/>
<string key="objectName">firstName</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">10</int>
<reference key="object" ref="261477247"/>
<reference key="parent" ref="675878782"/>
<string key="objectName">lastName</string>
<string key="objectName">nameLabel</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">23</int>
@ -196,6 +207,12 @@
<reference key="parent" ref="675878782"/>
<string key="objectName">avatarImage</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">25</int>
<reference key="object" ref="647977481"/>
<reference key="parent" ref="675878782"/>
<string key="objectName">linphoneImage</string>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@ -203,18 +220,116 @@
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="10.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<reference key="16.IBNSViewMetadataGestureRecognizers" ref="0"/>
<string key="16.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="23.CustomClassName">UIRoundedImageView</string>
<string key="23.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="25.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">24</int>
<int key="maxID">27</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">UIContactCell</string>
<string key="superclassName">UITransparentTVCell</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="avatarImage">UIImageView</string>
<string key="linphoneImage">UIImageView</string>
<string key="nameLabel">UILabel</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="avatarImage">
<string key="name">avatarImage</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo" key="linphoneImage">
<string key="name">linphoneImage</string>
<string key="candidateClassName">UIImageView</string>
</object>
<object class="IBToOneOutletInfo" key="nameLabel">
<string key="name">nameLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../Classes/LinphoneUI/UIContactCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIRoundedImageView</string>
<string key="superclassName">UIImageView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../Classes/LinphoneUI/UIRoundedImageView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UITransparentTVCell</string>
<string key="superclassName">UITableViewCell</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">../Classes/LinphoneUI/UITransparentTVCell.h</string>
</object>
</object>
</array>
<array class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<object class="IBPartialClassDescription">
<string key="className">UIGestureRecognizer</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIGestureRecognizer.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIImageView</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIImageView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UILabel</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UILabel.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIResponder</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIResponder.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UITableViewCell</string>
<string key="superclassName">UIView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UITableViewCell.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">UIView</string>
<string key="superclassName">UIResponder</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIView.h</string>
</object>
</object>
</array>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.previouslyAttemptedUpgradeToXcode5">NO</bool>
@ -224,5 +339,9 @@
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="avatar.png">{751, 751}</string>
<string key="incoming_call_icon.png">{111, 62}</string>
</dictionary>
</data>
</archive>

View file

@ -24,9 +24,9 @@
@interface UIContactCell : UITransparentTVCell {
}
@property (nonatomic, strong) IBOutlet UILabel* firstNameLabel;
@property (nonatomic, strong) IBOutlet UILabel* lastNameLabel;
@property(nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *avatarImage;
@property(weak, nonatomic) IBOutlet UIImageView *linphoneImage;
@property (nonatomic, assign) ABRecordRef contact;
- (id)initWithIdentifier:(NSString*)identifier;

View file

@ -20,11 +20,11 @@
#import "UIContactCell.h"
#import "Utils.h"
#import "FastAddressBook.h"
#import "UILabel+Boldify.h"
@implementation UIContactCell
@synthesize firstNameLabel;
@synthesize lastNameLabel;
@synthesize nameLabel;
@synthesize avatarImage;
@synthesize contact;
@ -45,7 +45,25 @@
- (void)setContact:(ABRecordRef)acontact {
contact = acontact;
[self update];
if (contact != nil) {
NSString *lFirstName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonFirstNameProperty));
NSString *lLocalizedFirstName = [FastAddressBook localizedLabel:lFirstName];
NSString *lLastName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonLastNameProperty));
NSString *lLocalizedLastName = [FastAddressBook localizedLabel:lLastName];
NSString *lOrganization = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonOrganizationProperty));
NSString *lLocalizedOrganization = [FastAddressBook localizedLabel:lOrganization];
if (lLocalizedFirstName == nil && lLocalizedLastName == nil) {
[nameLabel setText:(NSString *)(lLocalizedOrganization)];
} else {
nameLabel.text = [NSString stringWithFormat:@"%@ %@", lLocalizedFirstName, lLocalizedLastName];
[nameLabel boldSubstring:lLocalizedLastName];
}
_linphoneImage.hidden = !([FastAddressBook contactHasValidSipDomain:contact]);
}
}
#pragma mark -
@ -59,60 +77,7 @@
}
- (NSString *)accessibilityLabel {
return [NSString stringWithFormat:@"%@ %@", firstNameLabel.text, lastNameLabel.text];
}
- (void)update {
if (contact == NULL) {
LOGW(@"Cannot update contact cell: null contact");
return;
}
NSString *lFirstName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonFirstNameProperty));
NSString *lLocalizedFirstName = [FastAddressBook localizedLabel:lFirstName];
NSString *lLastName = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonLastNameProperty));
NSString *lLocalizedLastName = [FastAddressBook localizedLabel:lLastName];
NSString *lOrganization = CFBridgingRelease(ABRecordCopyValue(contact, kABPersonOrganizationProperty));
NSString *lLocalizedOrganization = [FastAddressBook localizedLabel:lOrganization];
[firstNameLabel setText:(NSString *)(lLocalizedFirstName)];
[lastNameLabel setText:(NSString *)(lLocalizedLastName)];
if (lLocalizedFirstName == nil && lLocalizedLastName == nil) {
[firstNameLabel setText:(NSString *)(lLocalizedOrganization)];
}
}
- (void)layoutSubviews {
[super layoutSubviews];
//
// Adapt size
//
CGRect firstNameFrame = [firstNameLabel frame];
CGRect lastNameFrame = [lastNameLabel frame];
// Compute firstName size
CGSize firstNameSize = [[firstNameLabel text] sizeWithFont:[firstNameLabel font]];
CGSize lastNameSize = [[lastNameLabel text] sizeWithFont:[lastNameLabel font]];
float sum = firstNameSize.width + 5 + lastNameSize.width;
float limit = self.bounds.size.width - 5 - firstNameFrame.origin.x;
if (sum > limit) {
firstNameSize.width *= limit / sum;
lastNameSize.width *= limit / sum;
}
firstNameFrame.size.width = firstNameSize.width;
lastNameFrame.size.width = lastNameSize.width;
// Compute lastName size & position
lastNameFrame.origin.x = firstNameFrame.origin.x + firstNameFrame.size.width;
if (firstNameFrame.size.width)
lastNameFrame.origin.x += 5;
[firstNameLabel setFrame:firstNameFrame];
[lastNameLabel setFrame:lastNameFrame];
return nameLabel.text;
}
- (void)setHighlighted:(BOOL)highlighted {
@ -122,11 +87,9 @@
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
if (highlighted) {
[lastNameLabel setTextColor:[UIColor whiteColor]];
[firstNameLabel setTextColor:[UIColor whiteColor]];
[nameLabel setTextColor:[UIColor whiteColor]];
} else {
[lastNameLabel setTextColor:[UIColor blackColor]];
[firstNameLabel setTextColor:[UIColor blackColor]];
[nameLabel setTextColor:[UIColor blackColor]];
}
}

View file

@ -0,0 +1,16 @@
//
// UILabel+Boldify.h
// linphone
//
// Created by guillaume on 20/05/2015.
// Copyright (c) 2015 Urmet. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface UILabel (Boldify)
- (void)boldSubstring:(NSString *)substring;
- (void)boldRange:(NSRange)range;
@end

View file

@ -0,0 +1,30 @@
//
// UILabel+Boldify.m
// linphone
//
// Created by guillaume on 20/05/2015.
//
//
#import "UILabel+Boldify.h"
@implementation UILabel (Boldify)
- (void)boldRange:(NSRange)range {
if (![self respondsToSelector:@selector(setAttributedText:)]) {
return;
}
NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:self.text];
[attributedText setAttributes:@{
NSFontAttributeName : [UIFont boldSystemFontOfSize:self.font.pointSize]
} range:range];
self.attributedText = attributedText;
}
- (void)boldSubstring:(NSString *)substring {
NSRange range = [self.text rangeOfString:substring];
[self boldRange:range];
}
@end

View file

@ -36,7 +36,7 @@
+ (NSString*)appendCountryCodeIfPossible:(NSString*)number;
+ (NSString*)normalizePhoneNumber:(NSString*)number;
+ (NSString*)normalizeSipURI:(NSString*)address;
+ (BOOL)contactHasValidSipDomain:(ABRecordRef)person;
// TOOLS

View file

@ -19,6 +19,7 @@
#import "FastAddressBook.h"
#import "LinphoneManager.h"
#import "ContactsViewController.h"
@implementation FastAddressBook
@ -268,4 +269,42 @@ void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info, void
return @"";
}
+ (BOOL)contactHasValidSipDomain:(ABRecordRef)person {
// Check if one of the contact' sip URI matches the expected SIP filter
ABMultiValueRef personSipAddresses = ABRecordCopyValue(person, kABPersonInstantMessageProperty);
BOOL match = false;
NSString *domain = [ContactSelection getSipFilter];
for (int i = 0; i < ABMultiValueGetCount(personSipAddresses) && !match; ++i) {
CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(personSipAddresses, i);
if (CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) {
CFStringRef serviceKey = CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey);
if (CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, serviceKey,
kCFCompareCaseInsensitive) == 0) {
match = true;
}
} else if (domain != nil) {
// check domain
LinphoneAddress *address = linphone_address_new(
[(NSString *)CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey) UTF8String]);
if (address) {
const char *dom = linphone_address_get_domain(address);
if (dom != NULL) {
NSString *contactDomain =
[NSString stringWithCString:dom encoding:[NSString defaultCStringEncoding]];
match = (([domain compare:@"*" options:NSCaseInsensitiveSearch] == NSOrderedSame) ||
([domain compare:contactDomain options:NSCaseInsensitiveSearch] == NSOrderedSame));
}
linphone_address_destroy(address);
}
}
CFRelease(lDict);
}
CFRelease(personSipAddresses);
return match;
}
@end

View file

@ -110,6 +110,7 @@
631C4FB719D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m in Sources */ = {isa = PBXBuildFile; fileRef = 631C4FB619D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m */; };
632DA24D1B43EE9400EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; };
632DA24E1B43EEEF00EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; };
634610061B61330300548952 /* UILabel+Boldify.m in Sources */ = {isa = PBXBuildFile; fileRef = 634610051B61330300548952 /* UILabel+Boldify.m */; };
636316D11A1DEBCB0009B839 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D31A1DEBCB0009B839 /* AboutViewController.xib */; };
636316D41A1DEC650009B839 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D61A1DEC650009B839 /* SettingsViewController.xib */; };
636316D91A1DECC90009B839 /* PhoneMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D71A1DECC90009B839 /* PhoneMainView.xib */; };
@ -683,6 +684,8 @@
631C4FB519D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIDigitButtonLongVoiceMail.h; sourceTree = "<group>"; };
631C4FB619D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIDigitButtonLongVoiceMail.m; sourceTree = "<group>"; };
633E388219FFB0F400936D1C /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
634610041B61330300548952 /* UILabel+Boldify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UILabel+Boldify.h"; sourceTree = "<group>"; };
634610051B61330300548952 /* UILabel+Boldify.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UILabel+Boldify.m"; sourceTree = "<group>"; };
636316D21A1DEBCB0009B839 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/AboutViewController.xib; sourceTree = "<group>"; };
636316D51A1DEC650009B839 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SettingsViewController.xib; sourceTree = "<group>"; };
636316D81A1DECC90009B839 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/PhoneMainView.xib; sourceTree = "<group>"; };
@ -1480,6 +1483,8 @@
D32460E5159D9AAD00BA7F3A /* UITransparentView.m */,
340751E5150F38FC00B89C47 /* UIVideoButton.h */,
340751E6150F38FD00B89C47 /* UIVideoButton.m */,
634610041B61330300548952 /* UILabel+Boldify.h */,
634610051B61330300548952 /* UILabel+Boldify.m */,
);
path = LinphoneUI;
sourceTree = "<group>";
@ -2535,6 +2540,7 @@
22F2508E107141E100AC9B3F /* DialerViewController.m in Sources */,
22E0A822111C44E100B04932 /* AboutViewController.m in Sources */,
631C4FB119D2A8F2004BFE77 /* UIDigitButtonLongPlus.m in Sources */,
634610061B61330300548952 /* UILabel+Boldify.m in Sources */,
2248E90E12F7E4CF00220D9C /* UIDigitButton.m in Sources */,
2214EB7A12F846B1002A5394 /* UICallButton.m in Sources */,
2214EB8912F84EBB002A5394 /* UIHangUpButton.m in Sources */,