diff --git a/.gitignore b/.gitignore index 6d21af37..1146ffa9 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ doc/api/ .flutter-plugins .flutter-plugins-dependencies +.idea \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d33521..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 3ce5b9d9..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/starLock.iml b/.idea/starLock.iml deleted file mode 100644 index 43102452..00000000 --- a/.idea/starLock.iml +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddf..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/star_lock/.docker/.env.example b/star_lock/.docker/.env.example index 46afd189..bc23dbeb 100644 --- a/star_lock/.docker/.env.example +++ b/star_lock/.docker/.env.example @@ -1,7 +1,7 @@ -FLUTTER_STORAGE_BASE_URL="https://mirrors.tuna.tsinghua.edu.cn/flutter" -PUB_HOSTED_URL="https://mirrors.tuna.tsinghua.edu.cn/dart-pub" +FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter +PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub -HTTP_PROXY=http://127.0.0.1:1080/``` +HTTP_PROXY=http://127.0.0.1:1080/ HTTPS_PROXY=http://127.0.0.1:1080/ # curl只支持小写 diff --git a/star_lock/.gitignore b/star_lock/.gitignore index 24476c5d..d2b4a6eb 100644 --- a/star_lock/.gitignore +++ b/star_lock/.gitignore @@ -14,7 +14,7 @@ migrate_working_dir/ *.iml *.ipr *.iws -.idea/ +.idea # The .vscode folder contains launch configuration and tasks you configure in # VS Code which you may wish to be included in version control, so this line diff --git a/star_lock/README.md b/star_lock/README.md index 43035382..480f9ba1 100644 --- a/star_lock/README.md +++ b/star_lock/README.md @@ -30,7 +30,7 @@ flutter pub get ```bash # 运行sky渠道 -flutter run --flavor sky -t lib/main_sky.dart +flutter run --flavor sky -t lib/main_sky_full.dart ``` diff --git a/star_lock/flavorizr.yaml b/star_lock/flavorizr.yaml index f45858db..e411ad41 100644 --- a/star_lock/flavorizr.yaml +++ b/star_lock/flavorizr.yaml @@ -38,12 +38,12 @@ # 下面是4个运行示例: # flutter run --flavor dev -t lib/main_dev.dart # flutter run --flavor pre -t lib/main_pre.dart -# flutter run --flavor sky -t lib/main_sky.dart +# flutter run --flavor sky -t lib/main_sky_full.dart # flutter run --flavor xhj -t lib/main_xhj.dart # 下面是安卓发布编译命令 -# flutter build apk --split-per-abi --release --flavor sky -t lib/main_sky.dart -# flutter build apk --release --flavor sky -t lib/main_sky.dart +# flutter build apk --split-per-abi --release --flavor sky -t lib/main_sky_full.dart +# flutter build apk --release --flavor sky -t lib/main_sky_full.dart # IOS编译发布 # TODO 待补充 diff --git a/star_lock/images/main/icon_iris.png b/star_lock/images/main/icon_iris.png new file mode 100644 index 00000000..84a7c706 Binary files /dev/null and b/star_lock/images/main/icon_iris.png differ diff --git a/star_lock/images/main/icon_palm.png b/star_lock/images/main/icon_palm.png new file mode 100644 index 00000000..100b1a9e Binary files /dev/null and b/star_lock/images/main/icon_palm.png differ diff --git a/star_lock/lib/flavors.dart b/star_lock/lib/flavors.dart index cfb882c4..84e28c0b 100644 --- a/star_lock/lib/flavors.dart +++ b/star_lock/lib/flavors.dart @@ -80,7 +80,8 @@ class F { static String get apiPrefix { switch (appFlavor) { case Flavor.local: - return 'https://ge.lock.star-lock.cn'; + // return 'https://ge.lock.star-lock.cn'; // 葛工 + return 'http://192.168.1.15:8022'; // 谢工 case Flavor.dev: return 'https://dev.lock.star-lock.cn'; case Flavor.pre: @@ -90,8 +91,6 @@ class F { case Flavor.xhj: return 'https://lock.xhjcn.ltd'; default: - // "http://192.168.1.15:8022"; //谢总本地 - // "https://ge.lock.star-lock.cn"; //葛工开发环境地址 throw Exception('flavor[$name] apiPrefix not found'); } } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 93036dee..db7f7900 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter/material.dart'; @@ -678,7 +677,7 @@ class _LockDetailPageState extends State with TickerProviderStat } showWidgetArr.add( - bottomItem('images/main/icon_face.png', '虹膜', + bottomItem('images/main/icon_iris.png', '虹膜', state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.irisListPage, arguments: { "lockId": state.keyInfos.value.lockId, @@ -687,7 +686,7 @@ class _LockDetailPageState extends State with TickerProviderStat ); showWidgetArr.add( - bottomItem('images/main/icon_face.png', '手掌', + bottomItem('images/main/icon_palm.png', '手掌', state.openDoorBtnisUneable.value, state.bottomBtnisEable.value, () { Get.toNamed(Routers.palmListPage, arguments: { "lockId": state.keyInfos.value.lockId, diff --git a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart index be08e520..d4e6c733 100644 --- a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart +++ b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart @@ -21,22 +21,6 @@ class LockMonitoringLogic extends BaseGetXController { state.voiceProcessor = VoiceProcessor.instance; } - /// 收到视频流数据 - StreamSubscription? _getTVDataRefreshUIEvent; - void _getTVDataRefreshUIAction() { - // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus - _getTVDataRefreshUIEvent = - eventBus.on().listen((event) async { - if (event.tvList.isNotEmpty) { - // print('收到图片了啦啦啦啦啦啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊'); - // 预加载图片数据 - Uint8List imageData = Uint8List.fromList(event.tvList); - // 更新状态 - state.listPhotoData.value = imageData; - } - }); - } - /// 收到UDP发送的状态 StreamSubscription? _getUDPStatusRefreshUIEvent; void _getUDPStatusRefreshUIAction() { @@ -164,6 +148,7 @@ class LockMonitoringLogic extends BaseGetXController { //开始录音 Future startProcessing() async { + CallTalk().finishPcmSound(); state.isButtonDisabled.value = true; state.voiceProcessor?.addFrameListener(_onFrame); @@ -217,6 +202,8 @@ class LockMonitoringLogic extends BaseGetXController { state.isButtonDisabled.value = true; try { await state.voiceProcessor?.stop(); + state.voiceProcessor?.removeFrameListener(_onFrame); + state.udpSendDataFrameNumber = 0; } on PlatformException catch (ex) { state.errorMessage.value = "Failed to stop recorder: $ex"; } finally { @@ -309,7 +296,7 @@ class LockMonitoringLogic extends BaseGetXController { topBytes[7] = ((state.udpSendDataFrameNumber & 0x0000FF00) >> 8); // print( - // "udpSendDataFrameNumber:${state.udpSendDataFrameNumber} topBytes[63]:${topBytes[6]} topBytes[64]:${topBytes[7]}"); + // "udpSendDataFrameNumber:${state.udpSendDataFrameNumber} topBytes[63]:${topBytes[6]} topBytes[64]:${topBytes[7]}"); topBytes.addAll(bytes); Get.log("G711编码后为:$topBytes"); @@ -407,9 +394,7 @@ class LockMonitoringLogic extends BaseGetXController { void onReady() { // TODO: implement onReady super.onReady(); - print("onReady()"); - _getTVDataRefreshUIAction(); _getUDPStatusRefreshUIAction(); initRecorder(); @@ -425,10 +410,11 @@ class LockMonitoringLogic extends BaseGetXController { void onClose() { // TODO: implement onClose print("锁详情界面销毁了"); - CallTalk().stopPcmSound(); + CallTalk().finishPcmSound(); stopProcessing(); - _getTVDataRefreshUIEvent!.cancel(); _getUDPStatusRefreshUIEvent!.cancel(); + state.getTVDataRefreshUIEvent!.cancel(); + if (state.oneMinuteTimeTimer != null) { state.oneMinuteTimeTimer.cancel(); state.oneMinuteTime.value = 0; diff --git a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart index 8d5bc8ae..bc040719 100644 --- a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart +++ b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'dart:ui' as ui; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; @@ -11,6 +12,7 @@ import 'package:image_gallery_saver/image_gallery_saver.dart'; import 'package:path_provider/path_provider.dart'; import 'package:star_lock/talk/call/callTalk.dart'; import 'package:star_lock/talk/udp/udp_manage.dart'; +import 'package:star_lock/tools/eventBusEventManage.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../login/selectCountryRegion/common/index.dart'; @@ -32,6 +34,7 @@ class _LockMonitoringPageState extends State { void initState() { super.initState(); initAsync(); + _getTVDataRefreshUIAction(); } Future initAsync() async { @@ -50,23 +53,33 @@ class _LockMonitoringPageState extends State { // color: Colors.white, child: Stack( children: [ - Obx(() { - if (state.listPhotoData.value.isEmpty || - state.listPhotoData.value.length < 10) { + Image.memory( + state.listPhotoData.value, + gaplessPlayback: true, + width: 1.sw, + height: 1.sh, + fit: BoxFit.cover, + errorBuilder: (context, error, stackTrace) { return Container(color: Colors.transparent); - } else { - return Image.memory( - state.listPhotoData.value, - gaplessPlayback: true, - width: 1.sw, - height: 1.sh, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) { - return Container(color: Colors.transparent); - }, - ); - } - }), + }, + ), + // Obx(() { + // if (state.listPhotoData.value.isEmpty || + // state.listPhotoData.value.length < 10) { + // return Container(color: Colors.transparent); + // } else { + // return Image.memory( + // state.listPhotoData.value, + // gaplessPlayback: true, + // width: 1.sw, + // height: 1.sh, + // fit: BoxFit.cover, + // errorBuilder: (context, error, stackTrace) { + // return Container(color: Colors.transparent); + // }, + // ); + // } + // }), Positioned( top: ScreenUtil().statusBarHeight + 30.h, width: 1.sw, @@ -220,7 +233,7 @@ class _LockMonitoringPageState extends State { bottomBtnItemWidget( "images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async { logic.stopProcessing(); - CallTalk().stopPcmSound(); + CallTalk().finishPcmSound(); // 挂断 if (state.isClickHangUp.value == false) { logic.initiateUdpHangUpAction(3); @@ -387,9 +400,40 @@ class _LockMonitoringPageState extends State { } } + /// 收到视频流数据 + void _getTVDataRefreshUIAction() { + // 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus + state.getTVDataRefreshUIEvent = + eventBus.on().listen((event) async { + if (event.tvList.isNotEmpty && event.tvList.length > 100) { + // 比较新旧数据是否相同 + Uint8List imageData = Uint8List.fromList(event.tvList); + + if (!listEquals(state.listPhotoData.value, imageData)) { + // 更新状态 + state.listPhotoData.value = imageData; + // 设置标志为true,表示需要更新UI + state.shouldUpdateUI.value = true; + // WidgetsBinding.instance.addPostFrameCallback((_) { + // print('addPostFrameCallback'); + // 调用setState方法之前检查标志,只有当标志为true时才更新UI + if (state.shouldUpdateUI.value) { + setState(() { + // 更新UI + }); + // 更新完UI后将标志重新设置为false + state.shouldUpdateUI.value = false; + } + // }); + } + } + }); + } + @override void dispose() { super.dispose(); logic.stopProcessing(); + state.getTVDataRefreshUIEvent!.cancel(); } } diff --git a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_state.dart b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_state.dart index 90c14f8a..7b4fdfeb 100644 --- a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_state.dart +++ b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_state.dart @@ -12,6 +12,8 @@ class LockMonitoringState { var isOpenVoice = false.obs; int udpSendDataFrameNumber = 0; // 帧序号 // var isSenderAudioData = false.obs;// 是否要发送音频数据 + StreamSubscription? getTVDataRefreshUIEvent; //收到视频流数据 + var shouldUpdateUI = false.obs; //是否需要更新UI var userMobileIP = NetworkInfo().getWifiIP(); var userUid = Storage.getUid(); @@ -24,7 +26,7 @@ class LockMonitoringState { var listAudioData = [].obs; //得到的音频流字节数据 //录音相关 - late final VoiceProcessor? voiceProcessor; + late VoiceProcessor? voiceProcessor; var isProcessing = false.obs; //是否正在处理音频数据 var isButtonDisabled = false.obs; //是否禁用按钮 final int frameLength = 320; //音视频帧长度为320 diff --git a/star_lock/lib/main/lockDetail/realTimePicture/realTimePicture_logic.dart b/star_lock/lib/main/lockDetail/realTimePicture/realTimePicture_logic.dart index d963ee48..8b96f863 100644 --- a/star_lock/lib/main/lockDetail/realTimePicture/realTimePicture_logic.dart +++ b/star_lock/lib/main/lockDetail/realTimePicture/realTimePicture_logic.dart @@ -318,7 +318,7 @@ class RealTimePictureLogic extends BaseGetXController { void onClose() { // TODO: implement onClose print("锁详情界面销毁了"); - CallTalk().stopPcmSound(); + CallTalk().finishPcmSound(); _getTVDataRefreshUIEvent!.cancel(); _getUDPStatusRefreshUIEvent!.cancel(); if (state.oneMinuteTimeTimer != null) { diff --git a/star_lock/lib/main/lockDetail/realTimePicture/realTimePicture_page.dart b/star_lock/lib/main/lockDetail/realTimePicture/realTimePicture_page.dart index 13af984b..13969237 100644 --- a/star_lock/lib/main/lockDetail/realTimePicture/realTimePicture_page.dart +++ b/star_lock/lib/main/lockDetail/realTimePicture/realTimePicture_page.dart @@ -261,7 +261,7 @@ class _RealTimePicturePageState extends State "images/main/icon_lockDetail_hangUp.png", "挂断", Colors.red, () async { // 挂断 logic.udpHangUpAction(); - CallTalk().stopPcmSound(); + CallTalk().finishPcmSound(); Get.back(); }), bottomBtnItemWidget("images/main/icon_lockDetail_monitoringUnlock.png", @@ -401,7 +401,7 @@ class _RealTimePicturePageState extends State void _handleFailure() { // 在这里处理失败的逻辑 - CallTalk().stopPcmSound(); + CallTalk().finishPcmSound(); state.realTimePicTimer.cancel(); state.autoBackTimer.cancel(); if (state.animationController != null) { @@ -414,7 +414,7 @@ class _RealTimePicturePageState extends State state.animationController.dispose(); state.realTimePicTimer.cancel(); state.autoBackTimer.cancel(); - CallTalk().stopPcmSound(); + CallTalk().finishPcmSound(); super.dispose(); } } diff --git a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart index 1d81ccca..f7be6d8c 100644 --- a/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart +++ b/star_lock/lib/mine/mineSet/authorizedAdministrator/addAuthorizedAdministrator/addAuthorizedAdministrator_logic.dart @@ -1,6 +1,5 @@ import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; -import 'package:star_lock/appRouters.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/translations/trans_lib.dart'; @@ -12,6 +11,11 @@ import 'addAuthorizedAdministrator_state.dart'; class AddAuthorizedAdministratorLogic extends BaseGetXController { AddAuthorizedAdministratorState state = AddAuthorizedAdministratorState(); + bool isPhoneNumber(String input) { + // 手机号正则表达式,这里简化为11位数字 + final RegExp phoneRegExp = RegExp(r'^\d{11}$'); + return phoneRegExp.hasMatch(input); + } //发送批量授权管理员 Future addAuthorizedAdminRequest() async { if (state.emailOrPhoneController.text.isEmpty) { @@ -59,7 +63,9 @@ class AddAuthorizedAdministratorLogic extends BaseGetXController { startDate: startDate, userid: state.emailOrPhoneController.text, countryCode: state.countryCode.value, - usernameType:'1', + usernameType: isPhoneNumber(state.emailOrPhoneController.text) == true + ? '1' + : '2', ); if (entity.errorCode!.codeIsSuccessful) { print('发送电子钥匙成功'); diff --git a/star_lock/lib/starLockApplication/starLockApplication.dart b/star_lock/lib/starLockApplication/starLockApplication.dart index 25182df5..e0789be5 100644 --- a/star_lock/lib/starLockApplication/starLockApplication.dart +++ b/star_lock/lib/starLockApplication/starLockApplication.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:star_lock/flavors.dart'; import 'package:star_lock/login/login/starLock_login_page.dart'; import 'package:star_lock/tools/appFirstEnterHandle.dart'; import 'package:star_lock/debug/debug_tool.dart'; @@ -20,7 +21,9 @@ class _StarLockApplicationState extends State { super.initState(); print("StarLockApplication initState"); WidgetsBinding.instance.addPostFrameCallback((_) { - DeBug.showFloatWidget(); + if (F.debug) { + DeBug.showFloatWidget(); + } }); } diff --git a/star_lock/lib/talk/call/callTalk.dart b/star_lock/lib/talk/call/callTalk.dart index 6b9c8838..b71cdef2 100644 --- a/star_lock/lib/talk/call/callTalk.dart +++ b/star_lock/lib/talk/call/callTalk.dart @@ -146,11 +146,12 @@ class CallTalk { } //停止接收音频数据 - void stopPcmSound() { + void finishPcmSound() { // FlutterPcmSound.setup(sampleRate: 8000, channelCount: 1); FlutterPcmSound.pause(); FlutterPcmSound.clear(); FlutterPcmSound.stop(); + // print('已停止播放声音'); iframe = IframeInfo(); iframe!.iframeIndex = 0; diff --git a/star_lock/lib/talk/udp/udp_reciverData.dart b/star_lock/lib/talk/udp/udp_reciverData.dart index 49da0cf5..631cb774 100644 --- a/star_lock/lib/talk/udp/udp_reciverData.dart +++ b/star_lock/lib/talk/udp/udp_reciverData.dart @@ -203,7 +203,7 @@ class CommandUDPReciverManager { break; case 30: { - CallTalk().stopPcmSound(); + CallTalk().finishPcmSound(); // 监视结束 if ((data[7] & 0x3) == 1) { diff --git a/star_lock/lib/talk/udp/udp_talkClass.dart b/star_lock/lib/talk/udp/udp_talkClass.dart index 810b8dc6..dac2e50d 100644 --- a/star_lock/lib/talk/udp/udp_talkClass.dart +++ b/star_lock/lib/talk/udp/udp_talkClass.dart @@ -188,7 +188,7 @@ class UDPTalkClass { isBeCall = false; // isEndCall = true; // LockMonitoringState().isClickHangUp.value = false; - CallTalk().stopPcmSound(); + CallTalk().finishPcmSound(); eventBus.fire(GetUDPStatusRefreshUI(UDPTalkClass().status)); Get.back();