|
@@ -84,6 +84,9 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
@IBOutlet weak var licenseCodeTextField: NSTextField!
|
|
|
@IBOutlet weak var notFoundButton: NSButton!
|
|
|
@IBOutlet weak var licenseCodeTopLayout: NSLayoutConstraint!
|
|
|
+ @IBOutlet weak var licenseCodeErrorView: NSView!
|
|
|
+ @IBOutlet weak var licenseCodeErrorLabel: NSTextField!
|
|
|
+ @IBOutlet weak var licenseCodeErrorTopLayout: NSLayoutConstraint!
|
|
|
|
|
|
@IBOutlet weak var emailLabel: NSTextField!
|
|
|
@IBOutlet weak var emailTextField: NSTextField!
|
|
@@ -276,12 +279,17 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
licenseCodeLabel.textColor = NSColor(named: "KMPurchaseTitleColor1")
|
|
|
licenseCodeLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
licenseCodeTextField.placeholderString = NSLocalizedString("Input license code previously activated the app", comment: "")
|
|
|
+ licenseCodeTextField.delegate = self
|
|
|
licenseCodeBox.borderColor = NSColor(named: "KMPurchase_DADBDE")!
|
|
|
licenseCodeBox.fillColor = NSColor(named: "KMPurchase_FFFFFF")!
|
|
|
notFoundButton.title = NSLocalizedString("Not Found?", comment: "")
|
|
|
notFoundButton.setTitleColor(color: NSColor(named: "KMPurchaseCouponColor")!, font: NSFont(name: "body-s-regular", size: 14))
|
|
|
licenseCodeTextField.stringValue = VerificationManager.default().originLicenseCode
|
|
|
refreshLicenseCodeView(isReveal: true)
|
|
|
+ licenseCodeErrorLabel.stringValue = NSLocalizedString("Please enter right license code. How to Retrieve License.", comment: "")
|
|
|
+ licenseCodeErrorLabel.textColor = NSColor(named: "KMPurchaseErrorColor")
|
|
|
+ licenseCodeErrorLabel.font = NSFont.SFProTextRegularFont(11.0)
|
|
|
+ refreshLicenseCodeErrorView(isReveal: false)
|
|
|
} else if productType == .ipaAI {
|
|
|
pdfReaderProLabel.stringValue = NSLocalizedString("PDF Reader Pro AI Tools", comment: "")
|
|
|
prmiumLabel.stringValue = NSLocalizedString("50 credits for 30 days", comment: "")
|
|
@@ -438,7 +446,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
payExplainLabel.font = NSFont.SFProTextRegularFont(11.0)
|
|
|
let localizedString = NSLocalizedString("By submitting this order, I agree to the %@ and %@ for subscription products", comment: "")
|
|
|
let privacyPolicy = NSLocalizedString("Privacy Policy", comment: "")
|
|
|
- let termsOfService = NSLocalizedString("Term Service", comment: "")
|
|
|
+ let termsOfService = NSLocalizedString("Terms of Service", comment: "")
|
|
|
let fullString1 = String(format: localizedString, privacyPolicy, termsOfService)
|
|
|
let attributedString1 = NSMutableAttributedString(string: fullString1)
|
|
|
let privacyPolicyRange = (fullString1 as NSString).range(of: privacyPolicy)
|
|
@@ -848,7 +856,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- applyButton.isEnabled = true
|
|
|
+ discountScale = ""
|
|
|
+ discountAmount = ""
|
|
|
coupomTextField.isEnabled = true
|
|
|
// 价格刷新
|
|
|
priceRefresh()
|
|
@@ -897,7 +906,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- applyButton.isEnabled = true
|
|
|
+ discountScale = ""
|
|
|
+ discountAmount = ""
|
|
|
coupomTextField.isEnabled = true
|
|
|
// 价格刷新
|
|
|
priceRefresh()
|
|
@@ -1092,6 +1102,21 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
var licenseCode = ""
|
|
|
if productID == "com.brother.pdfreaderpro.mac.product_2" {
|
|
|
+ if licenseCodeTextField.stringValue.count > 0 {
|
|
|
+ licenseCode = licenseCodeTextField.stringValue
|
|
|
+ } else {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
+ alert.informativeText = NSLocalizedString("Input license code previously activated the app", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
+ if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
|
|
|
+ alert.beginSheetModal(for: self.window!, completionHandler: nil)
|
|
|
+ } else {
|
|
|
+ alert.runModal()
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
if let license = VerificationManager.default().originLicenseCode, license.count > 0 {
|
|
|
licenseCode = license
|
|
|
}
|
|
@@ -1458,7 +1483,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
self.scanLabel.stringValue = NSLocalizedString("Scan QR Code with WeChat", comment: "")
|
|
|
self.payTypeImageView.image = NSImage(named: "EmbeddedPayment27")
|
|
|
} else if self.paymentMethod == .alipay {
|
|
|
- self.scanLabel.stringValue = NSLocalizedString("Scan QR Code with AliPay", comment: "")
|
|
|
+ self.scanLabel.stringValue = NSLocalizedString("Scan QR Code with Alipay", comment: "")
|
|
|
self.payTypeImageView.image = NSImage(named: "EmbeddedPayment28")
|
|
|
}
|
|
|
|
|
@@ -1587,38 +1612,25 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
let infoDic = ["cdkey": license]
|
|
|
AIInfoManager.default().activateAI(withInfo: infoDic) { info, error in
|
|
|
- if error != nil {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("Activation Error", comment: "")
|
|
|
- alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
- if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
|
|
|
- alert.beginSheetModal(for: self.window!, completionHandler: nil)
|
|
|
- } else {
|
|
|
- alert.runModal()
|
|
|
- }
|
|
|
- return
|
|
|
- } else {
|
|
|
- if info.isEmpty == false {
|
|
|
- self._trackEvent_paid()
|
|
|
- }
|
|
|
+ if info.isEmpty == false {
|
|
|
+ self._trackEvent_paid()
|
|
|
+ }
|
|
|
|
|
|
- if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
|
|
|
- self.qrCodeImageView.isHidden = true
|
|
|
- self.successfullyView.isHidden = false
|
|
|
- } else {
|
|
|
- if let blockSelf = self.activityAlertViewController {
|
|
|
- blockSelf.alertTitle = NSLocalizedString("Successful Activation!", comment: "")
|
|
|
- blockSelf.alertMessage = NSLocalizedString("Congratulations! You can start using PDF Reader Pro AI features.", comment: "")
|
|
|
-
|
|
|
- var frame = self.window?.frame
|
|
|
- frame!.origin.y -= blockSelf.view.frame.size.height-frame!.size.height
|
|
|
- frame!.origin.x -= (blockSelf.view.frame.size.width-frame!.size.width)/2.0
|
|
|
- frame!.size.width = blockSelf.view.frame.size.width
|
|
|
- frame!.size.height = blockSelf.view.frame.size.height
|
|
|
- self.mainBox.contentView = blockSelf.view
|
|
|
- self.window?.setFrame(frame!, display: true, animate: true)
|
|
|
- }
|
|
|
+ if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
|
|
|
+ self.qrCodeImageView.isHidden = true
|
|
|
+ self.successfullyView.isHidden = false
|
|
|
+ } else {
|
|
|
+ if let blockSelf = self.activityAlertViewController {
|
|
|
+ blockSelf.alertTitle = NSLocalizedString("Successful Activation!", comment: "")
|
|
|
+ blockSelf.alertMessage = NSLocalizedString("Congratulations! You can start using PDF Reader Pro AI features.", comment: "")
|
|
|
+
|
|
|
+ var frame = self.window?.frame
|
|
|
+ frame!.origin.y -= blockSelf.view.frame.size.height-frame!.size.height
|
|
|
+ frame!.origin.x -= (blockSelf.view.frame.size.width-frame!.size.width)/2.0
|
|
|
+ frame!.size.width = blockSelf.view.frame.size.width
|
|
|
+ frame!.size.height = blockSelf.view.frame.size.height
|
|
|
+ self.mainBox.contentView = blockSelf.view
|
|
|
+ self.window?.setFrame(frame!, display: true, animate: true)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1749,6 +1761,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
image2BottomLayout.constant = licenseCodeView.isHidden ? 20.0 : 8.0
|
|
|
}
|
|
|
|
|
|
+ private func refreshLicenseCodeErrorView(isReveal: Bool) {
|
|
|
+ licenseCodeErrorView.isHidden = !isReveal
|
|
|
+ licenseCodeErrorTopLayout.constant = licenseCodeErrorView.isHidden ? -CGRectGetHeight(licenseCodeErrorView.bounds) : 4.0
|
|
|
+ }
|
|
|
+
|
|
|
private func refreshCouponError(isReveal: Bool) {
|
|
|
coupomErrorLabel.isHidden = !isReveal
|
|
|
coupomErrorTopLayout.constant = coupomErrorLabel.isHidden ? -CGRectGetHeight(coupomErrorLabel.bounds) : 8.0
|
|
@@ -1801,6 +1818,9 @@ extension KMPurchaseEmbeddedWindowController: NSTextFieldDelegate {
|
|
|
if Int(textField!.stringValue)! > 9999 {
|
|
|
pdfCount = 9999
|
|
|
textField?.stringValue = String(pdfCount)
|
|
|
+ } else if Int(textField!.stringValue)! < 1 {
|
|
|
+ pdfCount = 1
|
|
|
+ textField?.stringValue = String(pdfCount)
|
|
|
}
|
|
|
}
|
|
|
if pdfCount > 100 {
|
|
@@ -1829,8 +1849,20 @@ extension KMPurchaseEmbeddedWindowController: NSTextFieldDelegate {
|
|
|
if textField == amountTextField1 {
|
|
|
if !isNumeric(textField!.stringValue) {
|
|
|
if textField == amountTextField1 { textField?.stringValue = String(pdfCount) }
|
|
|
+ } else {
|
|
|
+ if Int(textField!.stringValue)! > 9999 {
|
|
|
+ textField?.stringValue = String(pdfCount)
|
|
|
+ } else if Int(textField!.stringValue)! < 1 {
|
|
|
+ textField?.stringValue = String(pdfCount)
|
|
|
+ }
|
|
|
}
|
|
|
priceRefresh()
|
|
|
+ } else if textField == licenseCodeTextField {
|
|
|
+ if textField!.stringValue.count > 0 {
|
|
|
+ refreshLicenseCodeErrorView(isReveal: false)
|
|
|
+ } else {
|
|
|
+ refreshLicenseCodeErrorView(isReveal: false)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|