Chat: fix file transfer and other bugs

This commit is contained in:
Gautier Pelloux-Prayer 2015-10-30 17:10:43 +01:00
parent 3034d8000d
commit 430e033ed2
6 changed files with 44 additions and 34 deletions

View file

@ -66,8 +66,6 @@
<animations/>
<accessibility key="accessibilityConfiguration" label="Linphone contacts filter"/>
<fontDescription key="fontDescription" type="system" pointSize="9"/>
<inset key="titleEdgeInsets" minX="-35" minY="15" maxX="0.0" maxY="0.0"/>
<inset key="imageEdgeInsets" minX="16" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" image="contacts_sip_default.png">
<color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
@ -82,7 +80,7 @@
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_A.png" id="A9k-KU-Dlm" userLabel="selectedButtonImage">
<rect key="frame" x="0.0" y="61" width="75" height="5"/>
<rect key="frame" x="0.0" y="63" width="75" height="3"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
<animations/>
</imageView>
@ -94,7 +92,6 @@
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Delete all"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="cancel_edit_default.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>

View file

@ -57,7 +57,6 @@
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Missed contacts filter"/>
<inset key="titleEdgeInsets" minX="0.0" minY="16" maxX="0.0" maxY="0.0"/>
<state key="normal" image="history_missed_default.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
@ -69,7 +68,7 @@
</connections>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_A.png" id="o8E-gw-vhI" userLabel="selectedButtonImage">
<rect key="frame" x="0.0" y="61" width="75" height="5"/>
<rect key="frame" x="0.0" y="63" width="75" height="3"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
<animations/>
</imageView>
@ -81,7 +80,6 @@
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Delete all"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="cancel_edit_default.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>

View file

@ -193,15 +193,6 @@ static UICompositeViewDescription *compositeDescription = nil;
_addressLabel.accessibilityValue = _addressLabel.text;
}
static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState state, void *ud) {
const char *text = (linphone_chat_message_get_file_transfer_information(msg) != NULL)
? "photo transfer"
: linphone_chat_message_get_text(msg);
LOGI(@"Delivery status for [%s] is [%s]", text, linphone_chat_message_state_to_string(state));
ChatConversationView *thiz = (__bridge ChatConversationView *)ud;
[thiz.tableController updateChatEntry:msg];
}
- (BOOL)sendMessage:(NSString *)message withExterlBodyUrl:(NSURL *)externalUrl withInternalURL:(NSURL *)internalUrl {
if (chatRoom == NULL) {
LOGW(@"Cannot send message: No chatroom");
@ -218,7 +209,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
[LinphoneManager setValueInMessageAppData:[internalUrl absoluteString] forKey:@"localimage" inMessage:msg];
}
linphone_chat_room_send_message2(chatRoom, msg, message_status, (__bridge void *)(self));
linphone_chat_room_send_chat_message(chatRoom, msg);
[_tableController addChatEntry:msg];
[_tableController scrollToBottom:true];

View file

@ -61,6 +61,8 @@
_messageImageView.image = nil;
_fileTransferProgress.progress = 0;
[super setChatMessage:amessage];
if (amessage) {
const LinphoneContent *c = linphone_chat_message_get_file_transfer_information(amessage);
if (c) {
@ -76,7 +78,7 @@
}
}
}
[super setChatMessage:amessage];
[self update];
}
- (void)update {
@ -186,6 +188,7 @@
- (void)connectToFileDelegate:(FileTransferDelegate *)aftd {
ftd = aftd;
// assert(ftd.message == self.message);
_fileTransferProgress.progress = 0;
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[NSNotificationCenter defaultCenter] addObserver:self

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="14F1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
@ -32,10 +32,12 @@
<imageView userInteractionEnabled="NO" alpha="0.20000000298023224" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_A.png" id="U2P-5n-gg8" userLabel="backgroundColorImage">
<rect key="frame" x="0.0" y="0.0" width="322" height="130"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" image="avatar.png" id="hD2-19-7IH" userLabel="avatarImage" customClass="UIRoundedImageView">
<rect key="frame" x="7" y="7" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Contact avatar">
<accessibilityTraits key="traits" none="YES" image="YES" notEnabled="YES"/>
<bool key="isElement" value="YES"/>
@ -44,6 +46,7 @@
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" usesAttributedText="YES" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="JyR-RQ-uwF" userLabel="contactDateLabel">
<rect key="frame" x="48" y="0.0" width="246" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<accessibility key="accessibilityConfiguration" label="Contact name"/>
<attributedString key="attributedText">
<fragment content="11:35 John ">
@ -66,6 +69,7 @@
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="splashscreen.png" id="yMW-cT-bpU" userLabel="image" customClass="UILoadingImageView">
<rect key="frame" x="48" y="24" width="274" height="67"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<animations/>
<gestureRecognizers/>
<connections>
<outletCollection property="gestureRecognizers" destination="aDF-hC-ddO" appends="YES" id="7kE-0j-s1g"/>
@ -74,51 +78,63 @@
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="128 Ko / 172 Ko" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Aaa-MV-yvm" userLabel="fileSizeLabel">
<rect key="frame" x="24" y="59" width="274" height="12"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" id="GmN-7v-uuO" userLabel="imageSubView">
<rect key="frame" x="48" y="91" width="274" height="32.000000029802322"/>
<rect key="frame" x="48" y="91" width="274" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" id="USm-wC-GvG" userLabel="transferProgress">
<rect key="frame" x="10" y="0.0" width="254" height="2"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<animations/>
</progressView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="N75-gL-R6t" userLabel="transferButton" customClass="UIRoundBorderedButton">
<rect key="frame" x="75" y="4.0000000298023224" width="124" height="27"/>
<rect key="frame" x="75" y="4" width="124" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<state key="normal" title="DOWNLOAD">
<animations/>
<state key="normal" title="DOWNLOAD" backgroundImage="color_G.png">
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onDownloadClick:" destination="-1" eventType="touchUpInside" id="8BO-9E-iOX"/>
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="6dl-Nz-rdv" userLabel="cancelButton" customClass="UIRoundBorderedButton">
<rect key="frame" x="75" y="4.0000000298023224" width="124" height="27"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="6dl-Nz-rdv" userLabel="cancelButton" customClass="UIRoundBorderedButton">
<rect key="frame" x="75" y="4" width="124" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<state key="normal" title="CANCEL">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<animations/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="15"/>
<state key="normal" title="CANCEL" backgroundImage="color_I.png">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted" backgroundImage="color_M.png"/>
<connections>
<action selector="onCancelClick:" destination="-1" eventType="touchUpInside" id="D9y-vf-I4Y"/>
</connections>
</button>
</subviews>
<animations/>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="chat_message_inprogress.png" id="hSL-MF-B9b" userLabel="statusImage">
<rect key="frame" x="307" y="0.0" width="15" height="15"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<animations/>
</imageView>
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_A.png" id="6dA-3U-OPW" userLabel="bottomBarColor">
<rect key="frame" x="0.0" y="129" width="322" height="1"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<animations/>
</imageView>
</subviews>
<animations/>
</view>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
@ -140,6 +156,9 @@
<image name="avatar.png" width="255" height="255"/>
<image name="chat_message_inprogress.png" width="11" height="12"/>
<image name="color_A.png" width="2" height="2"/>
<image name="color_G.png" width="2" height="2"/>
<image name="color_I.png" width="2" height="2"/>
<image name="color_M.png" width="2" height="2"/>
<image name="splashscreen.png" width="181" height="165"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">

View file

@ -97,23 +97,22 @@
_messageText.attributedText = attr_text;
}
// Date
_contactDateLabel.text = [NSString
stringWithFormat:@"%@ - %@", [LinphoneUtils timeToString:linphone_chat_message_get_time(_message)
withFormat:NSLocalizedString(@"yyyy/MM/dd '-' HH'h'mm", nil)],
[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);
if (outgoing) {
_avatarImage.image = [LinphoneUtils selfAvatar];
} else {
ABRecordRef contact = [FastAddressBook getContactWithAddress:linphone_chat_message_get_peer_address(_message)];
[_avatarImage setImage:[FastAddressBook imageForContact:contact thumbnail:YES]
[_avatarImage setImage:[FastAddressBook imageForAddress:linphone_chat_message_get_peer_address(_message)
thumbnail:YES]
bordered:NO
withRoundedRadius:YES];
}
_contactDateLabel.text = [NSString
stringWithFormat:@"%@ - %@", [LinphoneUtils timeToString:linphone_chat_message_get_time(_message)
withFormat:NSLocalizedString(@"yyyy/MM/dd '-' HH'h'mm", nil)],
[FastAddressBook displayNameForAddress:linphone_chat_message_get_from_address(_message)]];
_backgroundColorImage.image = _bottomBarColor.image =
[UIImage imageNamed:(outgoing ? @"color_A.png" : @"color_D.png")];
@ -206,6 +205,9 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
UIChatBubbleTextCell *thiz = (__bridge UIChatBubbleTextCell *)linphone_chat_message_get_user_data(msg);
LOGI(@"State for message [%p] changed to %s", msg, linphone_chat_message_state_to_string(state));
[thiz update];
ChatConversationView *view = VIEW(ChatConversationView);
[view.tableController updateChatEntry:msg];
}
#pragma mark - Bubble size computing