Chat messages icons adjustements for auto-download off & imageDrawer

This commit is contained in:
Christophe Deschamps 2021-07-23 23:18:41 +02:00
parent daadc1023a
commit 77f096a38d
9 changed files with 41 additions and 32 deletions

View file

@ -361,7 +361,7 @@
</subviews>
<color key="backgroundColor" red="0.93333333330000001" green="0.93333333330000001" blue="0.93333333330000001" alpha="1" colorSpace="calibratedRGB"/>
</view>
<view clipsSubviews="YES" alpha="0.90000000000000002" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3qd-ys-t2L" userLabel="imagesView">
<view clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3qd-ys-t2L" userLabel="imagesView">
<rect key="frame" x="0.0" y="625" width="414" height="0.0"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<subviews>

View file

@ -49,7 +49,7 @@
@interface ChatConversationView
: TPMultiLayoutViewController <HPGrowingTextViewDelegate, UICompositeViewDelegate, ImagePickerDelegate, ChatConversationDelegate,
UIDocumentInteractionControllerDelegate, UISearchBarDelegate, UIImageViewDeletableDelegate,QLPreviewControllerDelegate, UICollectionViewDataSource,UIDocumentMenuDelegate,UIDocumentPickerDelegate,UITableViewDataSource, UITableViewDelegate> {
UIDocumentInteractionControllerDelegate, UISearchBarDelegate, UIImageViewDeletableDelegate,QLPreviewControllerDelegate, UICollectionViewDataSource,UICollectionViewDelegate,UIDocumentMenuDelegate,UIDocumentPickerDelegate,UITableViewDataSource, UITableViewDelegate> {
OrderedDictionary *imageQualities;
BOOL scrollOnGrowingEnabled;
BOOL composingVisible;

View file

@ -187,6 +187,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[_tableController setChatRoomDelegate:self];
[_imagesCollectionView registerClass:[UIImageViewDeletable class] forCellWithReuseIdentifier:NSStringFromClass([UIImageViewDeletable class])];
[_imagesCollectionView setDataSource:self];
[_imagesCollectionView setDelegate:self];
[_toggleSelectionButton setImage:[UIImage imageNamed:@"select_all_default.png"] forState:UIControlStateSelected];
_vrInnerView.layer.cornerRadius = 5.0f;
@ -250,12 +251,12 @@ static UICompositeViewDescription *compositeDescription = nil;
animations:^{
// resizing imagesView
CGRect imagesFrame = [_imagesView frame];
imagesFrame.origin.y = [_messageView frame].origin.y - 100;
imagesFrame.size.height = 100;
imagesFrame.origin.y = [_messageView frame].origin.y - 120;
imagesFrame.size.height = 120;
[_imagesView setFrame:imagesFrame];
// resizing chatTable
CGRect tableViewFrame = [_tableController.tableView frame];
tableViewFrame.size.height -= 100;
tableViewFrame.size.height -= 120;
[_tableController.tableView setFrame:tableViewFrame];
[self updateFramesInclRecordingView];
}
@ -1452,14 +1453,19 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog
return [_fileContext count];
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? CGSizeMake(60, 60) : CGSizeMake(120, 120);
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UIImageViewDeletable *imgView = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([UIImageViewDeletable class]) forIndexPath:indexPath];
CGRect imgFrame = imgView.frame;
imgFrame.origin.y = 5;
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
imgFrame.size.height = 50;
imgFrame.size.height = 60;
} else {
imgFrame.size.height = 100;
imgFrame.size.height = 120;
}
[imgView.image setImage:[UIImage resizeImage:[_fileContext.previewsArray objectAtIndex:[indexPath item]] withMaxWidth:imgFrame.size.width andMaxHeight:imgFrame.size.height]];
@ -1471,7 +1477,7 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog
}
- (void)refreshImageDrawer {
int heightDiff = UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? 55 : 105;
int heightDiff = UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) ? 65 : 125;
if ([_fileContext count] == 0) {
[UIView animateWithDuration:0
@ -1560,7 +1566,7 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog
NSFileCoordinator *co =[[NSFileCoordinator alloc] init];
NSError *error = nil;
[co coordinateReadingItemAtURL:url options:0 error:&error byAccessor:^(NSURL * _Nonnull newURL) {
UIImage *image = [ChatConversationView drawText:[newURL lastPathComponent] image:[ChatConversationView getBasicImage] textSize:10];
UIImage *image = [UIChatBubbleTextCell getImageFromFileName:[newURL lastPathComponent]];
[_fileContext addObject:[NSData dataWithContentsOfURL:newURL] name:[newURL lastPathComponent] type:@"file" image:image];
[self refreshImageDrawer];
}];

@ -1 +0,0 @@
Subproject commit 99ae001ae51f4883d189e3f77544828ec035395d

View file

@ -268,10 +268,15 @@
_playButton.hidden = YES;
_fileName.hidden = _fileView.hidden = _fileButton.hidden =YES;
} else {
_downloadButton.hidden = NO;
_downloadButton.hidden = YES;
UIChatContentView * contentView = [[UIChatContentView alloc] init];
[contentView setContent:fileContent message:self.message];
contentView.position = 0;
[_contentViews addObject:contentView];
_cancelButton.hidden = _fileTransferProgress.hidden = YES;
_playButton.hidden = YES;
_fileName.hidden = _fileView.hidden = _fileButton.hidden = YES;
[self layoutSubviews];
}
return;
}

