rework chat conversation / check boxes

This commit is contained in:
Gautier Pelloux-Prayer 2015-10-12 17:27:03 +02:00
parent 31ba4d0a51
commit 4a6a6092d6
10 changed files with 196 additions and 156 deletions

View file

@ -44,8 +44,8 @@
</button>
</subviews>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" allowsSelectionDuringEditing="YES" allowsMultipleSelectionDuringEditing="YES" showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="60" sectionHeaderHeight="22" sectionFooterHeight="22" id="6" userLabel="tableView">
<rect key="frame" x="0.0" y="84" width="375" height="475"/>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" allowsSelectionDuringEditing="YES" allowsMultipleSelectionDuringEditing="YES" showsSelectionImmediatelyOnTouchBegin="NO" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="6" userLabel="tableView">
<rect key="frame" x="5" y="84" width="365" height="475"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="separatorColor" red="0.7254902124" green="0.76862746479999999" blue="0.79607844350000001" alpha="1" colorSpace="deviceRGB"/>
@ -63,6 +63,7 @@
</connections>
</searchBar>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>

View file

@ -8,10 +8,11 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ChatConversationView">
<connections>
<outlet property="addressLabel" destination="40" id="43"/>
<outlet property="backButton" destination="9" id="9Pw-ZA-KcF"/>
<outlet property="callButton" destination="Wzg-i0-spp" id="w9L-aT-1AD"/>
<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="editButton" destination="10" id="35"/>
<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"/>
@ -73,32 +74,73 @@
<action selector="onCallClick:" destination="-1" eventType="touchUpInside" id="Dsf-nS-K3V"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" adjustsImageWhenHighlighted="NO" lineBreakMode="middleTruncation" id="10" userLabel="editButton" customClass="UIToggleButton">
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Wag-Nx-kd6" userLabel="deleteButton" customClass="UIIconButton">
<rect key="frame" x="300" y="0.0" width="75" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Delete all"/>
<inset key="titleEdgeInsets" minX="0.0" minY="18" maxX="0.0" maxY="0.0"/>
<state key="normal" image="delete.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" backgroundImage="color_E.png"/>
<connections>
<action selector="onDeleteClick:" destination="-1" eventType="touchUpInside" id="JoY-wC-JQy"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="FqM-Ud-i58" userLabel="editButton" customClass="UIIconButton">
<rect key="frame" x="300" y="0.0" width="75" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<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">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted" backgroundImage="color_E.png"/>
<state key="selected" backgroundImage="color_E.png"/>
<connections>
<action selector="onEditClick:" destination="-1" eventType="touchUpInside" id="13"/>
<action selector="onEditClick:" destination="29" eventType="touchUpInside" id="2Q7-xM-Shx"/>
<action selector="onEditionChangeClick:" destination="-1" eventType="touchUpInside" id="0we-lw-TyJ"/>
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" reversesTitleShadowWhenHighlighted="YES" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="c9z-aq-2UP" userLabel="toggleSelectionButton" customClass="UIIconButton">
<rect key="frame" x="225" y="0.0" width="75" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<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="select_all.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" image="deselect_all.png"/>
<connections>
<action selector="onSelectionToggle:" destination="29" eventType="touchUpInside" id="eP5-bU-LEA"/>
</connections>
</button>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="bci-3K-AcG" userLabel="cancelButton" customClass="UIIconButton">
<rect key="frame" x="0.0" y="0.0" width="75" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<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.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected" backgroundImage="color_E.png"/>
<connections>
<action selector="onCancelClick:" destination="29" eventType="touchUpInside" id="tdO-wP-Ttr"/>
<action selector="onEditionChangeClick:" destination="-1" eventType="touchUpInside" id="c6C-ow-Yhi"/>
</connections>
</button>
</subviews>
</view>
<view contentMode="scaleToFill" id="49" userLabel="contentView">
<rect key="frame" x="0.0" y="40" width="375" height="515"/>
<rect key="frame" x="0.0" y="40" width="375" height="519"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" id="bJF-qS-vBP" userLabel="chatView">
<rect key="frame" x="0.0" y="0.0" width="375" height="450"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="453"/>
<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="8" userLabel="messagesTableView">
<rect key="frame" x="0.0" y="0.0" width="375" height="422"/>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" allowsSelectionDuringEditing="YES" allowsMultipleSelectionDuringEditing="YES" rowHeight="60" sectionHeaderHeight="22" sectionFooterHeight="22" id="8" userLabel="messagesTableView">
<rect key="frame" x="0.0" y="0.0" width="375" height="425"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
@ -108,7 +150,7 @@
</connections>
</tableView>
<view contentMode="scaleToFill" id="fx4-ao-53M" userLabel="composeIndicatorView">
<rect key="frame" x="0.0" y="427" width="375" height="22"/>
<rect key="frame" x="0.0" y="430" width="375" 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">
@ -124,9 +166,13 @@
</subviews>
</view>
<view contentMode="scaleToFill" id="14" userLabel="messageView">
<rect key="frame" x="0.0" y="449" width="375" height="66"/>
<rect key="frame" x="0.0" y="453" width="375" height="66"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_F.png" id="pGT-LQ-zpg" userLabel="backgroundColor">
<rect key="frame" x="0.0" y="0.0" width="375" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="73" userLabel="pictureButton">
<rect key="frame" x="0.0" y="2" width="72" height="63"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
@ -164,7 +210,6 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</subviews>
</view>
@ -181,6 +226,10 @@
<extendedEdge key="edgesForExtendedLayout"/>
<nil key="simulatedStatusBarMetrics"/>
<connections>
<outlet property="cancelButton" destination="bci-3K-AcG" id="ZTI-gJ-SEL"/>
<outlet property="deleteButton" destination="Wag-Nx-kd6" id="hOb-3g-mnR"/>
<outlet property="editButton" destination="FqM-Ud-i58" id="9L7-rC-Aqy"/>
<outlet property="toggleSelectionButton" destination="c9z-aq-2UP" id="a2J-JQ-rhX"/>
<outlet property="view" destination="8" id="g4m-ne-lbP"/>
</connections>
<point key="canvasLocation" x="639" y="328"/>
@ -191,13 +240,17 @@
<image name="call_alt_start.png" width="29" height="29"/>
<image name="call_start_body_disabled.png" width="51" height="51"/>
<image name="call_start_body_over.png" width="51" height="51"/>
<image name="cancel_edit.png" width="29" height="29"/>
<image name="chat_picture_default.png" width="25" height="19"/>
<image name="chat_picture_over.png" width="42" height="42"/>
<image name="chat_send_default.png" width="40" height="40"/>
<image name="chat_send_over.png" width="40" height="40"/>
<image name="color_E.png" width="1" height="1"/>
<image name="color_F.png" width="1" height="1"/>
<image name="delete.png" width="21" height="27"/>
<image name="deselect_all.png" width="26" height="26"/>
<image name="edit_list.png" width="29" height="28"/>
<image name="select_all.png" width="26" height="26"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>

View file

@ -20,6 +20,8 @@
#import <UIKit/UIKit.h>
#include "linphone/linphonecore.h"
#import "UICheckBoxTVTableViewController.h"
@protocol ChatConversationDelegate <NSObject>
- (BOOL)startImageUpload:(UIImage *)image url:(NSURL *)url;
@ -27,7 +29,7 @@
@end
@interface ChatConversationTableView : UITableViewController {
@interface ChatConversationTableView : UICheckBoxTVTableViewController {
@private
LinphoneChatRoom *chatRoom;
MSList *messageList;

View file

@ -182,6 +182,7 @@
}
[cell setChatMessage:chat];
[cell setChatRoomDelegate:chatRoomDelegate];
[super accessoryForCell:cell atPath:indexPath];
return cell;
}
@ -204,15 +205,6 @@
}
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
// Detemine if it's in editing mode
if (self.editing) {
return UITableViewCellEditingStyleDelete;
}
return UITableViewCellEditingStyleNone;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
UIChatBubbleTextCell *cell = (UIChatBubbleTextCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
return [cell viewSizeWithWidth:self.view.frame.size.width].height;

View file

@ -49,7 +49,8 @@
@property(strong, nonatomic) IBOutlet UILabel *composeLabel;
@property(strong, nonatomic) IBOutlet UIView *composeIndicatorView;
@property(nonatomic, strong) IBOutlet UIButton *pictureButton;
@property(weak, nonatomic) IBOutlet UIView *createChatView;
@property(weak, nonatomic) IBOutlet UIIconButton *backButton;
@property(weak, nonatomic) IBOutlet UIIconButton *callButton;
- (IBAction)onBackClick:(id)event;
- (IBAction)onEditClick:(id)event;
@ -58,6 +59,8 @@
- (IBAction)onPictureClick:(id)event;
- (IBAction)onListTap:(id)sender;
- (IBAction)onCallClick:(id)sender;
- (IBAction)onDeleteClick:(id)sender;
- (IBAction)onEditionChangeClick:(id)sender;
- (void)setChatRoom:(LinphoneChatRoom *)room;

View file

@ -25,21 +25,6 @@
@implementation ChatConversationView
@synthesize messageField;
@synthesize tableController;
@synthesize sendButton;
@synthesize editButton;
@synthesize addressLabel;
@synthesize composeLabel;
@synthesize composeIndicatorView;
@synthesize avatarImage;
@synthesize headerView;
@synthesize chatView;
@synthesize messageView;
@synthesize listTapGestureRecognizer;
@synthesize listSwipeGestureRecognizer;
@synthesize pictureButton;
#pragma mark - Lifecycle Functions
- (id)init {
@ -47,8 +32,8 @@
if (self != nil) {
scrollOnGrowingEnabled = TRUE;
chatRoom = NULL;
listTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onListTap:)];
self.listSwipeGestureRecognizer =
_listTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onListTap:)];
_listSwipeGestureRecognizer =
[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(onListSwipe:)];
imageQualities = [[OrderedDictionary alloc]
initWithObjectsAndKeys:[NSNumber numberWithFloat:0.9], NSLocalizedString(@"Maximum", nil),
@ -87,14 +72,14 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewDidLoad {
[super viewDidLoad];
[tableController setChatRoomDelegate:self];
[_tableController setChatRoomDelegate:self];
[tableController.tableView addGestureRecognizer:listTapGestureRecognizer];
[listTapGestureRecognizer setEnabled:FALSE];
[_tableController.tableView addGestureRecognizer:_listTapGestureRecognizer];
[_listTapGestureRecognizer setEnabled:FALSE];
listSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[tableController.tableView addGestureRecognizer:listSwipeGestureRecognizer];
listSwipeGestureRecognizer.enabled = TRUE;
_listSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[_tableController.tableView addGestureRecognizer:_listSwipeGestureRecognizer];
_listSwipeGestureRecognizer.enabled = TRUE;
}
- (void)viewWillAppear:(BOOL)animated {
@ -124,19 +109,19 @@ static UICompositeViewDescription *compositeDescription = nil;
name:kLinphoneTextComposeEvent
object:nil];
if ([tableController isEditing])
[tableController setEditing:FALSE animated:FALSE];
[editButton setOff];
[[tableController tableView] reloadData];
if ([_tableController isEditing])
[_tableController setEditing:FALSE animated:FALSE];
[_editButton setOff];
[[_tableController tableView] reloadData];
BOOL fileSharingEnabled = linphone_core_get_file_transfer_server([LinphoneManager getLc]) != NULL;
[pictureButton setEnabled:fileSharingEnabled];
[_pictureButton setEnabled:fileSharingEnabled];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[messageField resignFirstResponder];
[_messageField resignFirstResponder];
[self setComposingVisible:FALSE withDelay:0]; // will hide the "user is composing.." message
@ -145,7 +130,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[tableController scrollToBottom:true];
[_tableController scrollToBottom:true];
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
@ -161,19 +146,17 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)setChatRoom:(LinphoneChatRoom *)room {
chatRoom = room;
[messageField setText:@""];
[tableController setChatRoom:room];
[_messageField setText:@""];
[_tableController setChatRoom:room];
if (chatRoom != NULL) {
_createChatView.hidden = YES;
chatView.hidden = NO;
_chatView.hidden = NO;
[self update];
linphone_chat_room_mark_as_read(chatRoom);
[self setComposingVisible:linphone_chat_room_is_remote_composing(chatRoom) withDelay:0];
[[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self];
} else {
_createChatView.hidden = NO;
chatView.hidden = YES;
_chatView.hidden = YES;
}
}
@ -204,9 +187,9 @@ static UICompositeViewDescription *compositeDescription = nil;
[error show];
return;
}
[ContactDisplay setDisplayNameLabel:addressLabel forAddress:linphoneAddress];
addressLabel.accessibilityValue = addressLabel.text;
avatarImage.image =
[ContactDisplay setDisplayNameLabel:_addressLabel forAddress:linphoneAddress];
_addressLabel.accessibilityValue = _addressLabel.text;
_avatarImage.image =
[FastAddressBook getContactImage:[FastAddressBook getContactWithLinphoneAddress:linphoneAddress] thumbnail:YES];
}
@ -235,8 +218,8 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
[LinphoneManager setValueInMessageAppData:[internalUrl absoluteString] forKey:@"localimage" inMessage:msg];
}
[tableController addChatEntry:msg];
[tableController scrollToBottom:true];
[_tableController addChatEntry:msg];
[_tableController scrollToBottom:true];
linphone_chat_room_send_message2(chatRoom, msg, message_status, (__bridge void *)(self));
@ -297,13 +280,13 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
if (composingVisible == visible)
return;
CGRect keyboardFrame = [self.messageView frame];
CGRect newComposingFrame = [self.composeIndicatorView frame];
CGRect newTableFrame = [self.tableController.tableView frame];
CGRect keyboardFrame = [_messageView frame];
CGRect newComposingFrame = [_composeIndicatorView frame];
CGRect newTableFrame = [_tableController.tableView frame];
if (visible) {
composeLabel.text =
[NSString stringWithFormat:NSLocalizedString(@"%@ is composing...", nil), addressLabel.text];
_composeLabel.text =
[NSString stringWithFormat:NSLocalizedString(@"%@ is composing...", nil), _addressLabel.text];
// pull up the composing frame and shrink the table view
newTableFrame.size.height -= newComposingFrame.size.height;
@ -316,11 +299,11 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
composingVisible = visible;
[UIView animateWithDuration:delay
animations:^{
self.tableController.tableView.frame = newTableFrame;
self.composeIndicatorView.frame = newComposingFrame;
_tableController.tableView.frame = newTableFrame;
_composeIndicatorView.frame = newComposingFrame;
}
completion:^(BOOL finished) {
[self.tableController scrollToBottom:TRUE];
[_tableController scrollToBottom:TRUE];
}];
}
@ -345,8 +328,8 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
linphone_chat_room_mark_as_read(room);
[[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self];
}
[tableController addChatEntry:chat];
[tableController scrollToLastUnread:TRUE];
[_tableController addChatEntry:chat];
[_tableController scrollToLastUnread:TRUE];
}
}
ms_free(fromStr);
@ -364,22 +347,22 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
#pragma mark - UITextFieldDelegate Functions
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
if (editButton.selected) {
[tableController setEditing:FALSE animated:TRUE];
[editButton setOff];
if (_editButton.selected) {
[_tableController setEditing:FALSE animated:TRUE];
[_editButton setOff];
}
[listTapGestureRecognizer setEnabled:TRUE];
[_listTapGestureRecognizer setEnabled:TRUE];
return TRUE;
}
- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
[listTapGestureRecognizer setEnabled:FALSE];
[_listTapGestureRecognizer setEnabled:FALSE];
return TRUE;
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
if ([text isEqualToString:@"\n"]) {
[listTapGestureRecognizer setEnabled:FALSE];
[_listTapGestureRecognizer setEnabled:FALSE];
[self onSendClick:nil];
textView.text = @"";
return NO;
@ -394,7 +377,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
}
- (void)textViewDidEndEditing:(UITextView *)textView {
[listTapGestureRecognizer setEnabled:FALSE];
[_listTapGestureRecognizer setEnabled:FALSE];
[textView resignFirstResponder];
}
@ -403,30 +386,30 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
int diff = height - growingTextView.bounds.size.height;
if (diff != 0) {
CGRect messageRect = [messageView frame];
CGRect messageRect = [_messageView frame];
messageRect.origin.y -= diff;
messageRect.size.height += diff;
[messageView setFrame:messageRect];
[_messageView setFrame:messageRect];
// Always stay at bottom
if (scrollOnGrowingEnabled) {
CGRect tableFrame = [tableController.view frame];
CGPoint contentPt = [tableController.tableView contentOffset];
CGRect tableFrame = [_tableController.view frame];
CGPoint contentPt = [_tableController.tableView contentOffset];
contentPt.y += diff;
if (contentPt.y + tableFrame.size.height > tableController.tableView.contentSize.height)
if (contentPt.y + tableFrame.size.height > _tableController.tableView.contentSize.height)
contentPt.y += diff;
[tableController.tableView setContentOffset:contentPt animated:FALSE];
[_tableController.tableView setContentOffset:contentPt animated:FALSE];
}
CGRect tableRect = [tableController.view frame];
CGRect tableRect = [_tableController.view frame];
tableRect.size.height -= diff;
[tableController.view setFrame:tableRect];
[_tableController.view setFrame:tableRect];
// if we're showing the compose message, update it position
if (![composeLabel isHidden]) {
CGRect frame = [composeLabel frame];
if (![_composeLabel isHidden]) {
CGRect frame = [_composeLabel frame];
frame.origin.y -= diff;
[composeLabel setFrame:frame];
[_composeLabel setFrame:frame];
}
}
}*/
@ -434,26 +417,26 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
#pragma mark - Action Functions
- (IBAction)onBackClick:(id)event {
[self.tableController setChatRoom:NULL];
[_tableController setChatRoom:NULL];
[PhoneMainView.instance popCurrentView];
}
- (IBAction)onEditClick:(id)event {
[tableController setEditing:![tableController isEditing] animated:TRUE];
[messageField resignFirstResponder];
[_tableController setEditing:![_tableController isEditing] animated:TRUE];
[_messageField resignFirstResponder];
}
- (IBAction)onSendClick:(id)event {
if ([self sendMessage:[messageField text] withExterlBodyUrl:nil withInternalURL:nil]) {
if ([self sendMessage:[_messageField text] withExterlBodyUrl:nil withInternalURL:nil]) {
scrollOnGrowingEnabled = FALSE;
[messageField setText:@""];
[_messageField setText:@""];
scrollOnGrowingEnabled = TRUE;
[self onMessageChange:nil];
}
}
- (IBAction)onListTap:(id)sender {
[messageField resignFirstResponder];
[_messageField resignFirstResponder];
}
- (IBAction)onCallClick:(id)sender {
@ -465,21 +448,41 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
[view call:[NSString stringWithUTF8String:uri] displayName:displayName];
ms_free(uri);
}
- (IBAction)onDeleteClick:(id)sender {
NSString *msg =
[NSString stringWithFormat:NSLocalizedString(@"Are you sure that you want to delete %d messages?", nil),
_tableController.selectedItems.count];
[UIConfirmationDialog ShowWithMessage:msg
onCancelClick:^() {
[self onEditionChangeClick:nil];
}
onConfirmationClick:^() {
[_tableController removeSelection];
[_tableController loadData];
[self onEditionChangeClick:nil];
}];
}
- (IBAction)onEditionChangeClick:(id)sender {
_backButton.hidden = _callButton.hidden = _tableController.isEditing;
}
- (IBAction)onListSwipe:(id)sender {
[self onBackClick:sender];
}
- (IBAction)onMessageChange:(id)sender {
if ([[messageField text] length] > 0) {
[sendButton setEnabled:TRUE];
if ([[_messageField text] length] > 0) {
[_sendButton setEnabled:TRUE];
} else {
[sendButton setEnabled:FALSE];
[_sendButton setEnabled:FALSE];
}
}
- (IBAction)onPictureClick:(id)event {
[messageField resignFirstResponder];
CGRect rect = [self.messageView convertRect:[pictureButton frame] toView:self.view];
[_messageField resignFirstResponder];
CGRect rect = [_messageView convertRect:[_pictureButton frame] toView:self.view];
[ImagePickerView SelectImageFromDevice:self atPosition:rect inView:self.view];
}
@ -488,8 +491,8 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
- (BOOL)startImageUpload:(UIImage *)image url:(NSURL *)url {
FileTransferDelegate *fileTransfer = [[FileTransferDelegate alloc] init];
[fileTransfer upload:image withURL:url forChatRoom:chatRoom];
[tableController addChatEntry:linphone_chat_message_ref(fileTransfer.message)];
[tableController scrollToBottom:true];
[_tableController addChatEntry:linphone_chat_message_ref(fileTransfer.message)];
[_tableController scrollToBottom:true];
return TRUE;
}
@ -517,37 +520,37 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
delay:0
options:UIViewAnimationOptionBeginFromCurrentState
animations:^{
CGFloat composeIndicatorCompensation = composingVisible ? composeIndicatorView.frame.size.height : 0.0f;
CGFloat composeIndicatorCompensation = composingVisible ? _composeIndicatorView.frame.size.height : 0.0f;
// Resize chat view
{
CGRect chatFrame = [[self chatView] frame];
CGRect chatFrame = [_chatView frame];
chatFrame.size.height = [[self view] frame].size.height - chatFrame.origin.y;
[[self chatView] setFrame:chatFrame];
[_chatView setFrame:chatFrame];
}
// Move header view back into place (was hidden before)
{
CGRect headerFrame = [headerView frame];
CGRect headerFrame = [_headerView frame];
headerFrame.origin.y = 0;
[headerView setFrame:headerFrame];
[headerView setAlpha:1.0];
[_headerView setFrame:headerFrame];
[_headerView setAlpha:1.0];
}
// Resize & Move table view
{
CGRect tableFrame = [tableController.view frame];
tableFrame.origin.y = [headerView frame].origin.y + [headerView frame].size.height;
CGRect tableFrame = [_tableController.view frame];
tableFrame.origin.y = [_headerView frame].origin.y + [_headerView frame].size.height;
tableFrame.size.height =
[messageView frame].origin.y - tableFrame.origin.y - composeIndicatorCompensation;
[tableController.view setFrame:tableFrame];
[_messageView frame].origin.y - tableFrame.origin.y - composeIndicatorCompensation;
[_tableController.view setFrame:tableFrame];
// Scroll to bottom
NSInteger lastSection = [tableController.tableView numberOfSections] - 1;
NSInteger lastSection = [_tableController.tableView numberOfSections] - 1;
if (lastSection >= 0) {
NSInteger lastRow = [tableController.tableView numberOfRowsInSection:lastSection] - 1;
NSInteger lastRow = [_tableController.tableView numberOfRowsInSection:lastSection] - 1;
if (lastRow >= 0) {
[tableController.tableView
[_tableController.tableView
scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:lastRow inSection:lastSection]
atScrollPosition:UITableViewScrollPositionBottom
animated:FALSE];
@ -562,7 +565,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
- (void)keyboardWillShow:(NSNotification *)notif {
NSTimeInterval duration = [[[notif userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
CGFloat composeIndicatorCompensation = composingVisible ? composeIndicatorView.frame.size.height : 0.0f;
CGFloat composeIndicatorCompensation = composingVisible ? _composeIndicatorView.frame.size.height : 0.0f;
[UIView animateWithDuration:duration
delay:0
@ -590,34 +593,34 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
float diff = (rect.size.height - gPos.y - endFrame.size.height);
if (diff > 0)
diff = 0;
CGRect chatFrame = [[self chatView] frame];
CGRect chatFrame = [_chatView frame];
chatFrame.size.height = viewFrame.size.height - chatFrame.origin.y + diff;
[[self chatView] setFrame:chatFrame];
[_chatView setFrame:chatFrame];
}
// Move header view
{
CGRect headerFrame = [headerView frame];
CGRect headerFrame = [_headerView frame];
headerFrame.origin.y = -headerFrame.size.height;
[headerView setFrame:headerFrame];
[headerView setAlpha:0.0];
[_headerView setFrame:headerFrame];
[_headerView setAlpha:0.0];
}
// Resize & Move table view
{
CGRect tableFrame = [tableController.view frame];
tableFrame.origin.y = [headerView frame].origin.y + [headerView frame].size.height;
CGRect tableFrame = [_tableController.view frame];
tableFrame.origin.y = [_headerView frame].origin.y + [_headerView frame].size.height;
tableFrame.size.height =
[messageView frame].origin.y - tableFrame.origin.y - composeIndicatorCompensation;
[tableController.view setFrame:tableFrame];
[_messageView frame].origin.y - tableFrame.origin.y - composeIndicatorCompensation;
[_tableController.view setFrame:tableFrame];
}
// Scroll
NSInteger lastSection = [tableController.tableView numberOfSections] - 1;
NSInteger lastSection = [_tableController.tableView numberOfSections] - 1;
if (lastSection >= 0) {
NSInteger lastRow = [tableController.tableView numberOfRowsInSection:lastSection] - 1;
NSInteger lastRow = [_tableController.tableView numberOfRowsInSection:lastSection] - 1;
if (lastRow >= 0) {
[tableController.tableView
[_tableController.tableView
scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:lastRow inSection:lastSection]
atScrollPosition:UITableViewScrollPositionBottom
animated:FALSE];

View file

@ -143,15 +143,6 @@ static void chatTable_free_chatrooms(void *data) {
}
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
// Detemine if it's in editing mode
if (self.editing) {
return UITableViewCellEditingStyleDelete;
}
return UITableViewCellEditingStyleNone;
}
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {

View file

@ -141,6 +141,7 @@
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
_messageText.userInteractionEnabled = !editing;
if (animated) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
@ -270,11 +271,13 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
- (void)layoutSubviews {
[super layoutSubviews];
if (message != nil) {
UITableView *tableView = VIEW(ChatConversationView).tableController.tableView;
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;
bubbleFrame.origin.x =
tableView.isEditing ? 0 : (is_outgoing ? self.frame.size.width - bubbleFrame.size.width : 0);
_bubbleView.frame = bubbleFrame;
}
}

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>
@ -12,18 +13,18 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="WTc-GF-a0y">
<rect key="frame" x="0.0" y="0.0" width="375" height="50"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="40"/>
<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" text="john.doe@linphone.org" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Bjy-H9-VyJ" userLabel="addressLabel">
<rect key="frame" x="0.0" y="30" width="375" height="20"/>
<rect key="frame" x="3" y="22" width="369" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="0.36862745099999999" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<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="0.0" y="0.0" width="375" height="30"/>
<rect key="frame" x="3" y="0.0" width="369" height="22"/>
<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"/>

View file

@ -50,15 +50,6 @@
_toggleSelectionButton.selected = (_selectedItems.count == 0);
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
// Detemine if it's in editing mode
if (self.editing) {
return UITableViewCellEditingStyleDelete;
}
return UITableViewCellEditingStyleNone;
}
#pragma mark -
- (void)accessoryForCell:(UITableViewCell *)cell atPath:(NSIndexPath *)indexPath {