mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Chat: fix chat photo width size and add debug code temporary (download button text is asset name)
This commit is contained in:
parent
2df2e4377a
commit
07a6dfe120
4 changed files with 25 additions and 23 deletions
|
|
@ -136,6 +136,14 @@
|
|||
_messageImageView.hidden = _cancelButton.hidden = (ftd.message == nil);
|
||||
_downloadButton.hidden = !_cancelButton.hidden;
|
||||
_fileTransferProgress.hidden = NO;
|
||||
|
||||
#if DEBUG
|
||||
const LinphoneContent *c = linphone_chat_message_get_file_transfer_information(self.message);
|
||||
if (c) {
|
||||
const char *name = linphone_content_get_name(c);
|
||||
[_downloadButton setTitle:[NSString stringWithUTF8String:name ?: "NULL"] forState:UIControlStateNormal];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// resize image so that it take the full bubble space available
|
||||
|
|
@ -234,14 +242,12 @@
|
|||
}
|
||||
|
||||
- (CGSize)viewSizeWithWidth:(int)width {
|
||||
static const CGFloat MARGIN_WIDTH = 60;
|
||||
static const CGFloat MARGIN_HEIGHT = 19 + 16 /*this 16 is because textview add some top&bottom padding*/;
|
||||
static const CGFloat IMAGE_HEIGHT = 100.0f;
|
||||
static const CGFloat IMAGE_WIDTH = 100.0f;
|
||||
|
||||
NSString *localImage = [LinphoneManager getMessageAppDataForKey:@"localimage" inMessage:self.message];
|
||||
|
||||
CGSize messageSize = (localImage != nil) ? CGSizeMake(IMAGE_WIDTH, IMAGE_HEIGHT) : CGSizeMake(50, 50);
|
||||
|
||||
CGSize dateSize = [self computeBoundingBox:self.contactDateLabel.text
|
||||
size:self.contactDateLabel.frame.size
|
||||
font:self.contactDateLabel.font];
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
<rect key="frame" x="48" y="24" width="266" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<imageView contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="splashscreen.png" id="yMW-cT-bpU" userLabel="image" customClass="UILoadingImageView">
|
||||
<imageView contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="linphone_logo.png" id="yMW-cT-bpU" userLabel="image" customClass="UILoadingImageView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="266" height="68"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<animations/>
|
||||
|
|
@ -157,6 +157,6 @@
|
|||
<image name="color_G.png" width="2" height="2"/>
|
||||
<image name="color_I.png" width="2" height="2"/>
|
||||
<image name="color_M.png" width="2" height="2"/>
|
||||
<image name="splashscreen.png" width="181" height="165"/>
|
||||
<image name="linphone_logo.png" width="26" height="22"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@
|
|||
#import "ChatConversationTableView.h"
|
||||
#import "UIRoundedImageView.h"
|
||||
|
||||
static const CGFloat TEXT_MIN_HEIGHT = 0.;
|
||||
static const CGFloat TEXT_MIN_WIDTH = 150.0f;
|
||||
static const CGFloat MARGIN_WIDTH = 60;
|
||||
static const CGFloat MARGIN_HEIGHT = 19 + 16 /*this 16 is because textview add some top&bottom padding*/;
|
||||
static const CGFloat CHECK_BOX_WIDTH = 40;
|
||||
|
||||
@interface UIChatBubbleTextCell : UITableViewCell
|
||||
|
||||
@property(readonly, nonatomic) LinphoneChatMessage *message;
|
||||
|
|
|
|||
|
|
@ -205,6 +205,9 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
|
|||
#pragma mark - Bubble size computing
|
||||
|
||||
- (CGSize)computeBoundingBox:(NSString *)text size:(CGSize)size font:(UIFont *)font {
|
||||
if (!text || text.length == 0)
|
||||
return CGSizeMake(0, 0);
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
|
||||
if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 7) {
|
||||
return [text boundingRectWithSize:size
|
||||
|
|
@ -220,28 +223,15 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st
|
|||
}
|
||||
|
||||
- (CGSize)viewSizeWithWidth:(int)width {
|
||||
static const CGFloat TEXT_MIN_HEIGHT = 0.;
|
||||
static const CGFloat TEXT_MIN_WIDTH = 150.0f;
|
||||
static const CGFloat MARGIN_WIDTH = 60;
|
||||
static const CGFloat MARGIN_HEIGHT = 19 + 16 /*this 16 is because textview add some top&bottom padding*/;
|
||||
static const CGFloat IMAGE_HEIGHT = 100.0f;
|
||||
static const CGFloat IMAGE_WIDTH = 100.0f;
|
||||
static const CGFloat CHECK_BOX_WIDTH = 40;
|
||||
|
||||
int messageAvailableWidth = width - MARGIN_WIDTH - CHECK_BOX_WIDTH;
|
||||
|
||||
const char *url = linphone_chat_message_get_external_body_url(_message);
|
||||
NSString *text = [UIChatBubbleTextCell TextMessageForChat:_message];
|
||||
|
||||
CGSize messageSize;
|
||||
if (url != nil || linphone_chat_message_get_file_transfer_information(_message) != NULL) {
|
||||
messageSize = CGSizeMake(IMAGE_WIDTH, IMAGE_HEIGHT);
|
||||
} else {
|
||||
messageSize =
|
||||
[self computeBoundingBox:text size:CGSizeMake(messageAvailableWidth, CGFLOAT_MAX) font:_messageText.font];
|
||||
messageSize.width = MAX(TEXT_MIN_WIDTH, ceil(messageSize.width));
|
||||
messageSize.height = MAX(TEXT_MIN_HEIGHT, ceil(messageSize.height));
|
||||
}
|
||||
CGSize messageSize =
|
||||
[self computeBoundingBox:text size:CGSizeMake(messageAvailableWidth, CGFLOAT_MAX) font:_messageText.font];
|
||||
messageSize.width = MAX(TEXT_MIN_WIDTH, ceil(messageSize.width));
|
||||
messageSize.height = MAX(TEXT_MIN_HEIGHT, ceil(messageSize.height));
|
||||
|
||||
CGSize dateSize =
|
||||
[self computeBoundingBox:_contactDateLabel.text size:_contactDateLabel.frame.size font:_contactDateLabel.font];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue