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.READ_LOGS" />
<!--联系人-->
<uses-permission android:name="android.permission.READ_CONTACTS" />
<!--相机-->
<uses-permission android:name="android.permission.CAMERA" />

View File

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

View File

@ -257,15 +257,42 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
onTap: () async {
final Contact? currentContact =
await logic.state.contactPicker.selectContact();
logic.state.contact = currentContact!;
if (currentContact.phoneNumbers!.isNotEmpty) {
logic.state.emailOrPhoneController.text = currentContact
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
}
if (currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
if (currentContact != null) {
setState(() {
logic.state.contact = currentContact;
//
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 = '';
}
});
}
},
),
@ -602,17 +629,42 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage>
onTap: () async {
final Contact? currentContact =
await state.contactPicker.selectContact();
setState(() {
state.contact = currentContact!;
if (currentContact.phoneNumbers!.isNotEmpty) {
state.emailOrPhoneController.text = currentContact
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
}
if (currentContact.fullName!.isNotEmpty) {
state.keyNameController.text = currentContact.fullName!;
}
});
if (currentContact != null) {
setState(() {
state.contact = currentContact;
//
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]'), '');
}
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,
child: InkWell(
onTap: () async {
final Contact? currentContact =
await state.contactPicker.selectContact();
// setState(() {
if (currentContact!.phoneNumbers!.isNotEmpty) {
state.emailOrPhoneController.text = currentContact
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
}
if (currentContact.fullName!.isNotEmpty) {
state.keyNameController.text = currentContact.fullName!;
}
// });
},
onTap: () async {
final Contact? currentContact =
await logic.state.contactPicker.selectContact();
if (currentContact != null) {
setState(() {
logic.state.contact = currentContact;
//
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

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/showTipView.dart';
import 'package:star_lock/tools/submitBtn.dart';
import 'package:permission_handler/permission_handler.dart';
class SendElectronicKeyView extends StatefulWidget {
SendElectronicKeyView({required this.type, Key? key}) : super(key: key);
@ -31,6 +32,8 @@ class SendElectronicKeyView extends StatefulWidget {
class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
with AutomaticKeepAliveClientMixin {
@override
Widget build(BuildContext context) {
super.build(context);
@ -163,8 +166,8 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
color: Colors.white,
border: Border(
bottom: BorderSide(
color: AppColors.greyLineColor, //
width: 2.0.h, //
color: AppColors.greyLineColor,
width: 2.0.h,
),
)),
child: Row(
@ -174,17 +177,14 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
Expanded(
child: TextField(
controller: logic.getCurrentController(1),
//
maxLines: 1,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.deny('\n'),
LengthLimitingTextInputFormatter(30),
],
// controller: _controller,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(
//
hintText: rightTitle,
hintStyle: TextStyle(fontSize: 22.sp),
focusedBorder: const OutlineInputBorder(
@ -205,9 +205,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
fontSize: 22.sp, textBaseline: TextBaseline.alphabetic),
),
),
SizedBox(
width: 10.w,
),
SizedBox(width: 10.w),
Container(
width: 32.w,
height: 32.w,
@ -222,22 +220,49 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
onTap: () async {
final Contact? currentContact =
await logic.state.contactPicker.selectContact();
logic.state.contact = currentContact!;
if (currentContact.phoneNumbers!.isNotEmpty) {
logic.state.emailOrPhoneController.text = currentContact
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
}
if (currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
if (currentContact != null) {
setState(() {
logic.state.contact = currentContact;
//
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 = '';
}
});
}
},
),
),
Container(
color: AppColors.greyLineColor, //
height: 2.0.h, //
color: AppColors.greyLineColor,
height: 2.0.h,
)
],
),
@ -616,19 +641,46 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
alignment: Alignment.center,
child: InkWell(
onTap: () async {
final Contact? currentContact =
await logic.state.contactPicker.selectContact();
logic.state.contact = currentContact!;
if (currentContact.phoneNumbers!.isNotEmpty) {
logic.state.emailOrPhoneController.text = currentContact
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
}
if (currentContact.fullName!.isNotEmpty) {
logic.state.keyNameController.text =
currentContact.fullName!;
}
},
final Contact? currentContact =
await logic.state.contactPicker.selectContact();
if (currentContact != null) {
setState(() {
logic.state.contact = currentContact;
//
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
@ -736,7 +788,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
child: Text(
'取消'.tr,
style: TextStyle(
color: Colors.black, fontSize: ScreenUtil().setSp(24)),
color: Colors.black, fontSize: 24.sp),
),
onPressed: () {
Navigator.pop(context);
@ -779,7 +831,7 @@ class _SendElectronicKeyViewState extends State<SendElectronicKeyView>
Text(
titleStr,
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 &&
state.ifCurrentScreen.value == true) {
_replyReferEventRecordTime(reply);
await _replyReferEventRecordTime(reply);
}
});
}
@ -118,7 +118,9 @@ class LockDetailLogic extends BaseGetXController {
state.animationController!.stop();
//
AppLog.log('开锁成功,开始同步所记录:getLockRecordLastUploadDataTime');
getLockRecordLastUploadDataTime();
AppLog.log('开锁成功,结束同步所记录:getLockRecordLastUploadDataTime');
//
if (StartChartManage().talkStatus.status ==
TalkStatus.answeredSuccessfully) {
@ -340,6 +342,7 @@ class LockDetailLogic extends BaseGetXController {
reply.data.removeRange(0, 7);
// 17
if (reply.data.length < 17) {
AppLog.log('数据长度不够17:${reply.data}');
return;
}
final List<List<int>> getList = splitList(reply.data, 17);
@ -380,12 +383,13 @@ class LockDetailLogic extends BaseGetXController {
if (i == getList.length - 1) {
//
state.operateDate = operateDate;
state.operateDate = time;
}
} catch (e) {
AppLog.log('操作记录:$indexList,解析失败,跳过该跳记录,进行下一条记录解析。');
}
}
AppLog.log('上传数据长度:${uploadList.length}');
lockRecordUploadData(uploadList);
if (dataLength == state.logCountPage) {
@ -512,6 +516,8 @@ class LockDetailLogic extends BaseGetXController {
});
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
AppLog.log(
'开始发送同步锁记录命令,蓝牙状态是否链接:${connectionState == BluetoothConnectionState.connected}');
if (connectionState == BluetoothConnectionState.connected) {
final List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
@ -526,6 +532,8 @@ class LockDetailLogic extends BaseGetXController {
final List<int> getPublicKeyList =
changeStringListToIntList(publicKey!);
AppLog.log(
'发送同步锁记录命令:${BlueManage().connectDeviceName}');
IoSenderManage.senderReferEventRecordTimeCommand(
keyID: BlueManage().connectDeviceName,
userID: await Storage.getUid(),
@ -604,11 +612,14 @@ class LockDetailLogic extends BaseGetXController {
final LockOperatingRecordGetLastRecordTimeEntity entity =
await ApiRepository.to.getLockRecordLastUploadDataTime(
lockId: state.keyInfos.value.lockId.toString());
AppLog.log('开始获取服务端所记录更新时间:${entity}');
if (entity.errorCode!.codeIsSuccessful) {
state.operateDate = entity.data!.operateDate! ~/ 1000;
state.currentDate = entity.data!.currentDate! ~/ 1000;
AppLog.log('发送同步所记录命令:---');
senderReferEventRecordTime();
}
AppLog.log('结束获取服务端所记录更新时间:${entity}');
}
//

View File

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

View File

@ -270,16 +270,46 @@ class _AddAuthorizedAdministratorPageState
alignment: Alignment.center,
child: InkWell(
onTap: () async {
final Contact? currentContact =
await state.contactPicker.selectContact();
setState(() {
if (currentContact!.phoneNumbers!.isNotEmpty) {
state.emailOrPhoneController.text = currentContact
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
final Contact? currentContact =
await logic.state.contactPicker.selectContact();
if (currentContact != null) {
setState(() {
logic.state.contact = currentContact;
//
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

View File

@ -146,14 +146,37 @@ class _RecipientInformationPageState extends State<RecipientInformationPage> {
),
GestureDetector(
onTap: () async {
Contact? currentContact = await state.contactPicker.selectContact();
state.contact = currentContact!;
if (currentContact.phoneNumbers!.isNotEmpty) {
state.numberController.text = currentContact
.phoneNumbers![0]
.replaceAll(RegExp(r'\s+\b|\b\s'), '');
}
},
final Contact? currentContact =
await logic.state.contactPicker.selectContact();
if (currentContact != null) {
setState(() {
logic.state.contact = currentContact;
//
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(
'images/icon_addressBook.png',
width: 28.w,

View File

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

View File

@ -158,7 +158,7 @@ dependencies:
# 选择日期时间
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
#生成二维码