pull/352/head
Niels Andriesse 3 years ago
parent c4f1ccda0a
commit e4aca65af0

@ -532,8 +532,6 @@
C3548F0624456447009433A8 /* PNModeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3548F0524456447009433A8 /* PNModeVC.swift */; };
C3548F0824456AB6009433A8 /* UIView+Wrapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3548F0724456AB6009433A8 /* UIView+Wrapping.swift */; };
C354E75A23FE2A7600CE22E3 /* BaseVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C354E75923FE2A7600CE22E3 /* BaseVC.swift */; };
C35D0DA125AE582D00B6BF49 /* MultiDeviceVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35D0DA025AE582D00B6BF49 /* MultiDeviceVC.swift */; };
C35D0DAB25AE5BDE00B6BF49 /* SettingRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35D0DAA25AE5BDE00B6BF49 /* SettingRow.swift */; };
C35D0DB525AE5F1200B6BF49 /* UIEdgeInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35D0DB425AE5F1200B6BF49 /* UIEdgeInsets.swift */; };
C35E8AAE2485E51D00ACB629 /* IP2Country.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35E8AAD2485E51D00ACB629 /* IP2Country.swift */; };
C364535C252467900045C478 /* AudioUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C364535B252467900045C478 /* AudioUtilities.swift */; };
@ -1533,8 +1531,6 @@
C3548F0524456447009433A8 /* PNModeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNModeVC.swift; sourceTree = "<group>"; };
C3548F0724456AB6009433A8 /* UIView+Wrapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Wrapping.swift"; sourceTree = "<group>"; };
C354E75923FE2A7600CE22E3 /* BaseVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseVC.swift; sourceTree = "<group>"; };
C35D0DA025AE582D00B6BF49 /* MultiDeviceVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiDeviceVC.swift; sourceTree = "<group>"; };
C35D0DAA25AE5BDE00B6BF49 /* SettingRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingRow.swift; sourceTree = "<group>"; };
C35D0DB425AE5F1200B6BF49 /* UIEdgeInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIEdgeInsets.swift; sourceTree = "<group>"; };
C35E8AA22485C72300ACB629 /* SwiftCSV.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftCSV.framework; path = ThirdParty/Carthage/Build/iOS/SwiftCSV.framework; sourceTree = "<group>"; };
C35E8AAD2485E51D00ACB629 /* IP2Country.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IP2Country.swift; sourceTree = "<group>"; };
@ -2386,7 +2382,6 @@
C31D1DE22521718E005D4DA8 /* UserSelectionVC.swift */,
34D2CCD82062E7D000CB1A14 /* OWSScreenLockUI.h */,
34D2CCD92062E7D000CB1A14 /* OWSScreenLockUI.m */,
C35D0DAA25AE5BDE00B6BF49 /* SettingRow.swift */,
);
path = Shared;
sourceTree = "<group>";
@ -2836,7 +2831,6 @@
B886B4A62398B23E00211ABE /* QRCodeVC.swift */,
B86BD08523399CEF000F5AE3 /* SeedModal.swift */,
B8CCF6422397711F0091D419 /* SettingsVC.swift */,
C35D0DA025AE582D00B6BF49 /* MultiDeviceVC.swift */,
);
path = Settings;
sourceTree = "<group>";
@ -4916,7 +4910,6 @@
D221A09A169C9E5E00537ABF /* main.m in Sources */,
3496957221A301A100DCFE74 /* OWSBackup.m in Sources */,
B835247925C38D880089A44F /* MessageCell.swift in Sources */,
C35D0DA125AE582D00B6BF49 /* MultiDeviceVC.swift in Sources */,
B86BD08623399CEF000F5AE3 /* SeedModal.swift in Sources */,
34E3E5681EC4B19400495BAC /* AudioProgressView.swift in Sources */,
B8D0A26925E4A2C200C1835E /* Onboarding.swift in Sources */,
@ -4927,7 +4920,6 @@
B82B408C239A068800A248E7 /* RegisterVC.swift in Sources */,
346129991FD1E4DA00532771 /* SignalApp.m in Sources */,
3496957121A301A100DCFE74 /* OWSBackupImportJob.m in Sources */,
C35D0DAB25AE5BDE00B6BF49 /* SettingRow.swift in Sources */,
34BECE301F7ABCF800D7438D /* GifPickerLayout.swift in Sources */,
C331FFFE2558FF3B00070591 /* ConversationCell.swift in Sources */,
C3DFFAC623E96F0D0058DAF8 /* Sheet.swift in Sources */,

@ -153,7 +153,6 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, NewConv
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
reload()
UserDefaults.standard[.hasLaunchedOnce] = true
}
deinit {

@ -1,165 +0,0 @@
final class MultiDeviceVC : BaseVC {
private let mnemonic: String = {
let collection = OWSPrimaryStorageIdentityKeyStoreCollection
let hexEncodedSeed: String! = OWSIdentityManager.shared().dbConnection.object(forKey: "LKLokiSeed", inCollection: collection) as! String?
return Mnemonic.encode(hexEncodedString: hexEncodedSeed)
}()
// MARK: UI Components
private lazy var toggleLabel: UILabel = {
let result = UILabel()
result.textColor = Colors.text
result.font = .systemFont(ofSize: Values.mediumFontSize)
result.text = "Enable multi device"
return result
}()
private lazy var toggle: UISwitch = {
let result = UISwitch()
result.onTintColor = Colors.accent
result.isOn = UserDefaults.standard[.isUsingMultiDevice]
return result
}()
private lazy var stepsRow: SettingRow = {
let result = SettingRow(autoSize: true)
result.isHidden = true
return result
}()
private lazy var stepsLabel1: UILabel = {
let result = UILabel()
result.textColor = Colors.text
result.font = .systemFont(ofSize: Values.smallFontSize)
result.text = """
1. Clear your other device if it currently has an account on it (Settings > Clear Data).
2. On the landing page, click "Continue your Session".
3. Enter the following words when prompted:
"""
result.numberOfLines = 0
result.lineBreakMode = .byWordWrapping
return result
}()
private lazy var mnemonicLabel: UILabel = {
let result = UILabel()
result.textColor = Colors.text
result.font = Fonts.spaceMono(ofSize: Values.smallFontSize)
result.text = mnemonic
result.numberOfLines = 0
result.lineBreakMode = .byWordWrapping
result.textAlignment = .center
return result
}()
private lazy var copyButton: Button = {
let result = Button(style: .prominentOutline, size: .medium)
result.setTitle(NSLocalizedString("copy", comment: ""), for: UIControl.State.normal)
result.addTarget(self, action: #selector(copyMnemonic), for: UIControl.Event.touchUpInside)
return result
}()
private lazy var stepsLabel2: UILabel = {
let result = UILabel()
result.textColor = Colors.text
result.font = .systemFont(ofSize: Values.smallFontSize)
result.text = """
4. Enter your display name.
5. That's it!
"""
result.numberOfLines = 0
result.lineBreakMode = .byWordWrapping
return result
}()
// MARK: Initialization
override func viewDidLoad() {
super.viewDidLoad()
setUpUI()
}
private func setUpUI() {
setUpGradientBackground()
setUpNavBarStyle()
setNavBarTitle("Multi Device (Beta)")
// Back button
let backButton = UIBarButtonItem(title: "Back", style: .plain, target: nil, action: nil)
backButton.tintColor = Colors.text
navigationItem.backBarButtonItem = backButton
// Toggle
toggle.addTarget(self, action: #selector(handleToggle), for: UIControl.Event.valueChanged)
let toggleStackView = UIStackView(arrangedSubviews: [ toggleLabel, toggle ])
toggleStackView.axis = .horizontal
toggleStackView.spacing = Values.mediumSpacing
toggleStackView.alignment = .center
let toggleRow = SettingRow()
toggleRow.contentView.addSubview(toggleStackView)
toggleStackView.pin(to: toggleRow.contentView, withInset: Values.mediumSpacing)
// Steps
let mnemonicLabelContainer = UIView()
mnemonicLabelContainer.addSubview(mnemonicLabel)
mnemonicLabel.pin(to: mnemonicLabelContainer, withInset: isIPhone6OrSmaller ? 4 : Values.smallSpacing)
mnemonicLabelContainer.layer.cornerRadius = TextField.cornerRadius
mnemonicLabelContainer.layer.borderWidth = 1
mnemonicLabelContainer.layer.borderColor = Colors.text.cgColor
let stepsLabel1Container = UIView()
stepsLabel1Container.addSubview(stepsLabel1)
stepsLabel1.pin(.leading, to: .leading, of: stepsLabel1Container, withInset: Values.smallSpacing)
stepsLabel1Container.pin(.trailing, to: .trailing, of: stepsLabel1, withInset: Values.smallSpacing)
stepsLabel1.pin([ UIView.VerticalEdge.top, UIView.VerticalEdge.bottom ], to: stepsLabel1Container)
let stepsLabel2Container = UIView()
stepsLabel2Container.addSubview(stepsLabel2)
stepsLabel2.pin(.leading, to: .leading, of: stepsLabel2Container, withInset: Values.smallSpacing)
stepsLabel2Container.pin(.trailing, to: .trailing, of: stepsLabel2, withInset: Values.smallSpacing)
stepsLabel2.pin([ UIView.VerticalEdge.top, UIView.VerticalEdge.bottom ], to: stepsLabel2Container)
let stepsStackView = UIStackView(arrangedSubviews: [ stepsLabel1Container, mnemonicLabelContainer, copyButton, stepsLabel2Container ])
stepsStackView.axis = .vertical
stepsStackView.spacing = Values.mediumSpacing
stepsRow.contentView.addSubview(stepsStackView)
stepsStackView.pin(to: stepsRow.contentView, withInset: Values.mediumSpacing)
// Main stack view
let mainStackView = UIStackView(arrangedSubviews: [ toggleRow, stepsRow ])
mainStackView.axis = .vertical
mainStackView.spacing = Values.mediumSpacing
mainStackView.isLayoutMarginsRelativeArrangement = true
mainStackView.layoutMargins = UIEdgeInsets(uniform: Values.mediumSpacing)
mainStackView.set(.width, to: UIScreen.main.bounds.width)
// Scroll view
let scrollView = UIScrollView()
scrollView.showsVerticalScrollIndicator = false
scrollView.addSubview(mainStackView)
mainStackView.pin(to: scrollView)
view.addSubview(scrollView)
scrollView.pin(to: view)
}
// MARK: Updating
@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)
}
// MARK: Interaction
@objc private func handleToggle() {
stepsRow.isHidden = !toggle.isOn
UserDefaults.standard[.isUsingMultiDevice] = toggle.isOn
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.forceSyncConfigurationNowIfNeeded().retainUntilComplete()
}
@objc private func copyMnemonic() {
UIPasteboard.general.string = mnemonic
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)
}
}

