UI: finish transfer call workflow

This commit is contained in:
Gautier Pelloux-Prayer 2016-01-21 11:17:14 +01:00
parent f798da2db0
commit 038194d831
11 changed files with 79 additions and 127 deletions

View file

@ -298,10 +298,12 @@
<nil key="highlightedColor"/>
<size key="shadowOffset" width="-1" height="-1"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Your account is created. Please check your mails in order to validate your account." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" minimumFontSize="10" id="UWU-j2-pUb" userLabel="activateDescLabel">
<rect key="frame" x="36" y="218" width="302" height="59"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="8" baselineAdjustment="alignBaselines" minimumFontSize="10" id="UWU-j2-pUb" userLabel="activateDescLabel">
<rect key="frame" x="36" y="192" width="302" height="96"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Account setup assistant"/>
<string key="text">Your account is created. Please check your mails to validate your account.
Once it is done, come back here and click on the button.</string>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
@ -343,7 +345,7 @@
<nil key="highlightedColor"/>
<size key="shadowOffset" width="-1" height="-1"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Enter your username and password of your linphone.org account." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" minimumFontSize="10" id="4n3-ZD-KVi" userLabel="subtitleLabel">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="Enter your username and password of Linphone account." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" minimumFontSize="10" id="4n3-ZD-KVi" userLabel="subtitleLabel">
<rect key="frame" x="36" y="66" width="302" height="29"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<accessibility key="accessibilityConfiguration" label="Account setup assistant"/>

View file

@ -131,6 +131,8 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
LinphoneManager.instance.nextCallIsTransfer = NO;
[self updateUnreadMessage:FALSE];
// Update on show
@ -709,7 +711,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) {
[self hideOptions:TRUE animated:TRUE];
DialerView *view = VIEW(DialerView);
[view setAddress:@""];
[view setTransferMode:TRUE];
LinphoneManager.instance.nextCallIsTransfer = YES;
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
}
@ -717,7 +719,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) {
[self hideOptions:TRUE animated:TRUE];
DialerView *view = VIEW(DialerView);
[view setAddress:@""];
[view setTransferMode:FALSE];
LinphoneManager.instance.nextCallIsTransfer = NO;
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
}

View file