View file

@ -635,10 +635,10 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 44;
NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:chat];
NSString *localVideo = [LinphoneManager getMessageAppDataForKey:@"localvideo" inMessage:chat];
NSString *filePath = [LinphoneManager getMessageAppDataForKey:@"encryptedfile" inMessage:chat];
NSString *fileName = [NSString stringWithUTF8String:linphone_content_get_name(fileContent)];
NSString *fileName = fileContent ? [NSString stringWithUTF8String:linphone_content_get_name(fileContent)] : nil;
CGSize textSize = CGSizeMake(0, 0);
if (![messageText isEqualToString:@"🗻"]) {
if (![messageText isEqualToString:@"🗻"] && messageText.length > 0) {
textSize = [self computeBoundingBox:messageText
size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX)
font:messageFont];
@ -677,7 +677,7 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 44;
} else {
if (!localImage && !localVideo) {
//We are loading the image
CGSize baseSize = CGSizeMake(CELL_MIN_WIDTH + CELL_MESSAGE_X_MARGIN, CELL_MIN_HEIGHT + CELL_MESSAGE_Y_MARGIN + textSize.height + 20);
CGSize baseSize = CGSizeMake(120 + CELL_MESSAGE_X_MARGIN, 120 + CELL_MESSAGE_Y_MARGIN + textSize.height + (textSize.height != 0 ? 20 : 0));
if (voiceContent) {
baseSize = [self addVoicePlayerToSize:baseSize withMargins:true];
}

View file

@ -31,19 +31,20 @@
if(!linphone_chat_message_is_outgoing(_message) && linphone_content_is_file_transfer(_content)) {
// has not yet downloaded
UIImage *basicImage = [ChatConversationView getBasicImage];
NSString *name = [NSString stringWithUTF8String:linphone_content_get_name(content)] ;
UIImage *image = [ChatConversationView drawText:name image:basicImage textSize:25];
UIImage *image = [UIChatBubbleTextCell getImageFromFileName:name];
[self setImage:image];
_downloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_downloadButton addTarget:self
action:@selector(onDownloadClick:)
forControlEvents:UIControlEventTouchUpInside];
_downloadButton.backgroundColor = [UIColor orangeColor];
UIFont *boldFont = [UIFont systemFontOfSize:10];
NSMutableAttributedString *boldText = [[NSMutableAttributedString alloc] initWithString:@"Download" attributes:@{ NSFontAttributeName : boldFont }];
UIFont *boldFont = [UIFont systemFontOfSize:12];
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = NSTextAlignmentCenter;
NSMutableAttributedString *boldText = [[NSMutableAttributedString alloc] initWithString:@"Download" attributes:@{ NSFontAttributeName : boldFont, NSParagraphStyleAttributeName:paragraphStyle,NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle) }];
[_downloadButton setAttributedTitle:boldText forState:UIControlStateNormal];
_downloadButton.frame = CGRectMake(3, 3, 60, 30);
_downloadButton.frame = CGRectMake(0, 90, 120, 30);
[self addSubview:_downloadButton];
} else {
if (_filePath == NULL) {

View file

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -17,15 +15,15 @@
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="50" height="100"/>
<rect key="frame" x="0.0" y="0.0" width="120" height="120"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="y2f-LK-bVa">
<rect key="frame" x="0.0" y="0.0" width="50" height="100"/>
<rect key="frame" x="0.0" y="0.0" width="120" height="120"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J60-eT-n9R">
<rect key="frame" x="30" y="0.0" width="20" height="20"/>
<rect key="frame" x="100" y="0.0" width="20" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration">
<accessibilityTraits key="traits" button="YES" image="YES"/>
@ -36,15 +34,15 @@
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
<point key="canvasLocation" x="7" y="47"/>
</view>
</objects>
<resources>
<image name="delete_img.png" width="50" height="50"/>
<image name="delete_img.png" width="37.5" height="37.5"/>
</resources>
</document>

View file

@ -33,7 +33,7 @@ import UIKit
image.draw(in: CGRect(origin: CGPoint(x: size.width/2 - (image.size.width)/2,y: 15), size: image.size))
let rect = CGRect(origin: CGPoint(x: 0,y: 70), size: size)
let rect = CGRect(origin: CGPoint(x: 0,y: 70), size: CGSize(width: size.width, height: 30))
text.draw(in: rect, withAttributes: textFontAttributes)
let newImage = UIGraphicsGetImageFromCurrentImageContext()