From 7a63d313ef7dd0afe27c2a34e4a49aa0025ea7cb Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 23 Mar 2012 15:08:04 +0100 Subject: [PATCH] Add 'busy' indicator when pressing add/remove video button --- Classes/IncallViewController.h | 7 ++- Classes/IncallViewController.m | 37 +++++++------ Classes/IncallViewController.xib | 66 +++++++++++++++++++++--- Classes/LinphoneUI/LinphoneManager.m | 26 +++++----- Classes/LinphoneUI/UIToggleVideoButton.h | 8 ++- Classes/LinphoneUI/UIToggleVideoButton.m | 6 +++ submodules/linphone | 2 +- 7 files changed, 111 insertions(+), 41 deletions(-) diff --git a/Classes/IncallViewController.h b/Classes/IncallViewController.h index e3d57e1c7..a7336bb22 100644 --- a/Classes/IncallViewController.h +++ b/Classes/IncallViewController.h @@ -22,6 +22,7 @@ #import "ConferenceCallDetailView.h" #import #include "UILinphone.h" +#import "UIToggleVideoButton.h" @class VideoViewController; @@ -36,7 +37,7 @@ UIButton* pause; UISpeakerButton* speaker; UIButton* contacts; - UIButton* addVideo; + UIToggleVideoButton* addVideo; UITableView* callTableView; UIButton* addCall, *mergeCalls; @@ -63,6 +64,7 @@ UIView* videoPreview; UIImageView* videoCallQuality; UICamSwitch* videoCameraSwitch; + UIActivityIndicatorView* videoUpdateIndicator; bool dismissed; @@ -108,7 +110,7 @@ @property (nonatomic, retain) IBOutlet UIButton* pause; @property (nonatomic, retain) IBOutlet UIButton* speaker; @property (nonatomic, retain) IBOutlet UIButton* contacts; -@property (nonatomic, retain) IBOutlet UIButton* addVideo; +@property (nonatomic, retain) IBOutlet UIToggleVideoButton* addVideo; @property (nonatomic, retain) IBOutlet UITableView* callTableView; @property (nonatomic, retain) IBOutlet UIButton* addCall; @property (nonatomic, retain) IBOutlet UIButton* mergeCalls; @@ -133,4 +135,5 @@ @property (nonatomic, retain) IBOutlet UIView* videoPreview; @property (nonatomic, retain) IBOutlet UIImageView* videoCallQuality; @property (nonatomic, retain) IBOutlet UICamSwitch* videoCameraSwitch; +@property (nonatomic, retain) IBOutlet UIActivityIndicatorView* videoUpdateIndicator; @end diff --git a/Classes/IncallViewController.m b/Classes/IncallViewController.m index cede3d142..550320619 100644 --- a/Classes/IncallViewController.m +++ b/Classes/IncallViewController.m @@ -72,6 +72,7 @@ const NSInteger SECURE_BUTTON_TAG=5; @synthesize videoPreview; @synthesize videoCallQuality; @synthesize videoCameraSwitch; +@synthesize videoUpdateIndicator; @synthesize addVideo; @@ -261,7 +262,7 @@ void addAnimationFadeTransition(UIView* view, float duration) { [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; } --(void) updateUIFromLinphoneState:(UIViewController *)viewCtrl { +-(void) updateUIFromLinphoneState:(BOOL) fullUpdate { activeCallCell = nil; [mute reset]; @@ -291,17 +292,21 @@ void addAnimationFadeTransition(UIView* view, float duration) { [LinphoneManager set:pause hidden:YES withName:"PAUSE button" andReason:AT]; } - if (linphone_call_get_state(selectedCall) == LinphoneCallStreamsRunning) { - if (linphone_call_params_video_enabled(linphone_call_get_current_params(selectedCall))) { - [addVideo setTitle:NSLocalizedString(@"-video", nil) forState:UIControlStateNormal]; - [IncallViewController updateIndicator: videoCallQuality withCallQuality:linphone_call_get_average_quality(selectedCall)]; + if (fullUpdate) { + videoUpdateIndicator.hidden = YES; + LinphoneCallState state = linphone_call_get_state(selectedCall); + if (state == LinphoneCallStreamsRunning || state == LinphoneCallUpdated || state == LinphoneCallUpdatedByRemote) { + if (linphone_call_params_video_enabled(linphone_call_get_current_params(selectedCall))) { + [addVideo setTitle:NSLocalizedString(@"-video", nil) forState:UIControlStateNormal]; + [IncallViewController updateIndicator: videoCallQuality withCallQuality:linphone_call_get_average_quality(selectedCall)]; + } else { + [addVideo setTitle:NSLocalizedString(@"+video", nil) forState:UIControlStateNormal]; + } + [addVideo setEnabled:YES]; } else { - [addVideo setTitle:NSLocalizedString(@"+video", nil) forState:UIControlStateNormal]; + [addVideo setEnabled:NO]; + [videoCallQuality setImage:nil]; } - [addVideo setEnabled:YES]; - } else { - [addVideo setEnabled:NO]; - [videoCallQuality setImage:nil]; } } else { if (callsCount == 1) { @@ -388,6 +393,7 @@ void addAnimationFadeTransition(UIView* view, float duration) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; [videoCameraSwitch setPreview:videoPreview]; + addVideo.videoUpdateIndicator = videoUpdateIndicator; } -(void) addCallPressed { @@ -433,7 +439,7 @@ void addAnimationFadeTransition(UIView* view, float duration) { -(void)updateCallsDurations { - [self updateUIFromLinphoneState: nil]; + [self updateUIFromLinphoneState: NO]; } -(void) awakeFromNib @@ -523,7 +529,7 @@ void addAnimationFadeTransition(UIView* view, float duration) { device.proximityMonitoringEnabled = YES; if ([speaker isOn]) [speaker toggle]; - [self updateUIFromLinphoneState: nil]; + [self updateUIFromLinphoneState: YES]; } -(void) displayIncomingCall:(LinphoneCall *)call NotificationFromUI:(UIViewController *)viewCtrl forUser:(NSString *)username withDisplayName:(NSString *)displayName { @@ -537,7 +543,7 @@ void addAnimationFadeTransition(UIView* view, float duration) { if (call !=nil && linphone_call_get_dir(call)==LinphoneCallIncoming) { if ([speaker isOn]) [speaker toggle]; } - [self updateUIFromLinphoneState: nil]; + [self updateUIFromLinphoneState: YES]; [self disableVideoDisplay]; } @@ -560,11 +566,12 @@ void addAnimationFadeTransition(UIView* view, float duration) { [self dismissModalViewControllerAnimated:FALSE]; //disable animation to avoid blanc bar just below status bar*/ dismissed = true; - [self updateUIFromLinphoneState: nil]; + [self updateUIFromLinphoneState: YES]; } -(void) displayVideoCall:(LinphoneCall*) call FromUI:(UIViewController*) viewCtrl forUser:(NSString*) username withDisplayName:(NSString*) displayName { [self enableVideoDisplay]; + [self updateUIFromLinphoneState: YES]; return; if (mIncallViewIsReady) { @@ -1017,7 +1024,7 @@ void addAnimationFadeTransition(UIView* view, float duration) { linphone_core_resume_call([LinphoneManager getLc], selectedCall); } - [self updateUIFromLinphoneState: nil]; + [self updateUIFromLinphoneState: YES]; } diff --git a/Classes/IncallViewController.xib b/Classes/IncallViewController.xib index 7d55123e4..ee5e4d9cc 100644 --- a/Classes/IncallViewController.xib +++ b/Classes/IncallViewController.xib @@ -12,12 +12,13 @@ YES - IBUITableView - IBUIViewController - IBUIImageView - IBUIView IBUIButton + IBUIImageView + IBUIViewController IBProxyObject + IBUIActivityIndicatorView + IBUITableView + IBUIView YES @@ -172,6 +173,7 @@ {{0, 1}, {320, 66}} + 1 MSAwIDAuMDgyMzIwMjU5MDQgMC4xOAA @@ -344,7 +346,7 @@ {{213, 70}, {107, 66}} - + NO NO @@ -371,6 +373,19 @@ + + + -2147483356 + {{247.5, 84.5}, {37, 37}} + + + + _NS:1030 + NO + IBCocoaTouchFramework + NO + 0 + 292 @@ -1061,6 +1076,14 @@ 141 + + + videoUpdateIndicator + + + + 143 + doAction: @@ -1193,6 +1216,7 @@ + controls @@ -1372,6 +1396,12 @@ camswitch + + 142 + + + video_update_indicator + @@ -1402,6 +1432,7 @@ 137.IBPluginDependency 140.CustomClassName 140.IBPluginDependency + 142.IBPluginDependency 15.IBPluginDependency 16.CustomClassName 16.IBPluginDependency @@ -1467,6 +1498,7 @@ UICamSwitch com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIMuteButton com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -1517,7 +1549,7 @@ - 141 + 143 @@ -1570,6 +1602,7 @@ videoCameraSwitch videoGroup videoPreview + videoUpdateIndicator videoView videoViewController zero @@ -1577,7 +1610,7 @@ YES UIButton - UIButton + UIToggleVideoButton UITableView UIButton UIViewController @@ -1606,6 +1639,7 @@ UICamSwitch UIView UIView + UIActivityIndicatorView UIView VideoViewController UIButton @@ -1645,6 +1679,7 @@ videoCameraSwitch videoGroup videoPreview + videoUpdateIndicator videoView videoViewController zero @@ -1657,7 +1692,7 @@ addVideo - UIButton + UIToggleVideoButton callTableView @@ -1771,6 +1806,10 @@ videoPreview UIView + + videoUpdateIndicator + UIActivityIndicatorView + videoView UIView @@ -1852,6 +1891,17 @@ UIToggleVideoButton UIButton + + videoUpdateIndicator + UIActivityIndicatorView + + + videoUpdateIndicator + + videoUpdateIndicator + UIActivityIndicatorView + + IBProjectSource ./Classes/UIToggleVideoButton.h diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m index 1bc1097d5..28a8e3eba 100644 --- a/Classes/LinphoneUI/LinphoneManager.m +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -162,19 +162,7 @@ extern void libmsbcg729_init(); bool canHideInCallView = (linphone_core_get_calls([LinphoneManager getLc]) == NULL); - switch (new_state) { - - case LinphoneCallStreamsRunning: - //check video - if (linphone_call_params_video_enabled(linphone_call_get_current_params(call))) { - [callDelegate displayVideoCall:call FromUI:mCurrentViewController - forUser:lUserName - withDisplayName:lDisplayName]; - } else { - [callDelegate displayInCall:call FromUI:mCurrentViewController forUser:lUserName withDisplayName:lDisplayName]; - } - break; - + switch (new_state) { case LinphoneCallIncomingReceived: [callDelegate displayIncomingCall:call NotificationFromUI:mCurrentViewController @@ -276,8 +264,18 @@ extern void libmsbcg729_init(); withDisplayName:lDisplayName]; } break; - default: + case LinphoneCallStreamsRunning: + //check video + if (linphone_call_params_video_enabled(linphone_call_get_current_params(call))) { + [callDelegate displayVideoCall:call FromUI:mCurrentViewController + forUser:lUserName + withDisplayName:lDisplayName]; + } else { + [callDelegate displayInCall:call FromUI:mCurrentViewController forUser:lUserName withDisplayName:lDisplayName]; + } break; + default: + break; } } diff --git a/Classes/LinphoneUI/UIToggleVideoButton.h b/Classes/LinphoneUI/UIToggleVideoButton.h index c9a6cc83c..37a712ddd 100644 --- a/Classes/LinphoneUI/UIToggleVideoButton.h +++ b/Classes/LinphoneUI/UIToggleVideoButton.h @@ -19,6 +19,12 @@ #import -@interface UIToggleVideoButton : UIButton +@interface UIToggleVideoButton : UIButton { + UIActivityIndicatorView* videoUpdateIndicator; +} + - (id)initWithCoder:(NSCoder *)decoder; + +@property (nonatomic, retain) IBOutlet UIActivityIndicatorView* videoUpdateIndicator; + @end diff --git a/Classes/LinphoneUI/UIToggleVideoButton.m b/Classes/LinphoneUI/UIToggleVideoButton.m index 9f8db414d..1c96079a3 100644 --- a/Classes/LinphoneUI/UIToggleVideoButton.m +++ b/Classes/LinphoneUI/UIToggleVideoButton.m @@ -22,12 +22,18 @@ @implementation UIToggleVideoButton +@synthesize videoUpdateIndicator; + -(void) touchUp:(id) sender { LinphoneCore* lc = [LinphoneManager getLc]; if (!linphone_core_video_enabled(lc)) return; + [videoUpdateIndicator startAnimating]; + videoUpdateIndicator.hidden = NO; + self.enabled = NO; + LinphoneCall* call = linphone_core_get_current_call([LinphoneManager getLc]); if (call) { LinphoneCallParams* call_params = linphone_call_params_copy(linphone_call_get_current_params(call)); diff --git a/submodules/linphone b/submodules/linphone index 058d6b297..a43d75d8a 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 058d6b2972138f8d2b3eb945fca19980544a1f12 +Subproject commit a43d75d8a36099f14638eaf14606535fe559df7b