Chat: gain some space when keyboard is shown

This commit is contained in:
Gautier Pelloux-Prayer 2015-10-28 15:32:36 +01:00
parent f9e82efd6b
commit 6fcc4c0a32
5 changed files with 69 additions and 74 deletions

View file

@ -102,7 +102,7 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="9" userLabel="callView">
<rect key="frame" x="0.0" y="0.0" width="375" height="499.00000044381898"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="499.0000006711665"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" tag="7" contentMode="scaleAspectFit" image="avatar.png" id="fZy-K5-yQp" userLabel="avatarImage" customClass="UIRoundedImageView">
@ -114,16 +114,16 @@
</accessibility>
</imageView>
<view alpha="0.0" contentMode="scaleToFill" id="126" userLabel="video">
<rect key="frame" x="0.0" y="0.0" width="375" height="499.00000044381898"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="499.0000006711665"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" id="173" userLabel="background">
<rect key="frame" x="0.0" y="0.0" width="375" height="499.00000044381898"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="499.0000006711665"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" id="132" userLabel="display">
<rect key="frame" x="0.0" y="0.0" width="375" height="499.00000044381898"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="499.0000006711665"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<accessibility key="accessibilityConfiguration">
@ -131,7 +131,7 @@
</accessibility>
</view>
<view contentMode="scaleAspectFit" id="127" userLabel="preview">
<rect key="frame" x="254" y="352" width="113" height="139.00000012564325"/>
<rect key="frame" x="254.00000029960563" y="352" width="113" height="139.00000019000436"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMinY="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
@ -174,8 +174,8 @@
<nil key="highlightedColor"/>
</label>
<view hidden="YES" alpha="0.80000000000000004" contentMode="scaleToFill" id="0MR-ml-8RY" userLabel="pausedByRemoteView">
<rect key="frame" x="0.0" y="0.0" width="375" height="503"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="503.0000006711665"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="waiting_time.png" id="DH6-pH-W9j" userLabel="pausedImage">
<rect key="frame" x="0.0" y="200" width="375" height="71"/>

View file

@ -11,14 +11,17 @@
<outlet property="backButton" destination="9" id="9Pw-ZA-KcF"/>
<outlet property="backToCallButton" destination="Hc0-GX-fC5" id="pYe-gN-Z64"/>
<outlet property="callButton" destination="Wzg-i0-spp" id="w9L-aT-1AD"/>
<outlet property="chatView" destination="bJF-qS-vBP" id="AF2-NN-muZ"/>
<outlet property="chatView" destination="49" id="Rxt-Zy-19x"/>
<outlet property="composeIndicatorView" destination="fx4-ao-53M" id="xk5-nK-lur"/>
<outlet property="composeLabel" destination="fpY-Fv-ht2" id="4L6-ik-ZAe"/>
<outlet property="listSwipeGestureRecognizer" destination="dzw-n4-l9i" id="JVP-Vl-lIa"/>
<outlet property="listTapGestureRecognizer" destination="tkk-Tm-A7C" id="gqU-iJ-RGm"/>
<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"/>
<outlet property="sendButton" destination="15" id="27"/>
<outlet property="tableController" destination="29" id="32"/>
<outlet property="topBar" destination="7" id="JH8-F4-Bdq"/>
<outlet property="view" destination="6" id="11"/>
</connections>
</placeholder>
@ -151,38 +154,34 @@
<rect key="frame" x="0.0" y="40" width="375" height="519"/>
<autoresizingMask key="autoresizingMask" widthSizable="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="453"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
<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/>
<connections>
<outlet property="dataSource" destination="29" id="6U9-NJ-Z7W"/>
<outlet property="delegate" destination="29" id="8Lv-aI-a0V"/>
<outletCollection property="gestureRecognizers" destination="dzw-n4-l9i" appends="YES" id="ba4-aY-7EA"/>
<outletCollection property="gestureRecognizers" destination="tkk-Tm-A7C" appends="YES" id="rxU-cr-Kav"/>
</connections>
</tableView>
<view contentMode="scaleToFill" id="fx4-ao-53M" userLabel="composeIndicatorView">
<rect key="frame" x="0.0" y="430" width="375" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
<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"/>
<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="375" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<connections>
<outlet property="dataSource" destination="29" id="6U9-NJ-Z7W"/>
<outlet property="delegate" destination="29" id="8Lv-aI-a0V"/>
</connections>
</tableView>
<view contentMode="scaleToFill" id="fx4-ao-53M" userLabel="composeIndicatorView">
<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">
<rect key="frame" x="0.0" y="1" width="375" 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>
<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>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No conversation." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="p7C-WH-uR1" userLabel="emptyTableLabel">
<rect key="frame" x="0.0" y="33" width="375" height="453"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="453"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
@ -259,6 +258,16 @@
</connections>
<point key="canvasLocation" x="639" y="328"/>
</tableViewController>
<swipeGestureRecognizer direction="right" id="dzw-n4-l9i">
<connections>
<action selector="onListSwipe:" destination="-1" id="bd8-v2-u8H"/>
</connections>
</swipeGestureRecognizer>
<tapGestureRecognizer enabled="NO" id="tkk-Tm-A7C">
<connections>
<action selector="onListTap:" destination="-1" id="ejK-2Q-qkC"/>
</connections>
</tapGestureRecognizer>
</objects>
<resources>
<image name="back_default.png" width="24" height="21"/>

