re-use shared call strings

// FREEBIE
This commit is contained in:
Michael Kirk 2017-02-02 17:42:06 -05:00
parent a339f52564
commit 08425853cf
5 changed files with 31 additions and 30 deletions

View File

@ -1,5 +1,6 @@
// Created by Michael Kirk on 12/23/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
/**
* TODO This is currently unused code. I started implenting new notifications as UserNotifications rather than the deprecated
@ -41,7 +42,7 @@ struct AppNotifications {
switch type {
case .callBack:
return UNNotificationAction(identifier: "org.whispersystems.signal.AppNotifications.Action.callBack",
title: Strings.Calls.callBackButtonTitle,
title: CallStrings.callBackButtonTitle,
options: .authenticationRequired)
}
}
@ -100,9 +101,9 @@ class UserNotificationsAdaptee: NSObject, OWSCallNotificationsAdaptee, UNUserNot
let notificationBody = { () -> String in
switch previewType {
case .noNameNoPreview:
return Strings.Calls.missedCallNotificationBody
return CallStrings.missedCallNotificationBody
case .nameNoPreview, .namePreview:
let format = Strings.Calls.missedCallNotificationBodyWithCallerName
let format = CallStrings.missedCallNotificationBodyWithCallerName
return String(format: format, callerName)
}}()

View File

@ -1,12 +1,14 @@
// Created by Michael Kirk on 12/29/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
import Foundation
@objc class Strings: NSObject {
@objc class Calls: NSObject {
static let callBackButtonTitle = NSLocalizedString("CALLBACK_BUTTON_TITLE", comment: "notification action")
static let missedCallNotificationBody = NSLocalizedString("MISSED_CALL", comment: "notification title")
static let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL", comment: "notification title. Embeds {{Caller's Name}}")
}
/**
* Strings re-used in multiple places should be added here.
*/
@objc class CallStrings: NSObject {
static let callBackButtonTitle = NSLocalizedString("CALLBACK_BUTTON_TITLE", comment: "notification action")
static let missedCallNotificationBody = NSLocalizedString("MISSED_CALL", comment: "notification title")
static let missedCallNotificationBodyWithCallerName = NSLocalizedString("MSGVIEW_MISSED_CALL", comment: "notification title. Embeds {{Caller's Name}}")
}

View File

@ -61,7 +61,7 @@
notification.soundName = @"NewMessage.aifc";
switch (self.notificationPreviewType) {
case NotificationNoNameNoPreview: {
notification.alertBody = [NSString stringWithFormat:NSLocalizedString(@"MISSED_CALL", nil)];
notification.alertBody = [CallStrings missedCallNotificationBody];
break;
}
case NotificationNamePreview:
@ -69,7 +69,7 @@
notification.userInfo = @{ Signal_Call_UserInfo_Key : cThread.contactIdentifier };
notification.category = Signal_CallBack_Category;
notification.alertBody =
[NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_MISSED_CALL", nil), [thread name]];
[NSString stringWithFormat:[CallStrings missedCallNotificationBodyWithCallerName], [thread name]];
break;
}
}
@ -130,13 +130,13 @@
NSString *alertMessage;
switch (self.notificationPreviewType) {
case NotificationNoNameNoPreview: {
alertMessage = [NSString stringWithFormat:NSLocalizedString(@"MISSED_CALL", @"notification body")];
alertMessage = [CallStrings missedCallNotificationBody];
break;
}
case NotificationNameNoPreview:
case NotificationNamePreview: {
alertMessage =
[NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_MISSED_CALL", @"notification body"), callerName];
[NSString stringWithFormat:[CallStrings missedCallNotificationBodyWithCallerName], callerName];
break;
}
}

View File

@ -489,17 +489,17 @@
- (UIUserNotificationCategory *)userNotificationsRPCallBackCategory
{
UIMutableUserNotificationAction *action_accept = [UIMutableUserNotificationAction new];
action_accept.identifier = Signal_CallBack_Identifier;
action_accept.title = NSLocalizedString(@"CALLBACK_BUTTON_TITLE", @"");
action_accept.activationMode = UIUserNotificationActivationModeForeground;
action_accept.destructive = NO;
action_accept.authenticationRequired = NO;
UIMutableUserNotificationAction *callBackAction = [UIMutableUserNotificationAction new];
callBackAction.identifier = Signal_CallBack_Identifier;
callBackAction.title = [CallStrings callBackButtonTitle];
callBackAction.activationMode = UIUserNotificationActivationModeForeground;
callBackAction.destructive = NO;
callBackAction.authenticationRequired = NO;
UIMutableUserNotificationCategory *callCategory = [UIMutableUserNotificationCategory new];
callCategory.identifier = Signal_CallBack_Category;
[callCategory setActions:@[ action_accept ] forContext:UIUserNotificationActionContextMinimal];
[callCategory setActions:@[ action_accept ] forContext:UIUserNotificationActionContextDefault];
[callCategory setActions:@[ callBackAction ] forContext:UIUserNotificationActionContextMinimal];
[callCategory setActions:@[ callBackAction ] forContext:UIUserNotificationActionContextDefault];
return callCategory;
}
@ -544,7 +544,7 @@ NSString *const PushManagerUserInfoKeysCallBackSignalRecipientId = @"PushManager
{
UIMutableUserNotificationAction *callBackAction = [UIMutableUserNotificationAction new];
callBackAction.identifier = PushManagerActionsCallBack;
callBackAction.title = NSLocalizedString(@"CALLBACK_BUTTON_TITLE", @"");
callBackAction.title = [CallStrings callBackButtonTitle];
callBackAction.activationMode = UIUserNotificationActivationModeForeground;
callBackAction.destructive = NO;
callBackAction.authenticationRequired = YES;

View File

@ -445,8 +445,7 @@
/* {{number of minutes}} embedded in strings, e.g. 'Alice updated disappearing messages expiration to {{5 minutes}}'. See other *_TIME_AMOUNT strings */
"MINUTES_TIME_AMOUNT" = "%u minutes";
/* notification body
notification title */
/* notification title */
"MISSED_CALL" = "Missed call";
/* Alert body
@ -457,8 +456,7 @@
Alert title when camera is not authorized */
"MISSING_CAMERA_PERMISSION_TITLE" = "Signal needs to access your camera.";
/* notification body
notification title. Embeds {{Caller's Name}} */
/* notification title. Embeds {{Caller's Name}} */
"MSGVIEW_MISSED_CALL" = "Missed call from %@.";
/* No comment provided by engineer. */