mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-30 17:59:21 +00:00
Enable remote typing indicator in the ChatRoom view
This commit is contained in:
parent
19b54bad8c
commit
b17d5a2d46
10 changed files with 91 additions and 14 deletions
|
|
@ -11,6 +11,7 @@
|
|||
<outlet property="avatarImage" destination="41" id="44"/>
|
||||
<outlet property="cancelTransferButton" destination="75" id="85"/>
|
||||
<outlet property="chatView" destination="49" id="54"/>
|
||||
<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="imageTransferProgressBar" destination="74" id="79"/>
|
||||
|
|
@ -74,6 +75,13 @@
|
|||
<outlet property="delegate" destination="29" id="31"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<label hidden="YES" opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="%@ is composing..." textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="10" id="fpY-Fv-ht2" userLabel="composeLabel">
|
||||
<rect key="frame" x="0.0" y="338" width="320" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<accessibility key="accessibilityConfiguration" label=""/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view hidden="YES" contentMode="scaleToFill" id="72" userLabel="transferView">
|
||||
<rect key="frame" x="0.0" y="359" width="320" height="57"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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...";
|
||||
"Enter an address" = "Entrez une addresse SIP ou un numéro de téléphone...";
|
||||
"%@ is composing..." = "%@ rédige un message...";
|
||||
"Resend" = "Renvoyer";
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue