diff --git a/HD wallpaper.xcodeproj/project.pbxproj b/HD wallpaper.xcodeproj/project.pbxproj index 20c5aa4..9e31bbf 100644 --- a/HD wallpaper.xcodeproj/project.pbxproj +++ b/HD wallpaper.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 0004D8852C3534AC00B3E467 /* WallPapaerADManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 0004D8842C3534AC00B3E467 /* WallPapaerADManager.m */; }; 0004D8862C354B7700B3E467 /* AppLovinSDK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0004D8602C352F4700B3E467 /* AppLovinSDK.xcframework */; }; 0004D8872C354B7700B3E467 /* AppLovinSDK.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0004D8602C352F4700B3E467 /* AppLovinSDK.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 0004D88B2C355DF100B3E467 /* WPUserPravcyVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 0004D88A2C355DF100B3E467 /* WPUserPravcyVC.m */; }; 0126BA97CEBE3D5058AF2043 /* Pods_HD_wallpaper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 18B9E38A7CF086ABC9920714 /* Pods_HD_wallpaper.framework */; }; 057AF7952BF1E86F00078C98 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 057AF7942BF1E86F00078C98 /* AppDelegate.m */; }; 057AF7A02BF1E87100078C98 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 057AF79F2BF1E87100078C98 /* Assets.xcassets */; }; @@ -75,6 +76,8 @@ 0004D8802C35301E00B3E467 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 0004D8832C3534AC00B3E467 /* WallPapaerADManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WallPapaerADManager.h; sourceTree = ""; }; 0004D8842C3534AC00B3E467 /* WallPapaerADManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WallPapaerADManager.m; sourceTree = ""; }; + 0004D8892C355DF100B3E467 /* WPUserPravcyVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WPUserPravcyVC.h; sourceTree = ""; }; + 0004D88A2C355DF100B3E467 /* WPUserPravcyVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WPUserPravcyVC.m; sourceTree = ""; }; 041A9EAF08B4BEE8FF03DD23 /* Pods-HD wallpaper.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HD wallpaper.debug.xcconfig"; path = "Target Support Files/Pods-HD wallpaper/Pods-HD wallpaper.debug.xcconfig"; sourceTree = ""; }; 057AF7902BF1E86F00078C98 /* HD wallpaper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HD wallpaper.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 057AF7932BF1E86F00078C98 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -182,6 +185,8 @@ 057AF7B32BF1F14300078C98 /* WPEditViewController.m */, 057AF7B52BF1F14900078C98 /* WPForMyViewController.h */, 057AF7B62BF1F14900078C98 /* WPForMyViewController.m */, + 0004D8892C355DF100B3E467 /* WPUserPravcyVC.h */, + 0004D88A2C355DF100B3E467 /* WPUserPravcyVC.m */, 057AF7B82BF1F73700078C98 /* WPSearchViewController.h */, 057AF7B92BF1F73700078C98 /* WPSearchViewController.m */, 057AF7BB2BF2067E00078C98 /* WPwallpaperViewController.h */, @@ -339,6 +344,7 @@ 0004D8852C3534AC00B3E467 /* WallPapaerADManager.m in Sources */, 057AF7C02BF209E100078C98 /* WPAllWallpaperViewController.m in Sources */, 057AF7A62BF1E87100078C98 /* main.m in Sources */, + 0004D88B2C355DF100B3E467 /* WPUserPravcyVC.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/HD wallpaper.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate b/HD wallpaper.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate index b1b2be6..1a2146b 100644 Binary files a/HD wallpaper.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate and b/HD wallpaper.xcworkspace/xcuserdata/aaa.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/HD wallpaper/AppDelegate.m b/HD wallpaper/AppDelegate.m index a6d6121..a63bab2 100644 --- a/HD wallpaper/AppDelegate.m +++ b/HD wallpaper/AppDelegate.m @@ -23,6 +23,15 @@ self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; + [[WallPapaerADManager shareInstance] showFirstOpenAD:^(NSInteger actionType) { + [self configureRootVC]; + } window:self.window]; + + + return YES; +} + +- (void)configureRootVC { WPOnePageViewController *wpHome = [[WPOnePageViewController alloc] init]; wpHome.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"" image:[[UIImage imageNamed:@"tab1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tab11"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; UINavigationController *wpHomeNV = [[UINavigationController alloc] initWithRootViewController:wpHome]; @@ -49,8 +58,6 @@ tb.selectedIndex = 0; self.window.rootViewController = tb; - - return YES; } diff --git a/HD wallpaper/WPForMyViewController.m b/HD wallpaper/WPForMyViewController.m index 363d724..6001f44 100644 --- a/HD wallpaper/WPForMyViewController.m +++ b/HD wallpaper/WPForMyViewController.m @@ -3,6 +3,7 @@ #import "WPForMyViewController.h" #import "WPwallpaperViewController.h" +#import "WPUserPravcyVC.h" #define WPScreen_w [UIScreen mainScreen].bounds.size.width #define WPScreen_h [UIScreen mainScreen].bounds.size.height #define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f] @@ -34,8 +35,24 @@ [self.view addSubview:btn]; } + UIButton *pracy_btn = [UIButton new]; + [self.view addSubview:pracy_btn]; + [pracy_btn addTarget:self action:@selector(showUserPravcy) forControlEvents:UIControlEventTouchUpInside]; + [pracy_btn setTitle:@"用户隐私" forState:UIControlStateNormal]; + [pracy_btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; + pracy_btn.titleLabel.font = [UIFont systemFontOfSize:14]; + CGFloat btn_w = 90; + CGFloat btn_h = 20; + pracy_btn.frame = CGRectMake((WPScreen_w - btn_w) * .5, WPScreen_h - btn_h - 90, btn_w, btn_h); } + +//显示用户隐私 +- (void)showUserPravcy { + WPUserPravcyVC *vc = [WPUserPravcyVC new]; + [self.navigationController pushViewController:vc animated:YES]; +} + - (void)iconEvent:(UIButton *)icon{ if (icon.tag == 0) { WPwallpaperViewController *wpdetail = [[WPwallpaperViewController alloc] init]; diff --git a/HD wallpaper/WPUserPravcyVC.h b/HD wallpaper/WPUserPravcyVC.h new file mode 100644 index 0000000..245d9fd --- /dev/null +++ b/HD wallpaper/WPUserPravcyVC.h @@ -0,0 +1,16 @@ +// +// WPUserPravcyVC.h +// HD wallpaper +// +// Created by aaa on 2024/7/3. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface WPUserPravcyVC : UIViewController + +@end + +NS_ASSUME_NONNULL_END diff --git a/HD wallpaper/WPUserPravcyVC.m b/HD wallpaper/WPUserPravcyVC.m new file mode 100644 index 0000000..cb034c5 --- /dev/null +++ b/HD wallpaper/WPUserPravcyVC.m @@ -0,0 +1,79 @@ +// +// WPUserPravcyVC.m +// HD wallpaper +// +// Created by aaa on 2024/7/3. +// + +#import "WPUserPravcyVC.h" +#import +#define WPScreen_w [UIScreen mainScreen].bounds.size.width +#define WPScreen_h [UIScreen mainScreen].bounds.size.height +#define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f] +@interface WPUserPravcyVC () +@property(nonatomic,strong)UIButton *backItem; +@property(nonatomic,strong)UIImageView *navImage; + +@end + +@implementation WPUserPravcyVC + +- (instancetype)init +{ + self = [super init]; + if (self) { + self.hidesBottomBarWhenPushed = YES; + } + return self; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + self.view.backgroundColor = [UIColor whiteColor]; + self.navigationItem.hidesBackButton = YES; +// UIImageView *bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WPScreen_w, 360)]; +// bgImage.image = [UIImage imageNamed:@"bgsearch"]; +// bgImage.userInteractionEnabled = YES; +// [self.view addSubview:bgImage]; + + UIButton *backItem = [[UIButton alloc] initWithFrame:CGRectMake(20, 0, 74, 44)]; + [backItem setImage:[UIImage imageNamed:@"backitem"] forState:UIControlStateNormal]; + [backItem addTarget:self action:@selector(backItemEvent) forControlEvents:UIControlEventTouchUpInside]; + self.backItem = backItem; + +// UILabel *titleLabel = [UILabel new]; +// [self.view addSubview:titleLabel]; +// titleLabel.text = @"用户隐私"; +// titleLabel.font = [UIFont systemFontOfSize:16]; +// titleLabel.textColor = [UIColor blackColor]; +// titleLabel.backgroundColor = [UIColor redColor]; +// titleLabel.frame = CGRectMake((self.view.frame.size.width - 200)*0.5, 0, 200, 44); +// UIImageView *navImage = [[UIImageView alloc] initWithFrame:CGRectMake(WPScreen_w-150, 8, 130, 28)]; +// navImage.image = [UIImage imageNamed:@"navsearch"]; +// self.navImage = navImage; + + WKWebView *webView = [WKWebView new]; + [self.view addSubview:webView]; + webView.frame = self.view.bounds; + NSURL *url = [NSURL URLWithString:@"https://trendwallpaper.bitbucket.io/privacy.html"]; + NSURLRequest *request = [NSURLRequest requestWithURL:url]; + [webView loadRequest:request]; +} + +- (void)backItemEvent{ + [self.navigationController popViewControllerAnimated:YES]; + +} + +- (void)viewWillAppear:(BOOL)animated{ + [super viewWillAppear:animated]; + [self.navigationController.navigationBar addSubview:self.backItem]; + [self.navigationController.navigationBar addSubview:self.navImage]; +} +- (void)viewWillDisappear:(BOOL)animated{ + [super viewWillDisappear:animated]; + [self.backItem removeFromSuperview]; + [self.navImage removeFromSuperview]; +} + +@end diff --git a/HD wallpaper/WallPapaerADManager/WallPapaerADManager.h b/HD wallpaper/WallPapaerADManager/WallPapaerADManager.h index c66917c..915713d 100644 --- a/HD wallpaper/WallPapaerADManager/WallPapaerADManager.h +++ b/HD wallpaper/WallPapaerADManager/WallPapaerADManager.h @@ -6,7 +6,7 @@ // #import - +#import NS_ASSUME_NONNULL_BEGIN typedef void(^WallPapaerADManagerCallback)(NSInteger actionType);//actionType,1表示关闭广告 @interface WallPapaerADManager : NSObject @@ -16,6 +16,7 @@ typedef void(^WallPapaerADManagerCallback)(NSInteger actionType);//actionType,1 - (void)initOpenAD; +- (void)showFirstOpenAD:(WallPapaerADManagerCallback)callback window:(UIWindow *)window; - (void)showOpenAD; - (void)initIntersitialAD; diff --git a/HD wallpaper/WallPapaerADManager/WallPapaerADManager.m b/HD wallpaper/WallPapaerADManager/WallPapaerADManager.m index c671030..5c31b31 100644 --- a/HD wallpaper/WallPapaerADManager/WallPapaerADManager.m +++ b/HD wallpaper/WallPapaerADManager/WallPapaerADManager.m @@ -21,6 +21,7 @@ @property (nonatomic) NSInteger retryAttempt_searchAD; @property (nonatomic,strong) NSTimer *openADTimer; +@property (nonatomic,strong) UIProgressView *processView; @end // @@ -30,13 +31,19 @@ #define kInterstitial_BackAD @"43c096614eb15e06"//返回 插页 #define kInterstitial_SaveAD @"99a545c14fe760b4" //保存 插页 #define kInterstitial_SearchAD @"fcfba91be4420a25" //搜索 插页 - +#define kOpenAdCTimeLength 15.0//最多等待开屏广告加载时常 +#define kOpenADPerSec 0.05 @implementation WallPapaerADManager //配置广告 - (void)configureAD{ _adConfig = [ALSdkInitializationConfiguration configurationWithSdkKey: kAppLovinSDK_Key builderBlock:^(ALSdkInitializationConfigurationBuilder *builder) { - builder.mediationProvider = ALMediationProviderMAX; + builder.mediationProvider = ALMediationProviderMAX; + NSString *currentIDFV = UIDevice.currentDevice.identifierForVendor.UUIDString; + if ( currentIDFV.length > 0 ) + { + builder.testDeviceAdvertisingIdentifiers = @[currentIDFV]; + } }]; // Initialize the SDK with the configuration @@ -121,14 +128,74 @@ } } -- (void)showOpenAD { - if ( ![[ALSdk shared] isInitialized] ) - { +- (void)checkOpenADReadyState{ + static CGFloat totalTimeC = 0.0; + totalTimeC += kOpenADPerSec; + + if ( [self.openAD isReady] ){ + [_openADTimer invalidate]; + _openADTimer = nil; + [self.openAD showAd]; + } + else { + if (totalTimeC > kOpenAdCTimeLength) {//超时 + NSLog(@"超时关闭等待开屏广告页..."); + if(self.callback) { + self.callback(1); + } + [_openADTimer invalidate]; + _openADTimer = nil; + } + else { + CGFloat v = totalTimeC / kOpenAdCTimeLength; + _processView.progress = v; + } + } +} + +- (void)showFirstOpenAD:(WallPapaerADManagerCallback)callback window:(UIWindow *)window { + + self.callback = callback; + + if ( ![[ALSdk shared] isInitialized] ){ + _openADTimer = [NSTimer scheduledTimerWithTimeInterval:kOpenADPerSec target:self selector:@selector(checkOpenADReadyState) userInfo:nil repeats:YES]; + [self confiugreLanuchBgView:window]; + return; + } + if ( [self.openAD isReady] ){ + + [self.openAD showAd]; + } + else + { + _openADTimer = [NSTimer scheduledTimerWithTimeInterval:kOpenADPerSec target:self selector:@selector(checkOpenADReadyState) userInfo:nil repeats:YES]; + [self confiugreLanuchBgView:window]; + [self.openAD loadAd]; + } +} + +- ( void)confiugreLanuchBgView:(UIWindow *)window{ + UIViewController *vc = [UIViewController new]; + window.rootViewController = vc; + + UIImageView *imgView = [UIImageView new]; + imgView.frame = window.bounds; + [window addSubview:imgView]; + imgView.image = [UIImage imageNamed:@"wlaunch"]; + imgView.contentMode = UIViewContentModeScaleAspectFit; + _processView = [UIProgressView new]; + _processView.frame = CGRectMake(80, window.frame.size.height - 60, window.frame.size.width - 160, 20); + _processView.tintColor = [UIColor systemPinkColor]; + [imgView addSubview:_processView]; + + [vc.view addSubview:imgView]; +} + +- (void)showOpenAD { + if ( ![[ALSdk shared] isInitialized] ){ return; } - if ( [self.openAD isReady] ){ -// [self.openAD showAdForPlacement: @"«test-placement-ID»"]; [self.openAD showAd]; } else