diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 3f2b8af..15a18c0 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -399,7 +399,7 @@ CODE_SIGN_IDENTITY = "Apple Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 6; DART_OBFUSCATION = true; DEVELOPMENT_TEAM = TW3K3253KL; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = TW3K3253KL; @@ -545,7 +545,7 @@ CODE_SIGN_IDENTITY = "Apple Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 6; DART_OBFUSCATION = true; DEVELOPMENT_TEAM = TW3K3253KL; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = TW3K3253KL; @@ -581,7 +581,7 @@ CODE_SIGN_IDENTITY = "Apple Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 5; + CURRENT_PROJECT_VERSION = 6; DART_OBFUSCATION = true; DEVELOPMENT_TEAM = TW3K3253KL; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = TW3K3253KL; diff --git a/lib/ads/interstitial_ad_manage.dart b/lib/ads/interstitial_ad_manage.dart index 2225c38..8b16213 100644 --- a/lib/ads/interstitial_ad_manage.dart +++ b/lib/ads/interstitial_ad_manage.dart @@ -47,11 +47,14 @@ class InterstitialAdManager { /// 初始化 Future init() async { - MaxConfiguration? configuration = await AppLovinMAX.initialize(applovinKey); - if (configuration != null) { - isInitialized = true; - _attachAdListeners(); - loadAllAd(); + try { + MaxConfiguration? configuration = await AppLovinMAX.initialize(applovinKey); + if (configuration != null) { + isInitialized = true; + _attachAdListeners(); + } + } catch (e) { + LogPrint.d(e.toString()); } } @@ -87,7 +90,7 @@ class InterstitialAdManager { LogPrint.d('插页广告显示失败adUnitId:${ad.adUnitId},code:${error.code},message:${error.message}'); isShowingAd = false; - if (onTap != null) onTap!(); + _handleOnTap(); }, onAdClickedCallback: (ad) {}, onAdHiddenCallback: (ad) { @@ -95,7 +98,7 @@ class InterstitialAdManager { isShowingAd = false; AppLovinMAX.loadInterstitial(ad.adUnitId); - if (onTap != null) onTap!(); + _handleOnTap(); }, )); } @@ -105,6 +108,9 @@ class InterstitialAdManager { if (!adSwitch) { return; } + if (!isInitialized) { + return; + } AppLovinMAX.loadInterstitial(launchAdId); for (var id in adIds) { AppLovinMAX.loadInterstitial(id); @@ -119,11 +125,11 @@ class InterstitialAdManager { } bool adSwitch = UPCache.getInstance().get('adSwitch') ?? false; if (!adSwitch) { - if (this.onTap != null) this.onTap!(); + _handleOnTap(); return; } if (!isInitialized) { - if (this.onTap != null) this.onTap!(); + _handleOnTap(); return; } var adId = launchAdId; @@ -135,13 +141,20 @@ class InterstitialAdManager { if (isReady) { if (isShowingAd) { LogPrint.d('尝试在已显示广告的情况下显示广告'); - if (this.onTap != null) this.onTap!(); + _handleOnTap(); return; } AppLovinMAX.showInterstitial(adId); } else { - if (this.onTap != null) this.onTap!(); + _handleOnTap(); AppLovinMAX.loadInterstitial(adId); } } + + void _handleOnTap() { + if (onTap != null) { + onTap!(); + onTap = null; + } + } } \ No newline at end of file diff --git a/lib/common/components/dialog/remind_dialog.dart b/lib/common/components/dialog/remind_dialog.dart index c79d69a..f5d7a07 100644 --- a/lib/common/components/dialog/remind_dialog.dart +++ b/lib/common/components/dialog/remind_dialog.dart @@ -101,7 +101,7 @@ class RemindDialog extends StatelessWidget { label, textAlign: TextAlign.center, style: TextStyle( - color: isConfirm ? Colors.red : const Color(0xFF666666), + color: isConfirm ? Colors.black : const Color(0xFF666666), fontSize: 16.sp, fontWeight: FontWeight.w500, ), diff --git a/lib/facebook/facebook_manager.dart b/lib/facebook/facebook_manager.dart index 1a2362d..f6e7f2f 100644 --- a/lib/facebook/facebook_manager.dart +++ b/lib/facebook/facebook_manager.dart @@ -3,10 +3,15 @@ // Description: facebook管理 import 'package:facebook_app_events/facebook_app_events.dart'; +import 'package:wallpaperx/common/utils/log_print.dart'; class FacebookManager { - static void init() { - FacebookAppEvents().setAdvertiserTracking(enabled: true); - FacebookAppEvents().setAutoLogAppEventsEnabled(true); + static Future init() async { + try { + await FacebookAppEvents().setAdvertiserTracking(enabled: true); + await FacebookAppEvents().setAutoLogAppEventsEnabled(true); + } catch (e) { + LogPrint.d(e.toString()); + } } } \ No newline at end of file diff --git a/lib/global/app_config.dart b/lib/global/app_config.dart index e46ba59..893d604 100644 --- a/lib/global/app_config.dart +++ b/lib/global/app_config.dart @@ -4,7 +4,7 @@ const appName = 'Visual Wallpaper'; /// 保底逻辑:本地设定截止日期(提交日期+3天,网络时间超过,则默认展示所有广告) DateTime getGuaranteedDate () { - DateTime? commitDate = DateUtils.getDateTime('2024-08-14 18:30:00'); + DateTime? commitDate = DateUtils.getDateTime('2024-08-15 18:30:00'); if (commitDate != null) { return commitDate.add(const Duration(days: 3)); } else { diff --git a/lib/global/network_connectivity_service.dart b/lib/global/network_connectivity_service.dart index 0787f30..c15cb0e 100644 --- a/lib/global/network_connectivity_service.dart +++ b/lib/global/network_connectivity_service.dart @@ -6,7 +6,9 @@ import 'dart:async'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:get/get.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:wallpaperx/ads/interstitial_ad_manage.dart'; +import 'package:wallpaperx/common/components/dialog/remind_dialog.dart'; import 'package:wallpaperx/common/utils/log_print.dart'; import 'package:wallpaperx/common/utils/shared_util.dart'; import 'package:wallpaperx/firebase/firebase_remote_config_manager.dart'; @@ -22,17 +24,17 @@ class NetworkConnectivityService extends GetxService { subscription = Connectivity().onConnectivityChanged.listen((List result) async { LogPrint.d('当前网络连接类型:$result'); if (result.contains(ConnectivityResult.none)) { - - if (Get.isRegistered() && !isShowNetworkDialog) { - LaunchController.to.openNetworkDialog(); - isShowNetworkDialog = true; - } + _checkNetworkDialog(); + isShowNetworkDialog = true; } else { if (Get.isRegistered()) { - if (isShowNetworkDialog) { - Get.back(); + if (LaunchController.to.timer == null) { + LaunchController.to.startTimer(); } - LaunchController.to.startTimer(); + } + if (Get.isDialogOpen != null && Get.isDialogOpen! && isShowNetworkDialog) { + Get.back(); + isShowNetworkDialog = false; } bool adSwitch = UPCache.getInstance().get('adSwitch') ?? false; if (adSwitch) { @@ -48,4 +50,18 @@ class NetworkConnectivityService extends GetxService { subscription?.cancel(); super.onClose(); } + + void _checkNetworkDialog() { + Get.dialog( + barrierDismissible: false, + RemindDialog( + content: 'No network connection\nPlease check the current network', + showCancelBtn: false, + enableBack: false, + confirmOnTap: () { + openAppSettings(); + }, + ), + ); + } } \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index af4c1cd..387a500 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -40,9 +40,9 @@ void main() async { debugPrint("Firebase initialization error: $e"); } - FacebookManager.init(); + await FacebookManager.init(); - InterstitialAdManager().init(); + await InterstitialAdManager().init(); // EasyLoading配置 configLoading(); diff --git a/lib/page/launch/launch_controller.dart b/lib/page/launch/launch_controller.dart index 062e726..82660e5 100644 --- a/lib/page/launch/launch_controller.dart +++ b/lib/page/launch/launch_controller.dart @@ -1,9 +1,7 @@ import 'dart:async'; import 'package:get/get.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:wallpaperx/ads/interstitial_ad_manage.dart'; -import 'package:wallpaperx/common/components/dialog/remind_dialog.dart'; import 'package:wallpaperx/common/utils/shared_util.dart'; import 'package:wallpaperx/global/app_config.dart'; import 'package:wallpaperx/global/network_connectivity_service.dart'; @@ -11,7 +9,7 @@ import 'package:wallpaperx/routes/app_pages.dart'; class LaunchController extends GetxController with GetSingleTickerProviderStateMixin { static LaunchController get to => Get.find(); - Timer? _timer; + Timer? timer; /// 进度总时长 var timeTotal = 15.0 * 1000; /// 当前进度 @@ -32,20 +30,6 @@ class LaunchController extends GetxController with GetSingleTickerProviderStateM super.onClose(); } - void openNetworkDialog() { - Get.dialog( - barrierDismissible: false, - RemindDialog( - content: 'Please check if the wireless or cellular network is turned on?', - showCancelBtn: false, - enableBack: false, - confirmOnTap: () { - openAppSettings(); - }, - ), - ); - } - /// 检查是否到保底日期 Future _checkGuaranteedDate() async { bool adSwitch = UPCache.getInstance().get('adSwitch') ?? false; @@ -58,7 +42,7 @@ class LaunchController extends GetxController with GetSingleTickerProviderStateM /// 开始定时器 void startTimer() { - _timer = Timer.periodic(const Duration(milliseconds: 10), (Timer t) async { + timer = Timer.periodic(const Duration(milliseconds: 10), (Timer t) async { if (currentProcess.value + changeValue >= timeTotal) { currentProcess.value = timeTotal; _stopTimer(); @@ -71,8 +55,8 @@ class LaunchController extends GetxController with GetSingleTickerProviderStateM /// 停止定时器 void _stopTimer() { - _timer?.cancel(); - _timer = null; + timer?.cancel(); + timer = null; } /// 修改进度变化值 diff --git a/pubspec.yaml b/pubspec.yaml index 8a13c59..73ae83a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: wallpaperx description: "A new Flutter project." publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 1.2.0+5 +version: 1.2.0+6 environment: sdk: '>=3.4.1 <4.0.0'