@ -515,7 +515,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (IBAction)onCallClick:(id)sender {
[LinphoneManager.instance call:linphone_chat_room_get_peer_address(chatRoom) transfer:NO];
[LinphoneManager.instance call:linphone_chat_room_get_peer_address(chatRoom)];
}
- (IBAction)onListSwipe:(id)sender {

View file

@ -29,15 +29,10 @@
: TPMultiLayoutViewController <UITextFieldDelegate, UICompositeViewDelegate, MFMailComposeViewControllerDelegate> {
}
- (void)setAddress:(NSString *)address;
@property(nonatomic, assign) BOOL transferMode;
@property(nonatomic, strong) IBOutlet UITextField *addressField;
@property(nonatomic, strong) IBOutlet UIButton *addContactButton;
@property(nonatomic, strong) IBOutlet UICallButton *callButton;
@property(nonatomic, strong) IBOutlet UICallButton *addCallButton;
@property(nonatomic, strong) IBOutlet UICallButton *transferButton;
@property(nonatomic, strong) IBOutlet UIButton *backButton;
@property(weak, nonatomic) IBOutlet UIIconButton *backspaceButton;
@ -63,4 +58,6 @@
- (IBAction)onAddressChange:(id)sender;
- (IBAction)onBackspaceClick:(id)sender;
- (void)setAddress:(NSString *)address;
@end

View file

@ -25,48 +25,6 @@
@implementation DialerView
@synthesize transferMode;
@synthesize addressField;
@synthesize addContactButton;
@synthesize backButton;
@synthesize addCallButton;
@synthesize transferButton;
@synthesize callButton;
@synthesize backspaceButton;
@synthesize oneButton;
@synthesize twoButton;
@synthesize threeButton;
@synthesize fourButton;
@synthesize fiveButton;
@synthesize sixButton;
@synthesize sevenButton;
@synthesize eightButton;
@synthesize nineButton;
@synthesize starButton;
@synthesize zeroButton;
@synthesize hashButton;
@synthesize backgroundView;
@synthesize videoPreview;
@synthesize videoCameraSwitch;
#pragma mark - Lifecycle Functions
- (id)init {
self = [super initWithNibName:NSStringFromClass(self.class) bundle:[NSBundle mainBundle]];
if (self) {
transferMode = FALSE;
}
return self;
}
- (void)dealloc {
// Remove all observers
[NSNotificationCenter.defaultCenter removeObserver:self];
}
#pragma mark - UICompositeViewDelegate Functions
static UICompositeViewDescription *compositeDescription = nil;
@ -108,12 +66,6 @@ static UICompositeViewDescription *compositeDescription = nil;
name:kLinphoneCoreUpdate
object:nil];
// technically not needed, but older versions of linphone had this button
// disabled by default. In this case, updating by pushing a new version with
// xcode would result in the callbutton being disabled all the time.
// We force it enabled anyway now.
[callButton setEnabled:TRUE];
// Update on show
LinphoneManager *mgr = LinphoneManager.instance;
LinphoneCall *call = linphone_core_get_current_call(LC);
@ -125,24 +77,24 @@ static UICompositeViewDescription *compositeDescription = nil;
BOOL previewPref = [mgr lpConfigBoolForKey:@"preview_preference"];
if (videoEnabled && previewPref) {
linphone_core_set_native_preview_window_id(LC, (__bridge void *)(videoPreview));
linphone_core_set_native_preview_window_id(LC, (__bridge void *)(_videoPreview));
if (!linphone_core_video_preview_enabled(LC)) {
linphone_core_enable_video_preview(LC, TRUE);
}
[backgroundView setHidden:FALSE];
[videoCameraSwitch setHidden:FALSE];
[_backgroundView setHidden:FALSE];
[_videoCameraSwitch setHidden:FALSE];
} else {
linphone_core_set_native_preview_window_id(LC, NULL);
linphone_core_enable_video_preview(LC, FALSE);
[backgroundView setHidden:TRUE];
[videoCameraSwitch setHidden:TRUE];
[_backgroundView setHidden:TRUE];
[_videoCameraSwitch setHidden:TRUE];
}
} else {
linphone_core_enable_video_preview(LC, FALSE);
}
[addressField setText:@""];
[_addressField setText:@""];
}
- (void)viewWillDisappear:(BOOL)animated {
@ -153,37 +105,37 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)viewDidLoad {
[super viewDidLoad];
[zeroButton setDigit:'0'];
[oneButton setDigit:'1'];
[twoButton setDigit:'2'];
[threeButton setDigit:'3'];
[fourButton setDigit:'4'];
[fiveButton setDigit:'5'];
[sixButton setDigit:'6'];
[sevenButton setDigit:'7'];
[eightButton setDigit:'8'];
[nineButton setDigit:'9'];
[starButton setDigit:'*'];
[hashButton setDigit:'#'];
[_zeroButton setDigit:'0'];
[_oneButton setDigit:'1'];
[_twoButton setDigit:'2'];
[_threeButton setDigit:'3'];
[_fourButton setDigit:'4'];
[_fiveButton setDigit:'5'];
[_sixButton setDigit:'6'];
[_sevenButton setDigit:'7'];
[_eightButton setDigit:'8'];
[_nineButton setDigit:'9'];
[_starButton setDigit:'*'];
[_hashButton setDigit:'#'];
[addressField setAdjustsFontSizeToFitWidth:TRUE]; // Not put it in IB: issue with placeholder size
[_addressField setAdjustsFontSizeToFitWidth:TRUE]; // Not put it in IB: issue with placeholder size
UILongPressGestureRecognizer *backspaceLongGesture =
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onBackspaceLongClick:)];
[backspaceButton addGestureRecognizer:backspaceLongGesture];
[_backspaceButton addGestureRecognizer:backspaceLongGesture];
UILongPressGestureRecognizer *zeroLongGesture =
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onZeroLongClick:)];
[zeroButton addGestureRecognizer:zeroLongGesture];
[_zeroButton addGestureRecognizer:zeroLongGesture];
UILongPressGestureRecognizer *oneLongGesture =
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onOneLongClick:)];
[oneButton addGestureRecognizer:oneLongGesture];
[_oneButton addGestureRecognizer:oneLongGesture];
if (IPAD) {
if (LinphoneManager.instance.frontCamId != nil) {
// only show camera switch button if we have more than 1 camera
[videoCameraSwitch setHidden:FALSE];
[_videoCameraSwitch setHidden:FALSE];
}
}
}
@ -193,23 +145,23 @@ static UICompositeViewDescription *compositeDescription = nil;
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
[videoPreview setTransform:CGAffineTransformMakeRotation(0)];
[_videoPreview setTransform:CGAffineTransformMakeRotation(0)];
break;
case UIInterfaceOrientationPortraitUpsideDown:
[videoPreview setTransform:CGAffineTransformMakeRotation(M_PI)];
[_videoPreview setTransform:CGAffineTransformMakeRotation(M_PI)];
break;
case UIInterfaceOrientationLandscapeLeft:
[videoPreview setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
[_videoPreview setTransform:CGAffineTransformMakeRotation(M_PI / 2)];
break;
case UIInterfaceOrientationLandscapeRight:
[videoPreview setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[_videoPreview setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
break;
default:
break;
}
CGRect frame = self.view.frame;
frame.origin = CGPointMake(0, 0);
videoPreview.frame = frame;
_videoPreview.frame = frame;
_padView.hidden = !IPAD && UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
@ -224,13 +176,13 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)coreUpdateEvent:(NSNotification *)notif {
if (IPAD) {
if (linphone_core_video_display_enabled(LC) && linphone_core_video_preview_enabled(LC)) {
linphone_core_set_native_preview_window_id(LC, (__bridge void *)(videoPreview));
[backgroundView setHidden:FALSE];
[videoCameraSwitch setHidden:FALSE];
linphone_core_set_native_preview_window_id(LC, (__bridge void *)(_videoPreview));
[_backgroundView setHidden:FALSE];
[_videoCameraSwitch setHidden:FALSE];
} else {
linphone_core_set_native_preview_window_id(LC, NULL);
[backgroundView setHidden:TRUE];
[videoCameraSwitch setHidden:TRUE];
[_backgroundView setHidden:TRUE];
[_videoCameraSwitch setHidden:TRUE];
}
}
}
@ -329,22 +281,13 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)callUpdate:(LinphoneCall *)call state:(LinphoneCallState)state {
BOOL callInProgress = (linphone_core_get_calls_nb(LC) > 0);
addCallButton.hidden = (!callInProgress || transferMode);
transferButton.hidden = (!callInProgress || !transferMode);
addContactButton.hidden = callButton.hidden = callInProgress;
backButton.hidden = !callInProgress;
[callButton updateIcon];
_addContactButton.hidden = callInProgress;
_backButton.hidden = !callInProgress;
[_callButton updateIcon];
}
- (void)setAddress:(NSString *)address {
[addressField setText:address];
}
- (void)setTransferMode:(BOOL)atransferMode {
transferMode = atransferMode;
LinphoneCall *call = linphone_core_get_current_call(LC);
LinphoneCallState state = (call != NULL) ? linphone_call_get_state(call) : 0;
[self callUpdate:call state:state];
[_addressField setText:address];
}
#pragma mark - UITextFieldDelegate Functions
@ -357,12 +300,12 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (textField == addressField) {
[addressField resignFirstResponder];
if (textField == _addressField) {
[_addressField resignFirstResponder];
}
if (textField.text.length > 0) {
LinphoneAddress *addr = linphone_core_interpret_url(LC, textField.text.UTF8String);
[LinphoneManager.instance call:addr transfer:FALSE];
[LinphoneManager.instance call:addr];
if (addr)
linphone_address_destroy(addr);
}
@ -384,7 +327,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (IBAction)onAddContactClick:(id)event {
[ContactSelection setSelectionMode:ContactSelectionModeEdit];
[ContactSelection setAddAddress:[addressField text]];
[ContactSelection setAddAddress:[_addressField text]];
[ContactSelection setSipFilter:nil];
[ContactSelection setNameOrEmailFilter:nil];
[ContactSelection enableEmailFilter:FALSE];
@ -396,28 +339,27 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (IBAction)onAddressChange:(id)sender {
if ([self displayDebugPopup:self.addressField.text]) {
self.addressField.text = @"";
if ([self displayDebugPopup:_addressField.text]) {
_addressField.text = @"";
}
addContactButton.enabled = backspaceButton.enabled = addCallButton.enabled = transferButton.enabled =
([[addressField text] length] > 0);
_addContactButton.enabled = _backspaceButton.enabled = ([[_addressField text] length] > 0);
}
- (IBAction)onBackspaceClick:(id)sender {
if ([addressField.text length] > 0) {
[addressField setText:[addressField.text substringToIndex:[addressField.text length] - 1]];
if ([_addressField.text length] > 0) {
[_addressField setText:[_addressField.text substringToIndex:[_addressField.text length] - 1]];
}
}
- (void)onBackspaceLongClick:(id)sender {
[addressField setText:@""];
[_addressField setText:@""];
}
- (void)onZeroLongClick:(id)sender {
// replace last character with a '+'
NSString *newAddress =
[[self.addressField.text substringToIndex:[self.addressField.text length] - 1] stringByAppendingString:@"+"];
[self.addressField setText:newAddress];
[[_addressField.text substringToIndex:[_addressField.text length] - 1] stringByAppendingString:@"+"];
[_addressField setText:newAddress];
linphone_core_stop_dtmf(LC);
}
@ -427,7 +369,7 @@ static UICompositeViewDescription *compositeDescription = nil;
LinphoneAddress *addr = linphone_core_interpret_url(LC, voiceMail ? voiceMail.UTF8String : NULL);
if (addr) {
linphone_address_set_display_name(addr, NSLocalizedString(@"Voice mail", nil).UTF8String);
[lm call:addr transfer:FALSE];
[lm call:addr];
linphone_address_destroy(addr);
} else {
LOGE(@"Cannot call voice mail because URI not set or invalid!");

View file

@ -166,7 +166,7 @@ static UICompositeViewDescription *compositeDescription = nil;
- (IBAction)onCallClick:(id)event {
LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog);
[LinphoneManager.instance call:addr transfer:NO];
[LinphoneManager.instance call:addr];
}
- (IBAction)onChatClick:(id)event {

View file

@ -228,7 +228,7 @@
[cell onDetails:self];
} else {
LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog);
[LinphoneManager.instance call:addr transfer:NO];
[LinphoneManager.instance call:addr];
}
}
}

View file

@ -161,7 +161,7 @@ typedef struct _LinphoneManagerSounds {
+ (NSString*)cacheDirectory;
- (void)acceptCall:(LinphoneCall *)call evenWithVideo:(BOOL)video;
- (BOOL)call:(const LinphoneAddress *)address transfer:(BOOL)transfer;
- (BOOL)call:(const LinphoneAddress *)address;
+(id)getMessageAppDataForKey:(NSString*)key inMessage:(LinphoneChatMessage*)msg;
+(void)setValueInMessageAppData:(id)value forKey:(NSString*)key inMessage:(LinphoneChatMessage*)msg;
@ -216,5 +216,6 @@ typedef struct _LinphoneManagerSounds {
@property (readonly) LpConfig *configDb;
@property(readonly) InAppProductsManager *iapManager;
@property(strong, nonatomic) NSMutableArray *fileTransferDelegates;
@property BOOL nextCallIsTransfer;
@end

View file

@ -1904,7 +1904,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
linphone_core_accept_call_with_params(theLinphoneCore, call, lcallParams);
}
- (BOOL)call:(const LinphoneAddress *)iaddr transfer:(BOOL)transfer {
- (BOOL)call:(const LinphoneAddress *)iaddr {
// First verify that network is available, abort otherwise.
if (!linphone_core_is_network_reachable(theLinphoneCore)) {
UIAlertView *error = [[UIAlertView alloc]
@ -1964,9 +1964,11 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
linphone_address_set_domain(
addr, [[LinphoneManager.instance lpConfigStringForKey:@"domain" inSection:@"assistant"] UTF8String]);
}
if (transfer) {
if (LinphoneManager.instance.nextCallIsTransfer) {
char *caddr = linphone_address_as_string(addr);
linphone_core_transfer_call(theLinphoneCore, linphone_core_get_current_call(theLinphoneCore), caddr);
LinphoneManager.instance.nextCallIsTransfer = NO;
ms_free(caddr);
} else {
LinphoneCall *call = linphone_core_invite_address_with_params(theLinphoneCore, addr, lcallParams);

View file

@ -87,7 +87,7 @@
if ([address length] > 0) {
LinphoneAddress *addr = linphone_core_interpret_url(LC, address.UTF8String);
[LinphoneManager.instance call:addr transfer:FALSE];
[LinphoneManager.instance call:addr];
if (addr)
linphone_address_destroy(addr);
}
@ -102,6 +102,12 @@
[self setImage:[UIImage imageNamed:@"call_audio_start_disabled.png"] forState:UIControlStateDisabled];
}
if (LinphoneManager.instance.)
if (LinphoneManager.instance.nextCallIsTransfer) {
[self setImage:[UIImage imageNamed:@"call_transfer_default.png"] forState:UIControlStateNormal];
[self setImage:[UIImage imageNamed:@"call_transfer_disabled.png"] forState:UIControlStateDisabled];
} else if (linphone_core_get_calls_nb(LC) > 0) {
[self setImage:[UIImage imageNamed:@"call_add_default.png"] forState:UIControlStateNormal];
[self setImage:[UIImage imageNamed:@"call_add_disabled.png"] forState:UIControlStateDisabled];
}
}
@end

View file

@ -76,7 +76,7 @@
- (IBAction)onCallClick:(id)event {
LinphoneAddress *addr = linphone_core_interpret_url(LC, _addressLabel.text.UTF8String);
[LinphoneManager.instance call:addr transfer:NO];
[LinphoneManager.instance call:addr];
if (addr)
linphone_address_destroy(addr);
}