fix initial default value taken from bundle

This commit is contained in:
Jehan Monnier 2011-03-25 17:12:41 +01:00
parent df5635e506
commit 59a798d199
2 changed files with 12 additions and 24 deletions

View file

@ -43,17 +43,17 @@
[[LinphoneManager instance] becomeActive];
}
- (void)registerDefaultsFromSettingsBundle {
// source: http://stackoverflow.com/questions/510216/
- (void) loadDefaultSettings {
NSString *settingsBundle = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"];
if(!settingsBundle) {
NSLog(@"Could not find Settings.bundle");
return;
}
NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:[settingsBundle stringByAppendingPathComponent:@"Root.plist"]];
NSArray *preferences = [settings objectForKey:@"PreferenceSpecifiers"];
NSMutableDictionary *defaultsToRegister = [[NSMutableDictionary alloc] initWithCapacity:[preferences count]];
for(NSDictionary *prefSpecification in preferences) {
NSString *key = [prefSpecification objectForKey:@"Key"];
@ -61,26 +61,15 @@
[defaultsToRegister setObject:[prefSpecification objectForKey:@"DefaultValue"] forKey:key];
}
}
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
@"NO", @"enable_first_login_view_preference", //
nil];
[defaultsToRegister addEntriesFromDictionary:appDefaults];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultsToRegister];
[defaultsToRegister release];
}
- (void) loadDefaultSettings {
// if this is the first launch after installing, we would like to load default settings values from Settings.bundle
NSObject *somePrefVal = [[NSUserDefaults standardUserDefaults] objectForKey:@"debugenable_preference"];
if(!somePrefVal) {
// has no value, so defaults have not been loaded yet
[self registerDefaultsFromSettingsBundle];
}
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
@"NO", @"enable_first_login_view_preference", //
nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[[NSUserDefaults standardUserDefaults] synchronize];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

View file

@ -401,8 +401,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
proxyReachability=SCNetworkReachabilityCreateWithName(nil, linphone_address_get_domain(addr));
} else {
if (configCheckDisable == false
&& (!domain && !username)) {
if (configCheckDisable == false ) {
UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Warning"
message:@"It seems you have not configured any proxy server from settings"
delegate:self