KMVerificationMessageViewController.m 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  1. //
  2. // KMVerificationMessageViewController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by 王帅 on 2018/5/9.
  6. //
  7. #import "KMVerificationMessageViewController.h"
  8. #import <PDF_Reader_Pro-Swift.h>
  9. #import "VerificationManager.h"
  10. #import "AIInfoManager.h"
  11. #import "KMVerificationWindowController.h"
  12. #import "KMUnlockAlertViewController.h"
  13. #import "KMMessageModel.h"
  14. #import "KMMessageItemView.h"
  15. #define kbottomGap 0
  16. @interface KMVerificationMessageViewController ()<
  17. NSPopoverDelegate>
  18. @property (nonatomic, assign) IBOutlet NSTextField *label;
  19. @property (nonatomic, assign) IBOutlet NSButton *button;
  20. @property (nonatomic, assign) IBOutlet NSButton *secondTrialBtn;
  21. @property (assign) IBOutlet NSView *labelContentView;
  22. @property (assign) IBOutlet NSImageView *bgImg;
  23. @property (assign) IBOutlet NSView *aiContendView;
  24. @property (assign) IBOutlet NSImageView *aiIconImg;
  25. @property (assign) IBOutlet NSTextField *aiLabel;
  26. @property (weak) IBOutlet NSButton *userButton;
  27. @property (assign) IBOutlet NSView *signUpView;
  28. @property (assign) IBOutlet NSImageView *signUpImg;
  29. @property (assign) IBOutlet NSTextField *signUpLabel;
  30. @property (weak) IBOutlet NSButton *officeButton;
  31. @property (assign) IBOutlet NSImageView *officeImg;
  32. @property (strong) IBOutlet NSBox *betaFeedBackBox;
  33. @property (strong) IBOutlet NSTextField *betaFeedBackLabel;
  34. @property (strong) IBOutlet NSImageView *betaFeedBackBGImg;
  35. @property (strong) IBOutlet NSLayoutConstraint *betaFeedBackRightConst;
  36. @property (nonatomic, retain) NSTrackingArea *trackingArea;
  37. @property (nonatomic, retain) NSPopover *popover;
  38. @property (nonatomic, assign) BOOL isPopoverShow;
  39. @property (nonatomic, assign) BOOL checkValue;
  40. @property (nonatomic, assign) BOOL stopPopOverHide;
  41. @property (nonatomic, retain) KMUnlockAlertViewController *testVC;
  42. @property (nonatomic, retain) NSMenu *userMenu;
  43. // 远程按钮 最大宽度限制 100
  44. @property (nonatomic, assign) CGFloat remoteButtonMaxWidth;
  45. @property (nonatomic, strong) NSMutableArray *datas;
  46. @property (nonatomic, strong) KMMessageDiscountItemView *userGiftView;
  47. @property (nonatomic, strong) KMMessageDiscountItemView *discountItemView;
  48. @end
  49. @implementation KMVerificationMessageViewController
  50. #pragma mark Init Methods
  51. - (instancetype)init {
  52. if (self = [super initWithNibName:@"KMVerificationMessageViewController" bundle:nil]) {
  53. self.remoteButtonMaxWidth = 200;
  54. #if VERSION_DMG
  55. [[NSNotificationCenter defaultCenter] addObserver:self
  56. selector:@selector(deviceActivateStatusChangeNotification:)
  57. name:kDeviceActivateStatusChangeNotification
  58. object:nil];
  59. [[NSNotificationCenter defaultCenter] addObserver:self
  60. selector:@selector(deviceActivateStatusChangeNotification:)
  61. name:KMIAPSubscriptionLoadedNotification
  62. object:nil];
  63. #else
  64. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPProductLoaded:) name:KMIAPProductLoadedNotification object:nil];
  65. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPResultReceived:) name:KMIAPSubscriptionLoadedNotification object:nil];
  66. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPPurchaseSuccess:) name:KMIAPProductPurchasedNotification object:nil];
  67. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(IAPRestoreFinish:) name:KMIAPProductRestoreFinishedNotification object:nil];
  68. #endif
  69. _datas = [NSMutableArray arrayWithCapacity:4];
  70. }
  71. return self;
  72. }
  73. - (void)dealloc {
  74. [[NSNotificationCenter defaultCenter] removeObserver:self];
  75. if (self.trackingArea) {
  76. [self.button removeTrackingArea:self.trackingArea];
  77. }
  78. }
  79. #pragma mark Setter Methods
  80. - (void)loadView {
  81. [super loadView];
  82. // Do view setup here.
  83. self.button.wantsLayer = YES;
  84. self.button.layer.masksToBounds = YES;
  85. self.button.layer.cornerRadius = 4.0;
  86. self.button.font = [NSFont SFProTextSemiboldFont:11];
  87. self.button.layer.backgroundColor = [NSColor colorWithDeviceRed:121.0/255.0 green:196.0/255.0 blue:66.0/255.0 alpha:1.0].CGColor;
  88. [self.button setAlignment:NSTextAlignmentCenter];
  89. self.userButton.font = [NSFont SFProTextSemiboldFont:11];
  90. self.secondTrialBtn.wantsLayer = YES;
  91. self.secondTrialBtn.layer.masksToBounds = YES;
  92. self.secondTrialBtn.layer.cornerRadius = 4.0;
  93. self.secondTrialBtn.font = [NSFont SFProTextSemiboldFont:11];
  94. self.secondTrialBtn.layer.backgroundColor = [NSColor colorWithDeviceRed:121.0/255.0 green:196.0/255.0 blue:66.0/255.0 alpha:1.0].CGColor;
  95. [self.secondTrialBtn setAlignment:NSTextAlignmentCenter];
  96. NSString *tTips = NSLocalizedString(@"Upgrade to Pro", nil);
  97. #if VERSION_DMG
  98. tTips = @"";
  99. #else
  100. tTips = [NSString stringWithFormat:@"%@", NSLocalizedString(@"Subscribe to All Access Pack to enjoy more expanded features.", nil)];
  101. #endif
  102. self.button.toolTip = tTips;
  103. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  104. [self.button setTitleColor:[NSColor whiteColor]];
  105. [self.button setAlignment:NSTextAlignmentCenter];
  106. self.secondTrialBtn.toolTip = tTips;
  107. self.secondTrialBtn.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)];
  108. [self.secondTrialBtn setTitleColor:[NSColor whiteColor]];
  109. [self.secondTrialBtn setAlignment:NSTextAlignmentCenter];
  110. self.secondTrialBtn.hidden = YES;
  111. self.labelContentView.hidden = self.bgImg.hidden = self.button.hidden = NO;
  112. self.bgImg.wantsLayer = YES;
  113. self.bgImg.image = [NSImage imageNamed:@"Upgarde_bg_icon"];
  114. self.bgImg.layer.masksToBounds = YES;
  115. self.bgImg.layer.cornerRadius = 4.;
  116. self.bgImg.hidden = YES;
  117. self.aiLabel.font = [NSFont SFProTextSemiboldFont:11];
  118. self.aiLabel.textColor = [NSColor whiteColor];
  119. self.signUpView.wantsLayer = true;
  120. self.signUpView.layer.cornerRadius = 4;
  121. self.userGiftView = [[KMMessageDiscountItemView alloc] init];
  122. self.userGiftView.gradientColors = @[[NSColor colorWithRed:248/255.0 green:150/255.0 blue:90/255.0 alpha:1.0],
  123. [NSColor colorWithRed:253/255.0 green:113/255.0 blue:113/255.0 alpha:1.0]];
  124. self.userGiftView.radius = 4;
  125. self.userGiftView.titleLabel.font = [NSFont SFProTextBoldFont:11];
  126. self.userGiftView.titleLabel.textColor = NSColor.whiteColor;
  127. self.userGiftView.hidden = true;
  128. self.userGiftView.leftImageView.image = [NSImage imageNamed:@"NewUserGift"];
  129. self.userGiftView.kTarget = self;
  130. self.userGiftView.kAction = @selector(userGiftAction:);
  131. _discountItemView = [[KMMessageDiscountItemView alloc] init];
  132. _discountItemView.gradientColors = @[[NSColor colorWithRed:248/255.0 green:150/255.0 blue:90/255.0 alpha:1.0],
  133. [NSColor colorWithRed:253/255.0 green:113/255.0 blue:113/255.0 alpha:1.0]];
  134. _discountItemView.radius = 4;
  135. _discountItemView.titleLabel.font = [NSFont SFProTextBoldFont:11];
  136. _discountItemView.titleLabel.textColor = NSColor.whiteColor;
  137. _discountItemView.hidden = true;
  138. _discountItemView.leftImageView.image = [NSImage imageNamed:@"KMImageNameCancelSubscribeDiscount"];
  139. _discountItemView.kTarget = self;
  140. _discountItemView.kAction = @selector(discountAction:);
  141. self.betaFeedBackBox.hidden = true;
  142. #if VERSION_BETA
  143. self.betaFeedBackBox.hidden = false;
  144. self.betaFeedBackBox.borderWidth = 0;
  145. self.betaFeedBackBox.clipsToBounds = true;
  146. self.betaFeedBackBox.fillColor = NSColor.clearColor;
  147. self.betaFeedBackBox.borderColor = NSColor.clearColor;
  148. self.betaFeedBackBGImg.wantsLayer = true;
  149. self.betaFeedBackBGImg.layer.cornerRadius = 4;
  150. self.betaFeedBackBGImg.layer.masksToBounds = true;
  151. self.betaFeedBackLabel.stringValue = NSLocalizedString(@"Feedback to Win Gifts", nil);
  152. self.betaFeedBackLabel.textColor = NSColor.whiteColor;
  153. #endif
  154. [self reloadData];
  155. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popoverShowNoti:) name:@"KMVerificationMessagePopShowNoti" object:nil];
  156. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccessNotification:) name:@"MemberCenterLoginSuccess" object:nil];
  157. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(logoutSuccessNotification:) name:@"MemberCenterLogoutSuccess" object:nil];
  158. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(expandPersonalCenterNotification:) name:@"ExpandPersonalCenter" object:nil];
  159. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closeMenu:) name:@"CloseMenuNotification" object:nil];
  160. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(memberInfoChangeNotification:) name:KMMemberInfoChangeNotification object:nil];
  161. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(subscriptionLoadedNotification:) name:KMIAPSubscriptionLoadedNotification object:nil];
  162. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(trailCancelStateDidChange:) name:@"KMTrailCancelStateDidChangeNotificationName" object:nil];
  163. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(advertisementDidLoaded:) name:@"KMAdvertisementDidLoadedNotification" object:nil];
  164. }
  165. // MARK: - Private Methods
  166. - (NSString *)_getAppStoreFreeVersionBuyNowTitle {
  167. return [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Purchase without Login", nil)];
  168. }
  169. - (NSString *)_getDiscountTitle {
  170. #if VERSION_DMG
  171. if ([NSLocalizedString(@"USD", "") isEqualToString:@"USD"]) {
  172. return [NSString stringWithFormat:NSLocalizedString(@"%@ Coupons", @""), @"$60"];
  173. } else {
  174. return [NSString stringWithFormat:NSLocalizedString(@"%@ Coupons", @""), @"¥360"];
  175. }
  176. #else
  177. BOOL showCNY = false;
  178. #if VERSION_FREE
  179. NSString *localeId = [IAPProductsManager defaultManager].allAccessPackPermanent_lite.product.priceLocale.localeIdentifier;
  180. if ([localeId containsString:@"zh_CN"] || [localeId containsString:@"zh_TW"] || [localeId containsString:@"zh-TW"]) {
  181. showCNY = true;
  182. }
  183. #endif
  184. if ([[KMCheckInManager default] trailCancel] || [[KMCheckInManager default] advancedYearSubscribeTrailCancelForLocal]) {
  185. if (showCNY == false) {
  186. // if ([NSLocalizedString(@"USD", "") isEqualToString:@"USD"]) {
  187. return [NSString stringWithFormat:NSLocalizedString(@"%@ Coupons", @""), @"USD 60"];
  188. } else {
  189. return [NSString stringWithFormat:NSLocalizedString(@"%@ Coupons", @""), @"¥360"];
  190. }
  191. } else {
  192. if ([[KMMemberInfo shared] isFreeAccount]) {
  193. if (showCNY == false) {
  194. // if ([NSLocalizedString(@"USD", "") isEqualToString:@"USD"]) {
  195. return [NSString stringWithFormat:NSLocalizedString(@"%@ Coupons", @""), @"USD 30"];
  196. } else {
  197. return [NSString stringWithFormat:NSLocalizedString(@"%@ Coupons", @""), @"¥180"];
  198. }
  199. } else {
  200. return @"";
  201. }
  202. }
  203. #endif
  204. }
  205. - (CGFloat)_calTextWidth:(NSString *)textString font:(NSFont *)font {
  206. NSMutableDictionary *attri = [NSMutableDictionary dictionary];
  207. if (font != nil) {
  208. [attri setObject:font forKey:NSFontAttributeName];
  209. }
  210. NSRect rect = [textString boundingRectWithSize:CGSizeMake(MAXFLOAT, 30) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attri];
  211. return rect.size.width;
  212. }
  213. // 是否定向跳转比较表
  214. - (BOOL)_isNowGotoPurcahseTable {
  215. #if VERSION_FREE
  216. #if VERSION_DMG
  217. return false;
  218. #else
  219. // AppStore 免费版 有特定需求
  220. // 无本机权益 true,否则 false
  221. return IAPProductsManager.defaultManager.isAvailableAllFunction == false;
  222. #endif
  223. #else
  224. return false;
  225. #endif
  226. }
  227. - (CGFloat)_dealDiscountViewWithMessageType:(KMMessageType)messageType {
  228. KMMessageModel *newUserGiftModel = nil;
  229. KMMessageModel *discountModel = nil;
  230. for (KMMessageModel *model in self.datas) {
  231. if (model.type == KMMessageTypeNewUserGift) {
  232. newUserGiftModel = model;
  233. }
  234. if (model.type == KMMessageTypeDiscount) {
  235. discountModel = model;
  236. }
  237. }
  238. CGFloat discountWidth = 0;
  239. if (newUserGiftModel != nil && newUserGiftModel.show) {
  240. if (self.userGiftView.superview == nil) {
  241. [self.view addSubview:self.userGiftView positioned:NSWindowAbove relativeTo:self.button];
  242. }
  243. [self.userGiftView mas_remakeConstraints:^(MASConstraintMaker *make) {
  244. if (messageType == KMMessageTypeFreeTrail || messageType == KMMessageTypePurchaseWithoutLogin) {
  245. make.trailing.equalTo(self.button.mas_leading).mas_offset(-4);;
  246. } else {
  247. make.trailing.equalTo(self.button);
  248. }
  249. make.top.mas_equalTo(0);
  250. make.width.mas_equalTo(newUserGiftModel.viewWidth);
  251. make.height.equalTo(self.view);
  252. }];
  253. discountWidth = newUserGiftModel.viewWidth + 4;
  254. self.userGiftView.hidden = false;
  255. self.userGiftView.titleLabel.stringValue = newUserGiftModel.titleText;
  256. } else if (discountModel != nil && discountModel.show) {
  257. if (self.discountItemView.superview == nil) {
  258. [self.view addSubview:self.discountItemView positioned:NSWindowAbove relativeTo:self.button];
  259. }
  260. [self.discountItemView mas_remakeConstraints:^(MASConstraintMaker *make) {
  261. if (messageType == KMMessageTypeFreeTrail || messageType == KMMessageTypePurchaseWithoutLogin) {
  262. make.trailing.equalTo(self.button.mas_leading).mas_offset(-4);
  263. } else {
  264. make.trailing.equalTo(self.button);
  265. }
  266. make.top.mas_equalTo(0);
  267. make.width.mas_equalTo(discountModel.viewWidth);
  268. make.height.equalTo(self.view);
  269. }];
  270. discountWidth = discountModel.viewWidth + 4;
  271. self.discountItemView.hidden = false;
  272. _discountItemView.titleLabel.stringValue = discountModel.titleText;
  273. }
  274. return discountWidth;
  275. }
  276. - (KMMessageModel *)_createDiscountModelWithType:(KMMessageType)type {
  277. NSString *titleText = @"";
  278. if (type == KMMessageTypeNewUserGift) {
  279. titleText = NSLocalizedString(@"Welcome Gifts", @"");
  280. } else if (type == KMMessageTypeDiscount) {
  281. titleText = [self _getDiscountTitle];
  282. }
  283. NSString *calTitleText = [NSString stringWithFormat:@" %@",titleText];
  284. CGFloat width = [self _calTextWidth:calTitleText font:nil];
  285. KMMessageModel *model = [[KMMessageModel alloc] init];
  286. model.type = type;
  287. model.show = true;
  288. model.titleText = titleText;
  289. model.viewWidth = width + 10;
  290. return model;
  291. }
  292. - (void)_trackButtonEvent {
  293. if (self.button.tag == KMMessageTypePurchaseWithoutLogin) {
  294. #if VERSION_FREE
  295. #if VERSION_DMG
  296. #else
  297. [FMTrackEventManager.defaultManager trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn" : @"Btn_Tbr_PurchasewithoutLogin"}];
  298. #endif
  299. #endif
  300. } else if (self.button.tag == KMMessageTypeFreeTrail) {
  301. [FMTrackEventManager.defaultManager trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn" : @"Btn_Tbr_FreeTrial"}];
  302. }
  303. }
  304. - (CGFloat)dealSignUpView {
  305. self.signUpLabel.stringValue = NSLocalizedStringFromTable(@"Sign in", @"MemberCenterLocalizable", nil);
  306. self.signUpLabel.font = [NSFont SFProTextSemiboldFont:11];
  307. [self.signUpLabel sizeToFit];
  308. CGFloat signUpWidth = self.signUpLabel.frame.size.width;
  309. signUpWidth += 4;
  310. signUpWidth += 8;
  311. signUpWidth += 8;
  312. signUpWidth += 12;
  313. self.signUpImg.frame = CGRectMake(8, CGRectGetHeight(self.view.frame)/2.-6, 12, 12);
  314. CGRect signUplabelRect = self.signUpLabel.frame;
  315. signUplabelRect.origin.x = CGRectGetMaxX(self.signUpImg.frame) + 4;
  316. self.signUpLabel.frame = signUplabelRect;
  317. return signUpWidth;
  318. }
  319. - (void)reloadData {
  320. [self.datas removeAllObjects];
  321. // [self.userGiftView removeFromSuperview];
  322. self.userGiftView.hidden = true;
  323. self.discountItemView.hidden = true;
  324. self.label.textColor = [NSColor blackColor];
  325. self.label.hidden = NO;
  326. self.secondTrialBtn.hidden = YES;
  327. CGFloat totalWidth = 8;
  328. self.button.hidden = NO;
  329. self.officeButton.hidden = NO;
  330. self.bgImg.hidden = NO;
  331. self.officeImg.hidden = NO;
  332. self.label.hidden = YES;
  333. self.secondTrialBtn.hidden = YES;
  334. self.labelContentView.hidden = YES;
  335. self.aiContendView.hidden = YES;
  336. self.userButton.hidden = YES;
  337. self.signUpView.hidden = YES;
  338. CGFloat signUpWidth = [self dealSignUpView];
  339. self.button.layer.backgroundColor = [NSColor clearColor].CGColor;
  340. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade to Pro", nil)];
  341. [self.button setTitleColor:[NSColor whiteColor]];
  342. self.button.tag = KMMessageTypeNone;
  343. self.officeButton.layer.backgroundColor = [NSColor clearColor].CGColor;
  344. self.officeButton.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"PDF to Office", nil)];
  345. [self.officeButton setTitleColor:[NSColor whiteColor]];
  346. self.aiLabel.stringValue = NSLocalizedStringFromTable(@"Free Use 1-Year AI Tools", @"MemberCenterLocalizable", nil);
  347. [self.aiLabel sizeToFit];
  348. CGFloat aiWidth = self.aiLabel.frame.size.width;
  349. aiWidth += 4;
  350. aiWidth += 16;
  351. aiWidth += 16;
  352. self.aiIconImg.frame = CGRectMake(8, CGRectGetHeight(self.view.frame)/2.-8, 16, 16);
  353. self.aiContendView.frame = CGRectMake(totalWidth, 0, aiWidth, self.view.frame.size.height);
  354. CGRect ailabelRect = self.aiLabel.frame;
  355. ailabelRect.origin.x = CGRectGetMaxX(self.aiIconImg.frame) + 4;
  356. self.aiLabel.frame = ailabelRect;
  357. // totalWidth+=aiWidth;
  358. // totalWidth+=4;
  359. // self.aiContendView.hidden = NO;
  360. CGFloat userImageWidth = 24;
  361. if ([KMMemberInfo shared].isLogin) {
  362. self.userButton.image = [NSImage imageNamed:@"UserProfilePicture"];
  363. } else {
  364. self.userButton.image = [NSImage imageNamed:@"UserProfilePicture1"];
  365. }
  366. CGFloat buttonWidth = CGRectGetMaxX(self.button.frame);
  367. NSRect btnRect = [self.button.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.button.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  368. // if (fabs(buttonWidth-btnRect.size.width)>50) {
  369. buttonWidth = btnRect.size.width + 10;
  370. // buttonWidth += 10;
  371. // }
  372. CGFloat officeWidth = CGRectGetMaxX(self.officeButton.frame);
  373. NSRect officeRect = [self.officeButton.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.officeButton.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  374. if (fabs(officeWidth-officeRect.size.width)>50) {
  375. officeWidth = officeRect.size.width + 10;
  376. }
  377. #if VERSION_DMG
  378. self.button.hidden = YES;
  379. self.officeButton.hidden = YES;
  380. self.bgImg.hidden = YES;
  381. self.officeImg.hidden = YES;
  382. if ([[KMMemberInfo shared].isHaveAIDiscount isEqualToString:@"1"]) {
  383. self.aiContendView.hidden = NO;
  384. totalWidth+=aiWidth;
  385. totalWidth+=4;
  386. }
  387. KMUserScenarioType type = [KMMemberInfo shared].userScenarioType;
  388. KMMessageType messageType = KMMessageTypeNone;
  389. if (type == KMUserScenarioTypeDmg_type1 ||
  390. type == KMUserScenarioTypeDmg_type2 ||
  391. type == KMUserScenarioTypeDmg_type3 ||
  392. type == KMUserScenarioTypeDmg_type5 ||
  393. type == KMUserScenarioTypeDmg_type6 ||
  394. type == KMUserScenarioTypeDmg_type7 ||
  395. type == KMUserScenarioTypeDmg_type28 ||
  396. type == KMUserScenarioTypeDmg_type29 ||
  397. type == KMUserScenarioTypeDmg_type30 ||
  398. type == KMUserScenarioTypeDmg_type43 ||
  399. type == KMUserScenarioTypeDmg_type44 ||
  400. type == KMUserScenarioTypeDmg_type45) {
  401. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  402. messageType = KMMessageTypeUpgrade;
  403. } else if (type == KMUserScenarioTypeDmg_type4 ) {
  404. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)];
  405. messageType = KMMessageTypeFreeTrail;
  406. self.button.tag = KMMessageTypeFreeTrail;
  407. } else if (type == KMUserScenarioTypeDmg_type11 ||
  408. type == KMUserScenarioTypeDmg_type19 ||
  409. type == KMUserScenarioTypeDmg_type22 ||
  410. type == KMUserScenarioTypeDmg_type34 ||
  411. type == KMUserScenarioTypeDmg_type37 ) {
  412. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Buy Now", @"MemberCenterLocalizable", nil)];
  413. messageType = KMMessageTypeBuyNow;
  414. } else if (type == KMUserScenarioTypeDmg_type18 ||
  415. type == KMUserScenarioTypeDmg_type33 ||
  416. type == KMUserScenarioTypeDmg_type48) {
  417. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Renew now", @"MemberCenterLocalizable", nil)];
  418. messageType = KMMessageTypeRenew;
  419. }
  420. if (type == KMUserScenarioTypeDmg_type2 ||
  421. type == KMUserScenarioTypeDmg_type19 ||
  422. type == KMUserScenarioTypeDmg_type20 ||
  423. type == KMUserScenarioTypeDmg_type21 ||
  424. type == KMUserScenarioTypeDmg_type22 ||
  425. type == KMUserScenarioTypeDmg_type30 ||
  426. type == KMUserScenarioTypeDmg_type31 ||
  427. type == KMUserScenarioTypeDmg_type32 ||
  428. type == KMUserScenarioTypeDmg_type33) {
  429. [self.officeButton setTitleColor:[NSColor whiteColor]];
  430. self.officeButton.hidden = NO;
  431. self.officeImg.hidden = NO;
  432. self.officeButton.frame = CGRectMake(totalWidth, kbottomGap, officeWidth, self.view.frame.size.height -2 *kbottomGap);
  433. CGRect officeRect = self.officeButton.frame;
  434. self.officeImg.frame = officeRect;
  435. totalWidth+=CGRectGetWidth(self.officeButton.bounds);
  436. totalWidth+=4;
  437. }
  438. if (type == KMUserScenarioTypeDmg_type1 ||
  439. type == KMUserScenarioTypeDmg_type2 ||
  440. type == KMUserScenarioTypeDmg_type3 ||
  441. type == KMUserScenarioTypeDmg_type4 ||
  442. type == KMUserScenarioTypeDmg_type5 ||
  443. type == KMUserScenarioTypeDmg_type6 ||
  444. type == KMUserScenarioTypeDmg_type7 ||
  445. type == KMUserScenarioTypeDmg_type11 ||
  446. type == KMUserScenarioTypeDmg_type18 ||
  447. type == KMUserScenarioTypeDmg_type19 ||
  448. type == KMUserScenarioTypeDmg_type22 ||
  449. type == KMUserScenarioTypeDmg_type28 ||
  450. type == KMUserScenarioTypeDmg_type29 ||
  451. type == KMUserScenarioTypeDmg_type30 ||
  452. type == KMUserScenarioTypeDmg_type33 ||
  453. type == KMUserScenarioTypeDmg_type34 ||
  454. type == KMUserScenarioTypeDmg_type37 ||
  455. type == KMUserScenarioTypeDmg_type43 ||
  456. type == KMUserScenarioTypeDmg_type44 ||
  457. type == KMUserScenarioTypeDmg_type45 ||
  458. type == KMUserScenarioTypeDmg_type48 ||
  459. type == KMUserScenarioTypeDmg_type13) {
  460. [self.button setTitleColor:[NSColor whiteColor]];
  461. KMAdvertisementItem *advertiseItem = KMAdvertisementManager.manager.info.topRightInfoContent;
  462. if (advertiseItem != nil && advertiseItem.content.firstObject != nil) {
  463. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject;
  464. NSString *name = [KMAdvertisementModelTransition transitionLanguageWithLangeuage:info.name];
  465. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(name, nil)];
  466. NSURL *url = [NSURL URLWithString: [KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight: YES]];
  467. __weak typeof(self)weakSelf = self;
  468. NSImage * img = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage *image) {
  469. if (image != nil) {
  470. weakSelf.bgImg.image = image;
  471. }
  472. }];
  473. } else {
  474. KMMemberInfo *member = [KMMemberInfo shared];
  475. KMNewUserGiftManager *man = [KMNewUserGiftManager default];
  476. if ([man needShow] && [member isLogin] == false && member.isMemberAllFunction == false) { // 未登陆的新用户
  477. NSString *titleText = NSLocalizedString(@"Welcome Gifts", @"");
  478. NSString *calTitleText = [NSString stringWithFormat:@" %@",titleText];
  479. if (messageType != KMMessageTypeFreeTrail) {
  480. self.button.stringValue = calTitleText;
  481. }
  482. [self.datas addObject:[self _createDiscountModelWithType:KMMessageTypeNewUserGift]];
  483. } else {
  484. if ([man needShow] && [member isFreeAccount]) {
  485. NSString *titleText = [self _getDiscountTitle];
  486. NSString *calTitleText = [NSString stringWithFormat:@" %@",titleText];
  487. if (messageType != KMMessageTypeFreeTrail) {
  488. self.button.stringValue = calTitleText;
  489. }
  490. [self.datas addObject:[self _createDiscountModelWithType:KMMessageTypeDiscount]];
  491. } else if (([member isMemberAllFunction] == false || type == KMUserScenarioTypeDmg_type13) && [[KMCheckInManager default] trailCancel]) {
  492. NSString *titleText = [self _getDiscountTitle];
  493. NSString *calTitleText = [NSString stringWithFormat:@" %@",titleText];
  494. if (messageType != KMMessageTypeFreeTrail) {
  495. self.button.stringValue = calTitleText;
  496. }
  497. [self.datas addObject:[self _createDiscountModelWithType:KMMessageTypeDiscount]];
  498. }
  499. }
  500. CGFloat discountWidth = [self _dealDiscountViewWithMessageType:messageType];
  501. totalWidth += discountWidth;
  502. }
  503. if (type != KMUserScenarioTypeDmg_type13 || self.datas.count > 0) {
  504. buttonWidth = CGRectGetWidth(self.button.frame);
  505. NSRect btnRect = [self.button.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.button.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  506. buttonWidth = btnRect.size.width + 10;
  507. self.bgImg.hidden = NO;
  508. self.button.hidden = NO;
  509. self.button.frame = CGRectMake(totalWidth, kbottomGap, buttonWidth, self.view.frame.size.height -2 *kbottomGap);
  510. CGRect rect = self.button.frame;
  511. self.bgImg.frame = rect;
  512. totalWidth+=CGRectGetWidth(self.button.bounds);
  513. totalWidth+=4;
  514. }
  515. }
  516. #else
  517. if ([[KMMemberInfo shared].isHaveAIDiscount isEqualToString:@"1"]) {
  518. #if VERSION_FREE
  519. if(IAPProductsManager.defaultManager.aiAllAccessPack12month_lite.isTrialPeriod == false) {
  520. self.aiContendView.hidden = NO;
  521. totalWidth+=aiWidth;
  522. totalWidth+=4;
  523. }
  524. #else
  525. if(IAPProductsManager.defaultManager.aiAllAccessPack12month_pro.isTrialPeriod == false) {
  526. self.aiContendView.hidden = NO;
  527. totalWidth+=aiWidth;
  528. totalWidth+=4;
  529. }
  530. #endif
  531. }
  532. KMUserScenarioType type = [KMMemberInfo shared].userScenarioType;
  533. BOOL buttonHiddenFlag = false;
  534. KMMessageType messageType = KMMessageTypeNone;
  535. if (type == KMUserScenarioTypeLite_type1 ||
  536. type == KMUserScenarioTypeLite_type3 ||
  537. type == KMUserScenarioTypeLite_type5 ||
  538. type == KMUserScenarioTypeLite_type7 ||
  539. type == KMUserScenarioTypeLite_type9 ||
  540. type == KMUserScenarioTypeLite_type11 ||
  541. type == KMUserScenarioTypePro_type1 ||
  542. type == KMUserScenarioTypePro_type3 ||
  543. type == KMUserScenarioTypePro_type4 || type == KMUserScenarioTypeLite_type8) {
  544. if (type == KMUserScenarioTypeLite_type1) { //免费用户
  545. #if !VERSION_DMG
  546. if(KMMemberInfo.shared.isLogin == NO) {
  547. #if VERSION_FREE
  548. if (IAPProductsManager.defaultManager.isAvailableAllFunction) {
  549. if (IAPProductsManager.defaultManager.isAvailableAdvancedPDFToOffice) {
  550. BOOL advanceFreeTrailing = [IAPReceiptTool isFreeTrailingWithModel:[IAPProductsManager defaultManager].receiptModel withProductId:[IAPProductsManager defaultManager].fourDevicesAllAccessPackNew12months_lite.product.productIdentifier];
  551. if (advanceFreeTrailing && [[KMCheckInManager default] advancedYearSubscribeTrailCancelForLocal]) {
  552. [self.datas addObject:[self _createDiscountModelWithType:KMMessageTypeDiscount]];
  553. } else {
  554. self.button.title = @"";
  555. buttonHiddenFlag = true;
  556. }
  557. } else {
  558. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  559. messageType = KMMessageTypeUpgrade;
  560. }
  561. } else {
  562. self.button.title = [self _getAppStoreFreeVersionBuyNowTitle];
  563. if ([[KMNewUserGiftManager default] needShow]) {
  564. [self.datas addObject:[self _createDiscountModelWithType:KMMessageTypeNewUserGift]];
  565. } else if ([[KMCheckInManager default] advancedYearSubscribeTrailCancelForLocal]) {
  566. [self.datas addObject:[self _createDiscountModelWithType:KMMessageTypeDiscount]];
  567. }
  568. messageType = KMMessageTypePurchaseWithoutLogin;
  569. self.button.tag = KMMessageTypePurchaseWithoutLogin;
  570. }
  571. #else
  572. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  573. messageType = KMMessageTypeUpgrade;
  574. #endif
  575. } else {
  576. if(IAPProductsManager.defaultManager.fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == YES) { //是否有试用
  577. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Buy Now",@"MemberCenterLocalizable", nil)];
  578. messageType = KMMessageTypeBuyNow;
  579. } else {
  580. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Free Trial", nil)];
  581. messageType = KMMessageTypeFreeTrail;
  582. self.button.tag = KMMessageTypeFreeTrail;
  583. }
  584. KMMemberInfo *member = [KMMemberInfo shared];
  585. KMNewUserGiftManager *man = [KMNewUserGiftManager default];
  586. if ([man needShow] && [member isFreeAccount]) {
  587. NSString *titleText = [self _getDiscountTitle];
  588. NSString *calTitleText = [NSString stringWithFormat:@" %@",titleText];
  589. if (messageType != KMMessageTypeFreeTrail) {
  590. self.button.stringValue = calTitleText;
  591. }
  592. [self.datas addObject:[self _createDiscountModelWithType:KMMessageTypeDiscount]];
  593. } else if (man.progressState != KMProgressStateNone && member.isMemberAllFunction == false && [[KMCheckInManager default] trailCancel]) {
  594. NSString *titleText = [self _getDiscountTitle];
  595. NSString *calTitleText = [NSString stringWithFormat:@" %@",titleText];
  596. if (messageType != KMMessageTypeFreeTrail) {
  597. self.button.stringValue = calTitleText;
  598. }
  599. [self.datas addObject:[self _createDiscountModelWithType:KMMessageTypeDiscount]];
  600. }
  601. }
  602. #else
  603. #endif
  604. } else if (type == KMUserScenarioTypeLite_type3 ) {
  605. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Buy Now", @"MemberCenterLocalizable", nil)];
  606. messageType = KMMessageTypeBuyNow;
  607. } else if (type == KMUserScenarioTypeLite_type5) {
  608. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  609. messageType = KMMessageTypeUpgrade;
  610. } else if (type == KMUserScenarioTypeLite_type7) {
  611. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Renew now", @"MemberCenterLocalizable", nil)];
  612. messageType = KMMessageTypeRenew;
  613. } else if (type == KMUserScenarioTypeLite_type8) {
  614. KMMemberInfo *member = [KMMemberInfo shared];
  615. KMNewUserGiftManager *man = [KMNewUserGiftManager default];
  616. if (man.progressState != KMProgressStateNone && [[KMCheckInManager default] trailCancel]) {
  617. NSString *titleText = [self _getDiscountTitle];
  618. NSString *calTitleText = [NSString stringWithFormat:@" %@",titleText];
  619. if (messageType != KMMessageTypeFreeTrail) {
  620. self.button.stringValue = calTitleText;
  621. }
  622. [self.datas addObject:[self _createDiscountModelWithType:KMMessageTypeDiscount]];
  623. }
  624. if (self.datas.count > 1) {
  625. } else {
  626. self.button.title = @"";
  627. buttonHiddenFlag = true;
  628. }
  629. } else if (type == KMUserScenarioTypeLite_type9) {
  630. if([KMMemberInfo shared].vip_status == 2) {
  631. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Renew now",@"MemberCenterLocalizable", nil)];
  632. messageType = KMMessageTypeRenew;
  633. } else if ([KMMemberInfo shared].vip_status == 4) {
  634. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Buy Now",@"MemberCenterLocalizable", nil)];
  635. messageType = KMMessageTypeBuyNow;
  636. } else {
  637. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  638. messageType = KMMessageTypeUpgrade;
  639. }
  640. } else if (type == KMUserScenarioTypeLite_type11) {
  641. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  642. messageType = KMMessageTypeUpgrade;
  643. } else if (type == KMUserScenarioTypePro_type3) {
  644. if([KMMemberInfo shared].vip_status == 2) {
  645. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedStringFromTable(@"Renew now",@"MemberCenterLocalizable", nil)];
  646. messageType = KMMessageTypeRenew;
  647. } else {
  648. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Upgrade", nil)];
  649. messageType = KMMessageTypeUpgrade;
  650. }
  651. }
  652. #if !VERSION_FREE
  653. BOOL isNoSupportMemberUpgrade = YES;
  654. if ([KMMemberInfo shared].vip_status == 1) { //订阅+永久
  655. isNoSupportMemberUpgrade = NO;
  656. }
  657. if (![IAPProductsManager defaultManager].isAvailableAdvancedPDFToOffice && isNoSupportMemberUpgrade) {
  658. [self.officeButton setTitleColor:[NSColor whiteColor]];
  659. self.officeButton.hidden = NO;
  660. self.officeImg.hidden = NO;
  661. self.officeButton.frame = CGRectMake(totalWidth, kbottomGap, officeWidth, self.view.frame.size.height -2 *kbottomGap);
  662. CGRect officeRect = self.officeButton.frame;
  663. self.officeImg.frame = officeRect;
  664. totalWidth+=CGRectGetWidth(self.officeButton.bounds);
  665. totalWidth+=4;
  666. } else {
  667. self.officeButton.hidden = YES;
  668. self.officeImg.hidden = YES;
  669. }
  670. #else
  671. self.officeButton.hidden = YES;
  672. self.officeImg.hidden = YES;
  673. #endif
  674. KMAdvertisementItem *advertiseItem = KMAdvertisementManager.manager.info.topRightInfoContent;
  675. if (advertiseItem != nil && advertiseItem.content.firstObject != nil) {
  676. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject;
  677. NSString *name = [KMAdvertisementModelTransition transitionLanguageWithLangeuage:info.name];
  678. self.button.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(name, nil)];
  679. NSURL *url = [NSURL URLWithString: [KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight: YES]];
  680. __weak typeof(self)weakSelf = self;
  681. NSImage * img = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage *image) {
  682. if (image != nil) {
  683. weakSelf.bgImg.image = image;
  684. }
  685. }];
  686. } else {
  687. CGFloat discountWidth = [self _dealDiscountViewWithMessageType:messageType];
  688. totalWidth += discountWidth;
  689. }
  690. [self.button setTitleColor:[NSColor whiteColor]];
  691. self.bgImg.hidden = NO;
  692. self.button.hidden = NO;
  693. BOOL isOldSubscribed = NO;
  694. #if VERSION_FREE
  695. #if !VERSION_DMG
  696. isOldSubscribed = (IAPProductsManager.defaultManager.allAccessPack6months_lite.isSubscribed == YES || IAPProductsManager.defaultManager.allAccessPack12months_lite.isSubscribed == YES);
  697. #endif
  698. #endif
  699. // 单平台高级版永久 未登录时 也不显示升级(因为点了也得先登录),但是登录后的卡片里是有升级按钮的,可以升级成全平台高级版年订阅
  700. //原来是订阅的,不需要升级,因为目前不支持订阅升级订阅这种场景
  701. if(type == KMUserScenarioTypeLite_type9 ||
  702. type == KMUserScenarioTypeLite_type10 ||
  703. type == KMUserScenarioTypeLite_type11) {
  704. if([KMMemberInfo shared].isLogin == NO) { //未登录
  705. self.button.hidden = YES;
  706. self.bgImg.hidden = YES;
  707. } else {
  708. if(isOldSubscribed) { //老版本付费功能是订阅包
  709. self.button.hidden = YES;
  710. self.bgImg.hidden = YES;
  711. } else {
  712. if((KMMemberInfo.shared.vip_status == 1) && [KMMemberInfo.shared.vip_paymentModel isEqualToString:@"1"]) { //会员订阅中
  713. self.button.hidden = YES;
  714. self.bgImg.hidden = YES;
  715. }
  716. }
  717. }
  718. }
  719. #if VERSION_FREE
  720. #if !VERSION_DMG
  721. if (buttonHiddenFlag) {
  722. self.bgImg.hidden = YES;
  723. self.button.hidden = YES;
  724. }
  725. #endif
  726. #endif
  727. buttonWidth = CGRectGetWidth(self.button.frame);
  728. NSRect btnRect = [self.button.attributedTitle boundingRectWithSize:CGSizeMake(MAXFLOAT, CGRectGetHeight(self.button.frame)) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading];
  729. // if (fabs(buttonWidth-btnRect.size.width)>50) {
  730. buttonWidth = btnRect.size.width + 10;
  731. // buttonWidth += 10;
  732. // }
  733. if (KMAdvertisementManager.manager.info.topRightInfoContent != nil) {
  734. if (KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject != nil) {
  735. buttonWidth += 10;
  736. buttonWidth = MIN(buttonWidth, self.remoteButtonMaxWidth);
  737. }
  738. }
  739. self.button.frame = CGRectMake(totalWidth, kbottomGap, buttonWidth, self.view.frame.size.height -2 *kbottomGap);
  740. CGRect rect = self.button.frame;
  741. self.bgImg.frame = rect;
  742. totalWidth+=CGRectGetWidth(self.button.bounds);
  743. totalWidth+=4;
  744. } else if (type == KMUserScenarioTypeLite_type12 ||
  745. type == KMUserScenarioTypeLite_type13 ||
  746. type == KMUserScenarioTypeLite_type2 ||
  747. type == KMUserScenarioTypeLite_type4 ||
  748. type == KMUserScenarioTypeLite_type6 ||
  749. type == KMUserScenarioTypeLite_type8 ||
  750. type == KMUserScenarioTypePro_type2 ||
  751. type == KMUserScenarioTypePro_type5) {
  752. self.button.hidden = YES;
  753. self.bgImg.hidden = YES;
  754. #if !VERSION_FREE
  755. BOOL isNoSupportMemberUpgrade = YES;
  756. if ([KMMemberInfo shared].vip_status == 1) { //订阅+永久
  757. isNoSupportMemberUpgrade = NO;
  758. }
  759. if (![IAPProductsManager defaultManager].isAvailableAdvancedPDFToOffice && isNoSupportMemberUpgrade) {
  760. [self.officeButton setTitleColor:[NSColor whiteColor]];
  761. self.officeButton.hidden = NO;
  762. self.officeImg.hidden = NO;
  763. self.officeButton.frame = CGRectMake(totalWidth, kbottomGap, officeWidth, self.view.frame.size.height -2 *kbottomGap);
  764. CGRect officeRect = self.officeButton.frame;
  765. self.officeImg.frame = officeRect;
  766. totalWidth+=CGRectGetWidth(self.officeButton.bounds);
  767. totalWidth+=4;
  768. } else {
  769. self.officeButton.hidden = YES;
  770. self.officeImg.hidden = YES;
  771. }
  772. #else
  773. self.officeButton.hidden = YES;
  774. self.officeImg.hidden = YES;
  775. #endif
  776. }
  777. #endif
  778. #if VERSION_BETA
  779. self.officeButton.hidden = YES;
  780. self.officeImg.hidden = YES;
  781. self.button.hidden = YES;
  782. self.bgImg.hidden = YES;
  783. totalWidth += self.betaFeedBackLabel.fittingSize.width;
  784. totalWidth += 44;
  785. if ([KMMemberInfo shared].isLogin) {
  786. self.betaFeedBackRightConst.constant = userImageWidth + 8;
  787. } else {
  788. self.betaFeedBackRightConst.constant = signUpWidth + 8;
  789. }
  790. #endif
  791. if ([KMMemberInfo shared].isLogin) {
  792. self.userButton.hidden = NO;
  793. self.userButton.frame = CGRectMake(totalWidth, 0, userImageWidth, userImageWidth);
  794. totalWidth += userImageWidth;
  795. totalWidth += 8;
  796. } else {
  797. self.signUpView.hidden = NO;
  798. self.signUpView.frame = CGRectMake(totalWidth, 0, signUpWidth, self.view.frame.size.height);
  799. totalWidth+=CGRectGetWidth(self.signUpView.bounds);
  800. }
  801. self.view.frame = CGRectMake(MAX(0, CGRectGetWidth(self.view.superview.frame)-totalWidth - 8), (CGRectGetHeight(self.view.superview.frame)-CGRectGetHeight(self.view.frame))/2., totalWidth, self.view.frame.size.height);
  802. if (self.frameUpdateHandle) {
  803. self.frameUpdateHandle(self.view.frame);
  804. }
  805. }
  806. #pragma mark - Button Actions
  807. - (IBAction)betaFeedbackAction:(NSButton *)sender {
  808. if ([KMMemberInfo shared].isLogin) {
  809. } else {
  810. [[KMLoginWindowsController shared] openWindow:^(BOOL success) {
  811. if (success) {
  812. }
  813. }];
  814. }
  815. }
  816. - (IBAction)secondTrialAction:(NSButton *)sender {
  817. if ([VerificationManager manager].secondTrialEnabled) {
  818. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialGuide];
  819. [vc showWindow:nil];
  820. } else {
  821. [[KMMemberInfo shared] advancedFunctionUsageWithType:KMSubscribeWaterMarkTypeNone];
  822. }
  823. }
  824. - (IBAction)buttonAction:(id)sender {
  825. if (KMAdvertisementManager.manager.info.topRightInfoContent != nil) {
  826. if (KMAdvertisementManager.manager.info.topRightInfoContent.content.firstObject != nil) {
  827. #if VERSION_FREE
  828. #if VERSION_DMG
  829. #else
  830. [FMTrackEventManager.defaultManager trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn" : @"Btn_Tbr_Sale"}];
  831. #endif
  832. #endif
  833. if ([KMMemberInfo shared].isLogin) {
  834. if ([[KMMemberInfo shared].vip_levels isEqualToString:@"1"]) {
  835. [[KMProductCompareWC shared] setOrientation:YES];
  836. #if VERSION_FREE
  837. #if VERSION_DMG
  838. // DMG
  839. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeDmg_Base];
  840. #else
  841. // AppStore 免费版本
  842. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeLite_Base];
  843. #endif
  844. #else
  845. // AppStore 付费版
  846. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypePro_Base];
  847. #endif
  848. [[KMProductCompareWC shared] showWindow:nil];
  849. } else {
  850. [[KMMemberInfo shared] advancedFunctionUsageWithType:KMSubscribeWaterMarkTypeNone];
  851. }
  852. } else {
  853. if ([self _isNowGotoPurcahseTable]) {
  854. KMProductCompareWC *winC = [KMProductCompareWC shared];
  855. // 定向跳转
  856. winC.orientation = true;
  857. // App Store 免费版 基础比较表
  858. winC.orientationType = KMCompareTableTypeLite_Base;
  859. [winC showWindow:nil];
  860. } else {
  861. [[KMLoginWindowsController shared] openWindow:^(BOOL success) {
  862. if (success) {
  863. if ([[KMMemberInfo shared].vip_levels isEqualToString:@"1"]) {
  864. [[KMProductCompareWC shared] setOrientation:YES];
  865. #if VERSION_FREE
  866. #if VERSION_DMG
  867. // DMG
  868. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeDmg_Base];
  869. #else
  870. // AppStore 免费版本
  871. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeLite_Base];
  872. #endif
  873. #else
  874. // AppStore 付费版
  875. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypePro_Base];
  876. #endif
  877. [[KMProductCompareWC shared] showWindow:nil];
  878. } else {
  879. [[KMMemberInfo shared] advancedFunctionUsageWithType:KMSubscribeWaterMarkTypeNone];
  880. }
  881. }
  882. }];
  883. }
  884. }
  885. } else {
  886. [self _trackButtonEvent];
  887. KMUserScenarioType type = [KMMemberInfo shared].userScenarioType;
  888. if (type == KMUserScenarioTypeDmg_type4) {
  889. if ([KMMemberInfo shared].isLogin) {
  890. [[KMProductCompareWC shared] setOrientation:YES];
  891. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial];
  892. // [[KMProductCompareWC shared] showWindow:nil];
  893. [[KMProductCompareWC shared] openWindowWithDiscountType:KMDiscountTypeFreeTrail];
  894. } else {
  895. [[KMLoginWindowsController shared] openWindow:^(BOOL success) {
  896. if (success) {
  897. [[KMProductCompareWC shared] setOrientation:YES];
  898. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial];
  899. // [[KMProductCompareWC shared] showWindow:nil];
  900. [[KMProductCompareWC shared] openWindowWithDiscountType:KMDiscountTypeFreeTrail];
  901. }
  902. }];
  903. }
  904. } else {
  905. if ([self _isNowGotoPurcahseTable] &&
  906. ![KMMemberInfo shared].isLogin) { //本机(Apple ID)无权益,且未未登录时,直接跳购买
  907. [self _doNowGotoPurcahseTable];
  908. } else {
  909. if ([[KMMemberInfo shared] isLogin] && self.button.tag == KMMessageTypeFreeTrail) { // 免费试用
  910. [[KMProductCompareWC shared] setOrientation:YES];
  911. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial];
  912. [[KMProductCompareWC shared] openWindowWithDiscountType:KMDiscountTypeFreeTrail];
  913. } else {
  914. [[KMMemberInfo shared] advancedFunctionUsageWithType:KMSubscribeWaterMarkTypeInvalid];
  915. }
  916. }
  917. }
  918. }
  919. } else {
  920. [self _trackButtonEvent];
  921. KMUserScenarioType type = [KMMemberInfo shared].userScenarioType;
  922. if (type == KMUserScenarioTypeDmg_type4) {
  923. if ([KMMemberInfo shared].isLogin) {
  924. [[KMProductCompareWC shared] setOrientation:YES];
  925. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial];
  926. // [[KMProductCompareWC shared] showWindow:nil];
  927. [[KMProductCompareWC shared] openWindowWithDiscountType:KMDiscountTypeFreeTrail];
  928. } else {
  929. [[KMLoginWindowsController shared] openWindow:^(BOOL success) {
  930. if (success) {
  931. [[KMProductCompareWC shared] setOrientation:YES];
  932. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial];
  933. // [[KMProductCompareWC shared] showWindow:nil];
  934. [[KMProductCompareWC shared] openWindowWithDiscountType:KMDiscountTypeFreeTrail];
  935. }
  936. }];
  937. }
  938. } else {
  939. if ([self _isNowGotoPurcahseTable] && ![KMMemberInfo shared].isLogin) { //本机(Apple ID)无权益,且未未登录时,直接跳购买
  940. [self _doNowGotoPurcahseTable];
  941. } else {
  942. if ([[KMMemberInfo shared] isLogin] && self.button.tag == KMMessageTypeFreeTrail) { // 免费试用
  943. [[KMProductCompareWC shared] setOrientation:YES];
  944. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeTrial];
  945. [[KMProductCompareWC shared] openWindowWithDiscountType:KMDiscountTypeFreeTrail];
  946. } else {
  947. [[KMMemberInfo shared] advancedFunctionUsageWithType:KMSubscribeWaterMarkTypeInvalid];
  948. }
  949. }
  950. }
  951. }
  952. }
  953. - (void)_doNowGotoPurcahseTable {
  954. KMProductCompareWC *winC = [KMProductCompareWC shared];
  955. // 定向跳转
  956. winC.orientation = true;
  957. // App Store 免费版 基础比较表
  958. winC.orientationType = KMCompareTableTypeLite_Base;
  959. if ([[KMMemberInfo shared] isLogin] && self.button.tag == KMMessageTypeFreeTrail) { // 免费试用
  960. [winC openWindowWithDiscountType:KMDiscountTypeFreeTrail];
  961. } else if (self.userGiftView.isHidden == false) { // 新手礼
  962. KMMessageModel *model = nil;
  963. for (KMMessageModel *m in self.datas) {
  964. if (m.type == KMMessageTypeNewUserGift) {
  965. model = m;
  966. break;
  967. }
  968. }
  969. if (model != nil) { // 检查数据
  970. if ([[KMNewUserGiftManager default] needShow]) { // 检查条件
  971. [winC openWindowWithDiscountType:KMDiscountTypeNewUserGift];
  972. } else {
  973. [winC showWindow:nil];
  974. }
  975. } else {
  976. [winC showWindow:nil];
  977. }
  978. } else if (self.discountItemView.isHidden == false) { // 优惠卷 (新手礼 & 试用退订)
  979. KMMessageModel *model = nil;
  980. for (KMMessageModel *m in self.datas) {
  981. if (m.type == KMMessageTypeDiscount) {
  982. model = m;
  983. }
  984. }
  985. if (model != nil) { // 检查数据
  986. if ([[KMCheckInManager default] trailCancel] || [[KMCheckInManager default] advancedYearSubscribeTrailCancelForLocal]) { // 检查条件
  987. [winC openWindowWithDiscountType:KMDiscountTypeAdvancedYearSubscribeTrialingCancel];
  988. } else if ([[KMNewUserGiftManager default] needShow]) { // 检查条件
  989. [winC openWindowWithDiscountType:KMDiscountTypeNewUserGift];
  990. } else {
  991. [winC showWindow:nil];
  992. }
  993. } else {
  994. [winC showWindow:nil];
  995. }
  996. } else {
  997. [winC showWindow:nil];
  998. }
  999. }
  1000. - (IBAction)officeButtonAction:(id)sender {
  1001. #if VERSION_FREE
  1002. #if VERSION_DMG
  1003. DMGEmbeddedOldWC *embeddedWC = [DMGEmbeddedOldWC currentFirstTrialWC:@"com.brother.pdfreaderpro.mac.product_2"];
  1004. [embeddedWC showWindow:nil];
  1005. [embeddedWC.window center];
  1006. #endif
  1007. #else
  1008. if ([KMMemberInfo shared].isLogin) {
  1009. [[KMMemberInfo shared] productCompareShow];
  1010. } else {
  1011. [[KMLoginWindowsController shared] openWindow:^(BOOL success) {
  1012. if (success) {
  1013. [[KMMemberInfo shared] productCompareShow];
  1014. }
  1015. }];
  1016. }
  1017. #endif
  1018. }
  1019. - (NSAttributedString *)numberConvertColor:(NSColor*)color String:(NSString *)string {
  1020. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
  1021. NSString *temp = nil;
  1022. for (NSUInteger i = 0; i <string.length; i++) {
  1023. temp = [string substringWithRange:NSMakeRange(i, 1)];
  1024. if ([self isPureInt:temp]) {
  1025. [attributedString setAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
  1026. color, NSForegroundColorAttributeName, nil] range:NSMakeRange(i, 1)];
  1027. }
  1028. }
  1029. return attributedString;
  1030. }
  1031. - (BOOL)isPureInt:(NSString *)string {
  1032. NSScanner *scan = [NSScanner scannerWithString:string];
  1033. int value;
  1034. return [scan scanInt:&value] && [scan isAtEnd];
  1035. }
  1036. - (IBAction)AIButtonAction:(NSButton *)sender {
  1037. if ([[[KMMemberInfo shared] validFlag] isEqualToString:@"5"]) {
  1038. [[KMMemberPromptWC shared] showWindow:sender];
  1039. [KMMemberPromptWC shared].tipType = KMMemberTipTypeSignouting;
  1040. } else {
  1041. #if VERSION_FREE
  1042. #if VERSION_DMG
  1043. KMPurchaseEmbeddedWindowController *winC = [KMPurchaseEmbeddedWindowController currentCode:KMAISubscriptionYearTrailCodeKey_DMG];
  1044. [winC showWindow:nil];
  1045. [winC.window center];
  1046. #else
  1047. [[KMFreeGetAIWC shared] showWindow:nil];
  1048. #endif
  1049. #else
  1050. [[KMFreeGetAIWC shared] showWindow:nil];
  1051. #endif
  1052. }
  1053. }
  1054. - (IBAction)userButtonAction:(NSButton *)sender {
  1055. if ([KMMemberInfo shared].isLogin) {
  1056. [self personalCenterAction:sender];
  1057. } else {
  1058. [KMLoginWindowsController.shared showWindow:nil];
  1059. }
  1060. }
  1061. - (BOOL)isConnectionAvailable {
  1062. BOOL isExistenceNetwork = YES;
  1063. Reachability *reach = [Reachability reachabilityWithHostname:@"www.apple.com"];
  1064. switch ([reach currentReachabilityStatus]) {
  1065. case NotReachable:
  1066. isExistenceNetwork = NO;
  1067. //NSLog(@"notReachable");
  1068. break;
  1069. case ReachableViaWiFi:
  1070. isExistenceNetwork = YES;
  1071. //NSLog(@"WIFI");
  1072. break;
  1073. case ReachableViaWWAN:
  1074. isExistenceNetwork = YES;
  1075. //NSLog(@"3G");
  1076. break;
  1077. }
  1078. if (NotReachable == [[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
  1079. return NO;
  1080. }
  1081. return YES;
  1082. }
  1083. - (IBAction)personalCenterAction:(NSButton *)sender {
  1084. if (![self isConnectionAvailable]) {
  1085. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Connection Error", nil)
  1086. defaultButton:NSLocalizedString(@"OK", nil)
  1087. alternateButton:nil
  1088. otherButton:nil
  1089. informativeTextWithFormat:NSLocalizedString(@"Please make sure your internet connection is available.", nil), nil];
  1090. [alert runModal];
  1091. return;
  1092. }
  1093. // 用户头像点击事件
  1094. self.userMenu = [[NSMenu alloc] init];
  1095. // KMUserInfoViewController *userInfo = [[KMUserInfoViewController alloc] init];
  1096. KMBetaUserInfoController *userInfo = [[KMBetaUserInfoController alloc] init];
  1097. NSMenuItem *item = [self.userMenu addItemWithTitle:@"" action:nil target:@""];
  1098. item.target = self;
  1099. item.representedObject = userInfo;
  1100. item.view = userInfo.view;
  1101. [self.userMenu popUpMenuPositioningItem:nil atLocation:NSMakePoint(-130, 30) inView:sender];
  1102. }
  1103. - (IBAction)signUpAction:(NSButton *)sender {
  1104. #if VERSION_FREE
  1105. #if VERSION_DMG
  1106. #else
  1107. [FMTrackEventManager.defaultManager trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn" : @"Btn_Tbr_Login"}];
  1108. #endif
  1109. #endif
  1110. [KMLoginWindowsController.shared showWindow:nil];
  1111. }
  1112. - (void)userGiftAction:(id)sender {
  1113. [FMTrackEventManager.defaultManager trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn" : @"Btn_Tbr_WelcomGift"}];
  1114. [[KMNewUserGiftWindowController shared] openWindow];
  1115. }
  1116. - (void)discountAction:(id)sender {
  1117. [FMTrackEventManager.defaultManager trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn" : @"Btn_Tbr_Conpon"}];
  1118. #if VERSION_FREE
  1119. if ([[KMCheckInManager default] trailCancel] || [[KMCheckInManager default] advancedYearSubscribeTrailCancelForLocal]) {
  1120. [[KMProductCompareWC shared] setOrientation:true];
  1121. #if VERSION_DMG
  1122. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeDmg_Base];
  1123. #else
  1124. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeLite_Base];
  1125. #endif
  1126. [[KMProductCompareWC shared] openWindowWithDiscountType:KMDiscountTypeAdvancedYearSubscribeTrialingCancel];
  1127. } else {
  1128. [[KMProductCompareWC shared] setOrientation:true];
  1129. #if VERSION_DMG
  1130. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeDmg_Base];
  1131. #else
  1132. [[KMProductCompareWC shared] setOrientationType:KMCompareTableTypeLite_Base];
  1133. #endif
  1134. [[KMProductCompareWC shared] openWindowWithDiscountType:KMDiscountTypeNewUserGift];
  1135. }
  1136. #endif
  1137. }
  1138. #pragma mark - NSNotification Methods
  1139. - (void)deviceActivateStatusChangeNotification:(NSNotification *)notification {
  1140. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  1141. [self reloadData];
  1142. });
  1143. }
  1144. - (void)IAPProductLoaded:(NSNotification *)notification {
  1145. dispatch_async(dispatch_get_main_queue(), ^{
  1146. [self reloadData];
  1147. });
  1148. }
  1149. - (void)IAPResultReceived:(NSNotification *)notification {
  1150. dispatch_async(dispatch_get_main_queue(), ^{
  1151. [self reloadData];
  1152. });
  1153. }
  1154. - (void)IAPPurchaseSuccess:(NSNotification *)notification {
  1155. dispatch_async(dispatch_get_main_queue(), ^{
  1156. [self reloadData];
  1157. #if VERSION_FREE
  1158. #if VERSION_DMG
  1159. #else
  1160. [[KMProductCompareWC shared] closeAction];
  1161. #endif
  1162. #endif
  1163. });
  1164. }
  1165. - (void)IAPRestoreFinish:(NSNotification *)notification {
  1166. dispatch_async(dispatch_get_main_queue(), ^{
  1167. [self reloadData];
  1168. });
  1169. }
  1170. - (void)trailCancelStateDidChange:(NSNotification *)noti {
  1171. dispatch_async(dispatch_get_main_queue(), ^{
  1172. [self reloadData];
  1173. });
  1174. }
  1175. - (void)advertisementDidLoaded:(NSNotification *)noti {
  1176. dispatch_async(dispatch_get_main_queue(), ^{
  1177. [self reloadData];
  1178. });
  1179. }
  1180. #pragma mark - Event
  1181. - (void)mouseEntered:(NSEvent *)event {
  1182. if (ActivityStatusTrialExpire == [VerificationManager manager].status ||
  1183. ActivityStatusTrial == [VerificationManager manager].status) {
  1184. [[self class] cancelPreviousPerformRequestsWithTarget:self];
  1185. if (!self.popover.isShown) {
  1186. [self buttonAction:self.button];
  1187. }
  1188. }
  1189. }
  1190. - (void)mouseExited:(NSEvent *)event {
  1191. [super mouseExited:event];
  1192. [self performSelector:@selector(popOverCloseAction) withObject:nil afterDelay:0.35];
  1193. }
  1194. - (void)popoverDidClose:(NSNotification *)notification {
  1195. self.stopPopOverHide = NO;
  1196. }
  1197. - (void)popoverShowNoti:(NSNotification *)noti {
  1198. if (self.popover) {
  1199. [self.popover close];
  1200. self.stopPopOverHide = NO;
  1201. }
  1202. }
  1203. - (void)loginSuccessNotification:(NSNotification *)noti {
  1204. dispatch_async(dispatch_get_main_queue(), ^{
  1205. self.userButton.image = [NSImage imageNamed:@"UserProfilePicture"];
  1206. [self reloadData];
  1207. });
  1208. }
  1209. - (void)logoutSuccessNotification:(NSNotification *)noti {
  1210. dispatch_async(dispatch_get_main_queue(), ^{
  1211. self.userButton.image = [NSImage imageNamed:@"UserProfilePicture1"];
  1212. [self reloadData];
  1213. });
  1214. }
  1215. - (void)expandPersonalCenterNotification:(NSNotification *)noti {
  1216. if (self.userMenu != nil) {
  1217. [self personalCenterAction:_userButton];
  1218. }
  1219. }
  1220. - (void)closeMenu:(NSNotification *)noti {
  1221. if (self.userMenu != nil) {
  1222. [self.userMenu cancelTracking];
  1223. self.userMenu = nil;
  1224. }
  1225. }
  1226. - (void)subscriptionLoadedNotification:(NSNotification *)noti {
  1227. dispatch_async(dispatch_get_main_queue(), ^{
  1228. [self reloadData];
  1229. });
  1230. }
  1231. - (void)memberInfoChangeNotification:(NSNotification *)noti {
  1232. dispatch_async(dispatch_get_main_queue(), ^{
  1233. [self reloadData];
  1234. });
  1235. }
  1236. - (void)popOverCloseAction {
  1237. if (self.stopPopOverHide == NO) {
  1238. if (ActivityStatusTrialExpire == [VerificationManager manager].status ||
  1239. ActivityStatusTrial == [VerificationManager manager].status) {
  1240. if (self.popover.isShown) {
  1241. [self.popover close];
  1242. self.stopPopOverHide = NO;
  1243. }
  1244. }
  1245. }
  1246. }
  1247. @end