@ -184,8 +184,6 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
getSeparator(),
getSettingButton(withTitle: NSLocalizedString("vc_settings_notifications_button_title", comment: ""), color: Colors.text, action: #selector(showNotificationSettings)),
getSeparator(),
// getSettingButton(withTitle: "Multi Device (Beta)", color: Colors.text, action: #selector(showMultiDeviceOptions)),
// getSeparator(),
getSettingButton(withTitle: "Invite", color: Colors.text, action: #selector(sendInvitation)),
getSeparator()
]
@ -410,11 +408,6 @@ final class SettingsVC : BaseVC, AvatarViewHelperDelegate {
navigationController!.pushViewController(notificationSettingsVC, animated: true)
}
@objc private func showMultiDeviceOptions() {
let multiDeviceVC = MultiDeviceVC()
navigationController!.pushViewController(multiDeviceVC, animated: true)
}
@objc private func sendInvitation() {
let invitation = "Hey, I've been using Session to chat with complete privacy and security. Come join me! Download it at https://getsession.org/. My Session ID is \(getUserHexEncodedPublicKey())!"
let shareVC = UIActivityViewController(activityItems: [ invitation ], applicationActivities: nil)

@ -1,53 +0,0 @@
final class SettingRow : UIView {
private let autoSize: Bool
lazy var contentView: UIView = {
let result = UIView()
result.backgroundColor = Colors.buttonBackground
result.layer.cornerRadius = 8
result.layer.masksToBounds = true
return result
}()
private static let defaultHeight: CGFloat = 60
init(autoSize: Bool) {
self.autoSize = autoSize
super.init(frame: CGRect.zero)
setUpUI()
}
override init(frame: CGRect) {
autoSize = false
super.init(frame: frame)
setUpUI()
}
required init?(coder: NSCoder) {
autoSize = false
super.init(coder: coder)
setUpUI()
}
private func setUpUI() {
// Height
if !autoSize {
let height = SettingRow.defaultHeight
set(.height, to: height)
}
// Shadow
layer.shadowColor = UIColor.black.cgColor
layer.shadowOffset = CGSize.zero
layer.shadowOpacity = 0.4
layer.shadowRadius = 4
// Content view
addSubview(contentView)
contentView.pin(to: self)
}
override func layoutSubviews() {
super.layoutSubviews()
layer.shadowPath = UIBezierPath(roundedRect: bounds, cornerRadius: 8).cgPath
}
}

@ -3,19 +3,15 @@ import Foundation
public enum SNUserDefaults {
public enum Bool : Swift.String {
case hasLaunchedOnce
case hasSeenGIFMetadataWarning
case hasSyncedConfiguration
case hasViewedSeed
case hasSeenLinkPreviewSuggestion
case isUsingFullAPNs
case isMigratingToV2KeyPair
case isUsingMultiDevice
}
public enum Date : Swift.String {
case lastProfilePictureUpload
case lastKeyPairMigrationNudge
case lastConfigurationSync
}
@ -23,7 +19,7 @@ public enum SNUserDefaults {
case lastDeviceTokenUpload = "lastDeviceTokenUploadTime"
}
public enum Int: Swift.String {
public enum Int : Swift.String {
case appMode
}

Loading…
Cancel
Save