diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index a0877f3e9..0fb6e97be 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -283,6 +283,7 @@ "settings_user_settings" = "USER SETTINGS"; "settings_notifications_settings" = "NOTIFICATION SETTINGS"; +"settings_calls_settings" = "CALLS"; "settings_ignored_users" = "IGNORED USERS"; "settings_contacts" = "LOCAL CONTACTS"; "settings_advanced" = "ADVANCED"; @@ -323,6 +324,9 @@ //"settings_join_leave_rooms" = "When people join or leave rooms"; //"settings_call_invitations" = "Call invitations"; +"settings_enable_callkit" = "Integrated calling"; +"settings_callkit_info" = "Receive incoming calls on your lock screen. See your Riot calls in the system's call history. If iCloud is enabled, this call history will be shared with Apple."; + "settings_unignore_user" = "Show all messages from %@?"; "settings_contacts_discover_matrix_users" = "Use emails and phone numbers to discover users"; diff --git a/Riot/ViewController/SettingsViewController.m b/Riot/ViewController/SettingsViewController.m index 444dace55..8003a2d95 100644 --- a/Riot/ViewController/SettingsViewController.m +++ b/Riot/ViewController/SettingsViewController.m @@ -17,32 +17,30 @@ #import "SettingsViewController.h" -#import "AppDelegate.h" - -#import "AvatarGenerator.h" - -#import +#import #import #import +#import +#import -#import "MXKEncryptionKeysExportView.h" +#import "AppDelegate.h" +#import "AvatarGenerator.h" #import "BugReportViewController.h" - #import "CountryPickerViewController.h" +#import "MXKEncryptionKeysExportView.h" +#import "NBPhoneNumberUtil.h" +#import "RageShakeManager.h" +#import "RiotDesignValues.h" #import "TableViewCellWithPhoneNumberTextField.h" -#import "NBPhoneNumberUtil.h" - -#import "OLMKit/OLMKit.h" - - -NSString* const kSettingsViewControllerPhoneBookCountryCellId = @"kSettingsViewControllerPhoneBookCountryCellId"; +static NSString* const kSettingsViewControllerPhoneBookCountryCellId = @"kSettingsViewControllerPhoneBookCountryCellId"; enum { SETTINGS_SECTION_SIGN_OUT_INDEX = 0, SETTINGS_SECTION_USER_SETTINGS_INDEX, SETTINGS_SECTION_NOTIFICATIONS_SETTINGS_INDEX, + SETTINGS_SECTION_CALLS_INDEX, SETTINGS_SECTION_IGNORED_USERS_INDEX, SETTINGS_SECTION_CONTACTS_INDEX, SETTINGS_SECTION_ADVANCED_INDEX, @@ -68,6 +66,13 @@ enum NOTIFICATION_SETTINGS_COUNT }; +enum +{ + CALLS_ENABLE_CALLKIT_INDEX = 0, + CALLS_DESCRIPTION_INDEX, + CALLS_COUNT +}; + enum { OTHER_VERSION_INDEX = 0, @@ -1076,6 +1081,13 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); { count = NOTIFICATION_SETTINGS_COUNT; } + else if (section == SETTINGS_SECTION_CALLS_INDEX) + { + if ([MXCallKitAdapter callKitAvailable]) + { + count = CALLS_COUNT; + } + } else if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX) { if ([AppDelegate theDelegate].mxSessions.count > 0) @@ -1541,6 +1553,29 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); cell = labelAndSwitchCell; } } + else if (section == SETTINGS_SECTION_CALLS_INDEX) + { + if (row == CALLS_ENABLE_CALLKIT_INDEX) + { + MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath]; + labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_enable_callkit", @"Vector", nil); + labelAndSwitchCell.mxkSwitch.on = [MXKAppSettings standardAppSettings].isCallKitEnabled; + labelAndSwitchCell.mxkSwitch.enabled = YES; + [labelAndSwitchCell.mxkSwitch removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside]; + [labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleCallKit:) forControlEvents:UIControlEventTouchUpInside]; + + cell = labelAndSwitchCell; + } + else if (row == CALLS_DESCRIPTION_INDEX) + { + MXKTableViewCell *globalInfoCell = [self getDefaultTableViewCell:tableView]; + globalInfoCell.textLabel.text = NSLocalizedStringFromTable(@"settings_callkit_info", @"Vector", nil); + globalInfoCell.textLabel.numberOfLines = 0; + globalInfoCell.selectionStyle = UITableViewCellSelectionStyleNone; + + cell = globalInfoCell; + } + } else if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX) { MXKTableViewCell *ignoredUserCell = [self getDefaultTableViewCell:tableView]; @@ -1843,6 +1878,13 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); { return NSLocalizedStringFromTable(@"settings_notifications_settings", @"Vector", nil); } + else if (section == SETTINGS_SECTION_CALLS_INDEX) + { + if ([MXCallKitAdapter callKitAvailable]) + { + return NSLocalizedStringFromTable(@"settings_calls_settings", @"Vector", nil); + } + } else if (section == SETTINGS_SECTION_IGNORED_USERS_INDEX) { // Check whether this section is visible @@ -1937,6 +1979,13 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); } } } + else if (section == SETTINGS_SECTION_CALLS_INDEX) + { + if (![MXCallKitAdapter callKitAvailable]) + { + return SECTION_TITLE_PADDING_WHEN_HIDDEN; + } + } return 24; } @@ -1955,6 +2004,13 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); } } } + else if (section == SETTINGS_SECTION_CALLS_INDEX) + { + if (![MXCallKitAdapter callKitAvailable]) + { + return SECTION_TITLE_PADDING_WHEN_HIDDEN; + } + } return 24; } @@ -2357,6 +2413,12 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)(); } } +- (void)toggleCallKit:(id)sender +{ + UISwitch *switchButton = (UISwitch*)sender; + [MXKAppSettings standardAppSettings].enableCallKit = switchButton.isOn; +} + - (void)toggleLocalContactsSync:(id)sender { UISwitch *switchButton = (UISwitch*)sender;