From 3e75e3fd629be33fa8d3891bae76fc9ea2b4cd7f Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Fri, 27 Jul 2012 14:04:03 +0200 Subject: [PATCH] Add landscape option --- Classes/LinphoneCoreSettingsStore.m | 4 +++ .../LinphoneUI/UICompositeViewController.m | 7 ++--- Classes/SettingsViewController.m | 31 +++++++++++++++++++ Settings/InAppSettings.bundle/Advanced.plist | 10 ++++++ 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 104bd95d7..d75a6aefe 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -176,6 +176,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } [self setString:val forKey:@"media_encryption_preference"]; } + [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","landscape_preference", 1) forKey:@"landscape_preference"]; [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","enable_first_login_view_preference", 0) forKey:@"enable_first_login_view_preference"]; [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","debugenable_preference", 0) forKey:@"debugenable_preference"]; [self setBool: lp_config_get_int(linphone_core_get_config(lc),"app","check_config_disable_preference", 0) forKey:@"check_config_disable_preference"]; @@ -448,6 +449,9 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); BOOL firstloginview = [self boolForKey:@"enable_first_login_view_preference"]; lp_config_set_int(linphone_core_get_config(lc),"app","enable_first_login_view_preference", firstloginview); + BOOL landscape = [self boolForKey:@"landscape_preference"]; + lp_config_set_int(linphone_core_get_config(lc),"app","landscape_preference", landscape); + BOOL debugmode = [self boolForKey:@"debugenable_preference"]; lp_config_set_int(linphone_core_get_config(lc),"app","debugenable_preference", debugmode); if (debugmode) linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler); diff --git a/Classes/LinphoneUI/UICompositeViewController.m b/Classes/LinphoneUI/UICompositeViewController.m index 578224e03..547de4cb0 100644 --- a/Classes/LinphoneUI/UICompositeViewController.m +++ b/Classes/LinphoneUI/UICompositeViewController.m @@ -201,16 +201,15 @@ } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - if(currentViewDescription != nil) { + if(currentViewDescription != nil && [[LinphoneManager instance].settingsStore boolForKey:@"landscape_preference"]) { if (UIInterfaceOrientationIsPortrait(interfaceOrientation) && [currentViewDescription portraitMode]) { return YES; } if (UIInterfaceOrientationIsLandscape(interfaceOrientation) && [currentViewDescription landscapeMode]) { return YES; } - return NO; } - return YES; + return NO; } @@ -254,7 +253,7 @@ } - (UIInterfaceOrientation)getCorrectInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - if(currentViewDescription != nil) { + if(currentViewDescription != nil && [[LinphoneManager instance].settingsStore boolForKey:@"landscape_preference"]) { if (UIInterfaceOrientationIsPortrait(interfaceOrientation)) { if ([currentViewDescription portraitMode]) { return interfaceOrientation; diff --git a/Classes/SettingsViewController.m b/Classes/SettingsViewController.m index 14c9fbefe..72c09b0a3 100644 --- a/Classes/SettingsViewController.m +++ b/Classes/SettingsViewController.m @@ -95,12 +95,43 @@ [((IASKSwitchEx*)cell.accessoryView) addTarget:self action:@selector(toggledValue:) forControlEvents:UIControlEventValueChanged]; [((IASKSwitchEx*)cell.accessoryView) setOnTintColor:LINPHONE_MAIN_COLOR]; cell.selectionStyle = UITableViewCellSelectionStyleNone; + cell.textLabel.minimumFontSize = kIASKMinimumFontSize; + cell.detailTextLabel.minimumFontSize = kIASKMinimumFontSize; } else { cell = [super newCellForIdentifier:identifier]; } return cell; } +- (void)toggledValue:(id)sender { + IASKSwitchEx *toggle = [[(IASKSwitchEx*)sender retain] autorelease]; + IASKSpecifier *spec = [_settingsReader specifierForKey:[toggle key]]; + + if ([toggle isOn]) { + if ([spec trueValue] != nil) { + [self.settingsStore setObject:[spec trueValue] forKey:[toggle key]]; + } + else { + [self.settingsStore setBool:YES forKey:[toggle key]]; + } + } + else { + if ([spec falseValue] != nil) { + [self.settingsStore setObject:[spec falseValue] forKey:[toggle key]]; + } + else { + [self.settingsStore setBool:NO forKey:[toggle key]]; + } + } + // Start notification after animation of DCRoundSwitch + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:kIASKAppSettingChanged + object:[toggle key] + userInfo:[NSDictionary dictionaryWithObject:[self.settingsStore objectForKey:[toggle key]] + forKey:[toggle key]]]; + }); +} + - (void)initIASKAppSettingsViewControllerEx { // Force kIASKSpecifierValuesViewControllerIndex static int kIASKSpecifierValuesViewControllerIndex = 0; diff --git a/Settings/InAppSettings.bundle/Advanced.plist b/Settings/InAppSettings.bundle/Advanced.plist index 787a4bbc0..6bec34682 100644 --- a/Settings/InAppSettings.bundle/Advanced.plist +++ b/Settings/InAppSettings.bundle/Advanced.plist @@ -14,6 +14,16 @@ Type PSToggleSwitchSpecifier + + DefaultValue + + Key + landscape_preference + Title + Landscape + Type + PSToggleSwitchSpecifier + DefaultValue