Final fix for bad UI at pristine first start

This commit is contained in:
Guillaume BIENKOWSKI 2014-10-15 10:49:11 +02:00
parent 9fd068be37
commit d29f0629cf
3 changed files with 43 additions and 27 deletions

View file

@ -26,13 +26,12 @@
@interface LinphoneAppDelegate : NSObject <UIApplicationDelegate,UIAlertViewDelegate> {
@private
UIBackgroundTaskIdentifier bgStartId;
BOOL started;
BOOL startedInBackground;
int savedMaxCall;
}
- (void)processRemoteNotification:(NSDictionary*)userInfo;
@property (assign) BOOL started;
@property (nonatomic, retain) UIAlertView *waitingIndicator;
@property (nonatomic, retain) NSString *configURL;
@property (nonatomic, strong) UIWindow* window;

View file

@ -32,7 +32,7 @@
@implementation LinphoneAppDelegate
@synthesize started,configURL;
@synthesize configURL;
@synthesize window;
#pragma mark - Lifecycle Functions
@ -40,7 +40,7 @@
- (id)init {
self = [super init];
if(self != nil) {
self->started = FALSE;
self->startedInBackground = FALSE;
}
return self;
}
@ -89,6 +89,11 @@
[LinphoneLogger logc:LinphoneLoggerLog format:"applicationDidBecomeActive"];
[self startApplication];
if( startedInBackground ){
startedInBackground = FALSE;
[[PhoneMainView instance] startUp];
[[PhoneMainView instance] updateStatusBar:nil];
}
LinphoneManager* instance = [LinphoneManager instance];
[instance becomeActive];
@ -172,6 +177,7 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIApplication* app= [UIApplication sharedApplication];
UIApplicationState state = app.applicationState;
if( [app respondsToSelector:@selector(registerUserNotificationSettings:)] ){
/* iOS8 notifications can be actioned! Awesome: */
@ -185,14 +191,14 @@
NSUInteger notifTypes = UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeNewsstandContentAvailability;
[app registerForRemoteNotificationTypes:notifTypes];
}
LinphoneManager* instance = [LinphoneManager instance];
BOOL background_mode = [instance lpConfigBoolForKey:@"backgroundmode_preference"];
BOOL start_at_boot = [instance lpConfigBoolForKey:@"start_at_boot_preference"];
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground)
&& state == UIApplicationStateBackground)
{
// we've been woken up directly to background;
if( !start_at_boot || !background_mode ) {
@ -207,14 +213,25 @@
[LinphoneLogger log:LinphoneLoggerWarning format:@"Background task for application launching expired."];
[[UIApplication sharedApplication] endBackgroundTask:bgStartId];
}];
[self startApplication];
// initialize UI
[self.window makeKeyAndVisible];
[RootViewManager setupWithPortrait:(PhoneMainView*)self.window.rootViewController];
if( state == UIApplicationStateBackground ){
startedInBackground = TRUE;
} else {
[[PhoneMainView instance] startUp];
[[PhoneMainView instance] updateStatusBar:nil];
}
NSDictionary *remoteNotif =[launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (remoteNotif){
[LinphoneLogger log:LinphoneLoggerLog format:@"PushNotification from launch received."];
[self processRemoteNotification:remoteNotif];
}
if (bgStartId!=UIBackgroundTaskInvalid) [[UIApplication sharedApplication] endBackgroundTask:bgStartId];
[[PhoneMainView instance] updateStatusBar:nil];
return YES;
}
@ -224,11 +241,6 @@
if(![LinphoneManager isLcReady]) {
[[LinphoneManager instance] startLibLinphone];
}
if([LinphoneManager isLcReady] && !started) {
started = TRUE;
[self.window makeKeyAndVisible];
[[PhoneMainView instance] startUp];
}
}
- (void)applicationWillTerminate:(UIApplication *)application {

View file

@ -431,26 +431,31 @@ static RootViewManager* rootViewManagerInstance = nil;
}
- (void)startUp {
if( linphone_core_get_global_state([LinphoneManager getLc]) != LinphoneGlobalOn ){
[self changeCurrentView: [DialerViewController compositeViewDescription]];
} else if ([[LinphoneManager instance] lpConfigBoolForKey:@"enable_first_login_view_preference"] == true) {
// Change to fist login view
[self changeCurrentView: [FirstLoginViewController compositeViewDescription]];
} else {
// Change to default view
const MSList *list = linphone_core_get_proxy_config_list([LinphoneManager getLc]);
if(list != NULL || ([[LinphoneManager instance] lpConfigBoolForKey:@"hide_wizard_preference"] == true)) {
LinphoneCore* core = nil;
@try {
core = [LinphoneManager getLc];
if( linphone_core_get_global_state(core) != LinphoneGlobalOn ){
[self changeCurrentView: [DialerViewController compositeViewDescription]];
} else if ([[LinphoneManager instance] lpConfigBoolForKey:@"enable_first_login_view_preference"] == true) {
// Change to fist login view
[self changeCurrentView: [FirstLoginViewController compositeViewDescription]];
} else {
WizardViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[WizardViewController compositeViewDescription]], WizardViewController);
if(controller != nil) {
[controller reset];
// Change to default view
const MSList *list = linphone_core_get_proxy_config_list(core);
if(list != NULL || ([[LinphoneManager instance] lpConfigBoolForKey:@"hide_wizard_preference"] == true)) {
[self changeCurrentView: [DialerViewController compositeViewDescription]];
} else {
WizardViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[WizardViewController compositeViewDescription]], WizardViewController);
if(controller != nil) {
[controller reset];
}
}
}
[self updateApplicationBadgeNumber]; // Update Badge at startup
}
@catch (NSException *exception) {
// we'll wait until the app transitions correctly
}
[self updateApplicationBadgeNumber]; // Update Badge at startup
}
- (void)updateApplicationBadgeNumber {