KMVerificationWindowController.m 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  1. //
  2. // KMVerificationWindowController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by 王帅 on 2018/5/8.
  6. //
  7. #import "KMVerificationWindowController.h"
  8. #import "KMVerificationViewController.h"
  9. #import "KMVerificationActivateViewController.h"
  10. #import "KMVerificationExpiredViewController.h"
  11. #import "KMVerificationTrialViewController.h"
  12. #import "KMVerificationAlertViewController.h"
  13. #import "KMActivityALertViewController.h"
  14. #import "KMVerificationInfoViewController.h"
  15. #import "VerificationManager.h"
  16. //#import "KMMailHelper.h"
  17. #import "GBDeviceInfo.h"
  18. #import "Reachability.h"
  19. //#import "SKInspectPublicTool.h"
  20. //#import "FMTrackEventManager.h"
  21. #import "KMRepeatTrialAlertController.h"
  22. #import "KMRepeatVerifyExpireController.h"
  23. #import <PDF_Reader_Pro-Swift.h>
  24. @interface KMVerificationWindowController ()
  25. @property (nonatomic, assign) KMVerificationType type;
  26. @property (nonatomic, assign) IBOutlet NSBox *box;
  27. @property (nonatomic, assign) IBOutlet NSProgressIndicator *progressIndicator;
  28. @property (nonatomic, retain) KMVerificationViewController *normalViewController;
  29. @property (nonatomic, retain) KMVerificationActivateViewController *activateViewController;
  30. @property (nonatomic, retain) KMVerificationExpiredViewController *expiredViewController;
  31. @property (nonatomic, retain) KMVerificationTrialViewController *trialViewController;
  32. @property (nonatomic, retain) KMVerificationAlertViewController *alertViewController;
  33. @property (nonatomic, retain) KMActivityALertViewController *activityAlertViewController;
  34. @property (nonatomic, retain) KMVerificationInfoViewController *infoViewController;
  35. @property (nonatomic, retain) KMRepeatTrialAlertController *repeatTrialAlertController;//二次试用提示弹窗
  36. @property (nonatomic, retain) KMRepeatVerifyExpireController *repeatTrialExpireController;//二次试用过期弹窗
  37. @property (nonatomic, retain) KMTrialSuccessController *trialSuccessController;
  38. @end
  39. @implementation KMVerificationWindowController
  40. + (void)launching {
  41. [VerificationManager manager];
  42. }
  43. + (BOOL)allowsShowExpired {
  44. #if VERSION_DMG
  45. if ([VerificationManager manager].status == ActivityStatusTrialExpire &&
  46. [VerificationManager manager].secondTrialEnabled == NO) {
  47. if (![[NSUserDefaults standardUserDefaults] objectForKey:@"allowTrialExpireShowKeyDMG"]) {
  48. [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"allowTrialExpireShowKeyDMG"];
  49. return YES;
  50. }
  51. }
  52. return NO;
  53. #else
  54. NSDate *lastTimeDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"kVerificationExpiredShowLastTimeDateKay"];
  55. if (lastTimeDate) {
  56. NSDate *date = [NSDate date];
  57. NSTimeInterval time = [date timeIntervalSinceDate:lastTimeDate];
  58. int days = ((int)time)/(3600*24);
  59. if (days < 15) {
  60. return NO;
  61. }
  62. }
  63. #endif
  64. return YES;
  65. }
  66. + (void)showExpiredInfo {
  67. if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
  68. if ([KMVerificationWindowController allowsShowExpired]) {
  69. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeTrialExpired];
  70. [vc showWindow:nil];
  71. [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"kVerificationExpiredShowLastTimeDateKay"];
  72. [[NSUserDefaults standardUserDefaults] synchronize];
  73. }
  74. } else if (ActivityStatusVerifExpire == [VerificationManager manager].status) {
  75. if ([KMVerificationWindowController allowsShowExpired]) {
  76. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivateExpired];
  77. [vc showWindow:nil];
  78. [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"kVerificationExpiredShowLastTimeDateKay"];
  79. [[NSUserDefaults standardUserDefaults] synchronize];
  80. }
  81. }
  82. }
  83. + (BOOL)allowRepeatTrialAlertShow {
  84. //是否在开启APP时弹出二次试用弹窗提示框
  85. if ([VerificationManager manager].secondTrialEnabled) {
  86. if (![[NSUserDefaults standardUserDefaults] objectForKey:@"allowRepeatTrialAlertShowKey"]) {
  87. return YES;
  88. }
  89. }
  90. return NO;
  91. }
  92. + (BOOL)allowRepeatTrialExpireShow {
  93. if ([VerificationManager manager].status == ActivityStatusTrialExpire &&
  94. [VerificationManager manager].trialTimes == 2) {
  95. if (![[NSUserDefaults standardUserDefaults] objectForKey:@"allowRepeatTrialExpireShowKey"]) {
  96. return YES;
  97. }
  98. }
  99. return NO;
  100. }
  101. static KMVerificationWindowController *_currentWindowController = nil;
  102. + (KMVerificationWindowController *)verificationWithType:(KMVerificationType)type {
  103. if (_currentWindowController) {
  104. if (type != _currentWindowController.type) {
  105. [_currentWindowController close];
  106. } else {
  107. return _currentWindowController;
  108. }
  109. }
  110. KMVerificationWindowController *vc = [[KMVerificationWindowController alloc] initWithType:type];
  111. return vc;
  112. }
  113. #pragma mark Init Methods
  114. - (instancetype)initWithType:(KMVerificationType)type {
  115. if (self = [super initWithWindowNibName:@"KMVerificationWindowController"]) {
  116. _type = type;
  117. }
  118. return self;
  119. }
  120. - (void)dealloc {
  121. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  122. }
  123. #pragma mark - Getter Methods
  124. - (KMVerificationViewController *)normalViewController {
  125. if (!_normalViewController) {
  126. __block __typeof(self) blockSelf = self;
  127. _normalViewController = [[KMVerificationViewController alloc] init];
  128. _normalViewController.callback = ^(NSInteger index) {
  129. if (index == 0) {
  130. [blockSelf setContentView:blockSelf.activateViewController.view];
  131. } else if (index == 1) {
  132. if (KMVerificationTypeActivateExpired == self.type) {
  133. [blockSelf verificationFeedback];
  134. } else {
  135. [blockSelf close];
  136. }
  137. } else {
  138. [blockSelf verificationBuy];
  139. }
  140. };
  141. if (KMVerificationTypeTrialExpired == self.type) {
  142. _normalViewController.titleText = NSLocalizedString(@"Thank you for trying PDF Reader Pro", nil);
  143. _normalViewController.messageText = NSLocalizedString(@"Your trial has expired. Buy Full version to annotate and edit PDF files.", nil);
  144. } else {
  145. _normalViewController.titleText = NSLocalizedString(@"PDF Reader Pro Activation", nil);
  146. _normalViewController.messageText = NSLocalizedString(@"Buy Full Version to annotate and edit your PDF documents.", nil);
  147. }
  148. }
  149. return _normalViewController;
  150. }
  151. - (KMVerificationActivateViewController *)activateViewController {
  152. if (!_activateViewController) {
  153. __block __typeof(self) blockSelf = self;
  154. _activateViewController = [[KMVerificationActivateViewController alloc] init];
  155. _activateViewController.callback = ^(NSInteger index, NSString *string) {
  156. if (index == 0) {
  157. if (blockSelf.callback) {
  158. blockSelf.callback();
  159. blockSelf.callback = nil;
  160. [blockSelf close];
  161. } else {
  162. if (KMVerificationTypeTrial == blockSelf.type) {
  163. [blockSelf setContentView:blockSelf.trialViewController.view];
  164. } else if (KMVerificationTypeActivateExpired == blockSelf.type) {
  165. [blockSelf setContentView:blockSelf.expiredViewController.view];
  166. } else {
  167. [blockSelf setContentView:blockSelf.normalViewController.view];
  168. }
  169. }
  170. } else {
  171. if (blockSelf.type == KMVerificationTypeActivateAIInfo) {
  172. [blockSelf verificationActivateAIInfo:string];
  173. } else {
  174. [blockSelf verificationActivate:string];
  175. }
  176. }
  177. };
  178. if (self.type == KMVerificationTypeActivateAIInfo) {
  179. _activateViewController.type = self.type;
  180. }
  181. }
  182. return _activateViewController;
  183. }
  184. - (KMVerificationExpiredViewController *)expiredViewController {
  185. if (!_expiredViewController) {
  186. __block __typeof(self) blockSelf = self;
  187. _expiredViewController = [[KMVerificationExpiredViewController alloc] init];
  188. _expiredViewController.callback = ^(NSInteger index) {
  189. if (index == 0) {
  190. [blockSelf setContentView:blockSelf.activateViewController.view];
  191. } else {
  192. [blockSelf verificationFeedback];
  193. }
  194. };
  195. }
  196. return _expiredViewController;
  197. }
  198. - (KMVerificationTrialViewController *)trialViewController {
  199. if (!_trialViewController) {
  200. __block __typeof(self) blockSelf = self;
  201. _trialViewController = [[KMVerificationTrialViewController alloc] init];
  202. _trialViewController.callback = ^(NSInteger index, NSString *email, NSString *name) {
  203. if (index == 0) {
  204. [blockSelf setContentView:blockSelf.activateViewController.view];
  205. } else {
  206. [blockSelf verificationTrialForEmail:email name:name];
  207. }
  208. };
  209. }
  210. return _trialViewController;
  211. }
  212. - (KMVerificationAlertViewController *)alertViewController {
  213. if (!_alertViewController) {
  214. __block __typeof(self) blockSelf = self;
  215. _alertViewController = [[KMVerificationAlertViewController alloc] init];
  216. _alertViewController.callback = ^{
  217. [blockSelf close];
  218. };
  219. _alertViewController.buyActionHandle = ^{
  220. #if VERSION_DMG
  221. NSURL *url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/store"];
  222. if([SKInspectPublicTool currentisLanguageHans]) {
  223. url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/zh-cn/store"];
  224. }
  225. [[NSWorkspace sharedWorkspace] openURL:url];
  226. #endif
  227. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_BuyNow-Trial"}];
  228. [blockSelf close];
  229. };
  230. }
  231. return _alertViewController;
  232. }
  233. - (KMActivityALertViewController *)activityAlertViewController {
  234. if (!_activityAlertViewController) {
  235. __block __typeof(self) blockSelf = self;
  236. _activityAlertViewController = [[KMActivityALertViewController alloc] init];
  237. _activityAlertViewController.callback = ^{
  238. [blockSelf close];
  239. };
  240. }
  241. return _activityAlertViewController;
  242. }
  243. - (KMVerificationInfoViewController *)infoViewController {
  244. if (!_infoViewController) {
  245. __block __typeof(self) blockSelf = self;
  246. _infoViewController = [[KMVerificationInfoViewController alloc] init];
  247. _infoViewController.callback = ^{
  248. [blockSelf close];
  249. };
  250. _infoViewController.unbindAction = ^{
  251. dispatch_async(dispatch_get_main_queue(), ^{
  252. [blockSelf unbindAction];
  253. });
  254. };
  255. }
  256. return _infoViewController;
  257. }
  258. - (KMRepeatTrialAlertController *)repeatTrialAlertController {
  259. if (!_repeatTrialAlertController) {
  260. __block __typeof(self) blockSelf = self;
  261. _repeatTrialAlertController = [[KMRepeatTrialAlertController alloc] init];
  262. _repeatTrialAlertController.callback = ^(NSInteger clickIndex, KMRepeatTrialAlertController * _Nonnull tRController) {
  263. if (clickIndex == 0) {
  264. //免费试用
  265. [blockSelf verificationTrialForEmail:[VerificationManager manager].email
  266. name:[VerificationManager manager].accountName] ;
  267. } else if (clickIndex == 1) {
  268. //了解更多
  269. NSURL *url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/store?utm_source=app_dmg&utm_medium=dmg_puw_sec_free_trial"];
  270. if([SKInspectPublicTool currentisLanguageHans]) {
  271. url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/zh-cn/store?utm_source=app_dmg&utm_medium=dmg_puw_sec_free_trial"];
  272. }
  273. [[NSWorkspace sharedWorkspace] openURL:url];
  274. [blockSelf close];
  275. } else if (clickIndex == 2) {
  276. //输入序列码
  277. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  278. vc.callback = ^{
  279. };
  280. [vc showWindow:nil];
  281. }
  282. };
  283. }
  284. return _repeatTrialAlertController;
  285. }
  286. - (KMRepeatVerifyExpireController *)repeatTrialExpireController {
  287. if (!_repeatTrialExpireController) {
  288. __block __typeof(self) blockSelf = self;
  289. _repeatTrialExpireController = [[KMRepeatVerifyExpireController alloc] init];
  290. _repeatTrialExpireController.callback = ^(NSInteger clickIndex, KMRepeatVerifyExpireController * _Nonnull tRController) {
  291. if (clickIndex == 0) {
  292. [blockSelf setContentView:blockSelf.activateViewController.view];
  293. } else if (clickIndex == 1) {
  294. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_SecondTrialExpire_Later"}];
  295. [blockSelf close];
  296. } else if (clickIndex == 2) {
  297. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_SecondTrialExpire_Buy"}];
  298. [blockSelf verificationBuy];
  299. }
  300. };
  301. }
  302. return _repeatTrialExpireController;
  303. }
  304. - (KMTrialSuccessController *)trialSuccessController {
  305. if (!_trialSuccessController) {
  306. __block __typeof(self) blockSelf = self;
  307. _trialSuccessController = [[KMTrialSuccessController alloc] init];
  308. _trialSuccessController.clickHandle = ^(KMTrialSuccessController * _Nonnull controller) {
  309. [blockSelf close];
  310. };
  311. }
  312. return _trialSuccessController;
  313. }
  314. #pragma mark Window Methods
  315. - (void)windowDidLoad {
  316. [super windowDidLoad];
  317. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  318. self.window.title = @"";
  319. [[self.window standardWindowButton:NSWindowZoomButton] setHidden:YES];
  320. [[self.window standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
  321. [self updateViewInfo];
  322. [self updateViewColor];
  323. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  324. }
  325. - (void)updateViewInfo {
  326. if (KMVerificationTypeNormal == self.type) {
  327. [self setContentView:self.normalViewController.view];
  328. } else if (KMVerificationTypeActivate == self.type) {
  329. [self setContentView:self.activateViewController.view];
  330. } else if (KMVerificationTypeTrial == self.type) {
  331. [self setContentView:self.trialViewController.view];
  332. } else if (KMVerificationTypeActivateExpired == self.type) {
  333. [self setContentView:self.expiredViewController.view];
  334. } else if (KMVerificationTypeTrialExpired == self.type) {
  335. [self setContentView:self.normalViewController.view];
  336. } else if (KMVerificationTypeInfo == self.type) {
  337. [self setContentView:self.infoViewController.view];
  338. } else if (KMVerificationTypeRepeatTrialGuide == self.type) {
  339. self.window.title = @"";
  340. [self setContentView:self.repeatTrialAlertController.view];
  341. [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"allowRepeatTrialAlertShowKey"];
  342. [[NSUserDefaults standardUserDefaults] synchronize];
  343. } else if (KMVerificationTypeRepeatTrialExpire == self.type) {
  344. [self setContentView:self.repeatTrialExpireController.view];
  345. [[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:@"allowRepeatTrialExpireShowKey"];
  346. [[NSUserDefaults standardUserDefaults] synchronize];
  347. } else if (self.type == KMVerificationTypeTrialSuccess ||
  348. self.type == KMVerificationTypeRepeatTrialSuccess) {
  349. [self setContentView:self.trialSuccessController.view];
  350. } else if (KMVerificationTypeActivateAIInfo == self.type) {
  351. [self setContentView:self.activateViewController.view];
  352. self.activateViewController.type = self.type;
  353. }
  354. }
  355. - (void)updateViewColor {
  356. if (KMVerificationTypeNormal == self.type) {
  357. } else if (KMVerificationTypeActivate == self.type) {
  358. } else if (KMVerificationTypeTrial == self.type) {
  359. } else if (KMVerificationTypeActivateExpired == self.type) {
  360. } else if (KMVerificationTypeTrialExpired == self.type) {
  361. } else if (KMVerificationTypeInfo == self.type) {
  362. } else if (KMVerificationTypeRepeatTrialGuide == self.type) {
  363. [self.repeatTrialAlertController updateViewColor];
  364. } else if (KMVerificationTypeRepeatTrialExpire == self.type) {
  365. [self.repeatTrialExpireController updateViewColor];
  366. } else if (KMVerificationTypeTrialSuccess == self.type ||
  367. KMVerificationTypeRepeatTrialSuccess == self.type) {
  368. [self.trialSuccessController updateViewColor];
  369. }
  370. }
  371. - (void)showWindow:(id)sender {
  372. if (!_currentWindowController) {
  373. _currentWindowController = self;
  374. }
  375. [super showWindow:sender];
  376. }
  377. - (void)windowWillClose:(NSNotification *)notification {
  378. if (_currentWindowController) {
  379. _currentWindowController = nil;
  380. }
  381. }
  382. #pragma mark - Setter
  383. - (void)setContentView:(NSView *)view {
  384. NSRect frame = self.window.frame;
  385. frame.origin.y -= view.frame.size.height-frame.size.height;
  386. frame.origin.x -= (view.frame.size.width-frame.size.width)/2.0;
  387. frame.size.width = view.frame.size.width;
  388. frame.size.height = view.frame.size.height;
  389. [self.box setContentView:view];
  390. [self.window setFrame:frame display:YES animate:YES];
  391. }
  392. #pragma mark - Private Methods
  393. - (void)verificationTrialForEmail:(NSString *)email name:(NSString *)name {
  394. if (email.length <= 0) {
  395. return;
  396. }
  397. if (![self isConnectionAvailable]) {
  398. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  399. defaultButton:NSLocalizedString(@"OK", nil)
  400. alternateButton:nil
  401. otherButton:nil
  402. informativeTextWithFormat:NSLocalizedString(@"Please make sure your internet connection is available.", nil), nil];
  403. [alert runModal];
  404. return;
  405. }
  406. __block __typeof(self) blockSelf = self;
  407. self.progressIndicator.hidden = NO;
  408. [self.progressIndicator startAnimation:nil];
  409. [self.trialViewController setEnabled:NO];
  410. [[VerificationManager manager] trialForDays:7 email:email name:name complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  411. blockSelf.progressIndicator.hidden = YES;
  412. [blockSelf.progressIndicator stopAnimation:nil];
  413. [blockSelf.trialViewController setEnabled:YES];
  414. if (error ||
  415. status != ActivityStatusTrial) {
  416. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  417. defaultButton:NSLocalizedString(@"Try Again", nil)
  418. alternateButton:nil
  419. otherButton:nil
  420. informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
  421. [alert runModal];
  422. } else {
  423. blockSelf.type = KMVerificationTypeTrialSuccess;
  424. [blockSelf updateViewInfo];
  425. }
  426. }];
  427. }
  428. - (void)verificationActivateAIInfo:(NSString *)license {
  429. if (license.length <= 0) {
  430. return;
  431. }
  432. if (![self isConnectionAvailable]) {
  433. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  434. defaultButton:NSLocalizedString(@"OK", nil)
  435. alternateButton:nil
  436. otherButton:nil
  437. informativeTextWithFormat:@"", nil];
  438. NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
  439. accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
  440. accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
  441. accessryBtn.bordered = NO;
  442. accessryBtn.target = self;
  443. accessryBtn.action = @selector(accessryBtnClicked:);
  444. NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
  445. [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
  446. [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
  447. [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
  448. accessryBtn.attributedTitle = mutAttrString;
  449. NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  450. CGRect frame = accessryBtn.frame;
  451. frame.size.height = rect.size.height;
  452. accessryBtn.frame = frame;
  453. alert.accessoryView = accessryBtn;
  454. [alert runModal];
  455. return;
  456. }
  457. __block __typeof(self) blockSelf = self;
  458. self.progressIndicator.hidden = NO;
  459. [self.progressIndicator startAnimation:nil];
  460. [self.activateViewController setEnabled:NO];
  461. NSDictionary *infoDic = @{@"cdkey":license};
  462. [[AIInfoManager defaultManager] activateAIWithInfo:infoDic complention:^(NSDictionary *info, NSError *error) {
  463. blockSelf.progressIndicator.hidden = YES;
  464. [blockSelf.progressIndicator stopAnimation:nil];
  465. [blockSelf.activateViewController setEnabled:YES];
  466. if (error) {
  467. NSString *tTitle0 = NSLocalizedString(@"The license you have entered is not correct. Please enter valid license.", nil);
  468. NSString *tTitle1 = NSLocalizedString(@"Please confirm your PDF Reader Pro AI license code through the email you provided when purchasing.", nil);
  469. NSString *message = [NSString stringWithFormat:@"%@\n\n%@", tTitle0, tTitle1];
  470. if (ActivityErrorTypeCDKeyEmpty == error.code) {
  471. message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number can not be empty.", nil), @""];
  472. } else if (ActivityErrorTypeCDKeyNotExist == error.code) {
  473. message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number does not exist.", nil), @""];
  474. } else if (ActivityErrorTypeOutNumber == error.code) {
  475. NSString *tMsg0 = NSLocalizedString(@"The devices connected to the license number has outnumbered.", nil);
  476. NSString *tMsg1 = NSLocalizedString(@"Please deactivate license on one of them, to use PDF Reader Pro on this computer", nil);
  477. message = [NSString stringWithFormat:@"%@\n\n%@", tMsg0, tMsg1];
  478. } else if (ActivityErrorTypeNetworkDisable == error.code) {
  479. message = NSLocalizedString(@"The network is unavailable.", nil);
  480. } else if (ActivityErrorTypeCDKeyExpire == error.code) {
  481. message = NSLocalizedString(@"The license number expired.", nil);
  482. } else if (ActivityErrorTypeInvalidInfo == error.code) {
  483. message = NSLocalizedString(@"Activation error. Please try to input correct license, or contact us.", nil);
  484. } else if (ActivityErrorTypeNotMatchProduct == error.code) {
  485. message = NSLocalizedString(@"The license number is wrong, please input right license which is for this app.", nil);
  486. } else if (ActivityErrorTypeFormatError == error.code) {
  487. message = NSLocalizedString(@"Error license. Please enter an AI license.", nil);
  488. }
  489. if ((ActivityErrorTypeUnknow == error.code) || (ActivityErrorTypeOutNumber == error.code) || (ActivityErrorTypeInvalidInfo == error.code)) {
  490. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  491. defaultButton:NSLocalizedString(@"Contact Us", nil)
  492. alternateButton:NSLocalizedString(@"Try Again", nil)
  493. otherButton:nil
  494. informativeTextWithFormat:message, nil];
  495. if ([alert runModal]) {
  496. [blockSelf verificationFeedback];
  497. }
  498. } else {
  499. if (ActivityErrorTypeNetworkDisable == error.code) {
  500. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  501. defaultButton:NSLocalizedString(@"OK", nil)
  502. alternateButton:nil
  503. otherButton:nil
  504. informativeTextWithFormat:@"", nil];
  505. NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
  506. accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
  507. accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
  508. accessryBtn.bordered = NO;
  509. accessryBtn.target = self;
  510. accessryBtn.action = @selector(accessryBtnClicked:);
  511. NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
  512. [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
  513. [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
  514. [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
  515. accessryBtn.attributedTitle = mutAttrString;
  516. NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  517. CGRect frame = accessryBtn.frame;
  518. frame.size.height = rect.size.height;
  519. accessryBtn.frame = frame;
  520. alert.accessoryView = accessryBtn;
  521. [alert runModal];
  522. } else {
  523. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  524. defaultButton:NSLocalizedString(@"Try Again", nil)
  525. alternateButton:nil
  526. otherButton:nil
  527. informativeTextWithFormat:message, nil];
  528. [alert runModal];
  529. }
  530. }
  531. } else {
  532. blockSelf.activityAlertViewController.alertTitle = NSLocalizedString(@"Successful Activation!", nil);
  533. blockSelf.activityAlertViewController.alertMessage = NSLocalizedString(@"Congratulations! You can start using PDF Reader Pro AI features.", nil);
  534. [blockSelf setContentView:blockSelf.activityAlertViewController.view];
  535. }
  536. }];
  537. }
  538. - (void)verificationActivate:(NSString *)license {
  539. if (license.length <= 0) {
  540. return;
  541. }
  542. if ([license hasPrefix:@"AI-"]) {
  543. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  544. defaultButton:NSLocalizedString(@"Try Again", nil)
  545. alternateButton:nil
  546. otherButton:nil
  547. informativeTextWithFormat:NSLocalizedString(@"For AI license code, please activate it via 'My AI Credit' - 'Enter AI License' in the upper right corner.", nil), nil];
  548. [alert runModal];
  549. return;
  550. }
  551. if (![self isConnectionAvailable]) {
  552. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  553. defaultButton:NSLocalizedString(@"OK", nil)
  554. alternateButton:nil
  555. otherButton:nil
  556. informativeTextWithFormat:@"", nil];
  557. NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
  558. accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
  559. accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
  560. accessryBtn.bordered = NO;
  561. accessryBtn.target = self;
  562. accessryBtn.action = @selector(accessryBtnClicked:);
  563. NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
  564. [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
  565. [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
  566. [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
  567. accessryBtn.attributedTitle = mutAttrString;
  568. NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  569. CGRect frame = accessryBtn.frame;
  570. frame.size.height = rect.size.height;
  571. accessryBtn.frame = frame;
  572. alert.accessoryView = accessryBtn;
  573. [alert runModal];
  574. return;
  575. }
  576. __block __typeof(self) blockSelf = self;
  577. self.progressIndicator.hidden = NO;
  578. [self.progressIndicator startAnimation:nil];
  579. [self.activateViewController setEnabled:NO];
  580. NSDictionary *infoDic = @{@"cdkey":license};
  581. [[VerificationManager manager] activateDeviceWithInfo:infoDic complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  582. blockSelf.progressIndicator.hidden = YES;
  583. [blockSelf.progressIndicator stopAnimation:nil];
  584. [blockSelf.activateViewController setEnabled:YES];
  585. if (error) {
  586. NSString *tTitle0 = NSLocalizedString(@"The license you have entered is not correct. Please enter valid license.", nil);
  587. NSString *tTitle1 = NSLocalizedString(@"If you have already purchased PDF Reader Pro for Mac, you should find your license in an email confirmation.", nil);
  588. NSString *message = [NSString stringWithFormat:@"%@\n\n%@", tTitle0, tTitle1];
  589. if (ActivityErrorTypeCDKeyEmpty == error.code) {
  590. message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number can not be empty.", nil), @""];
  591. } else if (ActivityErrorTypeCDKeyNotExist == error.code) {
  592. message = [NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"License number does not exist.", nil), @""];
  593. } else if (ActivityErrorTypeOutNumber == error.code) {
  594. NSString *tMsg0 = NSLocalizedString(@"The devices connected to the license number has outnumbered.", nil);
  595. NSString *tMsg1 = NSLocalizedString(@"Please deactivate license on one of them, to use PDF Reader Pro on this computer", nil);
  596. message = [NSString stringWithFormat:@"%@\n\n%@", tMsg0, tMsg1];
  597. } else if (ActivityErrorTypeNetworkDisable == error.code) {
  598. message = NSLocalizedString(@"The network is unavailable.", nil);
  599. } else if (ActivityErrorTypeCDKeyExpire == error.code) {
  600. message = NSLocalizedString(@"The license number expired.", nil);
  601. } else if (ActivityErrorTypeInvalidInfo == error.code) {
  602. message = NSLocalizedString(@"Activation error. Please try to input correct license, or contact us.", nil);
  603. } else if (ActivityErrorTypeNotMatchProduct == error.code) {
  604. message = NSLocalizedString(@"The license number is wrong, please input right license which is for this app.", nil);
  605. } else if (ActivityErrorTypeFormatError == error.code) {
  606. message = NSLocalizedString(@"The license format is wrong. Please input correct license.", nil);
  607. }
  608. if ((ActivityErrorTypeUnknow == error.code) || (ActivityErrorTypeOutNumber == error.code) || (ActivityErrorTypeInvalidInfo == error.code)) {
  609. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  610. defaultButton:NSLocalizedString(@"Contact Us", nil)
  611. alternateButton:NSLocalizedString(@"Try Again", nil)
  612. otherButton:nil
  613. informativeTextWithFormat:message, nil];
  614. if ([alert runModal]) {
  615. [blockSelf verificationFeedback];
  616. }
  617. } else {
  618. if (ActivityErrorTypeNetworkDisable == error.code) {
  619. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  620. defaultButton:NSLocalizedString(@"OK", nil)
  621. alternateButton:nil
  622. otherButton:nil
  623. informativeTextWithFormat:@"", nil];
  624. NSButton *accessryBtn = [[NSButton alloc] initWithFrame:CGRectMake(0, 0, 180, 44)];
  625. accessryBtn.autoresizingMask = NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
  626. accessryBtn.bezelStyle = NSBezelStyleRegularSquare;
  627. accessryBtn.bordered = NO;
  628. accessryBtn.target = self;
  629. accessryBtn.action = @selector(accessryBtnClicked:);
  630. NSMutableAttributedString *mutAttrString = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Please make sure your internet connection is available.", nil)];
  631. [mutAttrString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:12] range:NSMakeRange(0, [mutAttrString length])];
  632. [mutAttrString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [mutAttrString length])];
  633. [mutAttrString addAttribute:NSForegroundColorAttributeName value:[KMAppearance KMColor_Interactive_M0] range:NSMakeRange(0, [mutAttrString length])];
  634. accessryBtn.attributedTitle = mutAttrString;
  635. NSRect rect = [mutAttrString boundingRectWithSize:CGSizeMake(180, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  636. CGRect frame = accessryBtn.frame;
  637. frame.size.height = rect.size.height;
  638. accessryBtn.frame = frame;
  639. alert.accessoryView = accessryBtn;
  640. [alert runModal];
  641. } else {
  642. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  643. defaultButton:NSLocalizedString(@"Try Again", nil)
  644. alternateButton:nil
  645. otherButton:nil
  646. informativeTextWithFormat:message, nil];
  647. [alert runModal];
  648. }
  649. }
  650. } else {
  651. blockSelf.activityAlertViewController.alertTitle = NSLocalizedString(@"Successful Activation!", nil);
  652. blockSelf.activityAlertViewController.alertMessage = NSLocalizedString(@"Congrats! You are eligible to enjoy all advanced features (excluding AI) in PDF Reader Pro.", nil);
  653. [blockSelf setContentView:blockSelf.activityAlertViewController.view];
  654. }
  655. }];
  656. }
  657. - (void)verificationBuy {
  658. #if VERSION_DMG
  659. NSURL *url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/store?utm_source=MacAppDmg&utm_campaign=StoreLink&utm_medium=PdfStore"];
  660. if([SKInspectPublicTool currentisLanguageHans]) {
  661. url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/zh-cn/store?utm_source=MacAppDmg&utm_campaign=StoreLink&utm_medium=PdfStore"];
  662. }
  663. [[NSWorkspace sharedWorkspace] openURL:url];
  664. #endif
  665. }
  666. #pragma - 验证错误时反馈信息
  667. - (void)verificationFeedback {
  668. unsigned major, minor, bugFix;
  669. [self getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
  670. NSString *versionString = [NSString stringWithFormat:@"%@ - %u.%u.%u", [GBDeviceInfo deviceInfo].rawSystemInfoString, major, minor, bugFix];
  671. //application version (use short version preferentially)
  672. NSString *tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
  673. if ([tAppVersion length] < 1) {
  674. tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
  675. }
  676. NSString* subjects = [[self getAppNameForSupportEmail] stringByAppendingFormat:NSLocalizedString(@" - %@;Verification Feedback;%@", nil) ,tAppVersion,versionString];
  677. [KMMailHelper newEmailWithContacts:@"support@pdfreaderpro.com" andSubjects:subjects];
  678. }
  679. - (void)unbindAction {
  680. unsigned major, minor, bugFix;
  681. [self getSystemVersionMajor:&major minor:&minor bugFix:&bugFix];
  682. NSString *versionString = [NSString stringWithFormat:@"%@ - %u.%u.%u", [GBDeviceInfo deviceInfo].rawSystemInfoString, major, minor, bugFix];
  683. //application version (use short version preferentially)
  684. NSString *tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
  685. if ([tAppVersion length] < 1) {
  686. tAppVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
  687. }
  688. NSString *subjects = [[self getAppNameForEmail] stringByAppendingString:[NSString stringWithFormat:@" %@",@"Verification:"]];
  689. subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@"%@;",tAppVersion]];
  690. subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@" %@;",versionString]];
  691. subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@" %@",NSLocalizedString(@"Unbind License Code:", nil)]];
  692. subjects = [subjects stringByAppendingString:[NSString stringWithFormat:@"%@",[VerificationManager manager].detailInfo[@"device"][@"unique_sn"]?:@""]];
  693. NSString *mailtoAddress = [NSString stringWithFormat:@"mailto:%@?Subject=%@&body=%@",@"support@pdfreaderpro.com",[self URLEncodedString:subjects],[self URLEncodedString:NSLocalizedString(@"Hi PDF Reader Pro Team, I need to unbind my license code, thanks!\nNotice: Please do not modify the subtitle content", nil)]];
  694. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:mailtoAddress]];
  695. }
  696. - (void)accessryBtnClicked:(NSButton *)btn {
  697. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.pdfreaderpro.com/mac/help/activate-license-code-mac"]];
  698. }
  699. - (NSString *)URLEncodedString:(NSString *)string {
  700. CFStringRef stringRef = CFBridgingRetain(string);
  701. #pragma clang diagnostic push
  702. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  703. CFStringRef encoded = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
  704. stringRef,
  705. NULL,
  706. CFSTR("!*'\"();:@&=+$,/?%#[]% "),
  707. kCFStringEncodingUTF8);
  708. #pragma clang diagnostic pop
  709. CFRelease(stringRef);
  710. return CFBridgingRelease(encoded);
  711. }
  712. - (void)getSystemVersionMajor:(unsigned *)major
  713. minor:(unsigned *)minor
  714. bugFix:(unsigned *)bugFix {
  715. OSErr err;
  716. SInt32 systemVersion, versionMajor, versionMinor, versionBugFix;
  717. if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
  718. NSOperatingSystemVersion osSystemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
  719. *major = (unsigned)osSystemVersion.majorVersion;
  720. *minor = (unsigned)osSystemVersion.minorVersion;
  721. *bugFix = (unsigned)osSystemVersion.patchVersion;
  722. return;
  723. } else {
  724. #pragma clang diagnostic push
  725. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  726. if ((err = Gestalt(gestaltSystemVersion, &systemVersion)) != noErr) goto fail;
  727. if (systemVersion < 0x1040)
  728. {
  729. if (major) *major = ((systemVersion & 0xF000) >> 12) * 10 +
  730. ((systemVersion & 0x0F00) >> 8);
  731. if (minor) *minor = (systemVersion & 0x00F0) >> 4;
  732. if (bugFix) *bugFix = (systemVersion & 0x000F);
  733. }
  734. else
  735. {
  736. if ((err = Gestalt(gestaltSystemVersionMajor, &versionMajor)) != noErr) goto fail;
  737. if ((err = Gestalt(gestaltSystemVersionMinor, &versionMinor)) != noErr) goto fail;
  738. if ((err = Gestalt(gestaltSystemVersionBugFix, &versionBugFix)) != noErr) goto fail;
  739. if (major) *major = versionMajor;
  740. if (minor) *minor = versionMinor;
  741. if (bugFix) *bugFix = versionBugFix;
  742. }
  743. return;
  744. #pragma clang diagnostic pop
  745. }
  746. fail:
  747. NSLog(@"Unable to obtain system version: %ld", (long)err);
  748. if (major) *major = 10;
  749. if (minor) *minor = 0;
  750. if (bugFix) *bugFix = 0;
  751. }
  752. - (NSString *)getAppNameForEmail {
  753. NSString *tAppName = @"PDF Reader Pro Mac";
  754. #if VERSION_FREE
  755. #if VERSION_DMG
  756. #else
  757. // AppStore 免费版本
  758. tAppName = @"PDF Reader Pro Lite";
  759. #endif
  760. #else
  761. // AppStore 付费版
  762. tAppName = @"PDF Reader Pro Edition";
  763. #endif
  764. return tAppName;
  765. }
  766. - (NSString *)getAppNameForSupportEmail {
  767. NSString *tAppName = @"PDF Reader Pro";
  768. #if VERSION_FREE
  769. #if VERSION_DMG
  770. // 桌机版
  771. VerificationManager *tManager = [VerificationManager manager];
  772. switch ([tManager status]) {
  773. case ActivityStatusTrial:
  774. tAppName = @"PDF Reader Pro Trial";
  775. break;
  776. case ActivityStatusVerification:
  777. tAppName = @"PDF Reader Pro Verification";
  778. break;
  779. case ActivityStatusTrialExpire:
  780. tAppName = @"PDF Reader Pro TrialExpire";
  781. break;
  782. case ActivityStatusVerifExpire:
  783. tAppName = @"PDF Reader Pro VerifExpire";
  784. break;
  785. default:
  786. break;
  787. }
  788. #else
  789. // AppStore 免费版本
  790. tAppName = @"PDF Reader Pro Lite";
  791. #endif
  792. #else
  793. // AppStore 付费版
  794. tAppName = @"PDF Reader Pro Edition";
  795. #endif
  796. return tAppName;
  797. }
  798. - (BOOL)isConnectionAvailable {
  799. BOOL isExistenceNetwork = YES;
  800. Reachability *reach = [Reachability reachabilityWithHostname:@"www.apple.com"];
  801. switch ([reach currentReachabilityStatus]) {
  802. case NotReachable:
  803. isExistenceNetwork = NO;
  804. //NSLog(@"notReachable");
  805. break;
  806. case ReachableViaWiFi:
  807. isExistenceNetwork = YES;
  808. //NSLog(@"WIFI");
  809. break;
  810. case ReachableViaWWAN:
  811. isExistenceNetwork = YES;
  812. //NSLog(@"3G");
  813. break;
  814. }
  815. if (NotReachable == [[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
  816. return NO;
  817. }
  818. return YES;
  819. }
  820. #pragma mark - NSNotification
  821. - (void)themeChanged:(NSNotification *)notification {
  822. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  823. [self updateViewColor];
  824. });
  825. }
  826. @end