Fix resend in chat conversation

This commit is contained in:
Benjamin Reis 2017-11-14 15:54:34 +01:00
parent 1f8f4b00ff
commit 5c534def04
4 changed files with 55 additions and 65 deletions

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1217" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -20,17 +20,10 @@
<outlet property="imdmIcon" destination="WlS-fU-Aut" id="bYC-jb-Amo"/>
<outlet property="imdmLabel" destination="yKD-pC-Nhu" id="ge9-Yl-qsr"/>
<outlet property="messageText" destination="CYa-If-oB4" id="7xm-UF-1qB"/>
<outlet property="resendRecognizer" destination="OA2-9R-81Z" id="zVJ-IY-3yO"/>
<outlet property="statusErrorImage" destination="nLy-JO-TyL" id="ZkB-dR-cx2"/>
<outlet property="statusInProgressSpinner" destination="4Z8-PE-uPe" id="T9k-9x-DeB"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tapGestureRecognizer id="OA2-9R-81Z" userLabel="resendClick">
<connections>
<action selector="onResendClick:" destination="-1" id="l6k-1D-O4U"/>
</connections>
</tapGestureRecognizer>
<view contentMode="scaleToFill" misplaced="YES" id="ucH-2r-rar">
<rect key="frame" x="0.0" y="0.0" width="334" height="67"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
@ -59,11 +52,6 @@
<color key="textColor" red="0.98766469955444336" green="0.27512490749359131" blue="0.029739789664745331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="chat_message_not_delivered.png" id="nLy-JO-TyL" userLabel="statusErrorImage">
<rect key="frame" x="302" y="0.0" width="20" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Delivery failed"/>
</imageView>
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" animating="YES" style="gray" id="4Z8-PE-uPe" userLabel="statusInprogressSpinner">
<rect key="frame" x="302" y="0.0" width="20" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
@ -94,12 +82,11 @@
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" image="chat_read.png" id="WlS-fU-Aut" userLabel="imdmIcon">
<rect key="frame" x="306" y="42" width="13" height="13"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<accessibility key="accessibilityConfiguration" label="Delivery failed"/>
<accessibility key="accessibilityConfiguration" label="Delivery failed">
<accessibilityTraits key="traits" button="YES" image="YES"/>
</accessibility>
</imageView>
</subviews>
<connections>
<outletCollection property="gestureRecognizers" destination="OA2-9R-81Z" appends="YES" id="Phx-YZ-cwz"/>
</connections>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -110,14 +97,8 @@
</objects>
<resources>
<image name="avatar.png" width="259" height="259"/>
<image name="chat_message_not_delivered.png" width="11" height="10"/>
<image name="chat_read.png" width="24" height="24"/>
<image name="chat_unsecure.png" width="18" height="27"/>
<image name="color_A.png" width="2" height="2"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
</simulatedMetricsContainer>
</document>

View file

@ -172,7 +172,7 @@
} else if (_cancelButton.hidden == NO) {
[self onCancelClick:event];
} else {
[super onResendClick:event];
[super onResend];
}
}

View file

@ -29,7 +29,6 @@
@property(nonatomic, weak) IBOutlet UIImageView *backgroundColorImage;
@property(nonatomic, weak) IBOutlet UIRoundedImageView *avatarImage;
@property(nonatomic, weak) IBOutlet UILabel *contactDateLabel;
@property(nonatomic, weak) IBOutlet UIImageView *statusErrorImage;
@property(weak, nonatomic) IBOutlet UIActivityIndicatorView *statusInProgressSpinner;
@property(nonatomic, weak) IBOutlet UITextViewNoDefine *messageText;
@property(weak, nonatomic) IBOutlet UIImageView *bottomBarColor;
@ -44,8 +43,9 @@
- (void)setChatMessage:(LinphoneChatMessage *)message;
- (IBAction)onDeleteClick:(id)event;
- (IBAction)onResendClick:(id)event;
- (void)onDelete;
- (void)onResend;
- (void)onLime;
- (void)update;
- (void)displayImdmStatus:(LinphoneChatMessageState)state;

View file

