diff --git a/Riot/ViewController/RoomViewController.m b/Riot/ViewController/RoomViewController.m index 004881301..b434af949 100644 --- a/Riot/ViewController/RoomViewController.m +++ b/Riot/ViewController/RoomViewController.m @@ -1227,11 +1227,8 @@ // Set the right room title view if (self.isRoomPreview) { - // Disable the right buttons - for (UIBarButtonItem *barButtonItem in self.navigationItem.rightBarButtonItems) - { - barButtonItem.enabled = NO; - } + // Do not show the right buttons + self.navigationItem.rightBarButtonItems = nil; [self showPreviewHeader:YES]; } @@ -1583,7 +1580,8 @@ { if (previewHeader) { - if (isLandscapeOriented) + if (isLandscapeOriented + && [GBDeviceInfo deviceInfo].family != GBDeviceFamilyiPad) { CGRect frame = self.navigationController.navigationBar.frame; @@ -1605,7 +1603,32 @@ { previewHeader.mainHeaderContainer.hidden = NO; previewHeader.mainHeaderBackgroundHeightConstraint.constant = previewHeader.mainHeaderContainer.frame.size.height; - + + if ([previewHeader isKindOfClass:PreviewRoomTitleView.class]) + { + // In case of preview, update the header height so that we can + // display as much as possible the room topic in this header. + // Note: the header height is handled by the previewHeader.mainHeaderBackgroundHeightConstraint. + PreviewRoomTitleView *previewRoomTitleView = (PreviewRoomTitleView *)previewHeader; + + // Compute the height required to display all the room topic + CGSize sizeThatFitsTextView = [previewRoomTitleView.roomTopic sizeThatFits:CGSizeMake(previewRoomTitleView.roomTopic.frame.size.width, MAXFLOAT)]; + + // Increase the preview header height according to the room topic height + // but limit it in order to let room for room messages at the screen bottom. + // This free space depends on the device. + // On an iphone 5 screen, the room topic height cannot be more than 50px. + // Then, on larger screen, we can allow it a bit more height but we + // apply a factor to give more priority to the display of more messages. + CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height; + CGFloat maxRoomTopicHeight = 50 + (screenHeight - 568) / 3; + + CGFloat additionalHeight = MIN(maxRoomTopicHeight, sizeThatFitsTextView.height) + - previewRoomTitleView.roomTopic.frame.size.height; + + previewHeader.mainHeaderBackgroundHeightConstraint.constant += additionalHeight; + } + [self setRoomTitleViewClass:RoomAvatarTitleView.class]; // Note the avatar title view does not define tap gesture. diff --git a/Riot/Views/RoomTitle/PreviewRoomTitleView.h b/Riot/Views/RoomTitle/PreviewRoomTitleView.h index 619fc90b7..79fdde1bb 100644 --- a/Riot/Views/RoomTitle/PreviewRoomTitleView.h +++ b/Riot/Views/RoomTitle/PreviewRoomTitleView.h @@ -24,7 +24,7 @@ @property (weak, nonatomic) IBOutlet UIView *mainHeaderContainer; @property (weak, nonatomic) IBOutlet MXKImageView *roomAvatar; -@property (weak, nonatomic) IBOutlet UILabel *roomTopic; +@property (weak, nonatomic) IBOutlet UITextView *roomTopic; @property (weak, nonatomic) IBOutlet UILabel *roomMembers; @property (weak, nonatomic) IBOutlet UIView *roomMembersDetailsIcon; diff --git a/Riot/Views/RoomTitle/PreviewRoomTitleView.m b/Riot/Views/RoomTitle/PreviewRoomTitleView.m index 1e8888d46..6281e750e 100644 --- a/Riot/Views/RoomTitle/PreviewRoomTitleView.m +++ b/Riot/Views/RoomTitle/PreviewRoomTitleView.m @@ -67,7 +67,6 @@ self.displayNameTextField.textColor = (self.mxRoom.summary.displayname.length ? kRiotPrimaryTextColor : kRiotSecondaryTextColor); self.roomTopic.textColor = kRiotTopicTextColor; - self.roomTopic.numberOfLines = 0; self.roomMembers.textColor = kRiotColorGreen; @@ -106,6 +105,10 @@ // Room topic self.roomTopic.text = self.roomPreviewData.roomTopic; + + [UIView setAnimationsEnabled:NO]; + [self.roomTopic scrollRangeToVisible:NSMakeRange(0, 0)]; + [UIView setAnimationsEnabled:YES]; // Joined members count if (self.roomPreviewData.numJoinedMembers > 1) @@ -148,6 +151,14 @@ { roomName = NSLocalizedStringFromTable(@"room_preview_try_join_an_unknown_room_default", @"Vector", nil); } + else if (roomName.length > 20) + { + // Would have been nice to get the cropped string displayed by + // self.displayNameTextField but the value is not accessible. + // Cut it off by hand + roomName = [NSString stringWithFormat:@"%@…",[roomName substringToIndex:20]]; + } + self.previewLabel.text = [NSString stringWithFormat:NSLocalizedStringFromTable(@"room_preview_try_join_an_unknown_room", @"Vector", nil), roomName]; } } diff --git a/Riot/Views/RoomTitle/PreviewRoomTitleView.xib b/Riot/Views/RoomTitle/PreviewRoomTitleView.xib index 2cb75c155..31fcca273 100644 --- a/Riot/Views/RoomTitle/PreviewRoomTitleView.xib +++ b/Riot/Views/RoomTitle/PreviewRoomTitleView.xib @@ -1,11 +1,11 @@ - + - + @@ -47,22 +47,22 @@ - -