Commit 14f4a781 authored by Thomas Markiewicz's avatar Thomas Markiewicz

Updates for Librem One

parent 82674ee6
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"images" : [ "images" : [
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "piaWhiteCopy.pdf" "filename" : "nav-logo-white@3x"
} }
], ],
"info" : { "info" : {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"images" : [ "images" : [
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "piaDark2Copy2.pdf" "filename" : "nav-logo@3x.png"
} }
], ],
"info" : { "info" : {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"images" : [ "images" : [
{ {
"idiom" : "universal", "idiom" : "universal",
"filename" : "piaDark2Copy2.pdf" "filename" : "nav-logo@3x.png"
} }
], ],
"info" : { "info" : {
......
...@@ -9,18 +9,19 @@ ...@@ -9,18 +9,19 @@
"login.title" = "Sign in to your account"; "login.title" = "Sign in to your account";
"login.username.placeholder" = "Username (p1234567)"; "login.username.placeholder" = "Username (p1234567)";
"login.password.placeholder" = "Password"; "login.password.placeholder" = "Password";
"login.username.l1Placeholder" = "Librem One address";
"login.password.l1Placeholder" = "Passphrase";
"login.submit" = "LOGIN"; "login.submit" = "LOGIN";
"login.restore.button" = "Didn't receive account details?"; "login.restore.button" = "Didn't receive account details?";
"login.error.title" = "Log in"; "login.error.title" = "Log in";
"login.error.validation" = "You must enter a username and password."; "login.error.validation" = "You must enter a username and passphrase.";
"login.error.unauthorized" = "Your username or password is incorrect."; "login.error.unauthorized" = "Your username or passphrase is incorrect.";
"login.error.throttled" = "Too many failed login attempts with this username. Please try again later."; "login.error.throttled" = "Too many failed login attempts with this username. Please try again later.";
"login.receipt.button" = "Login using purchase receipt"; "login.receipt.button" = "Login using purchase receipt";
"login.magic.link.title" = "Login using magic email link"; "login.magic.link.title" = "Login using magic email link";
"login.magic.link.response" = "Please check your e-mail for a login link."; "login.magic.link.response" = "Please check your e-mail for a login link.";
"login.magic.link.send" = "Send Link"; "login.magic.link.send" = "Send Link";
"login.magic.link.invalid.email" = "Invalid email. Please try again."; "login.magic.link.invalid.email" = "Invalid email. Please try again.";
"purchase.title" = "Select a VPN plan"; "purchase.title" = "Select a VPN plan";
"purchase.subtitle" = "30-day money back guarantee"; "purchase.subtitle" = "30-day money back guarantee";
"purchase.email.placeholder" = "Email address"; "purchase.email.placeholder" = "Email address";
......
...@@ -68,7 +68,8 @@ internal struct ImageAsset { ...@@ -68,7 +68,8 @@ internal struct ImageAsset {
#if os(iOS) || os(tvOS) #if os(iOS) || os(tvOS)
let image = Image(named: name, in: bundle, compatibleWith: nil) let image = Image(named: name, in: bundle, compatibleWith: nil)
#elseif os(macOS) #elseif os(macOS)
let image = bundle.image(forResource: NSImage.Name(name)) let name = NSImage.Name(self.name)
let image = (bundle == .main) ? NSImage(named: name) : bundle.image(forResource: name)
#elseif os(watchOS) #elseif os(watchOS)
let image = Image(named: name) let image = Image(named: name)
#endif #endif
...@@ -97,7 +98,11 @@ internal extension ImageAsset.Image { ...@@ -97,7 +98,11 @@ internal extension ImageAsset.Image {
// swiftlint:disable convenience_type // swiftlint:disable convenience_type
private final class BundleToken { private final class BundleToken {
static let bundle: Bundle = { static let bundle: Bundle = {
Bundle(for: BundleToken.self) #if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: BundleToken.self)
#endif
}() }()
} }
// swiftlint:enable convenience_type // swiftlint:enable convenience_type
...@@ -8,7 +8,7 @@ import Foundation ...@@ -8,7 +8,7 @@ import Foundation
// MARK: - Strings // MARK: - Strings
// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length // swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:disable nesting type_body_length type_name // swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
internal enum L10n { internal enum L10n {
internal enum Signup { internal enum Signup {
internal enum Failure { internal enum Failure {
...@@ -263,9 +263,9 @@ internal enum L10n { ...@@ -263,9 +263,9 @@ internal enum L10n {
internal static let throttled = L10n.tr("Welcome", "login.error.throttled") internal static let throttled = L10n.tr("Welcome", "login.error.throttled")
/// Log in /// Log in
internal static let title = L10n.tr("Welcome", "login.error.title") internal static let title = L10n.tr("Welcome", "login.error.title")
/// Your username or password is incorrect. /// Your username or passphrase is incorrect.
internal static let unauthorized = L10n.tr("Welcome", "login.error.unauthorized") internal static let unauthorized = L10n.tr("Welcome", "login.error.unauthorized")
/// You must enter a username and password. /// You must enter a username and passphrase.
internal static let validation = L10n.tr("Welcome", "login.error.validation") internal static let validation = L10n.tr("Welcome", "login.error.validation")
} }
internal enum Magic { internal enum Magic {
...@@ -283,6 +283,8 @@ internal enum L10n { ...@@ -283,6 +283,8 @@ internal enum L10n {
} }
} }
internal enum Password { internal enum Password {
/// Passphrase
internal static let l1Placeholder = L10n.tr("Welcome", "login.password.l1Placeholder")
/// Password /// Password
internal static let placeholder = L10n.tr("Welcome", "login.password.placeholder") internal static let placeholder = L10n.tr("Welcome", "login.password.placeholder")
} }
...@@ -295,6 +297,8 @@ internal enum L10n { ...@@ -295,6 +297,8 @@ internal enum L10n {
internal static let button = L10n.tr("Welcome", "login.restore.button") internal static let button = L10n.tr("Welcome", "login.restore.button")
} }
internal enum Username { internal enum Username {
/// Librem One address
internal static let l1Placeholder = L10n.tr("Welcome", "login.username.l1Placeholder")
/// Username (p1234567) /// Username (p1234567)
internal static let placeholder = L10n.tr("Welcome", "login.username.placeholder") internal static let placeholder = L10n.tr("Welcome", "login.username.placeholder")
} }
...@@ -424,7 +428,7 @@ internal enum L10n { ...@@ -424,7 +428,7 @@ internal enum L10n {
} }
} }
// swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length // swiftlint:enable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:enable nesting type_body_length type_name // swiftlint:enable nesting type_body_length type_name vertical_whitespace_opening_braces
// MARK: - Implementation Details // MARK: - Implementation Details
...@@ -438,7 +442,11 @@ extension L10n { ...@@ -438,7 +442,11 @@ extension L10n {
// swiftlint:disable convenience_type // swiftlint:disable convenience_type
private final class BundleToken { private final class BundleToken {
static let bundle: Bundle = { static let bundle: Bundle = {
Bundle(for: BundleToken.self) #if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: BundleToken.self)
#endif
}() }()
} }
// swiftlint:enable convenience_type // swiftlint:enable convenience_type
...@@ -27,7 +27,7 @@ public class GetStartedViewController: PIAWelcomeViewController { ...@@ -27,7 +27,7 @@ public class GetStartedViewController: PIAWelcomeViewController {
private static let smallDeviceMaxViewHeight: CGFloat = 520 private static let smallDeviceMaxViewHeight: CGFloat = 520
private static let maxViewHeight: CGFloat = 500 private static let maxViewHeight: CGFloat = 500
private static let extraViewButtonsHeight: CGFloat = 48 private static let extraViewButtonsHeight: CGFloat = 48
private static let defaultViewHeight: CGFloat = 276 private static let defaultViewHeight: CGFloat = 100
@IBOutlet private weak var spinner: UIActivityIndicatorView! @IBOutlet private weak var spinner: UIActivityIndicatorView!
...@@ -120,9 +120,12 @@ public class GetStartedViewController: PIAWelcomeViewController { ...@@ -120,9 +120,12 @@ public class GetStartedViewController: PIAWelcomeViewController {
pageControl.numberOfPages = allData.count pageControl.numberOfPages = allData.count
visualEffectView.clipsToBounds = true visualEffectView.clipsToBounds = true
visualEffectView.layer.cornerRadius = 15
visualEffectView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner] /* Removed for L1
//visualEffectView.layer.cornerRadius = 15
//visualEffectView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMinXMinYCorner]
*/
let swipeDown = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture)) let swipeDown = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
swipeDown.direction = UISwipeGestureRecognizer.Direction.down swipeDown.direction = UISwipeGestureRecognizer.Direction.down
self.view.addGestureRecognizer(swipeDown) self.view.addGestureRecognizer(swipeDown)
...@@ -136,7 +139,7 @@ public class GetStartedViewController: PIAWelcomeViewController { ...@@ -136,7 +139,7 @@ public class GetStartedViewController: PIAWelcomeViewController {
} }
@objc func respondToSwipeGesture(gesture: UIGestureRecognizer) { @objc func respondToSwipeGesture(gesture: UIGestureRecognizer) {
/* Removed for L1
if let swipeGesture = gesture as? UISwipeGestureRecognizer { if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction { switch swipeGesture.direction {
...@@ -148,7 +151,7 @@ public class GetStartedViewController: PIAWelcomeViewController { ...@@ -148,7 +151,7 @@ public class GetStartedViewController: PIAWelcomeViewController {
break break
} }
} }
*/
} }
override public func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { override public func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
......
...@@ -71,8 +71,8 @@ class LoginViewController: AutolayoutViewController, WelcomeChild { ...@@ -71,8 +71,8 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
NotificationCenter.default.addObserver(self, selector: #selector(finishLoginWithMagicLink), name: .PIAFinishLoginWithMagicLink, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(finishLoginWithMagicLink), name: .PIAFinishLoginWithMagicLink, object: nil)
labelTitle.text = L10n.Welcome.Login.title labelTitle.text = L10n.Welcome.Login.title
textUsername.placeholder = L10n.Welcome.Login.Username.placeholder textUsername.placeholder = L10n.Welcome.Login.Username.l1Placeholder
textPassword.placeholder = L10n.Welcome.Login.Password.placeholder textPassword.placeholder = L10n.Welcome.Login.Password.l1Placeholder
textUsername.text = preset.loginUsername textUsername.text = preset.loginUsername
textPassword.text = preset.loginPassword textPassword.text = preset.loginPassword
...@@ -256,8 +256,6 @@ class LoginViewController: AutolayoutViewController, WelcomeChild { ...@@ -256,8 +256,6 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
/* START Librem One specific */ /* START Librem One specific */
// assume here for now that 'username' is in a form of an email
// if there is no @ sign, should I assume it's just the "username" part? (I think so...)
let emailParts = username.split(separator: "@") let emailParts = username.split(separator: "@")
let librem_username = emailParts[0] let librem_username = emailParts[0]
let librem_domain = emailParts.count > 1 ? emailParts[1] : "librem.one"; let librem_domain = emailParts.count > 1 ? emailParts[1] : "librem.one";
...@@ -270,6 +268,8 @@ class LoginViewController: AutolayoutViewController, WelcomeChild { ...@@ -270,6 +268,8 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
Alamofire.request(libremOneAccountUrl, headers: headers).responseJSON { response in Alamofire.request(libremOneAccountUrl, headers: headers).responseJSON { response in
var errorMessage: String?
if let result = response.result.value { if let result = response.result.value {
// got some result successfully - get PIA username and password out of it // got some result successfully - get PIA username and password out of it
...@@ -282,6 +282,9 @@ class LoginViewController: AutolayoutViewController, WelcomeChild { ...@@ -282,6 +282,9 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
self.logInToPIA(tunnelUser, tunnelPassword, username) self.logInToPIA(tunnelUser, tunnelPassword, username)
} else { } else {
log.error("Failed to obtain valid PIA username and password from Librem One"); log.error("Failed to obtain valid PIA username and password from Librem One");
errorMessage = L10n.Welcome.Login.Error.unauthorized
Macros.displayImageNote(withImage: Asset.iconWarning.image,
message: errorMessage ?? L10n.Welcome.Login.Error.title)
self.enableInteractions(true) self.enableInteractions(true)
self.hideLoadingAnimation() self.hideLoadingAnimation()
} }
...@@ -289,6 +292,9 @@ class LoginViewController: AutolayoutViewController, WelcomeChild { ...@@ -289,6 +292,9 @@ class LoginViewController: AutolayoutViewController, WelcomeChild {
log.error("Failed to obtain a response from Librem One login attempt"); log.error("Failed to obtain a response from Librem One login attempt");
self.enableInteractions(true) self.enableInteractions(true)
self.hideLoadingAnimation() self.hideLoadingAnimation()
Macros.displayImageNote(withImage: Asset.iconWarning.image,
message: L10n.Welcome.Login.Error.title)
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment