Hide voice mail icon on "1" button if it is not configured yet

This commit is contained in:
Gautier Pelloux-Prayer 2014-10-23 11:05:44 +02:00
parent 46d5d1a11c
commit 731cb1007f
4 changed files with 31 additions and 10 deletions

View file

@ -26,4 +26,10 @@
@interface UIDigitButtonLongVoiceMail : UIDigitButton {
}
/* Returns TRUE if voice mail is configured in LinphoneCore */
- (BOOL) voiceMailEnabled;
/*! Automatically chooses the right icon depending on voice mail configured or not */
- (void) refreshUI;
@end

View file

@ -29,17 +29,32 @@
}
- (void)onLongTouch {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger log:LinphoneLoggerWarning format:@"Cannot call voice mail: Linphone core not ready"];
return;
}
LinphoneManager* lm = [LinphoneManager instance];
NSString * voiceMailUri = [lm lpConfigStringForKey:@"voice_mail_uri" withDefault:NULL];
if (voiceMailUri != NULL) {
[lm call:voiceMailUri displayName:NSLocalizedString(@"Voice mail",nil) transfer:FALSE];
if ([self voiceMailEnabled]) {
LinphoneManager *lm = [LinphoneManager instance];
[lm call:[lm lpConfigStringForKey:@"voice_mail_uri"] displayName:NSLocalizedString(@"Voice mail",nil) transfer:FALSE];
}
}
- (BOOL) voiceMailEnabled {
if(![LinphoneManager isLcReady]) {
[LinphoneLogger log:LinphoneLoggerWarning format:@"Cannot call voice mail: Linphone core not ready"];
return FALSE;
}
NSString * voiceMailUri = [[LinphoneManager instance] lpConfigStringForKey:@"voice_mail_uri" withDefault:NULL];
return (voiceMailUri != NULL);
}
- (void)refreshUI {
NSMutableString *name = [[NSMutableString alloc] initWithString:@"numpad_one_"];
if ([self voiceMailEnabled]) {
[name appendString:@"voicemail_"];
}
[self setImage:[UIImage imageNamed:[name stringByAppendingString:@"default.png"]] forState: UIControlStateNormal];
[self setImage:[UIImage imageNamed:[name stringByAppendingString:@"over.png"]] forState: UIControlStateHighlighted];
}
@end

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB