From 6aa6f4895b911ca6ec057bd918fe6e61fc797138 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 2 Mar 2017 13:03:41 -0500 Subject: [PATCH] Combine callkit sections // FREEBIE --- .../PrivacySettingsTableViewController.m | 31 +++++++++---------- .../translations/en.lproj/Localizable.strings | 4 +-- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Signal/src/view controllers/PrivacySettingsTableViewController.m b/Signal/src/view controllers/PrivacySettingsTableViewController.m index 4d1561bb1..529b2fcb8 100644 --- a/Signal/src/view controllers/PrivacySettingsTableViewController.m +++ b/Signal/src/view controllers/PrivacySettingsTableViewController.m @@ -16,8 +16,7 @@ NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, PrivacySettingsTableViewControllerSectionIndex) { PrivacySettingsTableViewControllerSectionIndexScreenSecurity, PrivacySettingsTableViewControllerSectionIndexCalling, - PrivacySettingsTableViewControllerSectionIndexCallKitEnabled, - PrivacySettingsTableViewControllerSectionIndexCallKitPrivacy, + PrivacySettingsTableViewControllerSectionIndexCallKit, PrivacySettingsTableViewControllerSectionIndexHistoryLog, PrivacySettingsTableViewControllerSectionIndexBlockOnIdentityChange, PrivacySettingsTableViewControllerSectionIndex_Count // meta section to track how many sections @@ -135,10 +134,11 @@ typedef NS_ENUM(NSInteger, PrivacySettingsTableViewControllerSectionIndex) { return 1; case PrivacySettingsTableViewControllerSectionIndexCalling: return 1; - case PrivacySettingsTableViewControllerSectionIndexCallKitEnabled: - return [UIDevice currentDevice].supportsCallKit ? 1 : 0; - case PrivacySettingsTableViewControllerSectionIndexCallKitPrivacy: - return ([UIDevice currentDevice].supportsCallKit && [[Environment getCurrent].preferences isCallKitEnabled]) ? 1 : 0; + case PrivacySettingsTableViewControllerSectionIndexCallKit: + if (![UIDevice currentDevice].supportsCallKit) { + return 0; + } + return [Environment getCurrent].preferences.isCallKitEnabled ? 2 : 1; case PrivacySettingsTableViewControllerSectionIndexHistoryLog: return 1; case PrivacySettingsTableViewControllerSectionIndexBlockOnIdentityChange: @@ -156,15 +156,10 @@ typedef NS_ENUM(NSInteger, PrivacySettingsTableViewControllerSectionIndex) { case PrivacySettingsTableViewControllerSectionIndexCalling: return NSLocalizedString(@"SETTINGS_CALLING_HIDES_IP_ADDRESS_PREFERENCE_TITLE_DETAIL", @"User settings section footer, a detailed explanation"); - case PrivacySettingsTableViewControllerSectionIndexCallKitEnabled: + case PrivacySettingsTableViewControllerSectionIndexCallKit: return ([UIDevice currentDevice].supportsCallKit ? NSLocalizedString(@"SETTINGS_SECTION_CALL_KIT_DESCRIPTION", @"Settings table section footer.") : nil); - case PrivacySettingsTableViewControllerSectionIndexCallKitPrivacy: - return (([UIDevice currentDevice].supportsCallKit && [[Environment getCurrent].preferences isCallKitEnabled]) - ? NSLocalizedString(@"SETTINGS_SECTION_CALL_KIT_PRIVACY_DESCRIPTION", - @"Explanation of the 'CallKit Privacy` preference.") - : nil); case PrivacySettingsTableViewControllerSectionIndexBlockOnIdentityChange: return NSLocalizedString( @"SETTINGS_BLOCK_ON_IDENITY_CHANGE_DETAIL", @"User settings section footer, a detailed explanation"); @@ -179,10 +174,13 @@ typedef NS_ENUM(NSInteger, PrivacySettingsTableViewControllerSectionIndex) { return self.enableScreenSecurityCell; case PrivacySettingsTableViewControllerSectionIndexCalling: return self.callsHideIPAddressCell; - case PrivacySettingsTableViewControllerSectionIndexCallKitEnabled: - return self.enableCallKitCell; - case PrivacySettingsTableViewControllerSectionIndexCallKitPrivacy: - return self.enableCallKitPrivacyCell; + case PrivacySettingsTableViewControllerSectionIndexCallKit: + switch (indexPath.row) { + case 0: + return self.enableCallKitCell; + case 1: + return self.enableCallKitPrivacyCell; + } case PrivacySettingsTableViewControllerSectionIndexHistoryLog: return self.clearHistoryLogCell; case PrivacySettingsTableViewControllerSectionIndexBlockOnIdentityChange: @@ -265,6 +263,7 @@ typedef NS_ENUM(NSInteger, PrivacySettingsTableViewControllerSectionIndex) { - (void)didToggleEnableCallKitSwitch:(UISwitch *)sender { DDLogInfo(@"%@ user toggled call kit preference: %@", self.tag, (sender.isOn ? @"ON" : @"OFF")); [[Environment getCurrent].preferences setIsCallKitEnabled:sender.isOn]; + // rebuild callUIAdapter since CallKit vs not changed. [[Environment getCurrent].callService createCallUIAdapter]; [self.tableView reloadData]; } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 3629a6c74..6a5a5dd2f 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -833,7 +833,7 @@ "SETTINGS_NOTIFICATIONS" = "Notifications"; /* Label for 'CallKit privacy' preference */ -"SETTINGS_PRIVACY_CALLKIT_PRIVACY_TITLE" = "Show Names & Numbers"; +"SETTINGS_PRIVACY_CALLKIT_PRIVACY_TITLE" = "Show Name & Number"; /* Short table cell label */ "SETTINGS_PRIVACY_CALLKIT_TITLE" = "iOS Call Integration"; @@ -851,7 +851,7 @@ "SETTINGS_SCREEN_SECURITY_DETAIL" = "Prevent Signal previews from appearing in the app switcher."; /* Settings table section footer. */ -"SETTINGS_SECTION_CALL_KIT_DESCRIPTION" = "Show Signal calls on your lock screen and in the system's call history. If iCloud is enabled, call history will be shared with Apple."; +"SETTINGS_SECTION_CALL_KIT_DESCRIPTION" = "iOS Call Integration shows Signal calls on your lock screen and in the system's call history. If iCloud is enabled, call history will be shared with Apple. You may optionally show your contact's name and number."; /* Explanation of the 'CallKit Privacy` preference. */ "SETTINGS_SECTION_CALL_KIT_PRIVACY_DESCRIPTION" = "If you show the names and phone numbers of incoming callers in CallKit, this information will appear in your phone's call history and will be synced to your iCloud account.";