Make Session ID upgrades mandatory
This commit is contained in:
parent
4156b0e87e
commit
475eb06538
|
@ -167,15 +167,10 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol
|
||||||
|
|
||||||
private func showKeyPairMigrationNudgeIfNeeded() {
|
private func showKeyPairMigrationNudgeIfNeeded() {
|
||||||
guard !KeyPairUtilities.hasV2KeyPair() else { return }
|
guard !KeyPairUtilities.hasV2KeyPair() else { return }
|
||||||
let lastNudge = UserDefaults.standard[.lastKeyPairMigrationNudge]
|
|
||||||
let nudgeInterval: Double = 3 * 24 * 60 * 60 // 3 days
|
|
||||||
let nudge = given(lastNudge) { Date().timeIntervalSince($0) > nudgeInterval } ?? true
|
|
||||||
guard nudge else { return }
|
|
||||||
let sheet = KeyPairMigrationSheet()
|
let sheet = KeyPairMigrationSheet()
|
||||||
sheet.modalPresentationStyle = .overFullScreen
|
sheet.modalPresentationStyle = .overFullScreen
|
||||||
sheet.modalTransitionStyle = .crossDissolve
|
sheet.modalTransitionStyle = .crossDissolve
|
||||||
present(sheet, animated: true, completion: nil)
|
present(sheet, animated: true, completion: nil)
|
||||||
UserDefaults.standard[.lastKeyPairMigrationNudge] = Date()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func showKeyPairMigrationSuccessModalIfNeeded() {
|
private func showKeyPairMigrationSuccessModalIfNeeded() {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
final class KeyPairMigrationSheet : Sheet {
|
final class KeyPairMigrationSheet : Sheet {
|
||||||
|
|
||||||
|
override class var isDismissable: Bool { false }
|
||||||
|
|
||||||
override func populateContentView() {
|
override func populateContentView() {
|
||||||
// Image view
|
// Image view
|
||||||
let imageView = UIImageView(image: #imageLiteral(resourceName: "Shield").withTint(Colors.text))
|
let imageView = UIImageView(image: #imageLiteral(resourceName: "Shield").withTint(Colors.text))
|
||||||
|
@ -12,6 +14,7 @@ final class KeyPairMigrationSheet : Sheet {
|
||||||
titleLabel.textColor = Colors.text
|
titleLabel.textColor = Colors.text
|
||||||
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
|
titleLabel.font = .boldSystemFont(ofSize: isIPhone5OrSmaller ? Values.largeFontSize : Values.veryLargeFontSize)
|
||||||
titleLabel.text = "Session IDs Just Got Better"
|
titleLabel.text = "Session IDs Just Got Better"
|
||||||
|
titleLabel.textAlignment = .center
|
||||||
titleLabel.numberOfLines = 0
|
titleLabel.numberOfLines = 0
|
||||||
titleLabel.lineBreakMode = .byWordWrapping
|
titleLabel.lineBreakMode = .byWordWrapping
|
||||||
// Top stack view
|
// Top stack view
|
||||||
|
@ -25,9 +28,9 @@ final class KeyPairMigrationSheet : Sheet {
|
||||||
explanationLabel.font = .systemFont(ofSize: Values.smallFontSize)
|
explanationLabel.font = .systemFont(ofSize: Values.smallFontSize)
|
||||||
explanationLabel.textAlignment = .center
|
explanationLabel.textAlignment = .center
|
||||||
explanationLabel.text = """
|
explanationLabel.text = """
|
||||||
We’ve upgraded Session IDs to make them even more private and secure. We recommend upgrading to a new Session ID now.
|
We’ve upgraded Session IDs to make them even more private and secure. To ensure your continued privacy you're now required to upgrade.
|
||||||
|
|
||||||
You will lose existing contacts and conversations, but you’ll gain even more privacy and security. You will need to upgrade your Session ID eventually, but you can choose to delay the upgrade if you need to save contacts or conversations.
|
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.numberOfLines = 0
|
||||||
explanationLabel.lineBreakMode = .byWordWrapping
|
explanationLabel.lineBreakMode = .byWordWrapping
|
||||||
|
@ -36,18 +39,8 @@ final class KeyPairMigrationSheet : Sheet {
|
||||||
upgradeNowButton.set(.width, to: 240)
|
upgradeNowButton.set(.width, to: 240)
|
||||||
upgradeNowButton.setTitle("Upgrade Now", for: UIControl.State.normal)
|
upgradeNowButton.setTitle("Upgrade Now", for: UIControl.State.normal)
|
||||||
upgradeNowButton.addTarget(self, action: #selector(upgradeNow), for: UIControl.Event.touchUpInside)
|
upgradeNowButton.addTarget(self, action: #selector(upgradeNow), for: UIControl.Event.touchUpInside)
|
||||||
// Upgrade later 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(close), 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
|
// Main stack view
|
||||||
let stackView = UIStackView(arrangedSubviews: [ topStackView, explanationLabel, buttonStackView ])
|
let stackView = UIStackView(arrangedSubviews: [ topStackView, explanationLabel, upgradeNowButton ])
|
||||||
stackView.axis = .vertical
|
stackView.axis = .vertical
|
||||||
stackView.spacing = Values.veryLargeSpacing
|
stackView.spacing = Values.veryLargeSpacing
|
||||||
stackView.alignment = .center
|
stackView.alignment = .center
|
||||||
|
@ -60,15 +53,6 @@ final class KeyPairMigrationSheet : Sheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func upgradeNow() {
|
@objc private func upgradeNow() {
|
||||||
guard let presentingVC = presentingViewController else { return }
|
Storage.prepareForV2KeyPairMigration()
|
||||||
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))
|
|
||||||
presentingVC.dismiss(animated: true) { // Dismiss self first
|
|
||||||
presentingVC.present(alert, animated: true, completion: nil)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@ class Sheet : BaseVC {
|
||||||
|
|
||||||
// MARK: Settings
|
// MARK: Settings
|
||||||
let overshoot: CGFloat = 40
|
let overshoot: CGFloat = 40
|
||||||
|
class var isDismissable: Bool { true }
|
||||||
|
|
||||||
// MARK: Components
|
// MARK: Components
|
||||||
lazy var contentView: UIView = {
|
lazy var contentView: UIView = {
|
||||||
let result = UIView()
|
let result = UIView()
|
||||||
|
@ -24,9 +25,11 @@ class Sheet : BaseVC {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
let alpha = isLightMode ? CGFloat(0.1) : Values.modalBackgroundOpacity
|
let alpha = isLightMode ? CGFloat(0.1) : Values.modalBackgroundOpacity
|
||||||
view.backgroundColor = UIColor(hex: 0x000000).withAlphaComponent(alpha)
|
view.backgroundColor = UIColor(hex: 0x000000).withAlphaComponent(alpha)
|
||||||
let swipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(close))
|
if type(of: self).isDismissable {
|
||||||
swipeGestureRecognizer.direction = .down
|
let swipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(close))
|
||||||
view.addGestureRecognizer(swipeGestureRecognizer)
|
swipeGestureRecognizer.direction = .down
|
||||||
|
view.addGestureRecognizer(swipeGestureRecognizer)
|
||||||
|
}
|
||||||
setUpViewHierarchy()
|
setUpViewHierarchy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +53,9 @@ class Sheet : BaseVC {
|
||||||
if contentView.frame.contains(location) {
|
if contentView.frame.contains(location) {
|
||||||
super.touchesBegan(touches, with: event)
|
super.touchesBegan(touches, with: event)
|
||||||
} else {
|
} else {
|
||||||
close()
|
if type(of: self).isDismissable {
|
||||||
|
close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue