Merge branch 'master_sky' into 'develop_sky'

# Conflicts:
#   lib/blue/blue_manage.dart
This commit is contained in:
李仪 2025-05-30 06:19:57 +00:00
commit 4c9422bc5b
11 changed files with 292 additions and 91 deletions

View File

@ -29,6 +29,8 @@
<uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!--允许读设备日志,用于问题排查--> <!--允许读设备日志,用于问题排查-->
<uses-permission android:name="android.permission.READ_LOGS" /> <uses-permission android:name="android.permission.READ_LOGS" />
<!--联系人-->
<uses-permission android:name="android.permission.READ_CONTACTS" />
<!--相机--> <!--相机-->
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />

View File

@ -124,14 +124,18 @@ class BlueManage {
.eventBus! .eventBus!
.on<EventSendModel>() .on<EventSendModel>()
.listen((EventSendModel model) { .listen((EventSendModel model) {
AppLog.log('eventBus接收发送数据:${model}');
if (model.sendChannel == DataChannel.ble) { if (model.sendChannel == DataChannel.ble) {
FlutterBluePlus.isSupported.then((bool isAvailable) async { FlutterBluePlus.isSupported.then((bool isAvailable) async {
if (isAvailable) { if (isAvailable) {
if (_adapterState == BluetoothAdapterState.on) { if (_adapterState == BluetoothAdapterState.on) {
// //
AppLog.log('蓝牙已开启,开始收发送数据:${model.data}');
writeCharacteristicWithResponse(model.data); writeCharacteristicWithResponse(model.data);
} else { } else {
try {} catch (e) { try {
AppLog.log('蓝牙已关闭,停止发送数据:${model.data}');
} catch (e) {
AppLog.log('蓝牙打开失败'); AppLog.log('蓝牙打开失败');
} }
} }

View File

@ -257,15 +257,42 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
onTap: () async { onTap: () async {
final Contact? currentContact = final Contact? currentContact =
await logic.state.contactPicker.selectContact(); await logic.state.contactPicker.selectContact();
logic.state.contact = currentContact!; if (currentContact != null) {
if (currentContact.phoneNumbers!.isNotEmpty) { setState(() {
logic.state.emailOrPhoneController.text = currentContact logic.state.contact = currentContact;
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), ''); //
} if (currentContact.phoneNumbers != null &&
if (currentContact.fullName!.isNotEmpty) { currentContact.phoneNumbers!.isNotEmpty) {
logic.state.keyNameController.text = //
currentContact.fullName!; String phoneNumber = currentContact.phoneNumbers![0];
//
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
// ++
if (phoneNumber.startsWith('+')) {
phoneNumber = '+' +
phoneNumber
.substring(1)
.replaceAll(RegExp(r'[^\d]'), '');
} else {
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
}
logic.state.emailOrPhoneController.text = phoneNumber;
} else {
logic.state.emailOrPhoneController.text = '';
}
//
if (currentContact.fullName != null &&
currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
} else {
logic.state.keyNameController.text = '';
}
});
} }
}, },
), ),
@ -602,17 +629,42 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
onTap: () async { onTap: () async {
final Contact? currentContact = final Contact? currentContact =
await state.contactPicker.selectContact(); await state.contactPicker.selectContact();
setState(() { if (currentContact != null) {
state.contact = currentContact!; setState(() {
if (currentContact.phoneNumbers!.isNotEmpty) { state.contact = currentContact;
state.emailOrPhoneController.text = currentContact
.phoneNumbers![0] //
.replaceAll(RegExp(r'\s+\b|\b\s'), ''); if (currentContact.phoneNumbers != null &&
} currentContact.phoneNumbers!.isNotEmpty) {
if (currentContact.fullName!.isNotEmpty) { //
state.keyNameController.text = currentContact.fullName!; String phoneNumber = currentContact.phoneNumbers![0];
} //
}); phoneNumber =
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
// ++
if (phoneNumber.startsWith('+')) {
phoneNumber = '+' +
phoneNumber
.substring(1)
.replaceAll(RegExp(r'[^\d]'), '');
} else {
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
}
state.emailOrPhoneController.text = phoneNumber;
} else {
state.emailOrPhoneController.text = '';
}
//
if (currentContact.fullName != null &&
currentContact.fullName!.isNotEmpty) {
state.keyNameController.text = currentContact.fullName!;
} else {
state.keyNameController.text = '';
}
});
}
}, },
), ),
) )

View File

@ -286,20 +286,47 @@ class _VolumeAuthorizationLockPageState
), ),
alignment: Alignment.center, alignment: Alignment.center,
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
final Contact? currentContact = final Contact? currentContact =
await state.contactPicker.selectContact(); await logic.state.contactPicker.selectContact();
// setState(() { if (currentContact != null) {
if (currentContact!.phoneNumbers!.isNotEmpty) { setState(() {
state.emailOrPhoneController.text = currentContact logic.state.contact = currentContact;
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), ''); //
} if (currentContact.phoneNumbers != null &&
if (currentContact.fullName!.isNotEmpty) { currentContact.phoneNumbers!.isNotEmpty) {
state.keyNameController.text = currentContact.fullName!; //
} String phoneNumber = currentContact.phoneNumbers![0];
// }); //
}, phoneNumber =
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
// ++
if (phoneNumber.startsWith('+')) {
phoneNumber = '+' +
phoneNumber
.substring(1)
.replaceAll(RegExp(r'[^\d]'), '');
} else {
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
}
logic.state.emailOrPhoneController.text = phoneNumber;
} else {
logic.state.emailOrPhoneController.text = '';
}
//
if (currentContact.fullName != null &&
currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
} else {
logic.state.keyNameController.text = '';
}
});
}
},
), ),
) )
else else

View File

@ -20,6 +20,7 @@ import 'package:star_lock/tools/pickers/time_picker/model/pduration.dart';
import 'package:star_lock/tools/regularExpression.dart'; import 'package:star_lock/tools/regularExpression.dart';
import 'package:star_lock/tools/showTipView.dart'; import 'package:star_lock/tools/showTipView.dart';
import 'package:star_lock/tools/submitBtn.dart'; import 'package:star_lock/tools/submitBtn.dart';
import 'package:permission_handler/permission_handler.dart';
class SendElectronicKeyView extends StatefulWidget { class SendElectronicKeyView extends StatefulWidget {
SendElectronicKeyView({required this.type, Key? key}) : super(key: key); SendElectronicKeyView({required this.type, Key? key}) : super(key: key);
@ -31,6 +32,8 @@ class SendElectronicKeyView extends StatefulWidget {
class _SendElectronicKeyViewState extends State<SendElectronicKeyView> class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
with AutomaticKeepAliveClientMixin { with AutomaticKeepAliveClientMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
@ -163,8 +166,8 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
color: Colors.white, color: Colors.white,
border: Border( border: Border(
bottom: BorderSide( bottom: BorderSide(
color: AppColors.greyLineColor, // color: AppColors.greyLineColor,
width: 2.0.h, // width: 2.0.h,
), ),
)), )),
child: Row( child: Row(
@ -174,17 +177,14 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
Expanded( Expanded(
child: TextField( child: TextField(
controller: logic.getCurrentController(1), controller: logic.getCurrentController(1),
//
maxLines: 1, maxLines: 1,
inputFormatters: <TextInputFormatter>[ inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'), FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(30), LengthLimitingTextInputFormatter(30),
], ],
// controller: _controller,
autofocus: false, autofocus: false,
textAlign: TextAlign.end, textAlign: TextAlign.end,
decoration: InputDecoration( decoration: InputDecoration(
//
hintText: rightTitle, hintText: rightTitle,
hintStyle: TextStyle(fontSize: 22.sp), hintStyle: TextStyle(fontSize: 22.sp),
focusedBorder: const OutlineInputBorder( focusedBorder: const OutlineInputBorder(
@ -205,9 +205,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic), fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
), ),
), ),
SizedBox( SizedBox(width: 10.w),
width: 10.w,
),
Container( Container(
width: 32.w, width: 32.w,
height: 32.w, height: 32.w,
@ -222,22 +220,49 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
onTap: () async { onTap: () async {
final Contact? currentContact = final Contact? currentContact =
await logic.state.contactPicker.selectContact(); await logic.state.contactPicker.selectContact();
logic.state.contact = currentContact!; if (currentContact != null) {
if (currentContact.phoneNumbers!.isNotEmpty) { setState(() {
logic.state.emailOrPhoneController.text = currentContact logic.state.contact = currentContact;
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), ''); //
} if (currentContact.phoneNumbers != null &&
if (currentContact.fullName!.isNotEmpty) { currentContact.phoneNumbers!.isNotEmpty) {
logic.state.keyNameController.text = //
currentContact.fullName!; String phoneNumber = currentContact.phoneNumbers![0];
//
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
// ++
if (phoneNumber.startsWith('+')) {
phoneNumber = '+' +
phoneNumber
.substring(1)
.replaceAll(RegExp(r'[^\d]'), '');
} else {
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
}
logic.state.emailOrPhoneController.text = phoneNumber;
} else {
logic.state.emailOrPhoneController.text = '';
}
//
if (currentContact.fullName != null &&
currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
} else {
logic.state.keyNameController.text = '';
}
});
} }
}, },
), ),
), ),
Container( Container(
color: AppColors.greyLineColor, // color: AppColors.greyLineColor,
height: 2.0.h, // height: 2.0.h,
) )
], ],
), ),
@ -616,19 +641,46 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
alignment: Alignment.center, alignment: Alignment.center,
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
final Contact? currentContact = final Contact? currentContact =
await logic.state.contactPicker.selectContact(); await logic.state.contactPicker.selectContact();
logic.state.contact = currentContact!; if (currentContact != null) {
if (currentContact.phoneNumbers!.isNotEmpty) { setState(() {
logic.state.emailOrPhoneController.text = currentContact logic.state.contact = currentContact;
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), ''); //
} if (currentContact.phoneNumbers != null &&
if (currentContact.fullName!.isNotEmpty) { currentContact.phoneNumbers!.isNotEmpty) {
logic.state.keyNameController.text = //
currentContact.fullName!; String phoneNumber = currentContact.phoneNumbers![0];
} //
}, phoneNumber =
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
// ++
if (phoneNumber.startsWith('+')) {
phoneNumber = '+' +
phoneNumber
.substring(1)
.replaceAll(RegExp(r'[^\d]'), '');
} else {
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
}
logic.state.emailOrPhoneController.text = phoneNumber;
} else {
logic.state.emailOrPhoneController.text = '';
}
//
if (currentContact.fullName != null &&
currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
} else {
logic.state.keyNameController.text = '';
}
});
}
},
), ),
) )
else else
@ -736,7 +788,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
child: Text( child: Text(
'取消'.tr, '取消'.tr,
style: TextStyle( style: TextStyle(
color: Colors.black, fontSize: ScreenUtil().setSp(24)), color: Colors.black, fontSize: 24.sp),
), ),
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
@ -779,7 +831,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
Text( Text(
titleStr, titleStr,
style: TextStyle( style: TextStyle(
fontSize: ScreenUtil().setSp(20), color: Colors.black), fontSize: 20.sp, color: Colors.black),
), ),
], ],
), ),

View File

@ -61,7 +61,7 @@ class LockDetailLogic extends BaseGetXController {
// //
if (reply is SenderReferEventRecordTimeReply && if (reply is SenderReferEventRecordTimeReply &&
state.ifCurrentScreen.value == true) { state.ifCurrentScreen.value == true) {
_replyReferEventRecordTime(reply); await _replyReferEventRecordTime(reply);
} }
}); });
} }
@ -118,7 +118,9 @@ class LockDetailLogic extends BaseGetXController {
state.animationController!.stop(); state.animationController!.stop();
// //
AppLog.log('开锁成功,开始同步所记录:getLockRecordLastUploadDataTime');
getLockRecordLastUploadDataTime(); getLockRecordLastUploadDataTime();
AppLog.log('开锁成功,结束同步所记录:getLockRecordLastUploadDataTime');
// //
if (StartChartManage().talkStatus.status == if (StartChartManage().talkStatus.status ==
TalkStatus.answeredSuccessfully) { TalkStatus.answeredSuccessfully) {
@ -340,6 +342,7 @@ class LockDetailLogic extends BaseGetXController {
reply.data.removeRange(0, 7); reply.data.removeRange(0, 7);
// 17 // 17
if (reply.data.length < 17) { if (reply.data.length < 17) {
AppLog.log('数据长度不够17:${reply.data}');
return; return;
} }
final List<List<int>> getList = splitList(reply.data, 17); final List<List<int>> getList = splitList(reply.data, 17);
@ -380,12 +383,13 @@ class LockDetailLogic extends BaseGetXController {
if (i == getList.length - 1) { if (i == getList.length - 1) {
// //
state.operateDate = operateDate; state.operateDate = time;
} }
} catch (e) { } catch (e) {
AppLog.log('操作记录:$indexList,解析失败,跳过该跳记录,进行下一条记录解析。'); AppLog.log('操作记录:$indexList,解析失败,跳过该跳记录,进行下一条记录解析。');
} }
} }
AppLog.log('上传数据长度:${uploadList.length}');
lockRecordUploadData(uploadList); lockRecordUploadData(uploadList);
if (dataLength == state.logCountPage) { if (dataLength == state.logCountPage) {
@ -512,6 +516,8 @@ class LockDetailLogic extends BaseGetXController {
}); });
BlueManage().blueSendData(BlueManage().connectDeviceName, BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async { (BluetoothConnectionState connectionState) async {
AppLog.log(
'开始发送同步锁记录命令,蓝牙状态是否链接:${connectionState == BluetoothConnectionState.connected}');
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey = final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey); await Storage.getStringList(saveBluePrivateKey);
@ -526,6 +532,8 @@ class LockDetailLogic extends BaseGetXController {
final List<int> getPublicKeyList = final List<int> getPublicKeyList =
changeStringListToIntList(publicKey!); changeStringListToIntList(publicKey!);
AppLog.log(
'发送同步锁记录命令:${BlueManage().connectDeviceName}');
IoSenderManage.senderReferEventRecordTimeCommand( IoSenderManage.senderReferEventRecordTimeCommand(
keyID: BlueManage().connectDeviceName, keyID: BlueManage().connectDeviceName,
userID: await Storage.getUid(), userID: await Storage.getUid(),
@ -604,11 +612,14 @@ class LockDetailLogic extends BaseGetXController {
final LockOperatingRecordGetLastRecordTimeEntity entity = final LockOperatingRecordGetLastRecordTimeEntity entity =
await ApiRepository.to.getLockRecordLastUploadDataTime( await ApiRepository.to.getLockRecordLastUploadDataTime(
lockId: state.keyInfos.value.lockId.toString()); lockId: state.keyInfos.value.lockId.toString());
AppLog.log('开始获取服务端所记录更新时间:${entity}');
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.operateDate = entity.data!.operateDate! ~/ 1000; state.operateDate = entity.data!.operateDate! ~/ 1000;
state.currentDate = entity.data!.currentDate! ~/ 1000; state.currentDate = entity.data!.currentDate! ~/ 1000;
AppLog.log('发送同步所记录命令:---');
senderReferEventRecordTime(); senderReferEventRecordTime();
} }
AppLog.log('结束获取服务端所记录更新时间:${entity}');
} }
// //

View File

@ -4,7 +4,7 @@ import 'flavors.dart';
import 'main.dart' as runner; import 'main.dart' as runner;
Future<void> main() async { Future<void> main() async {
F.appFlavor = Flavor.xhj; F.appFlavor = Flavor.xhj_pre;
// AppLog.log('local调用了main函数'); // AppLog.log('local调用了main函数');
await runner.main(); await runner.main();
} }

View File

@ -270,16 +270,46 @@ class _AddAuthorizedAdministratorPageState
alignment: Alignment.center, alignment: Alignment.center,
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
final Contact? currentContact = final Contact? currentContact =
await state.contactPicker.selectContact(); await logic.state.contactPicker.selectContact();
setState(() { if (currentContact != null) {
if (currentContact!.phoneNumbers!.isNotEmpty) { setState(() {
state.emailOrPhoneController.text = currentContact logic.state.contact = currentContact;
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), ''); //
if (currentContact.phoneNumbers != null &&
currentContact.phoneNumbers!.isNotEmpty) {
//
String phoneNumber = currentContact.phoneNumbers![0];
//
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
// ++
if (phoneNumber.startsWith('+')) {
phoneNumber = '+' +
phoneNumber
.substring(1)
.replaceAll(RegExp(r'[^\d]'), '');
} else {
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
}
logic.state.emailOrPhoneController.text = phoneNumber;
} else {
logic.state.emailOrPhoneController.text = '';
}
//
if (currentContact.fullName != null &&
currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
} else {
logic.state.keyNameController.text = '';
}
});
} }
}); },
},
), ),
) )
else else

View File

@ -146,14 +146,37 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
), ),
GestureDetector( GestureDetector(
onTap: () async { onTap: () async {
Contact? currentContact = await state.contactPicker.selectContact(); final Contact? currentContact =
state.contact = currentContact!; await logic.state.contactPicker.selectContact();
if (currentContact.phoneNumbers!.isNotEmpty) { if (currentContact != null) {
state.numberController.text = currentContact setState(() {
.phoneNumbers![0] logic.state.contact = currentContact;
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
} //
}, if (currentContact.phoneNumbers != null &&
currentContact.phoneNumbers!.isNotEmpty) {
//
String phoneNumber = currentContact.phoneNumbers![0];
//
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[\s\(\)\-]'), '');
// ++
if (phoneNumber.startsWith('+')) {
phoneNumber = '+' +
phoneNumber
.substring(1)
.replaceAll(RegExp(r'[^\d]'), '');
} else {
phoneNumber =
phoneNumber.replaceAll(RegExp(r'[^\d]'), '');
}
logic.state.numberController.text = phoneNumber;
} else {
logic.state.numberController.text = '';
}
});
}
},
child: Image.asset( child: Image.asset(
'images/icon_addressBook.png', 'images/icon_addressBook.png',
width: 28.w, width: 28.w,

View File

@ -4,7 +4,7 @@ import 'package:star_lock/talk/starChart/constant/talk_status.dart';
class StartChartTalkStatus { class StartChartTalkStatus {
// //
TalkStatus _status = TalkStatus.uninitialized; TalkStatus _status = TalkStatus.none;
// //
StartChartTalkStatus._(); StartChartTalkStatus._();

View File

@ -158,7 +158,7 @@ dependencies:
# 选择日期时间 # 选择日期时间
flutter_cupertino_datetime_picker: ^3.0.0 flutter_cupertino_datetime_picker: ^3.0.0
# 选择原生通讯录 # 选择原生通讯录
flutter_native_contact_picker: ^0.0.4 flutter_native_contact_picker: 0.0.7
#底部弹出选择器 #底部弹出选择器
flutter_picker: ^2.1.0 flutter_picker: ^2.1.0
#生成二维码 #生成二维码