diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 0b388d1..e48f3b0 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -6,6 +6,11 @@ plugins { // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") } +val signingProperties = + project.rootProject.file("key.properties").takeIf { it.exists() } + ?.reader() + ?.use { Properties().apply { load(it) } } + ?: Properties() android { namespace = "com.kinetra.adehok.app" @@ -31,13 +36,44 @@ android { targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName + + ndk { + abiFilters.clear() + abiFilters.add("armeabi-v7a") + abiFilters.add("arm64-v8a") + } } + + signingConfigs { + create("release") { + storeFile = file(signingProperties["storeFile"].toString()) + storePassword = signingProperties["storePassword"].toString() + keyAlias = signingProperties["keyAlias"].toString() + keyPassword = signingProperties["keyPassword"].toString() + } + } + splits { + abi { + isEnable = false + } + } buildTypes { release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig = signingConfigs.getByName("debug") + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + + // 签名配置 + signingConfig = signingConfigs.getByName("release") + + } + debug { + signingConfig = signingConfigs.getByName("release") + } } } diff --git a/lib/kt_pages/kt_explore/logic.dart b/lib/kt_pages/kt_explore/logic.dart index 379021c..b27cc46 100644 --- a/lib/kt_pages/kt_explore/logic.dart +++ b/lib/kt_pages/kt_explore/logic.dart @@ -11,6 +11,7 @@ import '../../dio_cilent/kt_request.dart'; import '../../kt_model/kt_short_video_bean.dart'; import '../../kt_utils/kt_device_info_utils.dart'; import '../../kt_widgets/kt_status_widget.dart'; +import '../kt_main_page/view.dart'; class KtExploreLogic extends GetxController { final state = KtExploreState(); @@ -165,7 +166,8 @@ class KtExploreLogic extends GetxController { try { await controller.initialize(); if (index == state.currentPage) { - controller.play(); + final mainLogic = Get.find(); + if(mainLogic.curIndex == 1) controller.play(); update(); } controller.addListener(() { diff --git a/lib/kt_pages/kt_home/logic.dart b/lib/kt_pages/kt_home/logic.dart index 2345c14..9883516 100644 --- a/lib/kt_pages/kt_home/logic.dart +++ b/lib/kt_pages/kt_home/logic.dart @@ -1,4 +1,5 @@ import 'package:easy_refresh/easy_refresh.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_kinetra/kt_model/kt_home_category_bean.dart'; import 'package:flutter_kinetra/kt_pages/kt_home/state.dart'; import 'package:get/get.dart'; diff --git a/lib/kt_pages/kt_main_page/view.dart b/lib/kt_pages/kt_main_page/view.dart index f1cf7d5..86ab3d6 100644 --- a/lib/kt_pages/kt_main_page/view.dart +++ b/lib/kt_pages/kt_main_page/view.dart @@ -5,7 +5,6 @@ import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import '../../kt_utils/kt_keys.dart'; import '../kt_explore/view.dart'; import '../kt_home/view.dart'; import '../kt_mine/view.dart'; @@ -21,11 +20,12 @@ class KtMainPage extends StatefulWidget { class _KtMainPageState extends State with RouteAware, WidgetsBindingObserver { + final logic = Get.put(KtMainLogic()); final PageController _controller = PageController(); static const List _tabsTitle = [ {'icon': 'home', 'title': 'Home'}, {'icon': 'explore', 'title': 'Explore'}, - {'icon': 'actor', 'title': 'Actor'}, + {'icon': 'actor', 'title': 'Actors'}, {'icon': 'favorite', 'title': 'My List'}, {'icon': 'mine', 'title': 'Profile'}, ]; @@ -79,61 +79,67 @@ class _KtMainPageState extends State } } }, - child: Scaffold( - body: PageView.builder( - controller: _controller, - physics: const NeverScrollableScrollPhysics(), - onPageChanged: (index) { - _currentIndex = index; - setState(() {}); - }, - itemBuilder: (context, index) => _getTab(index), - itemCount: _tabsTitle.length, - ), - bottomNavigationBar: BottomNavigationBar( - selectedItemColor: Color(0xFF1E1E20), - selectedLabelStyle: TextStyle( - fontSize: 10.sp, - fontWeight: FontWeight.w400, - ), - unselectedLabelStyle: TextStyle( - fontSize: 10.sp, - color: Color(0xFF95959C), - fontWeight: FontWeight.w400, - ), - type: BottomNavigationBarType.fixed, - currentIndex: _currentIndex, - onTap: (index) { - _currentIndex = index; - _controller.jumpToPage(index); - final myListLogic = Get.put(MyListLogic()); - myListLogic.initData(); - }, - items: [ - ..._tabsTitle.map( - (item) => BottomNavigationBarItem( - icon: Container( - height: 24.w, - margin: EdgeInsets.only(top: 4.w), - alignment: Alignment.center, - child: Image.asset( - 'ic_${item['icon']}_unsel.png'.ktIcon, - width: 24.w, - ), - ), - activeIcon: Container( - margin: EdgeInsets.only(top: 4.w), - child: Image.asset( - 'ic_${item['icon']}_sel.png'.ktIcon, - width: 24.w, - height: 24.w, - ), - ), - label: item['title'], - ), + child: GetBuilder( + builder: (ctrl) { + return Scaffold( + body: PageView.builder( + controller: _controller, + physics: const NeverScrollableScrollPhysics(), + onPageChanged: (index) { + _currentIndex = index; + logic.curIndex = index; + setState(() {}); + }, + itemBuilder: (context, index) => _getTab(index), + itemCount: _tabsTitle.length, ), - ], - ), + bottomNavigationBar: BottomNavigationBar( + selectedItemColor: Color(0xFF1E1E20), + selectedLabelStyle: TextStyle( + fontSize: 10.sp, + fontWeight: FontWeight.w400, + ), + unselectedLabelStyle: TextStyle( + fontSize: 10.sp, + color: Color(0xFF95959C), + fontWeight: FontWeight.w400, + ), + type: BottomNavigationBarType.fixed, + currentIndex: _currentIndex, + onTap: (index) { + _currentIndex = index; + logic.curIndex = index; + _controller.jumpToPage(index); + final myListLogic = Get.put(MyListLogic()); + myListLogic.initData(); + }, + items: [ + ..._tabsTitle.map( + (item) => BottomNavigationBarItem( + icon: Container( + height: 24.w, + margin: EdgeInsets.only(top: 4.w), + alignment: Alignment.center, + child: Image.asset( + 'ic_${item['icon']}_unsel.png'.ktIcon, + width: 24.w, + ), + ), + activeIcon: Container( + margin: EdgeInsets.only(top: 4.w), + child: Image.asset( + 'ic_${item['icon']}_sel.png'.ktIcon, + width: 24.w, + height: 24.w, + ), + ), + label: item['title'], + ), + ), + ], + ), + ); + } ), ); } @@ -165,170 +171,174 @@ class _KtMainPageState extends State super.dispose(); } - // @override - // void didChangeAppLifecycleState(AppLifecycleState state) { - // super.didChangeAppLifecycleState(state); - // if (state == AppLifecycleState.paused) { - // _cycleLifeTime = DateTime.now(); - // } else if (state == AppLifecycleState.resumed) { - // AppBadgePlus.updateBadge(0); - // final now = DateTime.now(); - // final duration = now.difference(_cycleLifeTime ?? now); - // if ((duration.inMilliseconds > 3 || _isAndroidTwicePermission) && _pageOpen) { - // Future.delayed(const Duration(milliseconds: 1000)).then((_) { - // if (mounted) _checkDeeplink(); - // }); - // } - // _cycleLifeTime = null; - // } - // } - // - // void _checkDeeplink() { - // EasyThrottle.throttle('check-deeplink', Duration(seconds: 2), () async { - // try { - // // 获取deepling链接 - // // final adjustProvider = context.read(); - // final deepLink = AdjustService().deeplink ?? ''; - // debugPrint('[CheckDeeplink] DEEPLINK链接: $deepLink'); - // // 使用的原始链接和使用链接 - // String useString = ''; - // String useStr = ''; - // //优先使用直链 - // if (deepLink != '') { - // useString = deepLink; - // useStr = deepLink; - // // 清空deeplink - // AdjustService().clearDeeplink(); - // debugPrint('----清理deeplink:${AdjustService().deeplink}'); - // } else { - // // 获取剪贴板内容 - // final clipboardData = await Clipboard.getData(Clipboard.kTextPlain); - // final clipboardString = clipboardData?.text ?? ''; - // debugPrint('[CheckDeeplink] 剪贴板原始链接: $clipboardString'); - // // 判断剪贴板内容是否为跳转链接并处理 - // final clipboardStr = - // clipboardString != '' && - // clipboardString.startsWith(Apis.W2A_PREFIX) && - // clipboardString.contains(Apis.W2A_NAME) - // ? clipboardString.substring(Apis.W2A_PREFIX.length).trim() - // : ''; - // debugPrint('[CheckDeeplink] 剪贴板处理链接: $clipboardStr'); - // useString = clipboardString; - // useStr = clipboardStr; - // } - // - // // 使用链接 - // if (useStr != '') { - // final uri = Uri.tryParse(useStr); - // Map params = uri!.queryParameters; - // // params.forEach((k, v) { - // // debugPrint('----key:$k value:$v'); - // // }); - // - // final shortPlayId = params['short_play_id']; - // final videoId = params['video_id'] ?? 0; - // if (shortPlayId?.isEmpty ?? false) { - // debugPrint('[CheckDeeplink] 链接中没有参数'); - // return; - // } - // // 上报w2a - // HttpClient().request(Apis.uploadW2a, data: {"data": useString}); - // debugPrint('[CheckDeeplink] 跳转链接: $useStr'); - // debugPrint('[CheckDeeplink] 上报链接: $useString'); - // debugPrint('---current route:${Get.currentRoute}'); - // AdjustService().clearDeeplink(); - // // 清空剪贴板 - // await Clipboard.setData(const ClipboardData(text: '')); - // if (Get.currentRoute == AppRoutes.shortVideo) { - // // Get.offAndToNamed( - // // AppRoutes.shortVideo, - // // arguments: {'shortPlayId': int.parse(shortPlayId), "videoId": int.parse(videoId)}, - // // ); - // final logic = Get.put(ShortVideoLogic()); - // logic.state.shortPlayId = int.parse(shortPlayId); - // logic.state.videoId = int.parse(videoId); - // logic.initData(); - // } else { - // Get.toNamed( - // AppRoutes.shortVideo, - // arguments: {'shortPlayId': int.parse(shortPlayId.toString()), "videoId": int.parse(videoId.toString())}, - // ); - // } - // } - // } catch (e) { - // debugPrint('[AdjustManager] 读取剪贴板异常: $e'); - // } - // }); - // } - // - // _initFirebase() async { - // try { - // await Firebase.initializeApp(); - // } catch (e) { - // debugPrint("----initFirebase err: $e"); - // } - // if (Platform.isIOS) { - // await FirebaseIOS().initialize(); - // } else if (Platform.isAndroid) { - // await FirebaseAndroid().initialize(); - // await FirebaseAndroid().initializeNotifications(); - // } - // // 获取初始消息(应用通过通知启动)看是否是应用消息启动 - // if (Platform.isIOS) { - // WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { - // // 看是否是消息跳进来,然后跳转到详情页面 - // RemoteMessage? remoteMessage = await FirebaseMessaging.instance.getInitialMessage(); - // debugPrint("杀死app启动通知:$remoteMessage"); - // if (remoteMessage != null) { - // final msgData = remoteMessage.data as Map; - // final msgNotification = remoteMessage.notification; - // final String? msgId = msgData['msg_id']; - // final String title = msgNotification?.title ?? ""; - // if (msgId != null) { - // HttpClient().request(Apis.sendMessageReport, data: {"message_id": int.parse(msgId), "title": title}); - // } - // FirebaseCommon().onFirebaseRoute(msgData); - // } - // }); - // } - // } - // - // // 检查通知权限 - // Future _checkNotificationPermission() async { - // final permissionStatus = await Permission.notification.status; - // if (permissionStatus.isDenied) { - // if (Platform.isAndroid) { - // //安卓第二次请求权限,再次查询剪贴板的w2a链接 - // _isAndroidTwicePermission = true; - // } - // //再次请求 - // await Permission.notification.request(); - // } else if (permissionStatus.isPermanentlyDenied) { - // int now = DateTime.now().millisecondsSinceEpoch; - // int lastRequestTime = SpUtils().getInt(SpKeys.notiPermissionTime) ?? now; - // int hours = DateTime.now().difference(DateTime.fromMillisecondsSinceEpoch(lastRequestTime)).inHours; - // if (hours < 24) return; - // SpUtils().setInt(SpKeys.notiPermissionTime, now); - // //永久拒绝 - // Get.dialog( - // CommonDialog( - // topIconWidget: Positioned( - // left: -35.w, - // top: 0.w, - // child: Image.asset('ic_dialog_subscribe.png'.icon, width: 140.w, height: 100.w), - // ), - // title: 'Turn on Notifications?', - // subTitle: 'Get alerts for new episodes and exclusive offers.', - // hasLeftBtn: false, - // rightBtnText: 'Allow', - // rightBtnFunc: () => openAppSettings(), - // ), - // ); - // } - // } - // - // _restore() async { - // await Get.put(MineLogic()).getUserInfo(); - // EasyThrottle.throttle('restore', Duration(minutes: 5), () => BuyUtils.restorePay(showTips: false)); - // } +// @override +// void didChangeAppLifecycleState(AppLifecycleState state) { +// super.didChangeAppLifecycleState(state); +// if (state == AppLifecycleState.paused) { +// _cycleLifeTime = DateTime.now(); +// } else if (state == AppLifecycleState.resumed) { +// AppBadgePlus.updateBadge(0); +// final now = DateTime.now(); +// final duration = now.difference(_cycleLifeTime ?? now); +// if ((duration.inMilliseconds > 3 || _isAndroidTwicePermission) && _pageOpen) { +// Future.delayed(const Duration(milliseconds: 1000)).then((_) { +// if (mounted) _checkDeeplink(); +// }); +// } +// _cycleLifeTime = null; +// } +// } +// +// void _checkDeeplink() { +// EasyThrottle.throttle('check-deeplink', Duration(seconds: 2), () async { +// try { +// // 获取deepling链接 +// // final adjustProvider = context.read(); +// final deepLink = AdjustService().deeplink ?? ''; +// debugPrint('[CheckDeeplink] DEEPLINK链接: $deepLink'); +// // 使用的原始链接和使用链接 +// String useString = ''; +// String useStr = ''; +// //优先使用直链 +// if (deepLink != '') { +// useString = deepLink; +// useStr = deepLink; +// // 清空deeplink +// AdjustService().clearDeeplink(); +// debugPrint('----清理deeplink:${AdjustService().deeplink}'); +// } else { +// // 获取剪贴板内容 +// final clipboardData = await Clipboard.getData(Clipboard.kTextPlain); +// final clipboardString = clipboardData?.text ?? ''; +// debugPrint('[CheckDeeplink] 剪贴板原始链接: $clipboardString'); +// // 判断剪贴板内容是否为跳转链接并处理 +// final clipboardStr = +// clipboardString != '' && +// clipboardString.startsWith(Apis.W2A_PREFIX) && +// clipboardString.contains(Apis.W2A_NAME) +// ? clipboardString.substring(Apis.W2A_PREFIX.length).trim() +// : ''; +// debugPrint('[CheckDeeplink] 剪贴板处理链接: $clipboardStr'); +// useString = clipboardString; +// useStr = clipboardStr; +// } +// +// // 使用链接 +// if (useStr != '') { +// final uri = Uri.tryParse(useStr); +// Map params = uri!.queryParameters; +// // params.forEach((k, v) { +// // debugPrint('----key:$k value:$v'); +// // }); +// +// final shortPlayId = params['short_play_id']; +// final videoId = params['video_id'] ?? 0; +// if (shortPlayId?.isEmpty ?? false) { +// debugPrint('[CheckDeeplink] 链接中没有参数'); +// return; +// } +// // 上报w2a +// HttpClient().request(Apis.uploadW2a, data: {"data": useString}); +// debugPrint('[CheckDeeplink] 跳转链接: $useStr'); +// debugPrint('[CheckDeeplink] 上报链接: $useString'); +// debugPrint('---current route:${Get.currentRoute}'); +// AdjustService().clearDeeplink(); +// // 清空剪贴板 +// await Clipboard.setData(const ClipboardData(text: '')); +// if (Get.currentRoute == AppRoutes.shortVideo) { +// // Get.offAndToNamed( +// // AppRoutes.shortVideo, +// // arguments: {'shortPlayId': int.parse(shortPlayId), "videoId": int.parse(videoId)}, +// // ); +// final logic = Get.put(ShortVideoLogic()); +// logic.state.shortPlayId = int.parse(shortPlayId); +// logic.state.videoId = int.parse(videoId); +// logic.initData(); +// } else { +// Get.toNamed( +// AppRoutes.shortVideo, +// arguments: {'shortPlayId': int.parse(shortPlayId.toString()), "videoId": int.parse(videoId.toString())}, +// ); +// } +// } +// } catch (e) { +// debugPrint('[AdjustManager] 读取剪贴板异常: $e'); +// } +// }); +// } +// +// _initFirebase() async { +// try { +// await Firebase.initializeApp(); +// } catch (e) { +// debugPrint("----initFirebase err: $e"); +// } +// if (Platform.isIOS) { +// await FirebaseIOS().initialize(); +// } else if (Platform.isAndroid) { +// await FirebaseAndroid().initialize(); +// await FirebaseAndroid().initializeNotifications(); +// } +// // 获取初始消息(应用通过通知启动)看是否是应用消息启动 +// if (Platform.isIOS) { +// WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { +// // 看是否是消息跳进来,然后跳转到详情页面 +// RemoteMessage? remoteMessage = await FirebaseMessaging.instance.getInitialMessage(); +// debugPrint("杀死app启动通知:$remoteMessage"); +// if (remoteMessage != null) { +// final msgData = remoteMessage.data as Map; +// final msgNotification = remoteMessage.notification; +// final String? msgId = msgData['msg_id']; +// final String title = msgNotification?.title ?? ""; +// if (msgId != null) { +// HttpClient().request(Apis.sendMessageReport, data: {"message_id": int.parse(msgId), "title": title}); +// } +// FirebaseCommon().onFirebaseRoute(msgData); +// } +// }); +// } +// } +// +// // 检查通知权限 +// Future _checkNotificationPermission() async { +// final permissionStatus = await Permission.notification.status; +// if (permissionStatus.isDenied) { +// if (Platform.isAndroid) { +// //安卓第二次请求权限,再次查询剪贴板的w2a链接 +// _isAndroidTwicePermission = true; +// } +// //再次请求 +// await Permission.notification.request(); +// } else if (permissionStatus.isPermanentlyDenied) { +// int now = DateTime.now().millisecondsSinceEpoch; +// int lastRequestTime = SpUtils().getInt(SpKeys.notiPermissionTime) ?? now; +// int hours = DateTime.now().difference(DateTime.fromMillisecondsSinceEpoch(lastRequestTime)).inHours; +// if (hours < 24) return; +// SpUtils().setInt(SpKeys.notiPermissionTime, now); +// //永久拒绝 +// Get.dialog( +// CommonDialog( +// topIconWidget: Positioned( +// left: -35.w, +// top: 0.w, +// child: Image.asset('ic_dialog_subscribe.png'.icon, width: 140.w, height: 100.w), +// ), +// title: 'Turn on Notifications?', +// subTitle: 'Get alerts for new episodes and exclusive offers.', +// hasLeftBtn: false, +// rightBtnText: 'Allow', +// rightBtnFunc: () => openAppSettings(), +// ), +// ); +// } +// } +// +// _restore() async { +// await Get.put(MineLogic()).getUserInfo(); +// EasyThrottle.throttle('restore', Duration(minutes: 5), () => BuyUtils.restorePay(showTips: false)); +// } +} + +class KtMainLogic extends GetxController{ + int curIndex = 0; }