Try fix bubble but failed

This commit is contained in:
Gautier Pelloux-Prayer 2015-10-12 10:45:06 +02:00
parent c00f6e3dce
commit 9e791d33b9
4 changed files with 29 additions and 42 deletions

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
@ -10,7 +11,6 @@
<outlet property="chatView" destination="bJF-qS-vBP" id="AF2-NN-muZ"/>
<outlet property="composeIndicatorView" destination="fx4-ao-53M" id="xk5-nK-lur"/>
<outlet property="composeLabel" destination="fpY-Fv-ht2" id="4L6-ik-ZAe"/>
<outlet property="createChatView" destination="YYI-jh-UPG" id="FIv-GA-Thi"/>
<outlet property="editButton" destination="10" id="35"/>
<outlet property="messageField" destination="CPp-ts-xy0" id="wPX-Uo-vZQ"/>
<outlet property="messageView" destination="14" id="89"/>
@ -120,29 +120,6 @@
</view>
</subviews>
</view>
<view contentMode="scaleToFill" id="YYI-jh-UPG" userLabel="createChatView">
<rect key="frame" x="0.0" y="0.0" width="375" height="446"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="60" sectionHeaderHeight="22" sectionFooterHeight="22" id="d9Z-ch-tVO" userLabel="addressesTableView">
<rect key="frame" x="0.0" y="44" width="375" height="396"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<connections>
<outlet property="dataSource" destination="2fm-IU-Rv8" id="xxn-Q2-doz"/>
</connections>
</tableView>
<searchBar contentMode="redraw" id="vi8-rd-Oiw">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textInputTraits key="textInputTraits"/>
<connections>
<outlet property="delegate" destination="2fm-IU-Rv8" id="GyU-vl-XiG"/>
</connections>
</searchBar>
</subviews>
</view>
<view contentMode="scaleToFill" id="14" userLabel="messageView">
<rect key="frame" x="0.0" y="449" width="375" height="66"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
@ -205,11 +182,6 @@
</connections>
<point key="canvasLocation" x="639" y="328"/>
</tableViewController>
<tableViewController id="2fm-IU-Rv8" userLabel="addressesTableView" customClass="ChatConversationSearchTableView">
<connections>
<outlet property="view" destination="d9Z-ch-tVO" id="qI4-He-mtn"/>
</connections>
</tableViewController>
</objects>
<resources>
<image name="back.png" width="24" height="21"/>

View file

@ -138,8 +138,8 @@ static void chatTable_free_chatrooms(void *data) {
if (![self isEditing]) {
LinphoneChatRoom *chatRoom = (LinphoneChatRoom *)ms_list_nth_data(data, (int)[indexPath row]);
ChatConversationView *view = VIEW(ChatConversationView);
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE];
[view setChatRoom:chatRoom];
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE];
}
}

View file

