From f552d514235c3910c0354d65cf0ad0be233bd8e7 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 4 May 2021 15:06:41 +1000 Subject: [PATCH] Remove unused code --- Session.xcodeproj/project.pbxproj | 20 ---- Session/Database/Storage+Resetting.swift | 42 --------- Session/Onboarding/LandingVC.swift | 7 -- Session/Settings/SettingsVC.swift | 23 +---- .../KeyPairMigrationSheet.swift | 75 --------------- .../KeyPairMigrationSuccessSheet.swift | 94 ------------------- .../ProximityMonitoringManager.swift | 2 +- .../General/SNUserDefaults.swift | 4 +- 8 files changed, 4 insertions(+), 263 deletions(-) delete mode 100644 Session/Database/Storage+Resetting.swift delete mode 100644 Session/Sheets & Modals/KeyPairMigrationSheet.swift delete mode 100644 Session/Sheets & Modals/KeyPairMigrationSuccessSheet.swift diff --git a/Session.xcodeproj/project.pbxproj b/Session.xcodeproj/project.pbxproj index 52df658f3..aaf63c541 100644 --- a/Session.xcodeproj/project.pbxproj +++ b/Session.xcodeproj/project.pbxproj @@ -185,7 +185,6 @@ B835247925C38D880089A44F /* MessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B835247825C38D880089A44F /* MessageCell.swift */; }; B835249B25C3AB650089A44F /* VisibleMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B835249A25C3AB650089A44F /* VisibleMessageCell.swift */; }; B83524A525C3BA4B0089A44F /* InfoMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B83524A425C3BA4B0089A44F /* InfoMessageCell.swift */; }; - B83786802586D296003CE78E /* KeyPairMigrationSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = B837867F2586D296003CE78E /* KeyPairMigrationSheet.swift */; }; B83F2B88240CB75A000A54AB /* UIImage+Scaling.swift in Sources */ = {isa = PBXBuildFile; fileRef = B83F2B87240CB75A000A54AB /* UIImage+Scaling.swift */; }; B84664F5235022F30083A1CD /* MentionUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = B84664F4235022F30083A1CD /* MentionUtilities.swift */; }; B849789625D4A2F500D0D0B3 /* LinkPreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B849789525D4A2F500D0D0B3 /* LinkPreviewView.swift */; }; @@ -199,7 +198,6 @@ B8569AC325CB5D2900DBA3DB /* ConversationVC+Interaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8569AC225CB5D2900DBA3DB /* ConversationVC+Interaction.swift */; }; B8569AD325CBA13D00DBA3DB /* MediaTextOverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8569AD225CBA13D00DBA3DB /* MediaTextOverlayView.swift */; }; B8569AE325CBB19A00DBA3DB /* DocumentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8569AE225CBB19A00DBA3DB /* DocumentView.swift */; }; - B85A68B12587141A008CC492 /* Storage+Resetting.swift in Sources */ = {isa = PBXBuildFile; fileRef = B85A68B02587141A008CC492 /* Storage+Resetting.swift */; }; B866CE112581C1A900535CC4 /* Sodium+Conversion.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3E7134E251C867C009649BB /* Sodium+Conversion.swift */; }; B86BD08423399ACF000F5AE3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B86BD08323399ACF000F5AE3 /* Modal.swift */; }; B86BD08623399CEF000F5AE3 /* SeedModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B86BD08523399CEF000F5AE3 /* SeedModal.swift */; }; @@ -241,7 +239,6 @@ B893063F2383961A005EAA8E /* ScanQRCodeWrapperVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = B893063E2383961A005EAA8E /* ScanQRCodeWrapperVC.swift */; }; B894D0752339EDCF00B4D94D /* NukeDataModal.swift in Sources */ = {isa = PBXBuildFile; fileRef = B894D0742339EDCF00B4D94D /* NukeDataModal.swift */; }; B897621C25D201F7004F83B2 /* ScrollToBottomButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B897621B25D201F7004F83B2 /* ScrollToBottomButton.swift */; }; - B8A14D702589CE9000E70D57 /* KeyPairMigrationSuccessSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8A14D6F2589CE9000E70D57 /* KeyPairMigrationSuccessSheet.swift */; }; B8AE75A425A6C6A6001A84D2 /* Data+Trimming.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8AE75A325A6C6A6001A84D2 /* Data+Trimming.swift */; }; B8AE760B25ABFB5A001A84D2 /* GeneralUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = B8AE760A25ABFB5A001A84D2 /* GeneralUtilities.m */; }; B8AE761425ABFBB9001A84D2 /* GeneralUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = B8AE760925ABFB00001A84D2 /* GeneralUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1181,7 +1178,6 @@ B835247825C38D880089A44F /* MessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCell.swift; sourceTree = ""; }; B835249A25C3AB650089A44F /* VisibleMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VisibleMessageCell.swift; sourceTree = ""; }; B83524A425C3BA4B0089A44F /* InfoMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoMessageCell.swift; sourceTree = ""; }; - B837867F2586D296003CE78E /* KeyPairMigrationSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyPairMigrationSheet.swift; sourceTree = ""; }; B83F2B85240C7B8F000A54AB /* NewConversationButtonSet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewConversationButtonSet.swift; sourceTree = ""; }; B83F2B87240CB75A000A54AB /* UIImage+Scaling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Scaling.swift"; sourceTree = ""; }; B84072952565E9F50037CB17 /* TSOutgoingMessage+Conversion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TSOutgoingMessage+Conversion.swift"; sourceTree = ""; }; @@ -1198,7 +1194,6 @@ B8569AC225CB5D2900DBA3DB /* ConversationVC+Interaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConversationVC+Interaction.swift"; sourceTree = ""; }; B8569AD225CBA13D00DBA3DB /* MediaTextOverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaTextOverlayView.swift; sourceTree = ""; }; B8569AE225CBB19A00DBA3DB /* DocumentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DocumentView.swift; sourceTree = ""; }; - B85A68B02587141A008CC492 /* Storage+Resetting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Storage+Resetting.swift"; sourceTree = ""; }; B86BD08323399ACF000F5AE3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = ""; }; B86BD08523399CEF000F5AE3 /* SeedModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedModal.swift; sourceTree = ""; }; B8783E9D23EB948D00404FB8 /* UILabel+Interaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UILabel+Interaction.swift"; sourceTree = ""; }; @@ -1216,7 +1211,6 @@ B893063E2383961A005EAA8E /* ScanQRCodeWrapperVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanQRCodeWrapperVC.swift; sourceTree = ""; }; B894D0742339EDCF00B4D94D /* NukeDataModal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NukeDataModal.swift; sourceTree = ""; }; B897621B25D201F7004F83B2 /* ScrollToBottomButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollToBottomButton.swift; sourceTree = ""; }; - B8A14D6F2589CE9000E70D57 /* KeyPairMigrationSuccessSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyPairMigrationSuccessSheet.swift; sourceTree = ""; }; B8AE75A325A6C6A6001A84D2 /* Data+Trimming.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Trimming.swift"; sourceTree = ""; }; B8AE760925ABFB00001A84D2 /* GeneralUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneralUtilities.h; sourceTree = ""; }; B8AE760A25ABFB5A001A84D2 /* GeneralUtilities.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GeneralUtilities.m; sourceTree = ""; }; @@ -2678,14 +2672,6 @@ path = Mentions; sourceTree = ""; }; - C32C5D49256DD522003C73A2 /* Database */ = { - isa = PBXGroup; - children = ( - B85A68B02587141A008CC492 /* Storage+Resetting.swift */, - ); - path = Database; - sourceTree = ""; - }; C331FF1C2558F9D300070591 /* SessionUIKit */ = { isa = PBXGroup; children = ( @@ -2872,8 +2858,6 @@ C36096AF25AD1932008B62B2 /* Sheets & Modals */ = { isa = PBXGroup; children = ( - B837867F2586D296003CE78E /* KeyPairMigrationSheet.swift */, - B8A14D6F2589CE9000E70D57 /* KeyPairMigrationSuccessSheet.swift */, B86BD08323399ACF000F5AE3 /* Modal.swift */, C3DFFAC523E96F0D0058DAF8 /* Sheet.swift */, ); @@ -3575,7 +3559,6 @@ C36096BC25AD1C3E008B62B2 /* Backups */, C360969C25AD18BA008B62B2 /* Closed Groups */, B835246C25C38AA20089A44F /* Conversations */, - C32C5D49256DD522003C73A2 /* Database */, C32B405424A961E1001117B5 /* Dependencies */, C36096A525AD18D7008B62B2 /* DMs */, C360968E25AD16E8008B62B2 /* Home */, @@ -4877,7 +4860,6 @@ 34B0796D1FCF46B100E248C2 /* MainAppContext.m in Sources */, 34A8B3512190A40E00218A25 /* MediaAlbumView.swift in Sources */, 4C4AEC4520EC343B0020E72B /* DismissableTextField.swift in Sources */, - B85A68B12587141A008CC492 /* Storage+Resetting.swift in Sources */, 3496955E219B605E00DCFE74 /* PhotoLibrary.swift in Sources */, C3A76A8D25DB83F90074CB90 /* PermissionMissingModal.swift in Sources */, 340FC8A9204DAC8D007AEB0F /* NotificationSettingsOptionsViewController.m in Sources */, @@ -4956,7 +4938,6 @@ B82B4090239DD75000A248E7 /* RestoreVC.swift in Sources */, 3488F9362191CC4000E524CC /* MediaView.swift in Sources */, B8569AC325CB5D2900DBA3DB /* ConversationVC+Interaction.swift in Sources */, - B8A14D702589CE9000E70D57 /* KeyPairMigrationSuccessSheet.swift in Sources */, 3496955C219B605E00DCFE74 /* ImagePickerController.swift in Sources */, C31D1DE32521718E005D4DA8 /* UserSelectionVC.swift in Sources */, 34A6C28021E503E700B5B12E /* OWSImagePickerController.swift in Sources */, @@ -4976,7 +4957,6 @@ 340FC8AC204DAC8D007AEB0F /* PrivacySettingsTableViewController.m in Sources */, B8569AE325CBB19A00DBA3DB /* DocumentView.swift in Sources */, B85357BF23A1AE0800AAF6CD /* SeedReminderView.swift in Sources */, - B83786802586D296003CE78E /* KeyPairMigrationSheet.swift in Sources */, B821494F25D4E163009C0F2A /* BodyTextView.swift in Sources */, C35E8AAE2485E51D00ACB629 /* IP2Country.swift in Sources */, B835249B25C3AB650089A44F /* VisibleMessageCell.swift in Sources */, diff --git a/Session/Database/Storage+Resetting.swift b/Session/Database/Storage+Resetting.swift deleted file mode 100644 index faedb9737..000000000 --- a/Session/Database/Storage+Resetting.swift +++ /dev/null @@ -1,42 +0,0 @@ -import PromiseKit - -extension Storage { - - static func prepareForV2KeyPairMigration() { - let userDefaults = UserDefaults.standard - let isUsingAPNs = userDefaults[.isUsingFullAPNs] - if isUsingAPNs, let hexEncodedToken = userDefaults[.deviceToken] { - let token = Data(hex: hexEncodedToken) - PushNotificationAPI.unregister(token).retainUntilComplete() // TODO: Wait for this to complete? - } - let name = Storage.shared.getUser()!.name! - let appDelegate = UIApplication.shared.delegate as! AppDelegate - appDelegate.stopPoller() - appDelegate.stopClosedGroupPoller() - appDelegate.stopOpenGroupPollers() - OWSStorage.resetAllStorage() - OWSUserProfile.resetProfileStorage() - Environment.shared.preferences.clear() - AppEnvironment.shared.notificationPresenter.clearAllNotifications() - userDefaults[.isUsingFullAPNs] = isUsingAPNs - userDefaults[.displayName] = name - userDefaults[.isMigratingToV2KeyPair] = true - exit(0) - } - - static func finishV2KeyPairMigration(navigationController: UINavigationController) { - let seed = Data.getSecureRandomData(ofSize: 16)! - let (ed25519KeyPair, x25519KeyPair) = KeyPairUtilities.generate(from: seed) - KeyPairUtilities.store(seed: seed, ed25519KeyPair: ed25519KeyPair, x25519KeyPair: x25519KeyPair) - TSAccountManager.sharedInstance().phoneNumberAwaitingVerification = x25519KeyPair.hexEncodedPublicKey - UserDefaults.standard[.hasViewedSeed] = false - let displayName = UserDefaults.standard[.displayName]! // Checked earlier - OWSProfileManager.shared().updateLocalProfileName(displayName, avatarImage: nil, success: { }, failure: { _ in }, requiresSync: false) - TSAccountManager.sharedInstance().didRegister() - let homeVC = HomeVC() - navigationController.setViewControllers([ homeVC ], animated: true) - let syncTokensJob = SyncPushTokensJob(accountManager: AppEnvironment.shared.accountManager, preferences: Environment.shared.preferences) - syncTokensJob.uploadOnlyIfStale = false - let _: Promise = syncTokensJob.run() - } -} diff --git a/Session/Onboarding/LandingVC.swift b/Session/Onboarding/LandingVC.swift index adea91aa2..ab79a8fbc 100644 --- a/Session/Onboarding/LandingVC.swift +++ b/Session/Onboarding/LandingVC.swift @@ -82,13 +82,6 @@ final class LandingVC : BaseVC { view.addSubview(mainStackView) mainStackView.pin(to: view) topSpacer.heightAnchor.constraint(equalTo: bottomSpacer.heightAnchor, multiplier: 1).isActive = true - // Auto-migrate if needed - let userDefaults = UserDefaults.standard - if userDefaults[.isMigratingToV2KeyPair] { - if userDefaults[.displayName] != nil { - Storage.finishV2KeyPairMigration(navigationController: navigationController!) - } - } } // MARK: Interaction diff --git a/Session/Settings/SettingsVC.swift b/Session/Settings/SettingsVC.swift index af045ff6c..b79ab1075 100644 --- a/Session/Settings/SettingsVC.swift +++ b/Session/Settings/SettingsVC.swift @@ -204,26 +204,17 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate { button.set(.height, to: SettingsVC.buttonHeight) return button } - var result = [ + return [ getSeparator(), getSettingButton(withTitle: NSLocalizedString("vc_settings_privacy_button_title", comment: ""), color: Colors.text, action: #selector(showPrivacySettings)), getSeparator(), getSettingButton(withTitle: NSLocalizedString("vc_settings_notifications_button_title", comment: ""), color: Colors.text, action: #selector(showNotificationSettings)), - getSeparator() - ] - if !KeyPairUtilities.hasV2KeyPair() { - result += [ - getSettingButton(withTitle: "Upgrade Session ID", color: Colors.text, action: #selector(upgradeSessionID)), - getSeparator() - ] - } - result += [ + getSeparator(), getSettingButton(withTitle: NSLocalizedString("vc_settings_recovery_phrase_button_title", comment: ""), color: Colors.text, action: #selector(showSeed)), getSeparator(), getSettingButton(withTitle: NSLocalizedString("vc_settings_clear_all_data_button_title", comment: ""), color: Colors.destructive, action: #selector(clearAllData)), getSeparator() ] - return result } // MARK: General @@ -458,16 +449,6 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate { UIApplication.shared.open(url) } - @objc private func upgradeSessionID() { - let message = "You’re upgrading to a new Session ID. This will give you improved privacy and security, but it will clear ALL app data. Contacts and conversations will be lost. Proceed?" - let alert = UIAlertController(title: "Upgrade Session ID?", message: message, preferredStyle: .alert) - alert.addAction(UIAlertAction(title: "Yes", style: .destructive) { _ in - Storage.prepareForV2KeyPairMigration() - }) - alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil)) - present(alert, animated: true, completion: nil) - } - @objc private func showSeed() { let seedModal = SeedModal() seedModal.modalPresentationStyle = .overFullScreen diff --git a/Session/Sheets & Modals/KeyPairMigrationSheet.swift b/Session/Sheets & Modals/KeyPairMigrationSheet.swift deleted file mode 100644 index c4344ea9b..000000000 --- a/Session/Sheets & Modals/KeyPairMigrationSheet.swift +++ /dev/null @@ -1,75 +0,0 @@ - -final class KeyPairMigrationSheet : Sheet { - - override class var isDismissable: Bool { false } - - override func populateContentView() { - // Image view - let imageView = UIImageView(image: #imageLiteral(resourceName: "Shield").withTint(Colors.text)) - imageView.set(.width, to: 64) - imageView.set(.height, to: 64) - imageView.contentMode = .scaleAspectFit - // Title label - let titleLabel = UILabel() - titleLabel.textColor = Colors.text - titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize) - titleLabel.text = "Session IDs Just Got Better" - titleLabel.textAlignment = .center - titleLabel.numberOfLines = 0 - titleLabel.lineBreakMode = .byWordWrapping - // Top stack view - let topStackView = UIStackView(arrangedSubviews: [ imageView, titleLabel ]) - topStackView.axis = .vertical - topStackView.spacing = Values.largeSpacing - topStackView.alignment = .center - // Explanation label - let explanationLabel = UILabel() - explanationLabel.textColor = Colors.text - explanationLabel.font = .systemFont(ofSize: Values.smallFontSize) - explanationLabel.textAlignment = .center - explanationLabel.text = """ - We’ve upgraded Session IDs to make them even more private and secure. To ensure your continued privacy you're now required to upgrade. - - Your existing contacts and conversations will be lost, but you’ll be able to use Session knowing you have the best privacy and security possible. - """ - explanationLabel.numberOfLines = 0 - explanationLabel.lineBreakMode = .byWordWrapping - // Upgrade now button - let upgradeNowButton = Button(style: .prominentOutline, size: .large) - upgradeNowButton.set(.width, to: 240) - upgradeNowButton.setTitle("Upgrade Now", for: UIControl.State.normal) - upgradeNowButton.addTarget(self, action: #selector(upgradeNow), for: UIControl.Event.touchUpInside) - // Upgrade now button - let upgradeLaterButton = Button(style: .prominentOutline, size: .large) - upgradeLaterButton.set(.width, to: 240) - upgradeLaterButton.setTitle("Upgrade Later", for: UIControl.State.normal) - upgradeLaterButton.addTarget(self, action: #selector(upgradeLater), for: UIControl.Event.touchUpInside) - // Button stack view - let buttonStackView = UIStackView(arrangedSubviews: [ upgradeNowButton, upgradeLaterButton ]) - buttonStackView.axis = .vertical - buttonStackView.spacing = Values.mediumSpacing - buttonStackView.alignment = .center - // Main stack view - let stackView = UIStackView(arrangedSubviews: [ topStackView, explanationLabel, buttonStackView ]) - stackView.axis = .vertical - stackView.spacing = Values.veryLargeSpacing - stackView.alignment = .center - // Constraints - contentView.addSubview(stackView) - stackView.pin(.leading, to: .leading, of: contentView, withInset: Values.veryLargeSpacing) - stackView.pin(.top, to: .top, of: contentView, withInset: Values.largeSpacing) - contentView.pin(.trailing, to: .trailing, of: stackView, withInset: Values.veryLargeSpacing) - contentView.pin(.bottom, to: .bottom, of: stackView, withInset: Values.veryLargeSpacing + overshoot) - } - - @objc private func upgradeNow() { - Storage.prepareForV2KeyPairMigration() - } - - @objc private func upgradeLater() { - let alert = UIAlertController(title: "Warning", message: "You won't be able to send or receive messages until you upgrade.", preferredStyle: .alert) - alert.addAction(UIAlertAction(title: "OK", accessibilityIdentifier: nil, style: .default, handler: nil)) - presentingViewController?.dismiss(animated: true, completion: nil) // Dismiss self - presentingViewController?.present(alert, animated: true, completion: nil) - } -} diff --git a/Session/Sheets & Modals/KeyPairMigrationSuccessSheet.swift b/Session/Sheets & Modals/KeyPairMigrationSuccessSheet.swift deleted file mode 100644 index 3c863a67c..000000000 --- a/Session/Sheets & Modals/KeyPairMigrationSuccessSheet.swift +++ /dev/null @@ -1,94 +0,0 @@ - -final class KeyPairMigrationSuccessSheet : Sheet { - - private lazy var sessionIDLabel: UILabel = { - let result = UILabel() - result.textColor = Colors.text - result.font = Fonts.spaceMono(ofSize: isIPhone5OrSmaller ? Values.mediumFontSize : 20) - result.numberOfLines = 0 - result.lineBreakMode = .byCharWrapping - return result - }() - - private lazy var copyButton: Button = { - let result = Button(style: .prominentOutline, size: .large) - result.set(.width, to: 240) - result.setTitle(NSLocalizedString("copy", comment: ""), for: UIControl.State.normal) - result.addTarget(self, action: #selector(copySessionID), for: UIControl.Event.touchUpInside) - return result - }() - - override func populateContentView() { - // Image view - let imageView = UIImageView(image: #imageLiteral(resourceName: "Shield").withTint(Colors.text)) - imageView.set(.width, to: 64) - imageView.set(.height, to: 64) - imageView.contentMode = .scaleAspectFit - // Title label - let titleLabel = UILabel() - titleLabel.textColor = Colors.text - titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize) - titleLabel.text = "Upgrade Successful!" - titleLabel.numberOfLines = 0 - titleLabel.lineBreakMode = .byWordWrapping - // Top stack view - let topStackView = UIStackView(arrangedSubviews: [ imageView, titleLabel ]) - topStackView.axis = .vertical - topStackView.spacing = Values.largeSpacing - topStackView.alignment = .center - // Explanation label - let explanationLabel = UILabel() - explanationLabel.textColor = Colors.text - explanationLabel.font = .systemFont(ofSize: Values.smallFontSize) - explanationLabel.textAlignment = .center - explanationLabel.text = "Your new and improved Session ID is:" - explanationLabel.numberOfLines = 0 - explanationLabel.lineBreakMode = .byWordWrapping - // Session ID label - sessionIDLabel.text = getUserHexEncodedPublicKey() - // Session ID container - let sessionIDContainer = UIView() - sessionIDContainer.addSubview(sessionIDLabel) - sessionIDLabel.pin(to: sessionIDContainer, withInset: Values.mediumSpacing) - sessionIDContainer.layer.cornerRadius = TextField.cornerRadius - sessionIDContainer.layer.borderWidth = 1 - sessionIDContainer.layer.borderColor = Colors.text.cgColor - // OK button - let okButton = Button(style: .prominentOutline, size: .large) - okButton.set(.width, to: 240) - okButton.setTitle("OK", for: UIControl.State.normal) - okButton.addTarget(self, action: #selector(close), for: UIControl.Event.touchUpInside) - // Button stack view - let buttonStackView = UIStackView(arrangedSubviews: [ copyButton, okButton ]) - buttonStackView.axis = .vertical - buttonStackView.spacing = Values.mediumSpacing - buttonStackView.alignment = .center - // Main stack view - let stackView = UIStackView(arrangedSubviews: [ topStackView, explanationLabel, sessionIDContainer, buttonStackView ]) - stackView.axis = .vertical - stackView.spacing = Values.veryLargeSpacing - stackView.alignment = .center - // Constraints - contentView.addSubview(stackView) - stackView.pin(.leading, to: .leading, of: contentView, withInset: Values.veryLargeSpacing) - stackView.pin(.top, to: .top, of: contentView, withInset: Values.largeSpacing) - contentView.pin(.trailing, to: .trailing, of: stackView, withInset: Values.veryLargeSpacing) - contentView.pin(.bottom, to: .bottom, of: stackView, withInset: Values.veryLargeSpacing + overshoot) - } - - @objc private func copySessionID() { - UIPasteboard.general.string = getUserHexEncodedPublicKey() - copyButton.isUserInteractionEnabled = false - UIView.transition(with: copyButton, duration: 0.25, options: .transitionCrossDissolve, animations: { - self.copyButton.setTitle("Copied", for: UIControl.State.normal) - }, completion: nil) - Timer.scheduledTimer(timeInterval: 4, target: self, selector: #selector(enableCopyButton), userInfo: nil, repeats: false) - } - - @objc private func enableCopyButton() { - copyButton.isUserInteractionEnabled = true - UIView.transition(with: copyButton, duration: 0.25, options: .transitionCrossDissolve, animations: { - self.copyButton.setTitle(NSLocalizedString("copy", comment: ""), for: UIControl.State.normal) - }, completion: nil) - } -} diff --git a/SessionMessagingKit/Utilities/ProximityMonitoringManager.swift b/SessionMessagingKit/Utilities/ProximityMonitoringManager.swift index 3b74af82d..5dff015a7 100644 --- a/SessionMessagingKit/Utilities/ProximityMonitoringManager.swift +++ b/SessionMessagingKit/Utilities/ProximityMonitoringManager.swift @@ -3,7 +3,7 @@ // @objc -public protocol OWSProximityMonitoringManager: class { +public protocol OWSProximityMonitoringManager: AnyObject { func add(lifetime: AnyObject) func remove(lifetime: AnyObject) } diff --git a/SessionUtilitiesKit/General/SNUserDefaults.swift b/SessionUtilitiesKit/General/SNUserDefaults.swift index aa563e94f..a09ba86f3 100644 --- a/SessionUtilitiesKit/General/SNUserDefaults.swift +++ b/SessionUtilitiesKit/General/SNUserDefaults.swift @@ -7,10 +7,10 @@ public enum SNUserDefaults { case hasViewedSeed case hasSeenLinkPreviewSuggestion case isUsingFullAPNs - case isMigratingToV2KeyPair } public enum Date : Swift.String { + /// Deprecated. Remove with removal of v1 open groups. case lastProfilePictureUpload case lastConfigurationSync case lastDisplayNameUpdate @@ -28,8 +28,6 @@ public enum SNUserDefaults { public enum String : Swift.String { case deviceToken - /// Just used for migration purposes. - case displayName } }