call quality indicator on conf view

This commit is contained in:
Sylvain Berfini 2012-01-02 10:27:01 +01:00
parent c4a2d92ee4
commit 92f3d85dfd
3 changed files with 66 additions and 9 deletions

View file

@ -29,4 +29,6 @@
@property (nonatomic, retain) IBOutlet UITableView* table;
@property (nonatomic, assign) IBOutlet UITableViewCell* conferenceDetailCell;
-(void) updateCallQuality;
@end

View file

@ -21,6 +21,8 @@
@synthesize conferenceDetailCell;
NSTimer *callQualityRefresher;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
@ -75,6 +77,25 @@
[speaker reset];
}
-(void) viewDidAppear:(BOOL)animated {
callQualityRefresher = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(updateCallQuality)
userInfo:nil
repeats:YES];
}
-(void) viewDidDisappear:(BOOL)animated {
if (callQualityRefresher != nil) {
[callQualityRefresher invalidate];
callQualityRefresher=nil;
}
}
-(void) updateCallQuality {
[table setNeedsDisplay];
}
#pragma mark - UITableView delegates
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row % 2)
@ -97,9 +118,38 @@
UILabel* label = (UILabel*) [cell viewWithTag:2];
/* update cell content */
LinphoneCall* call = [IncallViewController retrieveCallAtIndex:indexPath.row inConference:YES];
LinphoneCall* call = [IncallViewController retrieveCallAtIndex:indexPath.row inConference:YES];
[IncallViewController updateCellImageView:image Label:label DetailLabel:nil AndAccessoryView:nil withCall:call];
cell.accessoryType = UITableViewCellAccessoryNone;
if (cell.accessoryView == nil) {
UIView *containerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 28, 28)] autorelease];
cell.accessoryView = containerView;
}
else {
for (UIView *view in cell.accessoryView.subviews) {
[view removeFromSuperview];
}
}
UIImageView* callquality = [UIImageView new];
[callquality setFrame:CGRectMake(0, 0, 28, 28)];
if (linphone_call_get_average_quality(call) >= 4) {
[callquality setImage: [IncallViewController stat_sys_signal_4]];
}
else if (linphone_call_get_average_quality(call) >= 3) {
[callquality setImage: [IncallViewController stat_sys_signal_3]];
}
else if (linphone_call_get_average_quality(call) >= 2) {
[callquality setImage: [IncallViewController stat_sys_signal_2]];
}
else if (linphone_call_get_average_quality(call) >= 1) {
[callquality setImage: [IncallViewController stat_sys_signal_1]];
}
else {
[callquality setImage: [IncallViewController stat_sys_signal_0]];
}
[cell.accessoryView addSubview:callquality];
tableView.rowHeight = 80;//cell.bounds.size.height;
return cell;

View file

@ -44,6 +44,8 @@
@synthesize mHangUpLandLeft;
@synthesize mCamSwitchLandLeft;
NSTimer *callQualityRefresher;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
@ -79,16 +81,8 @@
[mCamSwitchLandRight setPreview:mPreviewLandRight];
[mCamSwitchLandLeft setPreview:mPreviewLandLeft];
[self performSelector:@selector(waitBeforeUpdatingCallQualityIndicator) withObject:nil afterDelay:1];
isFirst=TRUE;
}
- (void) waitBeforeUpdatingCallQualityIndicator
{
[self performSelectorOnMainThread:@selector(updateCallQualityIndicator) withObject:nil waitUntilDone:YES];
[self performSelector:@selector(waitBeforeUpdatingCallQualityIndicator) withObject:nil afterDelay:1];
}
- (void) updateCallQualityIndicator
{
@ -158,6 +152,11 @@
[super viewDidDisappear:animated];
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
linphone_core_set_max_calls([LinphoneManager getLc], maxCall);
if (callQualityRefresher != nil) {
[callQualityRefresher invalidate];
callQualityRefresher=nil;
}
}
-(void) viewWillAppear:(BOOL)animated {
@ -183,6 +182,12 @@
- (void) viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
callQualityRefresher = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(updateCallQualityIndicator)
userInfo:nil
repeats:YES];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {