clean with constants

pull/1023/head
Ryan ZHAO 8 months ago
parent 1e1d71f788
commit 7764f7f3f6

@ -201,7 +201,7 @@
9473386E2BDF5F3E00B9E169 /* InfoPlist.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 9473386D2BDF5F3E00B9E169 /* InfoPlist.xcstrings */; };
94B3DC172AF8592200C88531 /* QuoteView_SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94B3DC162AF8592200C88531 /* QuoteView_SwiftUI.swift */; };
94C5DCB02BE88170003AA8C5 /* BezierPathView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C5DCAF2BE88170003AA8C5 /* BezierPathView.swift */; };
94FC7A8E2C759805004A8146 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94FC7A8D2C759805004A8146 /* Constants.swift */; };
94FC7A8F2C759F47004A8146 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94FC7A8D2C759805004A8146 /* Constants.swift */; };
A11CD70D17FA230600A2D1B1 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A11CD70C17FA230600A2D1B1 /* QuartzCore.framework */; };
A163E8AB16F3F6AA0094D68B /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A163E8AA16F3F6A90094D68B /* Security.framework */; };
A1C32D5017A06538000A904E /* AddressBookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A1C32D4F17A06537000A904E /* AddressBookUI.framework */; };
@ -2740,6 +2740,7 @@
B8A582B0258C66C900AFD84C /* General */ = {
isa = PBXGroup;
children = (
94FC7A8D2C759805004A8146 /* Constants.swift */,
FD428B182B4B576F006D0888 /* AppContext.swift */,
7BD477A727EC39F5004E2822 /* Atomic.swift */,
FDC438CC27BC641200C60D73 /* Set+Utilities.swift */,
@ -3543,7 +3544,6 @@
children = (
C3AAFFF125AE99710089E6DD /* AppDelegate.swift */,
34D99CE3217509C1000AFB39 /* AppEnvironment.swift */,
94FC7A8D2C759805004A8146 /* Constants.swift */,
7BFD1A952747689000FB91B9 /* TurnServers */,
B8FF8E6025C10D8B004D1F22 /* Countries */,
34330A581E7875FB00DF2FB9 /* Fonts */,
@ -6073,6 +6073,7 @@
FD428B192B4B576F006D0888 /* AppContext.swift in Sources */,
C32C5D83256DD5B6003C73A2 /* SSKKeychainStorage.swift in Sources */,
FD559DF52A7368CB00C7C62A /* DispatchQueue+Utilities.swift in Sources */,
94FC7A8F2C759F47004A8146 /* Constants.swift in Sources */,
FDF8488329405A12007DCAE5 /* BatchResponse.swift in Sources */,
FDFF9FDF2A787F57005E0628 /* JSONEncoder+Utilities.swift in Sources */,
FD7F746E2BB2766D006DDFD8 /* PreparedRequest.swift in Sources */,
@ -6505,7 +6506,6 @@
FD716E7128505E5200C96BF4 /* MessageRequestsCell.swift in Sources */,
FDF848F329413DB0007DCAE5 /* ImagePickerHandler.swift in Sources */,
B88FA7F2260C3EB10049422F /* OpenGroupSuggestionGrid.swift in Sources */,
94FC7A8E2C759805004A8146 /* Constants.swift in Sources */,
9422569F2C23F8FE00C0FDBF /* ScanQRCodeScreen.swift in Sources */,
FD71160428C95B5600B47552 /* PhotoCollectionPickerViewModel.swift in Sources */,
FD37EA1928AC5CCA003AE748 /* NotificationSoundViewModel.swift in Sources */,

@ -255,7 +255,7 @@ extension ConversationVC:
title: "giphyWarning".localized(),
body: .text(
"giphyWarningDescription"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
),
confirmTitle: "theContinue".localized()
@ -647,7 +647,7 @@ extension ConversationVC:
title: "linkPreviewsEnable".localized(),
body: .text(
"linkPreviewsFirstDescription"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
),
confirmTitle: "enable".localized()
@ -2261,7 +2261,7 @@ extension ConversationVC:
let modal: ConfirmationModal = ConfirmationModal(
targetView: self.view,
info: ConfirmationModal.Info(
title: Singleton.appName,
title: Constants.app_name,
body: .text("This will ban the selected user from this room. It won't ban them from other rooms."),
confirmTitle: "okay".localized(),
cancelStyle: .alert_text,
@ -2320,7 +2320,7 @@ extension ConversationVC:
let modal: ConfirmationModal = ConfirmationModal(
targetView: self.view,
info: ConfirmationModal.Info(
title: Singleton.appName,
title: Constants.app_name,
body: .text("This will ban the selected user from this room and delete all messages sent by them. It won't ban them from other rooms or delete the messages they sent there."),
confirmTitle: "okay".localized(),
cancelStyle: .alert_text,

@ -87,7 +87,7 @@ struct OpenGroupInvitationView_SwiftUI: View {
struct OpenGroupInvitationView_SwiftUI_Previews: PreviewProvider {
static var previews: some View {
OpenGroupInvitationView_SwiftUI(
name: Singleton.appName,
name: Constants.app_name,
url: "http://open.getsession.org/session?public_key=a03c383cf63c3c4efe67acc52112a6dd734b3a946b9545f488aaa93da7991238",
textColor: .messageBubble_outgoingText,
isOutgoing: true

@ -248,7 +248,7 @@ final class HomeVC: BaseVC, LibSessionRespondingViewController, UITableViewDataS
let welcomeLabel = UILabel()
welcomeLabel.font = .systemFont(ofSize: Values.smallFontSize)
welcomeLabel.text = "onboardingBubbleWelcomeToSession"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
welcomeLabel.themeTextColor = .sessionButton_text
welcomeLabel.textAlignment = .center

@ -439,7 +439,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
/// This **must** be a standard `UIAlertController` instead of a `ConfirmationModal` because we may not
/// have access to the database when displaying this so can't extract theme information for styling purposes
let alert: UIAlertController = UIAlertController(
title: Singleton.appName,
title: Constants.app_name,
message: error.message,
preferredStyle: .alert
)
@ -496,7 +496,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
default: break
}
alert.addAction(UIAlertAction(title: "quit".put(key: "app_name", value: Singleton.appName).localized(), style: .default) { _ in
alert.addAction(UIAlertAction(title: "quit".put(key: "app_name", value: Constants.app_name).localized(), style: .default) { _ in
Log.flush()
exit(0)
})
@ -943,12 +943,12 @@ private enum StartupError: Error {
case .databaseError(StorageError.migrationNoLongerSupported):
return "databaseErrorUpdate"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
case .startupTimeout:
return "databaseErrorTimeout"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
}
}

File diff suppressed because one or more lines are too long

@ -137,12 +137,12 @@ public class NotificationPresenter: NotificationsProtocol {
switch previewType {
case .noNameNoPreview:
notificationTitle = Singleton.appName
notificationTitle = Constants.app_name
case .nameNoPreview, .nameAndPreview:
switch thread.variant {
case .contact:
notificationTitle = (isMessageRequest ? Singleton.appName : senderName)
notificationTitle = (isMessageRequest ? Constants.app_name : senderName)
case .legacyGroup, .group, .community:
notificationTitle = "notificationsIosGroup"
@ -257,7 +257,7 @@ public class NotificationPresenter: NotificationsProtocol {
AppNotificationUserInfoKey.threadVariantRaw: thread.variant.rawValue
]
let notificationTitle: String = Singleton.appName
let notificationTitle: String = Constants.app_name
let senderName: String = Profile.displayName(db, id: interaction.authorId, threadVariant: thread.variant)
let notificationBody: String? = {
switch messageInfo.state {

@ -204,13 +204,13 @@ struct FakeChat: View {
let chatBubbles: [ChatBubble] = [
ChatBubble(
text: "onboardingBubbleWelcomeToSession"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized() + " 👋",
outgoing: false
),
ChatBubble(
text: "onboardingBubbleSessionIsEngineered"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized(),
outgoing: true
),

@ -40,7 +40,7 @@ struct PNModeScreen: View {
mode: .slow,
title: "notificationsSlowMode".localized(),
explanation: "notificationsSlowModeDescription"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized(),
isRecommended: false,
accessibility: Accessibility(
@ -67,7 +67,7 @@ struct PNModeScreen: View {
Text(
"onboardingMessageNotificationExplanation"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
)
.font(.system(size: Values.smallFontSize))

@ -522,7 +522,7 @@ private final class ScanQRCodePlaceholderVC: UIViewController {
let explanationLabel = UILabel()
explanationLabel.font = .systemFont(ofSize: Values.smallFontSize)
explanationLabel.text = "cameraGrantAccessQr"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
explanationLabel.themeTextColor = .textPrimary
explanationLabel.textAlignment = .center

@ -75,7 +75,7 @@ final class PathVC: BaseVC {
let explanationLabel = UILabel()
explanationLabel.font = .systemFont(ofSize: Values.smallFontSize)
explanationLabel.text = "onionRoutingPathDescription"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
explanationLabel.themeTextColor = .textSecondary
explanationLabel.textAlignment = .center

@ -54,7 +54,7 @@ class HelpViewModel: SessionTableViewModel, NavigatableStateHolder, ObservableTa
id: .report,
title: "helpReportABug".localized(),
subtitle: "helpReportABugExportLogsDescription"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized(),
rightAccessory: .highlightingBackgroundLabel(
title: "helpReportABugExportLogs".localized()
@ -69,7 +69,7 @@ class HelpViewModel: SessionTableViewModel, NavigatableStateHolder, ObservableTa
SessionCell.Info(
id: .translate,
title: "helpHelpUsTranslateSession"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized(),
rightAccessory: .icon(
UIImage(systemName: "arrow.up.forward.app")?

@ -109,7 +109,7 @@ class PrivacySettingsViewModel: SessionTableViewModel, NavigationItemSource, Nav
id: .screenLock,
title: "lockApp".localized(),
subtitle: "lockAppDescriptionIos"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized(),
rightAccessory: .toggle(
.boolValue(

@ -424,7 +424,7 @@ class SettingsViewModel: SessionTableViewModel, NavigationItemSource, Navigatabl
title: "sessionInviteAFriend".localized(),
onTap: {
let invitation: String = "accountIdShare"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.put(key: "account_id", value: state.profile.id)
.put(key: "download_url", value: "https://getsession.org/")
.localized()

@ -44,7 +44,7 @@ struct ScanQRCodeScreen: View {
Text(
"cameraGrantAccessQr"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
)
.font(.system(size: Values.smallFontSize))

@ -28,7 +28,7 @@ public enum Permissions {
title: "permissionsRequired".localized(),
body: .text(
"cameraGrantAccessDenied"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
),
confirmTitle: "sessionSettings".localized(),
@ -70,7 +70,7 @@ public enum Permissions {
title: "permissionsRequired".localized(),
body: .text(
"permissionsMicrophoneAccessRequiredIos"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
),
confirmTitle: "sessionSettings".localized(),
@ -130,7 +130,7 @@ public enum Permissions {
title: "permissionsRequired".localized(),
body: .text(
"permissionsLibrary"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
),
confirmTitle: "sessionSettings".localized(),

@ -79,7 +79,7 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
.localized()
case .noNameNoPreview:
notificationContent.title = Singleton.appName
notificationContent.title = Constants.app_name
notificationContent.body = "messageNewYouveGot"
.putNumber(1)
.localized()
@ -88,7 +88,7 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
// If it's a message request then overwrite the body to be something generic (only show a notification
// when receiving a new message request if there aren't any others or the user had hidden them)
if isMessageRequest {
notificationContent.title = Singleton.appName
notificationContent.title = Constants.app_name
notificationContent.body = "messageRequestsNew".localized()
}
@ -167,7 +167,7 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
.map { NSNumber(value: $0) }
.defaulting(to: NSNumber(value: 0))
notificationContent.title = Singleton.appName
notificationContent.title = Constants.app_name
notificationContent.body = ""
let senderName: String = Profile.displayName(db, id: interaction.authorId, threadVariant: thread.variant)

@ -461,7 +461,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
private func handleFailureForVoIP(_ db: Database, for callMessage: CallMessage) {
let notificationContent = UNMutableNotificationContent()
notificationContent.userInfo = [ NotificationServiceExtension.isFromRemoteKey : true ]
notificationContent.title = Singleton.appName
notificationContent.title = Constants.app_name
notificationContent.badge = (try? Interaction.fetchUnreadCount(db))
.map { NSNumber(value: $0) }
.defaulting(to: NSNumber(value: 0))
@ -500,7 +500,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
Storage.suspendDatabaseAccess()
Log.flush()
content.title = Singleton.appName
content.title = Constants.app_name
content.body = "messageNewYouveGot"
.putNumber(1)
.localized()

@ -32,7 +32,7 @@ final class SAEScreenLockViewController: ScreenLockViewController {
let titleLabel: UILabel = UILabel()
titleLabel.font = UIFont.boldSystemFont(ofSize: Values.veryLargeFontSize)
titleLabel.text = "shareToSession"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
titleLabel.themeTextColor = .textPrimary

@ -254,7 +254,7 @@ final class ShareNavController: UINavigationController, ShareViewDelegate {
let modal: ConfirmationModal = ConfirmationModal(
targetView: self.view,
info: ConfirmationModal.Info(
title: Singleton.appName,
title: Constants.app_name,
body: .text(error.localizedDescription),
cancelTitle: "okay".localized(),
cancelStyle: .alert_text,

@ -31,7 +31,7 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
let titleLabel: UILabel = UILabel()
titleLabel.font = .boldSystemFont(ofSize: Values.veryLargeFontSize)
titleLabel.text = "shareToSession"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
titleLabel.themeTextColor = .textPrimary

@ -12,8 +12,6 @@ public extension Singleton {
static var hasAppContext: Bool { _appContext.wrappedValue != nil }
static func setup(appContext: AppContext) { _appContext.mutate { $0 = appContext } }
static var appName: String { "Session" } // stringlint:disable
}
// MARK: - AppContext

@ -291,7 +291,7 @@ public class MediaMessageView: UIView {
// If we have no link preview info at this point then assume link previews are disabled
else {
label.text = "linkPreviewsTurnedOffDescription"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
label.themeTextColor = .textPrimary
label.textAlignment = .center

@ -53,7 +53,7 @@ public class ScreenLock {
// Description of how and why Signal iOS uses Touch ID/Face ID/Phone Passcode to
// unlock 'screen lock'.
localizedReason: "authenticateToOpen"
.put(key: "app_name", value: Singleton.appName)
.put(key: "app_name", value: Constants.app_name)
.localized()
) { outcome in
AssertIsOnMainThread()

Loading…
Cancel
Save