diff --git a/NextcloudTalk/CallKitManager.h b/NextcloudTalk/CallKitManager.h index ea24456f6..294be1a73 100644 --- a/NextcloudTalk/CallKitManager.h +++ b/NextcloudTalk/CallKitManager.h @@ -52,6 +52,7 @@ extern NSString * const CallKitManagerDidFailRequestingCallTransactionNotificati + (instancetype)sharedInstance; + (BOOL)isCallKitAvailable; +- (void)setDefaultProviderConfiguration; - (void)reportIncomingCall:(NSString *)token withDisplayName:(NSString *)displayName forAccountId:(NSString *)accountId; - (void)reportIncomingCallForNonCallKitDevicesWithPushNotification:(NCPushNotification *)pushNotification; - (void)reportIncomingCallForOldAccount; diff --git a/NextcloudTalk/CallKitManager.m b/NextcloudTalk/CallKitManager.m index 9fc279ac9..dd0259a6c 100644 --- a/NextcloudTalk/CallKitManager.m +++ b/NextcloudTalk/CallKitManager.m @@ -100,13 +100,7 @@ + (BOOL)isCallKitAvailable - (CXProvider *)provider { if (!_provider) { - CXProviderConfiguration *configuration = [[CXProviderConfiguration alloc] init]; - configuration.supportsVideo = YES; - configuration.maximumCallGroups = 1; - configuration.maximumCallsPerCallGroup = 1; - configuration.supportedHandleTypes = [NSSet setWithObjects:@(CXHandleTypePhoneNumber), @(CXHandleTypeEmailAddress), @(CXHandleTypeGeneric), nil]; - configuration.iconTemplateImageData = UIImagePNGRepresentation([UIImage imageNamed:@"app-logo-callkit"]); - _provider = [[CXProvider alloc] initWithConfiguration:configuration]; + _provider = [[CXProvider alloc] initWithConfiguration:[self defaultProviderConfiguration]]; [_provider setDelegate:self queue:nil]; } return _provider; @@ -134,6 +128,19 @@ - (CXCallUpdate *)defaultCallUpdate return update; } +- (CXProviderConfiguration *)defaultProviderConfiguration +{ + CXProviderConfiguration *configuration = [[CXProviderConfiguration alloc] init]; + configuration.supportsVideo = YES; + configuration.maximumCallGroups = 1; + configuration.maximumCallsPerCallGroup = 1; + configuration.includesCallsInRecents = [NCUserDefaults includeCallsInRecents]; + configuration.supportedHandleTypes = [NSSet setWithObjects:@(CXHandleTypePhoneNumber), @(CXHandleTypeEmailAddress), @(CXHandleTypeGeneric), nil]; + configuration.iconTemplateImageData = UIImagePNGRepresentation([UIImage imageNamed:@"app-logo-callkit"]); + + return configuration; +} + - (CallKitCall *)callForToken:(NSString *)token { for (CallKitCall *call in [_calls allValues]) { @@ -147,6 +154,13 @@ - (CallKitCall *)callForToken:(NSString *)token #pragma mark - Actions +- (void)setDefaultProviderConfiguration +{ + if (_provider) { + [_provider setConfiguration:[self defaultProviderConfiguration]]; + } +} + - (void)reportIncomingCall:(NSString *)token withDisplayName:(NSString *)displayName forAccountId:(NSString *)accountId { BOOL ongoingCalls = _calls.count > 0; diff --git a/NextcloudTalk/NCUserDefaults.h b/NextcloudTalk/NCUserDefaults.h index 92ef70168..7dff9c67c 100644 --- a/NextcloudTalk/NCUserDefaults.h +++ b/NextcloudTalk/NCUserDefaults.h @@ -31,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN + (NSInteger)preferredCameraFlashMode; + (void)setBackgroundBlurEnabled:(BOOL)enabled; + (BOOL)backgroundBlurEnabled; ++ (void)setIncludeCallsInRecentsEnabled:(BOOL)enabled; ++ (BOOL)includeCallsInRecents; @end diff --git a/NextcloudTalk/NCUserDefaults.m b/NextcloudTalk/NCUserDefaults.m index edb985d46..20ab91753 100644 --- a/NextcloudTalk/NCUserDefaults.m +++ b/NextcloudTalk/NCUserDefaults.m @@ -29,6 +29,7 @@ @implementation NCUserDefaults NSString * const kNCPreferredCameraFlashMode = @"ncPreferredCameraFlashMode"; NSString * const kNCBackgroundBlurEnabled = @"ncBackgroundBlurEnabled"; +NSString * const kNCIncludeCallsInRecents = @"ncIncludeCallsInRecents"; + (void)setPreferredCameraFlashMode:(NSInteger)flashMode { @@ -50,4 +51,20 @@ + (BOOL)backgroundBlurEnabled return [[[NSUserDefaults standardUserDefaults] objectForKey:kNCBackgroundBlurEnabled] boolValue]; } ++ (void)setIncludeCallsInRecentsEnabled:(BOOL)enabled +{ + [[NSUserDefaults standardUserDefaults] setObject:@(enabled) forKey:kNCIncludeCallsInRecents]; +} + ++ (BOOL)includeCallsInRecents +{ + id includeCallsInRecentsObject = [[NSUserDefaults standardUserDefaults] objectForKey:kNCIncludeCallsInRecents]; + if (includeCallsInRecentsObject == nil) { + [self setIncludeCallsInRecentsEnabled:YES]; + return YES; + } + + return [includeCallsInRecentsObject boolValue]; +} + @end diff --git a/NextcloudTalk/SettingsTableViewController.swift b/NextcloudTalk/SettingsTableViewController.swift index fe4828db6..8660b58be 100644 --- a/NextcloudTalk/SettingsTableViewController.swift +++ b/NextcloudTalk/SettingsTableViewController.swift @@ -44,6 +44,7 @@ enum AccountSettingsOptions: Int { enum ConfigurationSectionOption: Int { case kConfigurationSectionOptionVideo = 0 + case kConfigurationSectionOptionRecents } enum AdvancedSectionOption: Int { @@ -73,6 +74,7 @@ class SettingsTableViewController: UITableViewController, UITextFieldDelegate, U var contactSyncSwitch = UISwitch() var setPhoneAction: UIAlertAction? var phoneUtil = NBPhoneNumberUtil() + var includeInRecentsSwitch = UISwitch() var totalImageCacheSize = 0 var totalFileCacheSize = 0 @@ -116,6 +118,9 @@ class SettingsTableViewController: UITableViewController, UITextFieldDelegate, U readStatusSwitch.frame = .zero readStatusSwitch.addTarget(self, action: #selector(readStatusValueChanged(_:)), for: .valueChanged) + includeInRecentsSwitch.frame = .zero + includeInRecentsSwitch.addTarget(self, action: #selector(includeInRecentsValueChanged(_:)), for: .valueChanged) + typingIndicatorSwitch.frame = .zero typingIndicatorSwitch.addTarget(self, action: #selector(typingIndicatorValueChanged(_:)), for: .valueChanged) @@ -217,6 +222,9 @@ class SettingsTableViewController: UITableViewController, UITextFieldDelegate, U // Video quality options.append(ConfigurationSectionOption.kConfigurationSectionOptionVideo.rawValue) + // Calls in recents + options.append(ConfigurationSectionOption.kConfigurationSectionOptionRecents.rawValue) + return options } @@ -534,6 +542,11 @@ class SettingsTableViewController: UITableViewController, UITextFieldDelegate, U self.present(errorDialog, animated: true, completion: nil) } + @objc func includeInRecentsValueChanged(_ sender: Any?) { + NCUserDefaults.setIncludeCallsInRecentsEnabled(includeInRecentsSwitch.isOn) + CallKitManager.sharedInstance().setDefaultProviderConfiguration() + } + // MARK: - Advanced actions func diagnosticsPressed() { @@ -926,6 +939,15 @@ extension SettingsTableViewController { resolutionLabel.textColor = .secondaryLabel resolutionLabel.sizeToFit() cell.accessoryView = resolutionLabel + + case ConfigurationSectionOption.kConfigurationSectionOptionRecents.rawValue: + cell = UITableViewCell(style: .default, reuseIdentifier: videoConfigurationCellIdentifier) + cell.textLabel?.text = NSLocalizedString("Include calls in call history", comment: "") + cell.setSettingsImage(image: UIImage(systemName: "clock.arrow.circlepath")?.applyingSymbolConfiguration(iconConfiguration)) + cell.selectionStyle = .none + cell.accessoryView = includeInRecentsSwitch + includeInRecentsSwitch.isOn = NCUserDefaults.includeCallsInRecents() + default: break } diff --git a/NextcloudTalk/en.lproj/Localizable.strings b/NextcloudTalk/en.lproj/Localizable.strings index 4e985f172..32c53ba17 100644 --- a/NextcloudTalk/en.lproj/Localizable.strings +++ b/NextcloudTalk/en.lproj/Localizable.strings @@ -898,6 +898,9 @@ /* No comment provided by engineer. */ "in" = "in"; +/* No comment provided by engineer. */ +"Include calls in call history" = "Include calls in call history"; + /* Internal signaling used */ "Internal" = "Internal";