Skip to content

Commit

Permalink
Merge pull request #1622 from nextcloud/include-calls-in-recents-setting
Browse files Browse the repository at this point in the history
Include calls in recents setting
  • Loading branch information
Ivansss committed Apr 15, 2024
2 parents ac742ba + 5205127 commit 2d7aca5
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 7 deletions.
1 change: 1 addition & 0 deletions NextcloudTalk/CallKitManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 21 additions & 7 deletions NextcloudTalk/CallKitManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]) {
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions NextcloudTalk/NCUserDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSInteger)preferredCameraFlashMode;
+ (void)setBackgroundBlurEnabled:(BOOL)enabled;
+ (BOOL)backgroundBlurEnabled;
+ (void)setIncludeCallsInRecentsEnabled:(BOOL)enabled;
+ (BOOL)includeCallsInRecents;

@end

Expand Down
17 changes: 17 additions & 0 deletions NextcloudTalk/NCUserDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ @implementation NCUserDefaults

NSString * const kNCPreferredCameraFlashMode = @"ncPreferredCameraFlashMode";
NSString * const kNCBackgroundBlurEnabled = @"ncBackgroundBlurEnabled";
NSString * const kNCIncludeCallsInRecents = @"ncIncludeCallsInRecents";

+ (void)setPreferredCameraFlashMode:(NSInteger)flashMode
{
Expand All @@ -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
22 changes: 22 additions & 0 deletions NextcloudTalk/SettingsTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum AccountSettingsOptions: Int {

enum ConfigurationSectionOption: Int {
case kConfigurationSectionOptionVideo = 0
case kConfigurationSectionOptionRecents
}

enum AdvancedSectionOption: Int {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions NextcloudTalk/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down

0 comments on commit 2d7aca5

Please sign in to comment.