forked from mirrors/linphone-iphone
Better placement for "User is composing" in the ChatRoomView
This commit is contained in:
parent
d215dd91ef
commit
bf7af8ccfa
4 changed files with 48 additions and 28 deletions
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1072" identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
@ -11,6 +10,7 @@
|
|||
<outlet property="avatarImage" destination="41" id="44"/>
|
||||
<outlet property="cancelTransferButton" destination="75" id="85"/>
|
||||
<outlet property="chatView" destination="49" id="54"/>
|
||||
<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="headerView" destination="39" id="45"/>
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="8" userLabel="tableView">
|
||||
<rect key="frame" x="0.0" y="80" width="320" height="279"/>
|
||||
<rect key="frame" x="0.0" y="80" width="320" height="257"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<gestureRecognizers/>
|
||||
|
|
@ -75,13 +75,20 @@
|
|||
<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"/>
|
||||
<view contentMode="scaleToFill" id="fx4-ao-53M" userLabel="composeIndicatorView">
|
||||
<rect key="frame" x="0.0" y="337" width="320" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<accessibility key="accessibilityConfiguration" label=""/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<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">
|
||||
<rect key="frame" x="0.0" y="1" width="320" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<accessibility key="accessibilityConfiguration" label=""/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<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"/>
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
@property (nonatomic, retain) IBOutlet UIImageView *transferBackgroundImage;
|
||||
@property (nonatomic, retain) IBOutlet UITapGestureRecognizer *listTapGestureRecognizer;
|
||||
@property (retain, nonatomic) IBOutlet UILabel *composeLabel;
|
||||
@property (retain, nonatomic) IBOutlet UIView *composeIndicatorView;
|
||||
|
||||
@property (nonatomic, copy) NSString *remoteAddress;
|
||||
@property (nonatomic, retain) IBOutlet UIButton* pictureButton;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
@synthesize remoteAddress;
|
||||
@synthesize addressLabel;
|
||||
@synthesize composeLabel;
|
||||
@synthesize composeIndicatorView;
|
||||
@synthesize avatarImage;
|
||||
@synthesize headerView;
|
||||
@synthesize chatView;
|
||||
|
|
@ -90,6 +91,7 @@
|
|||
[waitView release];
|
||||
|
||||
[composeLabel release];
|
||||
[composeIndicatorView release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +179,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[tableController setEditing:FALSE animated:FALSE];
|
||||
[editButton setOff];
|
||||
[[tableController tableView] reloadData];
|
||||
|
||||
|
||||
[messageBackgroundImage setImage:[TUNinePatchCache imageOfSize:[messageBackgroundImage bounds].size
|
||||
forNinePatchNamed:@"chat_message_background"]];
|
||||
|
||||
|
|
@ -201,7 +203,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
chatRoom = NULL;
|
||||
}
|
||||
|
||||
[composeLabel setHidden:TRUE];
|
||||
[self setComposingVisible:FALSE withDelay:0]; // will hide the "user is composing.." message
|
||||
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:UIApplicationDidBecomeActiveNotification
|
||||
|
|
@ -264,16 +266,11 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
[messageField setText:@""];
|
||||
|
||||
if( chatRoom != NULL ){
|
||||
linphone_chat_room_destroy(chatRoom);
|
||||
chatRoom = NULL;
|
||||
}
|
||||
|
||||
chatRoom = linphone_core_get_or_create_chat_room([LinphoneManager getLc], [remoteAddress cStringUsingEncoding:[NSString defaultCStringEncoding]]);
|
||||
[self update];
|
||||
[tableController setRemoteAddress: remoteAddress];
|
||||
[ChatModel readConversation:remoteAddress];
|
||||
[self checkComposeForRoom:chatRoom];
|
||||
[self setComposingVisible:linphone_chat_room_is_remote_composing(chatRoom) withDelay:0];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneTextReceived object:self];
|
||||
}
|
||||
|
||||
|
|
@ -442,19 +439,30 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
|
|||
});
|
||||
}
|
||||
|
||||
- (void)checkComposeForRoom:(LinphoneChatRoom*)room {
|
||||
if( room && room == chatRoom ){
|
||||
BOOL composing = linphone_chat_room_is_remote_composing(room);
|
||||
- (void)setComposingVisible:(BOOL)visible withDelay:(CGFloat)delay {
|
||||
CGRect keyboardFrame = [self.messageView frame];
|
||||
CGRect newComposingFrame = [self.composeIndicatorView frame];
|
||||
CGRect newTableFrame = [self.tableController.tableView frame];
|
||||
|
||||
if( composing ){
|
||||
[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]; }];
|
||||
}
|
||||
if( visible ){
|
||||
[composeLabel setText:[NSString stringWithFormat:NSLocalizedString(@"%@ is composing...", @""), [addressLabel text]]];
|
||||
// pull up the composing frame and shrink the table view
|
||||
|
||||
newTableFrame.size.height -= newComposingFrame.size.height;
|
||||
newComposingFrame.origin.y = keyboardFrame.origin.y - newComposingFrame.size.height;
|
||||
} else {
|
||||
// pull down the composing frame and widen the tableview
|
||||
newTableFrame.size.height += newComposingFrame.size.height;
|
||||
newComposingFrame.origin.y = keyboardFrame.origin.y;
|
||||
}
|
||||
[UIView animateWithDuration:delay
|
||||
animations:^{
|
||||
self.tableController.tableView.frame = newTableFrame;
|
||||
self.composeIndicatorView.frame = newComposingFrame;
|
||||
} completion:^(BOOL finished) {
|
||||
[self.tableController scrollToBottom:TRUE];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -494,7 +502,10 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
|
|||
|
||||
- (void)textComposeEvent:(NSNotification*)notif {
|
||||
LinphoneChatRoom* room = [[[notif userInfo] objectForKey:@"room"] pointerValue];
|
||||
[self checkComposeForRoom:room];
|
||||
if( room && room == chatRoom ){
|
||||
BOOL composing = linphone_chat_room_is_remote_composing(room);
|
||||
[self setComposingVisible:composing withDelay:0.3];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UITextFieldDelegate Functions
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ extern NSString *const kLinphoneAddressBookUpdate;
|
|||
extern NSString *const kLinphoneLogsUpdate;
|
||||
extern NSString *const kLinphoneSettingsUpdate;
|
||||
extern NSString *const kLinphoneBluetoothAvailabilityUpdate;
|
||||
extern NSString *const kLinphoneConfiguringStateUpdate;
|
||||
|
||||
typedef enum _NetworkType {
|
||||
network_none = 0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue