You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
6.8 KiB
160 lines
6.8 KiB
4 years ago
|
//
|
||
|
// TFAgreementAlertView.m
|
||
|
// TFReader
|
||
|
//
|
||
|
// Created by 谢腾飞 on 2020/12/17.
|
||
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "TFAgreementAlertView.h"
|
||
|
#import "TFWebViewController.h"
|
||
|
#import "AppDelegate.h"
|
||
|
#import <MOBFoundation/MobSDK+Privacy.h>
|
||
|
|
||
|
@implementation TFAgreementAlertView
|
||
|
|
||
|
- (void)createSubviews
|
||
|
{
|
||
|
[super createSubviews];
|
||
|
|
||
|
/*** 穿山甲的背景视图,解决穿山甲加载广告期间的空白页面 ***/
|
||
|
UIView *backgroundView = ({
|
||
|
NSString *lauchStoryboardName = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchStoryboardName"];
|
||
|
switch (TFLanguageManager.localizedLanguage) {
|
||
|
case TFLanguageTypeSimplifiedChinese:
|
||
|
lauchStoryboardName = @"LaunchScreen_ZH";
|
||
|
break;
|
||
|
case TFLanguageTypeTraditionalChinese:
|
||
|
lauchStoryboardName = @"LaunchScreen_ZW";
|
||
|
break;
|
||
|
case TFLanguageTypeEnglish:
|
||
|
lauchStoryboardName = @"LaunchScreen_EN";
|
||
|
break;
|
||
|
case TFLanguageTypeTail:
|
||
|
lauchStoryboardName = @"LaunchScreen_TH";
|
||
|
break;
|
||
|
default:
|
||
|
lauchStoryboardName = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchStoryboardName"];
|
||
|
break;
|
||
|
}
|
||
|
UIViewController *launchScreen = [[UIStoryboard storyboardWithName:lauchStoryboardName bundle:nil] instantiateInitialViewController];
|
||
|
UIView *backgroundView = launchScreen.view;
|
||
|
backgroundView.backgroundColor = [UIColor whiteColor];
|
||
|
backgroundView.frame = [UIScreen mainScreen].bounds;
|
||
|
backgroundView;
|
||
|
});
|
||
|
[self addSubview:backgroundView];
|
||
|
[self sendSubviewToBack:backgroundView];
|
||
|
|
||
|
UIView *shadowView = [[UIView alloc] init];
|
||
|
shadowView.backgroundColor = kColorRGBA(0, 0, 0, 0.3);
|
||
|
[backgroundView addSubview:shadowView];
|
||
|
[shadowView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.edges.equalTo(backgroundView);
|
||
|
}];
|
||
|
|
||
|
|
||
|
self.alertDisappearType = TFAlertViewDisappearTypeConfirm;
|
||
|
self.closeButton.hidden = YES;
|
||
|
self.alertTitle = TFLocalizedString(@"用户隐私保护提示");
|
||
|
|
||
|
NSString *prefix = [NSString stringWithFormat:@"%@%@", App_Name, TFLocalizedString(@"隐私政策")];
|
||
|
NSString *suffix = TFLocalizedString(@"软件许可及服务协议");
|
||
|
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:TFLocalizedString(@"为了更好的保护您的隐私和信息安全,根据国家相关法律规定和国家标准制定并执行《%@》及《%@》,请您在使用前务必仔细阅读并透彻理解,如果您继续使用本产品即代表您同意本平台的协议条款,我们会全力保护您的个人信息安全。"), prefix, suffix]];
|
||
|
|
||
|
NSRange range1 = [str.string rangeOfString:prefix];
|
||
|
NSRange range2 = [str.string rangeOfString:suffix];
|
||
|
|
||
|
[str setColor:kColorRGB(102, 102, 102)];
|
||
|
[str setFont:kMainFont];
|
||
|
[str setLineSpacing:4];
|
||
|
|
||
|
[str setTextHighlightRange:range1 color:kMainColor backgroundColor:[UIColor whiteColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
|
if (![TFViewHelper getWindowRootController].presentedViewController) {
|
||
|
TFWebViewController *web = [[TFWebViewController alloc] init];
|
||
|
web.navTitle = TFLocalizedString(@"隐私政策");
|
||
|
AppDelegate *delegate = (AppDelegate *)kRCodeSync([UIApplication sharedApplication].delegate);
|
||
|
web.URLString = delegate.checkSettingModel.protocol_list.privacy ?: [NSString stringWithFormat:@"%@%@?language=%@", APIURL, Privacy_Policy, TFLanguageManager.serverLocalized];
|
||
|
|
||
|
web.isPresentState = YES;
|
||
|
[[TFViewHelper getWindowRootController] presentViewController:web animated:YES completion:nil];
|
||
|
}
|
||
|
}];
|
||
|
|
||
|
[str setTextHighlightRange:range2 color:kMainColor backgroundColor:[UIColor whiteColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
|
||
|
if (![TFViewHelper getWindowRootController].presentedViewController) {
|
||
|
TFWebViewController *web = [[TFWebViewController alloc] init];
|
||
|
web.navTitle = TFLocalizedString(@"软件许可");
|
||
|
web.URLString = [NSString stringWithFormat:@"%@%@?language=%@", APIURL, Notify_Note, TFLanguageManager.serverLocalized];
|
||
|
web.isPresentState = YES;
|
||
|
[[TFViewHelper getWindowRootController] presentViewController:web animated:YES completion:nil];
|
||
|
}
|
||
|
}];
|
||
|
self.attributedStr = str;
|
||
|
self.contentScrollView.hidden = YES;
|
||
|
|
||
|
UIScrollView *mainScrollView = [[UIScrollView alloc] init];
|
||
|
mainScrollView.showsHorizontalScrollIndicator = NO;
|
||
|
[self addSubview:mainScrollView];
|
||
|
|
||
|
[mainScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
|
||
|
make.top.equalTo(self.contentScrollView).offset(kMargin);
|
||
|
make.left.right.bottom.equalTo(self.contentScrollView);
|
||
|
}];
|
||
|
|
||
|
YYLabel *detailView = [[YYLabel alloc] init];
|
||
|
detailView.backgroundColor = [UIColor whiteColor];
|
||
|
detailView.numberOfLines = 0;
|
||
|
detailView.preferredMaxLayoutWidth = SCREEN_WIDTH - 3 * kMargin - 2 * kMargin;
|
||
|
detailView.attributedText = str;
|
||
|
[mainScrollView addSubview:detailView];
|
||
|
|
||
|
[detailView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
|
make.edges.width.equalTo(mainScrollView);
|
||
|
}];
|
||
|
|
||
|
self.cancelTitle = TFLocalizedString(@"拒绝并退出");
|
||
|
self.confirmTitle = TFLocalizedString(@"我已经阅读并同意");
|
||
|
|
||
|
[self.cancelButton addTarget:self action:@selector(cancelButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||
|
[self.confirmButton addTarget:self action:@selector(confirmButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||
|
}
|
||
|
|
||
|
- (void)showAlertView
|
||
|
{
|
||
|
[super showAlertView];
|
||
|
}
|
||
|
|
||
|
- (void)willMoveToWindow:(nullable UIWindow *)newWindow
|
||
|
{
|
||
|
[super willMoveToWindow:newWindow];
|
||
|
if (!newWindow) { // 跳转到协议时newWindow会为空
|
||
|
[UIApplication sharedApplication].statusBarHidden = NO;
|
||
|
} else {
|
||
|
[UIApplication sharedApplication].statusBarHidden = YES;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)cancelButtonClick
|
||
|
{
|
||
|
UIWindow *window = [UIApplication sharedApplication].keyWindow;
|
||
|
[UIView animateWithDuration:kAnimatedDuration animations:^{
|
||
|
window.alpha = 0;
|
||
|
window.frame = CGRectMake(0, window.bounds.size.height / 2, window.bounds.size.width, 0.5);
|
||
|
} completion:^(BOOL finished) {
|
||
|
exit(0);
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
- (void)confirmButtonClick
|
||
|
{
|
||
|
[self closeAlertView];
|
||
|
|
||
|
TFSystemInfoManager.isAgree = YES;
|
||
|
!self.confirmButtonClickBlock ?: self.confirmButtonClickBlock();
|
||
|
[MobSDK uploadPrivacyPermissionStatus:YES onResult:nil];
|
||
|
}
|
||
|
|
||
|
@end
|