@ -40,6 +40,21 @@
[self addSubview:sub];
}
}
UITapGestureRecognizer *limeRecognizer =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onLime)];
limeRecognizer.numberOfTapsRequired = 1;
[_LIMEKO addGestureRecognizer:limeRecognizer];
_LIMEKO.userInteractionEnabled = YES;
UITapGestureRecognizer *resendRecognizer =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onResend)];
resendRecognizer.numberOfTapsRequired = 1;
[_imdmIcon addGestureRecognizer:resendRecognizer];
_imdmIcon.userInteractionEnabled = YES;
[_imdmLabel addGestureRecognizer:resendRecognizer];
_imdmLabel.userInteractionEnabled = YES;
return self;
}
@ -135,13 +150,10 @@
_contactDateLabel.textColor = [UIColor colorWithPatternImage:_backgroundColorImage.image];
if (outgoing && state == LinphoneChatMessageStateInProgress) {
_statusErrorImage.hidden = YES;
[_statusInProgressSpinner startAnimating];
} else if (!outgoing && state == LinphoneChatMessageStateFileTransferError) {
_statusErrorImage.hidden = NO;
[_statusInProgressSpinner stopAnimating];
} else {
_statusErrorImage.hidden = YES;
[_statusInProgressSpinner stopAnimating];
}
@ -195,7 +207,7 @@
#pragma mark - Action Functions
- (IBAction)onDeleteClick:(id)event {
- (void)onDelete {
if (_message != NULL) {
UITableView *tableView = VIEW(ChatConversationView).tableController.tableView;
NSIndexPath *indexPath = [tableView indexPathForCell:self];
@ -205,45 +217,42 @@
}
}
- (IBAction)onResendClick:(id)event {
if (!_LIMEKO.hidden) {
- (void)onLime {
if (!_LIMEKO.hidden)
[self displayLIMEWarning];
return;
}
}
- (void)onResend {
if (_message == nil || !linphone_chat_message_is_outgoing(_message))
return;
LinphoneChatMessageState state = linphone_chat_message_get_state(_message);
if (state == LinphoneChatMessageStateNotDelivered || state == LinphoneChatMessageStateFileTransferError) {
if (linphone_chat_message_get_file_transfer_information(_message) != NULL) {
NSString *localImage = [LinphoneManager getMessageAppDataForKey:@"localimage" inMessage:_message];
NSNumber *uploadQuality =[LinphoneManager getMessageAppDataForKey:@"uploadQuality" inMessage:_message];
NSURL *imageUrl = [NSURL URLWithString:localImage];
if (state != LinphoneChatMessageStateNotDelivered && state != LinphoneChatMessageStateFileTransferError)
return;
[self onDeleteClick:nil];
[LinphoneManager.instance.photoLibrary assetForURL:imageUrl
resultBlock:^(ALAsset *asset) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL),
^(void) {
UIImage *image = [[UIImage alloc] initWithCGImage:[[asset defaultRepresentation] fullResolutionImage]];
[_chatRoomDelegate startImageUpload:image url:imageUrl withQuality:(uploadQuality ? [uploadQuality floatValue] : 0.9)];
});
}
failureBlock:^(NSError *error) {
LOGE(@"Can't read image");
}];
} else {
[self onDeleteClick:nil];
double delayInSeconds = 0.4;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
[_chatRoomDelegate resendChat:self.textMessage withExternalUrl:nil];
});
}
if (linphone_chat_message_get_file_transfer_information(_message) != NULL) {
NSString *localImage = [LinphoneManager getMessageAppDataForKey:@"localimage" inMessage:_message];
NSNumber *uploadQuality =[LinphoneManager getMessageAppDataForKey:@"uploadQuality" inMessage:_message];
NSURL *imageUrl = [NSURL URLWithString:localImage];
[self onDelete];
[LinphoneManager.instance.photoLibrary assetForURL:imageUrl
resultBlock:^(ALAsset *asset) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL),
^(void) {
UIImage *image = [[UIImage alloc] initWithCGImage:[[asset defaultRepresentation] fullResolutionImage]];
[_chatRoomDelegate startImageUpload:image url:imageUrl withQuality:(uploadQuality ? [uploadQuality floatValue] : 0.9)];
});
}
failureBlock:^(NSError *error) {
LOGE(@"Can't read image");
}];
} else {
[self onDelete];
double delayInSeconds = 0.4;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
[_chatRoomDelegate resendChat:self.textMessage withExternalUrl:nil];
});
}
}
#pragma mark - State changed handling