View file

@ -38,11 +38,10 @@
}
@property(nonatomic, strong) IBOutlet ChatConversationTableView *tableController;
@property(nonatomic, strong) IBOutlet UIToggleButton *editButton;
@property(weak, nonatomic) IBOutlet UITextView *messageField;
@property(weak, nonatomic) IBOutlet UIView *topBar;
@property(nonatomic, strong) IBOutlet UIButton *sendButton;
@property(nonatomic, strong) IBOutlet UILabel *addressLabel;
@property(nonatomic, strong) IBOutlet UIView *headerView;
@property(nonatomic, strong) IBOutlet UIView *chatView;
@property(nonatomic, strong) IBOutlet UIView *messageView;
@property(nonatomic, strong) IBOutlet UITapGestureRecognizer *listTapGestureRecognizer;

View file

@ -32,9 +32,6 @@
if (self != nil) {
scrollOnGrowingEnabled = TRUE;
chatRoom = NULL;
_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),
[NSNumber numberWithFloat:0.5], NSLocalizedString(@"Average", nil),
@ -74,13 +71,6 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewDidLoad {
[super viewDidLoad];
[_tableController setChatRoomDelegate:self];
[_tableController.tableView addGestureRecognizer:_listTapGestureRecognizer];
[_listTapGestureRecognizer setEnabled:FALSE];
_listSwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[_tableController.tableView addGestureRecognizer:_listSwipeGestureRecognizer];
_listSwipeGestureRecognizer.enabled = TRUE;
}
- (void)viewWillAppear:(BOOL)animated {
@ -114,9 +104,9 @@ static UICompositeViewDescription *compositeDescription = nil;
name:kLinphoneCallUpdate
object:nil];
if ([_tableController isEditing])
[_tableController setEditing:FALSE animated:FALSE];
[_editButton setOff];
if (_tableController.isEditing) {
[_tableController setEditing:NO];
}
[[_tableController tableView] reloadData];
BOOL fileSharingEnabled = linphone_core_get_file_transfer_server([LinphoneManager getLc]) != NULL;
@ -356,9 +346,8 @@ 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 (_tableController.isEditing) {
[_tableController setEditing:NO];
}
[_listTapGestureRecognizer setEnabled:TRUE];
return TRUE;
@ -534,25 +523,22 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
animations:^{
CGFloat composeIndicatorCompensation = composingVisible ? _composeIndicatorView.frame.size.height : 0.0f;
// Show TabBar and status bar and also top bar
[PhoneMainView.instance showTabBar:YES];
[PhoneMainView.instance showStatusBar:YES];
_topBar.alpha = 1.0;
// Resize chat view
{
CGRect chatFrame = [_chatView frame];
chatFrame.origin.y = _topBar.frame.origin.y + _topBar.frame.size.height;
chatFrame.size.height = [[self view] frame].size.height - chatFrame.origin.y;
[_chatView setFrame:chatFrame];
}
// Move header view back into place (was hidden before)
{
CGRect headerFrame = [_headerView frame];
headerFrame.origin.y = 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;
tableFrame.size.height =
[_messageView frame].origin.y - tableFrame.origin.y - composeIndicatorCompensation;
[_tableController.view setFrame:tableFrame];
@ -593,6 +579,11 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
endFrame.size.width = width;
}
// Hide TabBar and status bar and also top bar
[PhoneMainView.instance showTabBar:NO];
[PhoneMainView.instance showStatusBar:NO];
_topBar.alpha = 0.0;
// Resize chat view
{
CGRect viewFrame = [[self view] frame];
@ -606,22 +597,14 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
if (diff > 0)
diff = 0;
CGRect chatFrame = [_chatView frame];
chatFrame.origin.y = 0;
chatFrame.size.height = viewFrame.size.height - chatFrame.origin.y + diff;
[_chatView setFrame:chatFrame];
}
// Move header view
{
CGRect headerFrame = [_headerView frame];
headerFrame.origin.y = -headerFrame.size.height;
[_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.size.height =
[_messageView frame].origin.y - tableFrame.origin.y - composeIndicatorCompensation;
[_tableController.view setFrame:tableFrame];

View file

@ -312,11 +312,15 @@
cancelMessage:NSLocalizedString(@"DENY", nil)
confirmMessage:NSLocalizedString(@"ACCEPT", nil)
onCancelClick:^() {
linphone_call_set_authentication_token_verified(call, NO);
if (linphone_core_get_current_call([LinphoneManager getLc]) == call) {
linphone_call_set_authentication_token_verified(call, NO);
}
weakSelf->securityDialog = nil;
}
onConfirmationClick:^() {
linphone_call_set_authentication_token_verified(call, !valid);
if (linphone_core_get_current_call([LinphoneManager getLc]) == call) {
linphone_call_set_authentication_token_verified(call, !valid);
}
weakSelf->securityDialog = nil;
}];
}