Add landscape option

This commit is contained in:
Yann Diorcet 2012-07-27 14:04:03 +02:00
parent 332ab5e4ee
commit 3e75e3fd62
4 changed files with 48 additions and 4 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -14,6 +14,16 @@
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<false/>
<key>Key</key>
<string>landscape_preference</string>
<key>Title</key>
<string>Landscape</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<true/>