@ -97,8 +97,10 @@
_messageText.attributedText = attr_text;
// Date
_contactDateLabel.text =
[LinphoneUtils timeToString:linphone_chat_message_get_time(message) withStyle:NSDateFormatterMediumStyle];
_contactDateLabel.text = [NSString
stringWithFormat:@"%@ - %@", [LinphoneUtils timeToString:linphone_chat_message_get_time(message)
withStyle:NSDateFormatterShortStyle],
[FastAddressBook displayNameForAddress:linphone_chat_message_get_peer_address(message)]];
LinphoneChatMessageState state = linphone_chat_message_get_state(message);
BOOL outgoing = linphone_chat_message_is_outgoing(message);
@ -213,7 +215,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
static const CGFloat IMAGE_HEIGHT = 100.0f; // TODO: move that in bubblephpto
static const CGFloat IMAGE_WIDTH = 100.0f;
CGSize messageSize;
CGSize messageSize, dateSize;
int messageAvailableWidth = width - MARGIN_WIDTH;
const char *url = linphone_chat_message_get_external_body_url(message);
@ -230,12 +232,24 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
NSFontAttributeName : _messageText.font
} context:nil]
.size;
dateSize = [_contactDateLabel.text boundingRectWithSize:_contactDateLabel.frame.size
options:(NSStringDrawingUsesLineFragmentOrigin |
NSStringDrawingTruncatesLastVisibleLine |
NSStringDrawingUsesFontLeading)
attributes:@{
NSFontAttributeName : _contactDateLabel.font
}
context:nil]
.size;
} else
#endif
{
messageSize = [text sizeWithFont:_messageText.font
constrainedToSize:CGSizeMake(messageAvailableWidth, 10000.0f)
lineBreakMode:NSLineBreakByTruncatingTail];
dateSize = [text sizeWithFont:_contactDateLabel.font
constrainedToSize:_contactDateLabel.frame.size
lineBreakMode:NSLineBreakByTruncatingTail];
}
} else {
messageSize = CGSizeMake(IMAGE_WIDTH, IMAGE_HEIGHT);
@ -245,7 +259,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
messageSize.height = MAX(TEXT_MIN_HEIGHT, messageSize.height);
CGSize bubbleSize = messageSize;
bubbleSize.width += MARGIN_WIDTH;
bubbleSize.width = MAX(messageSize.width, dateSize.width) + MARGIN_WIDTH;
bubbleSize.height += MARGIN_HEIGHT;
LOGE(@"%d %fx%f for %@", width, bubbleSize.width, bubbleSize.height,
@ -259,6 +273,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
BOOL is_outgoing = linphone_chat_message_is_outgoing(message);
CGRect bubbleFrame = _bubbleView.frame;
bubbleFrame.size = [self viewSizeWithWidth:self.frame.size.width];
bubbleFrame.size.width += 10;
bubbleFrame.origin.x = is_outgoing ? self.frame.size.width - bubbleFrame.size.width : 0;
_bubbleView.frame = bubbleFrame;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
@ -24,9 +24,9 @@
</tapGestureRecognizer>
<view contentMode="scaleToFill" id="ucH-2r-rar">
<rect key="frame" x="0.0" y="0.0" width="357" height="199"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" id="vdk-RV-QRU" userLabel="innerView">
<view clipsSubviews="YES" contentMode="scaleToFill" id="vdk-RV-QRU" userLabel="innerView">
<rect key="frame" x="6" y="5" width="345" height="189"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
@ -36,7 +36,7 @@
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="avatar.png" id="P1c-sD-eOv" userLabel="avatarImage" customClass="UIRoundedImageView">
<rect key="frame" x="8" y="2" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Contact avatar">
<accessibilityTraits key="traits" none="YES" image="YES" notEnabled="YES"/>
<bool key="isElement" value="YES"/>
@ -66,7 +66,7 @@
</label>
<textView clipsSubviews="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" id="CYa-If-oB4" userLabel="messageText" customClass="UITextViewNoDefine">
<rect key="frame" x="48" y="10" width="299" height="168"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<string key="text">static const CGFloat CELL_MESSAGE_WIDTH_MARGIN = 26.0f + 10.0f + 48;
static const CGFloat CELL_MESSAGE_HEIGHT_MARGIN = 10.0f + 10;
static const CGFloat CELL_IMAGE_HEIGHT = 100.0f;
@ -77,7 +77,7 @@ static const CGFloat CELL_IMAGE_WIDTH = 100.0f;</string>
</textView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="chat_message_inprogress.png" id="nLy-JO-TyL" userLabel="statusImage">
<rect key="frame" x="330" y="0.0" width="15" height="15"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_A.png" id="mlr-pl-B6T" userLabel="bottomBarColor">
<rect key="frame" x="0.0" y="188" width="345" height="1"/>
@ -92,8 +92,8 @@ static const CGFloat CELL_IMAGE_WIDTH = 100.0f;</string>
</view>
</objects>
<resources>
<image name="avatar.png" width="261" height="261"/>
<image name="chat_message_inprogress.png" width="12" height="12"/>
<image name="avatar.png" width="255" height="255"/>
<image name="chat_message_inprogress.png" width="11" height="12"/>
<image name="color_A.png" width="1" height="1"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">