mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
- Allow to resend a message that's not delivered correctly
- Allow select-all on uitextviews
This commit is contained in:
parent
544d71d92d
commit
a63542cd03
9 changed files with 89 additions and 10 deletions
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
- (BOOL)chatRoomStartImageDownload:(NSURL*)url userInfo:(id)userInfo;
|
||||
- (BOOL)chatRoomStartImageUpload:(UIImage*)image url:(NSURL*)url;
|
||||
- (void)resendChat:(NSString*)message;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@
|
|||
ChatModel *chat = [data objectAtIndex:[indexPath row]];
|
||||
[data removeObjectAtIndex:[indexPath row]];
|
||||
[chat delete];
|
||||
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
||||
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom];
|
||||
[tableView endUpdates];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -612,6 +612,9 @@ static void message_status(LinphoneChatMessage* msg,LinphoneChatMessageState sta
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
- (void)resendChat:(NSString *)message {
|
||||
[self sendMessage:message withExterlBodyUrl:nil withInternalUrl:nil];
|
||||
}
|
||||
|
||||
#pragma mark ImageSharingDelegate
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#import "ChatRoomTableViewController.h"
|
||||
#import "UILoadingImageView.h"
|
||||
#import "UITransparentTVCell.h"
|
||||
#import "UITextViewNoDefine.h"
|
||||
|
||||
|
||||
@interface UIChatRoomCell : UITransparentTVCell {
|
||||
|
|
@ -32,13 +33,14 @@
|
|||
@property (nonatomic, retain) IBOutlet UIView *innerView;
|
||||
@property (nonatomic, retain) IBOutlet UIView *bubbleView;
|
||||
@property (nonatomic, retain) IBOutlet UIImageView* backgroundImage;
|
||||
@property (nonatomic, retain) IBOutlet UITextView *messageText;
|
||||
@property (nonatomic, retain) IBOutlet UITextViewNoDefine *messageText;
|
||||
@property (nonatomic, retain) IBOutlet UILoadingImageView *messageImageView;
|
||||
@property (nonatomic, retain) IBOutlet UIButton *deleteButton;
|
||||
@property (nonatomic, retain) IBOutlet UILabel *dateLabel;
|
||||
@property (nonatomic, retain) IBOutlet UIImageView* statusImage;
|
||||
@property (nonatomic, retain) IBOutlet UIButton* downloadButton;
|
||||
@property (nonatomic, retain) IBOutlet UITapGestureRecognizer* imageTapGestureRecognizer;
|
||||
@property (nonatomic, retain) IBOutlet UITapGestureRecognizer* resendTapGestureRecognizer;
|
||||
|
||||
- (id)initWithIdentifier:(NSString*)identifier;
|
||||
+ (CGFloat)height:(ChatModel*)chat width:(int)width;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
@synthesize downloadButton;
|
||||
@synthesize chatRoomDelegate;
|
||||
@synthesize imageTapGestureRecognizer;
|
||||
@synthesize resendTapGestureRecognizer;
|
||||
|
||||
static const CGFloat CELL_MIN_HEIGHT = 50.0f;
|
||||
static const CGFloat CELL_MIN_WIDTH = 150.0f;
|
||||
|
|
@ -62,6 +63,10 @@ static UIFont *CELL_FONT = nil;
|
|||
options:nil];
|
||||
imageTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onImageClick:)];
|
||||
[messageImageView addGestureRecognizer:imageTapGestureRecognizer];
|
||||
|
||||
resendTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onResendClick:)];
|
||||
[dateLabel addGestureRecognizer:resendTapGestureRecognizer];
|
||||
|
||||
[self addSubview:innerView];
|
||||
[deleteButton setAlpha:0.0f];
|
||||
|
||||
|
|
@ -71,6 +76,7 @@ static UIFont *CELL_FONT = nil;
|
|||
messageCoords.origin.y += 2;
|
||||
messageCoords.size.width -= 5;
|
||||
[messageText setFrame:messageCoords];
|
||||
messageText.allowSelectAll = TRUE;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
@ -88,6 +94,7 @@ static UIFont *CELL_FONT = nil;
|
|||
[chat release];
|
||||
[downloadButton release];
|
||||
[imageTapGestureRecognizer release];
|
||||
[resendTapGestureRecognizer release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
|
@ -179,6 +186,11 @@ static UIFont *CELL_FONT = nil;
|
|||
} else if ([chat.state intValue] == LinphoneChatMessageStateNotDelivered) {
|
||||
[statusImage setImage:[UIImage imageNamed:@"chat_message_not_delivered.png"]];
|
||||
statusImage.hidden = FALSE;
|
||||
|
||||
NSAttributedString* resend_text = [[NSAttributedString alloc]
|
||||
initWithString:NSLocalizedString(@"Resend", @"Resend")
|
||||
attributes:@{NSForegroundColorAttributeName: [UIColor redColor]}];
|
||||
[dateLabel setAttributedText:resend_text];
|
||||
} else {
|
||||
statusImage.hidden = TRUE;
|
||||
}
|
||||
|
|
@ -213,11 +225,11 @@ static UIFont *CELL_FONT = nil;
|
|||
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
|
||||
|
||||
if( [[[UIDevice currentDevice] systemVersion] doubleValue] >= 7){
|
||||
NSDictionary *stringAttributes = [NSDictionary dictionaryWithObject:CELL_FONT forKey: NSFontAttributeName];
|
||||
messageSize = [[chat message] boundingRectWithSize:CGSizeMake(width - CELL_MESSAGE_X_MARGIN, CGFLOAT_MAX)
|
||||
options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesFontLeading)
|
||||
attributes:stringAttributes
|
||||
context:nil].size;
|
||||
messageSize = [[chat message]
|
||||
boundingRectWithSize:CGSizeMake(width - CELL_MESSAGE_X_MARGIN, CGFLOAT_MAX)
|
||||
options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesFontLeading)
|
||||
attributes:@{NSFontAttributeName: CELL_FONT}
|
||||
context:nil].size;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
|
@ -303,4 +315,17 @@ static UIFont *CELL_FONT = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (IBAction)onResendClick:(id)event {
|
||||
if ([chat.state intValue] == LinphoneChatMessageStateNotDelivered) {
|
||||
NSString* message = [chat message];
|
||||
[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:message];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1072" identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
|
|
@ -42,7 +41,7 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<gestureRecognizers/>
|
||||
</imageView>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" text="They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety." id="43" userLabel="messageText">
|
||||
<textView clipsSubviews="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" text="They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety." id="43" userLabel="messageText" customClass="UITextViewNoDefine">
|
||||
<rect key="frame" x="-8" y="-11" width="310" height="126"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
|
|
@ -69,7 +68,7 @@
|
|||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="09/09/2009 at 09:09" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="8" adjustsFontSizeToFit="NO" id="22" userLabel="timestampLabel">
|
||||
<label opaque="NO" clipsSubviews="YES" contentMode="left" text="09/09/2009 at 09:09" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="8" adjustsFontSizeToFit="NO" id="22" userLabel="timestampLabel">
|
||||
<rect key="frame" x="0.0" y="104" width="280" height="10"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
|
|
|
|||
15
Classes/LinphoneUI/UITextViewNoDefine.h
Normal file
15
Classes/LinphoneUI/UITextViewNoDefine.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// UITextFieldNoDefine.h
|
||||
// linphone
|
||||
//
|
||||
// Created by guillaume on 05/03/2014.
|
||||
//
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UITextViewNoDefine : UITextView
|
||||
|
||||
@property BOOL allowSelectAll;
|
||||
|
||||
@end
|
||||
26
Classes/LinphoneUI/UITextViewNoDefine.m
Normal file
26
Classes/LinphoneUI/UITextViewNoDefine.m
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// UITextViewNoDefine.m
|
||||
// linphone
|
||||
//
|
||||
// Created by guillaume on 05/03/2014.
|
||||
//
|
||||
//
|
||||
|
||||
#import "UITextViewNoDefine.h"
|
||||
|
||||
@implementation UITextViewNoDefine
|
||||
|
||||
@synthesize allowSelectAll;
|
||||
|
||||
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender{
|
||||
// disable "define" option, since it messes with the keyboard
|
||||
if ([[NSStringFromSelector(action) lowercaseString] rangeOfString:@"define"].location != NSNotFound) {
|
||||
return NO;
|
||||
} else if(action == @selector(selectAll:) && allowSelectAll ) {
|
||||
return YES;
|
||||
} else {
|
||||
return [super canPerformAction:action withSender:sender];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1393,6 +1393,8 @@
|
|||
F03A9C7418C0E2ED00C4D7FE /* userdb.conf in Resources */ = {isa = PBXBuildFile; fileRef = F03A9C6B18C0E2ED00C4D7FE /* userdb.conf */; };
|
||||
F03A9C7518C46E7700C4D7FE /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22276E8813C73DC000210156 /* CoreMedia.framework */; };
|
||||
F03A9C7618C46EAF00C4D7FE /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 224567C1107B968500F10948 /* AVFoundation.framework */; };
|
||||
F03CA84318C72F1A0008889D /* UITextViewNoDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = F03CA84218C72F1A0008889D /* UITextViewNoDefine.m */; };
|
||||
F03CA84418C72F1A0008889D /* UITextViewNoDefine.m in Sources */ = {isa = PBXBuildFile; fileRef = F03CA84218C72F1A0008889D /* UITextViewNoDefine.m */; };
|
||||
F04892FF180C3296002FED35 /* ImageOptim.sh in Resources */ = {isa = PBXBuildFile; fileRef = F04892FE180C3296002FED35 /* ImageOptim.sh */; };
|
||||
F0489300180C3296002FED35 /* ImageOptim.sh in Resources */ = {isa = PBXBuildFile; fileRef = F04892FE180C3296002FED35 /* ImageOptim.sh */; };
|
||||
F04F1E9D1806A41800D080F2 /* libpolarssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 57B0E35F173C010400A476B8 /* libpolarssl.a */; };
|
||||
|
|
@ -2486,6 +2488,8 @@
|
|||
F03A9C6918C0E2ED00C4D7FE /* sounds */ = {isa = PBXFileReference; lastKnownFileType = folder; name = sounds; path = submodules/linphone/tester/sounds; sourceTree = SOURCE_ROOT; };
|
||||
F03A9C6A18C0E2ED00C4D7FE /* tester_hosts */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = tester_hosts; path = submodules/linphone/tester/tester_hosts; sourceTree = SOURCE_ROOT; };
|
||||
F03A9C6B18C0E2ED00C4D7FE /* userdb.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = userdb.conf; path = submodules/linphone/tester/userdb.conf; sourceTree = SOURCE_ROOT; };
|
||||
F03CA84118C72F1A0008889D /* UITextViewNoDefine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UITextViewNoDefine.h; sourceTree = "<group>"; };
|
||||
F03CA84218C72F1A0008889D /* UITextViewNoDefine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UITextViewNoDefine.m; sourceTree = "<group>"; };
|
||||
F04892FE180C3296002FED35 /* ImageOptim.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = ImageOptim.sh; sourceTree = "<group>"; };
|
||||
F066515317F9A02E0064280C /* UITransparentTVCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UITransparentTVCell.h; sourceTree = "<group>"; };
|
||||
F066515417F9A02E0064280C /* UITransparentTVCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UITransparentTVCell.m; sourceTree = "<group>"; };
|
||||
|
|
@ -3006,6 +3010,8 @@
|
|||
340751E6150F38FD00B89C47 /* UIVideoButton.m */,
|
||||
F066515317F9A02E0064280C /* UITransparentTVCell.h */,
|
||||
F066515417F9A02E0064280C /* UITransparentTVCell.m */,
|
||||
F03CA84118C72F1A0008889D /* UITextViewNoDefine.h */,
|
||||
F03CA84218C72F1A0008889D /* UITextViewNoDefine.m */,
|
||||
);
|
||||
path = LinphoneUI;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -5425,6 +5431,7 @@
|
|||
D35E7581159328EB0066B1C1 /* UIAddressTextField.m in Sources */,
|
||||
D35E7597159460580066B1C1 /* ChatViewController.m in Sources */,
|
||||
D35E759F159460B70066B1C1 /* SettingsViewController.m in Sources */,
|
||||
F03CA84318C72F1A0008889D /* UITextViewNoDefine.m in Sources */,
|
||||
D37DC6C11594AE1800B2A5EB /* LinphoneCoreSettingsStore.m in Sources */,
|
||||
D3EA53FD159850E80037DC6B /* LinphoneManager.m in Sources */,
|
||||
D3EA540D1598528B0037DC6B /* ChatTableViewController.m in Sources */,
|
||||
|
|
@ -5524,6 +5531,7 @@
|
|||
D35E7582159328EB0066B1C1 /* UIAddressTextField.m in Sources */,
|
||||
D35E7598159460580066B1C1 /* ChatViewController.m in Sources */,
|
||||
D35E75A0159460B70066B1C1 /* SettingsViewController.m in Sources */,
|
||||
F03CA84418C72F1A0008889D /* UITextViewNoDefine.m in Sources */,
|
||||
D37DC6C21594AE1800B2A5EB /* LinphoneCoreSettingsStore.m in Sources */,
|
||||
D3EA53FE159850E80037DC6B /* LinphoneManager.m in Sources */,
|
||||
D3EA540E1598528B0037DC6B /* ChatTableViewController.m in Sources */,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue