Merge remote-tracking branch 'origin/master'

This commit is contained in:
葛佳祥 2024-03-22 15:27:39 +08:00
commit f8a989939b
9 changed files with 200 additions and 274 deletions

View File

@ -1,17 +1,13 @@
// import 'package:aliyun_push/aliyun_push.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/tools/app_manager.dart';
import 'package:star_lock/tools/bindings/app_binding.dart';
import 'package:star_lock/tools/storage.dart';
// import 'package:star_lock/tools/storage.dart';
// import 'package:star_lock/tools/xs_aliyunPush.dart';
import 'package:star_lock/tools/xs_jPhush.dart';
import 'package:star_lock/translations/app_dept.dart';
import 'package:star_lock/translations/trans_lib.dart';
@ -32,8 +28,6 @@ class MyApp extends StatefulWidget {
// final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
final JPush jpush = JPush();
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
@ -106,7 +100,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
super.initState();
WidgetsBinding.instance.addObserver(this);
initJPushService();
XSJPushProvider().initJPushService();
}
@override
@ -114,43 +108,6 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
Future<void> initJPushService() async {
final data = await Storage.getString(saveUserLoginData);
if (data != null && data.isNotEmpty) {
jpush.setup(
appKey: "7ff37d174c1a568a89e98dad",
channel: "flutter_channel",
production: false,
debug: true,
);
jpush.addEventHandler(
//
onReceiveNotification: (Map<String, dynamic> message) async {
print("flutter onReceiveNotification: $message");
},
//
onOpenNotification: (Map<String, dynamic> message) async {
print("flutter onOpenNotification: $message");
},
//
onReceiveMessage: (Map<String, dynamic> message) async {
print("flutter onReceiveMessage: $message");
},
);
jpush.applyPushAuthority(
const NotificationSettingsIOS(sound: true, alert: true, badge: true));
// jpush.setChannelAndSound(
// channel: "flutter_channel", channelID: "115700", sound: "default");
// Platform messages may fail, so we use a try/catch PlatformException.
jpush.getRegistrationID().then((rid) {
print("flutter get registration id : $rid");
});
}
}
}
void openBlueScan() {

View File

@ -716,7 +716,8 @@ class _LockDetailPageState extends State<LockDetailPage>
// arguments: {"keyInfo": state.keyInfos.value});
// })
var endWiddget = [
var endWiddget = <Widget>[];
endWiddget.add(
//
bottomItem(
'images/main/icon_main_operatingRecord.png',
@ -728,15 +729,19 @@ class _LockDetailPageState extends State<LockDetailPage>
Get.toNamed(Routers.doorLockLogPage,
arguments: {"keyInfo": state.keyInfos.value});
}),
//
bottomItem(
);
if (state.keyInfos.value.lockFeature!.d3Face == 1) {
//
endWiddget.add(bottomItem(
'images/main/icon_lockDetail_videoLog.png',
TranslationLoader.lanKeys!.videoLog!.tr,
state.openDoorBtnisUneable.value,
state.bottomBtnisEable.value, () {
//
Get.toNamed(Routers.videoLogPage);
}),
}));
}
endWiddget.add(
//
bottomItem(
'images/main/icon_lockDetail_messageReminding.png',
@ -745,6 +750,9 @@ class _LockDetailPageState extends State<LockDetailPage>
state.bottomBtnisEable.value, () {
Get.toNamed(Routers.msgNotificationPage);
}),
);
endWiddget.add(
//
bottomItem(
'images/main/icon_main_set.png',
@ -757,7 +765,7 @@ class _LockDetailPageState extends State<LockDetailPage>
"isOnlyOneData": state.isOnlyOneData,
});
}),
];
);
showWidgetArr.addAll(endWiddget);
return showWidgetArr;
}

View File

