Add Application badge based on missed calls/unread messages

This commit is contained in:
Yann Diorcet 2012-08-03 12:01:22 +02:00
parent 0f330d8e6c
commit 95dc0fd88c
5 changed files with 23 additions and 8 deletions

View file

@ -81,6 +81,11 @@ static UICompositeViewDescription *compositeDescription = nil;
[editButton setOff];
[self changeView: History_All];
[self.tableView reloadData];
// Reset missed call
linphone_core_reset_missed_calls_count([LinphoneManager getLc]);
// Fake event
[[NSNotificationCenter defaultCenter] postNotificationName:@"LinphoneCallUpdate" object:self];
}
- (void)viewDidLoad {

View file

@ -165,6 +165,7 @@ int __aeabi_idiv(int a, int b) {
}
- (void)setupUI {
[[PhoneMainView instance] startUp];
if ([[LinphoneManager instance].settingsStore boolForKey:@"enable_first_login_view_preference"] == true) {
// Change to fist login view
[[PhoneMainView instance] changeCurrentView: [FirstLoginViewController compositeViewDescription]];

View file

@ -258,13 +258,7 @@
[target.layer removeAnimationForKey:animationID];
}
- (void)updateView:(UICompositeViewDescription*) view {
// Reset missed call
if([view equal:[HistoryViewController compositeViewDescription]]) {
linphone_core_reset_missed_calls_count([LinphoneManager getLc]);
[self updateMissedCall:0 appear:FALSE];
}
- (void)updateView:(UICompositeViewDescription*) view {
// Update buttons
if([view equal:[HistoryViewController compositeViewDescription]]) {
historyButton.selected = TRUE;

View file

@ -60,6 +60,8 @@
- (void)showStateBar:(BOOL)show;
- (void)showTabBar:(BOOL)show;
- (void)fullScreen:(BOOL)enabled;
- (void)startUp;
+ (void)forceOrientation:(UIInterfaceOrientation)orientation animated:(BOOL)animated;
+ (PhoneMainView*) instance;

View file

@ -114,7 +114,7 @@ static PhoneMainView* phoneMainViewInstance=nil;
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(batteryLevelChanged:)
name:UIDeviceBatteryLevelDidChangeNotification
name:UIDeviceBatteryLevelDidChangeNotification
object:nil];
}
@ -242,6 +242,7 @@ static PhoneMainView* phoneMainViewInstance=nil;
ChatModel *chat = [[notif userInfo] objectForKey:@"chat"];
if(chat != nil) {
[self displayMessage:chat];
[self updateApplicationBadgeNumber];
}
}
@ -340,11 +341,23 @@ static PhoneMainView* phoneMainViewInstance=nil;
default:
break;
}
[self updateApplicationBadgeNumber];
}
#pragma mark -
- (void)startUp {
[self updateApplicationBadgeNumber]; // Update Badge at startup
}
- (void)updateApplicationBadgeNumber {
int count = 0;
count += linphone_core_get_missed_calls_count([LinphoneManager getLc]);
count += [ChatModel unreadMessages];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:count];
}
+ (CATransition*)getBackwardTransition {
CATransition* trans = [CATransition animation];
[trans setType:kCATransitionPush];