diff --git a/Classes/Base.lproj/ChatRoomViewController.xib b/Classes/Base.lproj/ChatRoomViewController.xib
index 2f74f7e72..0bf82fefd 100644
--- a/Classes/Base.lproj/ChatRoomViewController.xib
+++ b/Classes/Base.lproj/ChatRoomViewController.xib
@@ -11,6 +11,7 @@
+
@@ -74,6 +75,13 @@
+
diff --git a/Classes/ChatRoomViewController.h b/Classes/ChatRoomViewController.h
index 4f45e8982..a5b21685c 100644
--- a/Classes/ChatRoomViewController.h
+++ b/Classes/ChatRoomViewController.h
@@ -49,6 +49,7 @@
@property (nonatomic, retain) IBOutlet UIImageView *messageBackgroundImage;
@property (nonatomic, retain) IBOutlet UIImageView *transferBackgroundImage;
@property (nonatomic, retain) IBOutlet UITapGestureRecognizer *listTapGestureRecognizer;
+@property (retain, nonatomic) IBOutlet UILabel *composeLabel;
@property (nonatomic, copy) NSString *remoteAddress;
@property (nonatomic, retain) IBOutlet UIButton* pictureButton;
diff --git a/Classes/ChatRoomViewController.m b/Classes/ChatRoomViewController.m
index dc5f1841c..4d83d98d0 100644
--- a/Classes/ChatRoomViewController.m
+++ b/Classes/ChatRoomViewController.m
@@ -34,6 +34,7 @@
@synthesize editButton;
@synthesize remoteAddress;
@synthesize addressLabel;
+@synthesize composeLabel;
@synthesize avatarImage;
@synthesize headerView;
@synthesize chatView;
@@ -88,6 +89,7 @@
[imageQualities release];
[waitView release];
+ [composeLabel release];
[super dealloc];
}
@@ -163,7 +165,10 @@ static UICompositeViewDescription *compositeDescription = nil;
selector:@selector(onMessageChange:)
name:UITextViewTextDidChangeNotification
object:nil];
-
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(textComposeEvent:)
+ name:kLinphoneTextComposeEvent
+ object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(coreUpdateEvent:)
name:kLinphoneCoreUpdate
@@ -195,6 +200,9 @@ static UICompositeViewDescription *compositeDescription = nil;
linphone_chat_room_destroy(chatRoom);
chatRoom = NULL;
}
+
+ [composeLabel setHidden:TRUE];
+
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIApplicationDidBecomeActiveNotification
object:nil];
@@ -214,6 +222,9 @@ static UICompositeViewDescription *compositeDescription = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self
name:kLinphoneCoreUpdate
object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:kLinphoneTextComposeEvent
+ object:nil];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
@@ -458,6 +469,27 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
}
}
+- (void)textComposeEvent:(NSNotification*)notif {
+ LinphoneChatRoom* room = [[[notif userInfo] objectForKey:@"room"] pointerValue];
+ if( room ){
+ const LinphoneAddress* remote_peer = linphone_chat_room_get_peer_address(room);
+ LinphoneAddress* current_peer= linphone_address_new([remoteAddress cStringUsingEncoding:[NSString defaultCStringEncoding]]);
+
+ BOOL composing = linphone_chat_room_is_remote_composing(room);
+
+ if( composing && linphone_address_weak_equal(remote_peer, current_peer) ){
+ [composeLabel setText:[NSString stringWithFormat:NSLocalizedString(@"%@ is composing...", @""), [addressLabel text]]];
+ [composeLabel setAlpha:0];
+ [composeLabel setHidden:FALSE];
+ [UIView animateWithDuration:0.3 animations:^{ composeLabel.alpha = 1.0; }];
+ } else {
+ [UIView animateWithDuration:0.3 animations:^{ composeLabel.alpha = 0.0; } completion:^(BOOL f) { [composeLabel setHidden:TRUE]; }];
+ }
+
+ linphone_address_destroy(current_peer);
+ }
+}
+
#pragma mark - UITextFieldDelegate Functions
@@ -475,6 +507,11 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
return TRUE;
}
+- (void)growingTextChanged:(HPGrowingTextView *)growingTextView text:(NSString *)text {
+ if( [text length] > 0 && chatRoom )
+ linphone_chat_room_compose(chatRoom);
+}
+
- (void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height {
int diff = height - growingTextView.bounds.size.height;
@@ -500,6 +537,12 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
[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];
+ frame.origin.y -= diff;
+ [composeLabel setFrame:frame];
+ }
}
}
diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h
index 3abc17c08..bc4829be8 100644
--- a/Classes/LinphoneManager.h
+++ b/Classes/LinphoneManager.h
@@ -39,6 +39,7 @@ extern const char *const LINPHONERC_APPLICATION_KEY;
extern NSString *const kLinphoneCoreUpdate;
extern NSString *const kLinphoneDisplayStatusUpdate;
extern NSString *const kLinphoneTextReceived;
+extern NSString *const kLinphoneTextComposeEvent;
extern NSString *const kLinphoneCallUpdate;
extern NSString *const kLinphoneRegistrationUpdate;
extern NSString *const kLinphoneMainViewChange;
diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m
index 52b6a0818..2f34d88a4 100644
--- a/Classes/LinphoneManager.m
+++ b/Classes/LinphoneManager.m
@@ -50,6 +50,7 @@ const char *const LINPHONERC_APPLICATION_KEY = "app";
NSString *const kLinphoneCoreUpdate = @"LinphoneCoreUpdate";
NSString *const kLinphoneDisplayStatusUpdate = @"LinphoneDisplayStatusUpdate";
NSString *const kLinphoneTextReceived = @"LinphoneTextReceived";
+NSString *const kLinphoneTextComposeEvent = @"LinphoneTextComposeStarted";
NSString *const kLinphoneCallUpdate = @"LinphoneCallUpdate";
NSString *const kLinphoneRegistrationUpdate = @"LinphoneRegistrationUpdate";
NSString *const kLinphoneAddressBookUpdate = @"LinphoneAddressBookUpdate";
@@ -672,6 +673,19 @@ static void linphone_iphone_message_received(LinphoneCore *lc, LinphoneChatRoom
[(LinphoneManager*)linphone_core_get_user_data(lc) onMessageReceived:lc room:room message:message];
}
+#pragma mark - Message composition start
+
+- (void)onMessageComposeReceived:(LinphoneCore*)core forRoom:(LinphoneChatRoom*)room {
+ [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneTextComposeEvent
+ object:self
+ userInfo:@{@"room":[NSValue valueWithPointer:room]}];
+}
+
+static void linphone_iphone_is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room){
+ [(LinphoneManager*)linphone_core_get_user_data(lc) onMessageComposeReceived:lc forRoom:room];
+}
+
+
#pragma mark - Network Functions
@@ -825,7 +839,8 @@ static LinphoneCoreVTable linphonec_vtable = {
.text_received=NULL,
.message_received=linphone_iphone_message_received,
.dtmf_received=NULL,
- .transfer_state_changed=linphone_iphone_transfer_state_changed
+ .transfer_state_changed=linphone_iphone_transfer_state_changed,
+ .is_composing_received = linphone_iphone_is_composing_received
};
//scheduling loop
diff --git a/Classes/Utils/GrowingTextView/HPGrowingTextView.h b/Classes/Utils/GrowingTextView/HPGrowingTextView.h
index 0a8a250ed..c9238b69d 100755
--- a/Classes/Utils/GrowingTextView/HPGrowingTextView.h
+++ b/Classes/Utils/GrowingTextView/HPGrowingTextView.h
@@ -45,6 +45,8 @@
- (void)growingTextViewDidBeginEditing:(HPGrowingTextView *)growingTextView;
- (void)growingTextViewDidEndEditing:(HPGrowingTextView *)growingTextView;
+- (void)growingTextChanged:(HPGrowingTextView *)growingTextView text:(NSString*)text;
+
- (BOOL)growingTextView:(HPGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
- (void)growingTextViewDidChange:(HPGrowingTextView *)growingTextView;
diff --git a/Classes/Utils/GrowingTextView/HPGrowingTextView.m b/Classes/Utils/GrowingTextView/HPGrowingTextView.m
index 1a5166a83..6eec61c24 100755
--- a/Classes/Utils/GrowingTextView/HPGrowingTextView.m
+++ b/Classes/Utils/GrowingTextView/HPGrowingTextView.m
@@ -623,14 +623,17 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
replacementText:(NSString *)atext {
-
+
//weird 1 pixel bug when clicking backspace when textView is empty
if(![textView hasText] && [atext isEqualToString:@""]) return NO;
-
+
+ if( [delegate respondsToSelector:@selector(growingTextChanged:text:)])
+ [delegate growingTextChanged:self text:atext];
+
//Added by bretdabaker: sometimes we want to handle this ourselves
- if ([delegate respondsToSelector:@selector(growingTextView:shouldChangeTextInRange:replacementText:)])
- return [delegate growingTextView:self shouldChangeTextInRange:range replacementText:atext];
-
+ if ([delegate respondsToSelector:@selector(growingTextView:shouldChangeTextInRange:replacementText:)])
+ return [delegate growingTextView:self shouldChangeTextInRange:range replacementText:atext];
+
if ([atext isEqualToString:@"\n"]) {
if ([delegate respondsToSelector:@selector(growingTextViewShouldReturn:)]) {
if (![delegate performSelector:@selector(growingTextViewShouldReturn:) withObject:self]) {
@@ -641,10 +644,8 @@
}
}
}
-
+
return YES;
-
-
}
///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings
index 1af1a457f..da3e56166 100644
--- a/Resources/en.lproj/Localizable.strings
+++ b/Resources/en.lproj/Localizable.strings
@@ -1,4 +1,4 @@
-/* No comment provided by engineer. */
+/* No comment provided by engineer. */
" (Aborted)" = " (Aborted)";
/* No comment provided by engineer. */
@@ -300,3 +300,5 @@
/* Placeholder for the address in DialerView */
"Enter an address" = "Enter SIP address or phone number...";
+"%@ is composing..." = "%@ is composing...";
+"Resend" = "Resend";
diff --git a/Resources/fr.lproj/Localizable.strings b/Resources/fr.lproj/Localizable.strings
index 427d70d98..fd6db7002 100644
--- a/Resources/fr.lproj/Localizable.strings
+++ b/Resources/fr.lproj/Localizable.strings
@@ -1,4 +1,4 @@
-/* No comment provided by engineer. */
+/* No comment provided by engineer. */
" (Aborted)" = " (Annulé)";
/* No comment provided by engineer. */
@@ -299,4 +299,6 @@
"© 2010-2012 Belledonne Communications " = "© 2010-2012 Belledonne Communications ";
/* Placeholder for the address in DialerView */
-"Enter an address" = "Entrez une addresse SIP ou un numéro de téléphone...";
\ No newline at end of file
+"Enter an address" = "Entrez une addresse SIP ou un numéro de téléphone...";
+"%@ is composing..." = "%@ rédige un message...";
+"Resend" = "Renvoyer";
diff --git a/Resources/ru.lproj/Localizable.strings b/Resources/ru.lproj/Localizable.strings
index f6956f94b..e8b5c0d8e 100644
--- a/Resources/ru.lproj/Localizable.strings
+++ b/Resources/ru.lproj/Localizable.strings
@@ -1,4 +1,4 @@
-/* No comment provided by engineer. */
+/* No comment provided by engineer. */
" (Aborted)" = " (Прервано)";
/* No comment provided by engineer. */
@@ -300,3 +300,5 @@
/* Placeholder for the address in DialerView */
"Enter an address" = "Введите адрес SIP или номер телефона...";
+"%@ is composing..." = "%@ is composing...";
+"Resend" = "Resend";