@ -20,6 +20,13 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
final logic = Get.put(LockMonitoringLogic());
final state = Get.find<LockMonitoringLogic>().state;
@override
void initState() {
super.initState();
requestMicrophonePermission();
}
@override
Widget build(BuildContext context) {
return SizedBox(
@ -155,18 +162,9 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
Widget bottomBottomBtnWidget() {
return Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
//
Obx(() => bottomBtnItemWidget(getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async {
//
await logic.getPermissionStatus().then((value) async {
if (!value) {
return;
}
// state.isSenderAudioData.value = false;
print("发送接听了");
//
logic.udpAnswerAction();
});
Obx(() => bottomBtnItemWidget(
getAnswerBtnImg(), getAnswerBtnName(), Colors.white, () async {
logic.udpAnswerAction();
}, longPress: () {
//
print("onLongPress");
@ -292,6 +290,19 @@ class _LockMonitoringPageState extends State<LockMonitoringPage> {
);
}
//
Future requestMicrophonePermission() async {
await logic.getPermissionStatus().then((value) async {
if (!value) {
return;
}
// state.isSenderAudioData.value = false;
print("发送接听了");
//
});
}
@override
void dispose() {
super.dispose();

View File

@ -1,4 +1,3 @@
import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
@ -14,27 +13,27 @@ import 'lockMain_state.dart';
class LockMainLogic extends BaseGetXController {
final LockMainState state = LockMainState();
Future<LockListInfoEntity> getStarLockInfo() async{
Future<LockListInfoEntity> getStarLockInfo() async {
LockListInfoEntity entity = await ApiRepository.to.getStarLockListInfo(
pageNo:pageNo,
pageSize:50,
pageNo: pageNo,
pageSize: 50,
);
if(entity.errorCode!.codeIsSuccessful){
if(entity.data!.groupList!.isEmpty){
if (entity.errorCode!.codeIsSuccessful) {
if (entity.data!.groupList!.isEmpty) {
state.dataLength.value = 0;
}else if(entity.data!.groupList!.length == 1){
} else if (entity.data!.groupList!.length == 1) {
GroupList groupList = entity.data!.groupList![0];
if(groupList.lockList!.length > 1){
if (groupList.lockList!.length > 1) {
state.dataLength.value = 2;
}else{
} else {
state.dataLength.value = 1;
}
}else{
} else {
state.dataLength.value = 2;
}
state.lockListInfoEntity.value = entity;
// return entity.data!;
}else{
} else {
print("首页锁列表请求失败");
state.dataLength.value = 0;
}
@ -70,7 +69,8 @@ class LockMainLogic extends BaseGetXController {
connectListener() async {
Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
print("设置网络切换监听:$result");
if(state.networkConnectionStatus.value == 0 && result != ConnectivityResult.none){
if (state.networkConnectionStatus.value == 0 &&
result != ConnectivityResult.none) {
//
state.networkConnectionStatus.value = 1;
getStarLockInfo();
@ -85,7 +85,7 @@ class LockMainLogic extends BaseGetXController {
print("onReady()");
// UDP
// UdpHelp().openUDP();
UdpHelp().openUDP();
BlueManage();
}
@ -112,5 +112,4 @@ class LockMainLogic extends BaseGetXController {
// _teamEvent.cancel();
// state.timer.cancel();
}
}
}

View File

@ -1,3 +1,4 @@
import 'dart:ffi';
import 'dart:io';
import 'package:flutter/material.dart';
@ -32,6 +33,8 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
super.initState();
WidgetsBinding.instance.addObserver(this); //
logic.getUserInfoRequest();
_checkCameraPermission();
_checkPhotoPermission();
}
@override
@ -40,15 +43,15 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
super.dispose();
}
//
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.resumed) {
//
checkCameraPermission();
}
}
// //
// @override
// void didChangeAppLifecycleState(AppLifecycleState state) {
// super.didChangeAppLifecycleState(state);
// if (state == AppLifecycleState.resumed) {
// //
// checkCameraPermission();
// }
// }
@override
Widget build(BuildContext context) {
@ -193,34 +196,58 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
));
}
Future<void> requestCameraPermission() async {
var status = await Permission.camera.status;
// Future<void> requestCameraPermission() async {
// var status = await Permission.camera.status;
// if (status.isGranted) {
// selectCamera();
// } else {
// status = await Permission.camera.request();
// if (status.isGranted) {
// selectCamera();
// } else {
// showPermissionDeniedDialog();
// }
// }
// }
Future<void> _requestCameraPermission() async {
var status = await Permission.camera.request();
if (status.isGranted) {
selectCamera();
setState(() {
state.hasCameraPermission.value = true; //
});
} else {
status = await Permission.camera.request();
if (status.isGranted) {
selectCamera();
} else {
showPermissionDeniedDialog();
}
//
showPermissionDeniedDialog();
}
}
Future<void> requestPhotoPermission() async {
var status = await Permission.photos.status;
Future<void> _requestPhotoPermission() async {
var status = await Permission.photos.request();
if (status.isGranted) {
selectImage();
setState(() {
state.hasPhotoPermission.value = true; //
});
} else {
status = await Permission.photos.request();
if (status.isGranted) {
selectImage();
} else {
showPermissionDeniedDialog();
}
//
showPermissionDeniedDialog();
}
}
// Future<void> requestPhotoPermission() async {
// var status = await Permission.photos.status;
// if (status.isGranted) {
// selectImage();
// } else {
// status = await Permission.photos.request();
// if (status.isGranted) {
// selectImage();
// } else {
// showPermissionDeniedDialog();
// }
// }
// }
//
void showPermissionDeniedDialog() {
showDialog(
@ -256,11 +283,13 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
int getSelectIndex = value;
if (getSelectIndex == 0) {
//
// selectCamera();
requestCameraPermission();
state.hasCameraPermission.value == true
? selectCamera()
: _requestCameraPermission();
} else if (getSelectIndex == 1) {
// selectImage();
requestPhotoPermission();
state.hasPhotoPermission.value == true
? selectImage()
: _requestPhotoPermission();
}
},
);
@ -297,41 +326,29 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage>
}
}
Future<void> checkCameraPermission() async {
Future<void> _checkCameraPermission() async {
var status = await Permission.camera.status;
if (status.isGranted) {
//
} else if (status.isPermanentlyDenied || status.isDenied) {
//
setState(() {
state.hasCameraPermission.value = true; //
});
} else {
setState(() {
state.hasCameraPermission.value = false; //
});
}
}
Future<void> checkPhotosPermission() async {
Future<void> _checkPhotoPermission() async {
var status = await Permission.photos.status;
if (status.isGranted) {
//
} else if (status.isPermanentlyDenied || status.isDenied) {
//
setState(() {
state.hasPhotoPermission.value = true; //
});
} else {
setState(() {
state.hasPhotoPermission.value = false; //
});
}
}
// child: state.mineInfoData.value.headUrl != null
// ? CachedNetworkImage(
// imageUrl: Uri.encodeFull(
// state.mineInfoData.value.headUrl!),
// width: 72.w,
// height: 72.w,
// fit: BoxFit.fill,
// placeholder: (context, url) => Image.asset(
// 'images/controls_user.png',
// width: 72.w,
// height: 72.w,
// fit: BoxFit.fill,
// ))
// : Image.asset(
// 'images/controls_user.png',
// width: 72.w,
// height: 72.w,
// fit: BoxFit.fill,
// ),
}

View File

@ -12,4 +12,7 @@ class MinePersonInfoState {
List<XFile>? imageList;
// 使ImagePicker前必须先实例化
final ImagePicker imagePicker = ImagePicker();
var hasPhotoPermission = false.obs; //
var hasCameraPermission = false.obs; //
}

View File

@ -2,6 +2,8 @@ import 'dart:async';
import 'package:audioplayers/audioplayers.dart';
import 'package:fast_gbk/fast_gbk.dart';
import 'package:get/get.dart';
import 'package:star_lock/main/lockDetail/monitoring/monitoring/lockMonitoring_logic.dart';
import 'package:star_lock/talk/call/callTalk.dart';
import '../../appRouters.dart';
import '../../tools/storage.dart';
import 'udp_manage.dart';
@ -68,6 +70,10 @@ class UDPTalkClass {
Get.toNamed(Routers.lockMonitoringPage, arguments: {"lockId": "111"});
}
Timer(const Duration(minutes: 1), () {
stopLocalAudio();
callNoAnswer();
});
playLocalAudio();
} else {
@ -127,4 +133,13 @@ class UDPTalkClass {
audioPlayer.setReleaseMode(ReleaseMode.loop);
await audioPlayer.stop();
}
//
void callNoAnswer() {
CallTalk().stopPcmSound();
//
LockMonitoringLogic().udpHangUpAction();
//
Get.back();
}
}

View File

@ -1,137 +0,0 @@
/*
import 'dart:io';
import 'package:aliyun_push/aliyun_push.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
class XSAliyunPushProvider {
late AliyunPush _aliyunPush = AliyunPush();
Future<void> init(AliyunPush aliyunPush) async {
_aliyunPush = aliyunPush;
if (Platform.isAndroid) {
_aliyunPush.createAndroidChannel('1', '测试通道A', 3, '测试创建通知通道');
_aliyunPush.setAndroidLogLevel(kAliyunPushLogLevelError);
}
_addPushCallback();
}
Future<void> _onNotification(Map<dynamic, dynamic> message) async {
// print('onNotification: $message');
}
Future<void> _onAndroidNotificationReceivedInApp(
Map<dynamic, dynamic> message) async {
// print('onAndroidNotificationReceivedInApp: $message');
}
Future<void> _onMessage(Map<dynamic, dynamic> message) async {
// print('onMessage: $message');
}
Future<void> _onNotificationOpened(Map<dynamic, dynamic> message) async {
// print('onNotificationOpened: $message');
}
Future<void> _onNotificationRemoved(Map<dynamic, dynamic> message) async {
// print('onNotificationRemoved: $message');
}
Future<void> _onAndroidNotificationClickedWithNoAction(
Map<dynamic, dynamic> message) async {
// print('onAndroidNotificationClickedWithNoAction: $message');
}
Future<void> _onIOSChannelOpened(Map<dynamic, dynamic> message) async {}
Future<void> _onIOSRegisterDeviceTokenSuccess(
Map<dynamic, dynamic> message) async {
// Toast.show(msg: 'APNs注册成功, $message');
}
Future<void> _onIOSRegisterDeviceTokenFailed(
Map<dynamic, dynamic> message) async {
// Toast.show(msg: '注册APNs失败, errorMsg: $message');
}
_addPushCallback() {
_aliyunPush.addMessageReceiver(
onNotification: _onNotification,
onNotificationOpened: _onNotificationOpened,
onNotificationRemoved: _onNotificationRemoved,
onMessage: _onMessage,
onAndroidNotificationReceivedInApp: _onAndroidNotificationReceivedInApp,
onAndroidNotificationClickedWithNoAction:
_onAndroidNotificationClickedWithNoAction,
onIOSChannelOpened: _onIOSChannelOpened,
onIOSRegisterDeviceTokenSuccess: _onIOSRegisterDeviceTokenSuccess,
onIOSRegisterDeviceTokenFailed: _onIOSRegisterDeviceTokenFailed);
}
Future<void> initAliyunPush() async {
String appKey;
String appSecret;
if (Platform.isIOS) {
if (F.appFlavor == Flavor.sky) {
appKey = "334068745";
appSecret = "bee9c200835e4951a85dc8709c319560";
} else {
appKey = "333904046";
appSecret = "3eead09a7fc7416cb4082319aa6f48c6";
}
} else {
if (F.appFlavor == Flavor.sky) {
appKey = "334068743";
appSecret = "64de537f14984159a66ada10e54c6b63";
} else {
appKey = "333904040";
appSecret = "c316965fe0a74fc9a481a5c44a535dc2";
}
}
_aliyunPush
.initPush(appKey: appKey, appSecret: appSecret)
.then((initResult) {
var code = initResult['code'];
if (code == kAliyunPushSuccessCode) {
// Toast.show(msg: "初始化推送成功");
} else {
String errorMsg = initResult['errorMsg'];
// print('初始化推送失败,原因为:$errorMsg');
// Toast.show(msg: '初始化推送失败, errorMsg: $errorMsg.}');
}
});
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
}
Future<void> initAliyunThirdPush() async {
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
_aliyunPush.initAndroidThirdPush().then((initResult) {
var code = initResult['code'];
if (code == kAliyunPushSuccessCode) {
// Toast.show(msg: "初始化辅助通道成功");
} else {
String errorMsg = initResult['errorMsg'];
// Toast.show(msg: '初始化辅助通道成功, errorMsg: $errorMsg');
// print("初始化辅助通道失败,原因为:$errorMsg");
}
});
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
}
void pushBindDeviceID(String deviceID, int deviceType) async {
var entity = await ApiRepository.to.pushBindAppId(deviceID, deviceType);
if (entity.errorCode!.codeIsSuccessful) {}
}
}
*/

View File

@ -0,0 +1,53 @@
import 'dart:io';
import 'package:jpush_flutter/jpush_flutter.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/storage.dart';
class XSJPushProvider {
final JPush jpush = JPush();
Future<void> initJPushService() async {
final data = await Storage.getString(saveUserLoginData);
if (data != null && data.isNotEmpty) {
jpush.setup(
appKey: "7ff37d174c1a568a89e98dad",
channel: "flutter_channel",
production: false,
debug: true,
);
jpush.addEventHandler(
//
onReceiveNotification: (Map<String, dynamic> message) async {
print("flutter onReceiveNotification: $message");
},
//
onOpenNotification: (Map<String, dynamic> message) async {
print("flutter onOpenNotification: $message");
},
//
onReceiveMessage: (Map<String, dynamic> message) async {
print("flutter onReceiveMessage: $message");
},
);
jpush.applyPushAuthority(
const NotificationSettingsIOS(sound: true, alert: true, badge: true));
// jpush.setChannelAndSound(
// channel: "flutter_channel", channelID: "115700", sound: "default");
// Platform messages may fail, so we use a try/catch PlatformException.
jpush.getRegistrationID().then((rid) {
print("flutter get registration id : $rid");
pushBindDeviceID(rid, Platform.isAndroid ? 10 : 20);
});
}
}
void pushBindDeviceID(String deviceID, int deviceType) async {
var entity = await ApiRepository.to.pushBindAppId(deviceID, deviceType);
if (entity.errorCode!.codeIsSuccessful) {}
}
}