Merge branch 'charlesmchen/honorPrivacyInCallNotifications'

pull/1/head
Matthew Chen 8 years ago
commit fcbc709b9f

@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *detailString; NSString *detailString;
switch (status) { switch (status) {
case kCallMissed: case kCallMissed:
detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_MISSED_CALL", nil), name]; detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_MISSED_CALL_WITH_NAME", nil), name];
break; break;
case kCallIncoming: case kCallIncoming:
detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_RECEIVED_CALL", nil), name]; detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_RECEIVED_CALL", nil), name];

@ -103,8 +103,9 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
case .noNameNoPreview: case .noNameNoPreview:
return CallStrings.missedCallNotificationBody return CallStrings.missedCallNotificationBody
case .nameNoPreview, .namePreview: case .nameNoPreview, .namePreview:
let format = CallStrings.missedCallNotificationBodyWithCallerName return (Environment.getCurrent().preferences.isCallKitPrivacyEnabled()
return String(format: format, callerName) ? CallStrings.missedCallNotificationBodyWithoutCallerName
: String(format: CallStrings.missedCallNotificationBodyWithCallerName, callerName))
}}() }}()
content.body = notificationBody content.body = notificationBody

@ -10,6 +10,7 @@ import Foundation
@objc class CallStrings: NSObject { @objc class CallStrings: NSObject {
static let callBackButtonTitle = NSLocalizedString("CALLBACK_BUTTON_TITLE", comment: "notification action") static let callBackButtonTitle = NSLocalizedString("CALLBACK_BUTTON_TITLE", comment: "notification action")
static let missedCallNotificationBody = NSLocalizedString("MISSED_CALL", comment: "notification title") static let missedCallNotificationBody = NSLocalizedString("MISSED_CALL", comment: "notification title")
static let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL", comment: "notification title. Embeds {{Caller's Name}}") static let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITH_NAME", comment: "notification title. Embeds {{Caller's Name}}")
static let missedCallNotificationBodyWithoutCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL_WITHOUT_NAME", comment: "notification title.")
static let callStatusFormat = NSLocalizedString("CALL_STATUS_FORMAT", comment: "embeds {{Call Status}} in call screen label. For ongoing calls, {{Call Status}} is a seconds timer like 01:23, otherwise {{Call Status}} is a short text like 'Ringing', 'Busy', or 'Failed Call'") static let callStatusFormat = NSLocalizedString("CALL_STATUS_FORMAT", comment: "embeds {{Call Status}} in call screen label. For ongoing calls, {{Call Status}} is a seconds timer like 01:23, otherwise {{Call Status}} is a short text like 'Ringing', 'Busy', or 'Failed Call'")
} }

@ -68,8 +68,9 @@
case NotificationNameNoPreview: { case NotificationNameNoPreview: {
notification.userInfo = @{ Signal_Call_UserInfo_Key : cThread.contactIdentifier }; notification.userInfo = @{ Signal_Call_UserInfo_Key : cThread.contactIdentifier };
notification.category = Signal_CallBack_Category; notification.category = Signal_CallBack_Category;
notification.alertBody = notification.alertBody = ([[Environment getCurrent].preferences isCallKitPrivacyEnabled]
[NSString stringWithFormat:[CallStrings missedCallNotificationBodyWithCallerName], [thread name]]; ? [CallStrings missedCallNotificationBodyWithoutCallerName]
: [NSString stringWithFormat:[CallStrings missedCallNotificationBodyWithCallerName], [thread name]]);
break; break;
} }
} }
@ -135,8 +136,9 @@
} }
case NotificationNameNoPreview: case NotificationNameNoPreview:
case NotificationNamePreview: { case NotificationNamePreview: {
alertMessage = alertMessage = ([[Environment getCurrent].preferences isCallKitPrivacyEnabled]
[NSString stringWithFormat:[CallStrings missedCallNotificationBodyWithCallerName], callerName]; ? [CallStrings missedCallNotificationBodyWithoutCallerName]
: [NSString stringWithFormat:[CallStrings missedCallNotificationBodyWithCallerName], callerName]);
break; break;
} }
} }

@ -520,7 +520,10 @@
"MISSING_CAMERA_PERMISSION_TITLE" = "Signal needs to access your camera."; "MISSING_CAMERA_PERMISSION_TITLE" = "Signal needs to access your camera.";
/* notification title. Embeds {{Caller's Name}} */ /* notification title. Embeds {{Caller's Name}} */
"MSGVIEW_MISSED_CALL" = "Missed call from %@."; "MSGVIEW_MISSED_CALL_WITH_NAME" = "Missed call from %@.";
/* notification title. */
"MSGVIEW_MISSED_CALL_WITHOUT_NAME" = "Missed call from Signal User.";
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"MSGVIEW_RECEIVED_CALL" = "You received a call from %@."; "MSGVIEW_RECEIVED_CALL" = "You received a call from %@.";

Loading…
Cancel
Save