Browse Source

Merge branch 'new_dev' of https://github.com/deepcloud2048/deep_voice into new_dev

weicu
lxm 1 year ago
parent
commit
8a187945db
  1. 5
      lib/modules/meeting/controllers/meeting_details_controller.dart
  2. 9
      lib/modules/meeting/controllers/meeting_mine_controller.dart
  3. 9
      lib/modules/meeting/controllers/mind_map_controller.dart
  4. 9
      lib/modules/meeting/views/bottomSheet/more_bottom_sheet.dart
  5. 10
      lib/modules/meeting/views/bottomSheet/share_bottom_sheet.dart
  6. 21
      lib/modules/meeting/views/meeting_details_view.dart
  7. 11
      lib/modules/meeting/views/tabs/summary_tab.dart
  8. 54
      local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleService.kt

5
lib/modules/meeting/controllers/meeting_details_controller.dart

@ -25,6 +25,8 @@ class MeetingDetailsController extends GetxController
late AnimationController lottieController;
late final Worker _tasktypeListener;
final _meetingUploadService = Get.find<MeetingUploadService>();
final _meetingTaskService = Get.find<MeetingTaskService>();
@ -84,7 +86,7 @@ class MeetingDetailsController extends GetxController
_meetingTaskService.meetingId = id;
_getDataDetails();
_loadJS();
ever(_meetingTaskService.tasktype, (value) {
_tasktypeListener = ever(_meetingTaskService.tasktype, (value) {
meetingDetails.value.tasktype = value;
if (_everType <= value) {
if (value == 2) {
@ -101,6 +103,7 @@ class MeetingDetailsController extends GetxController
@override
void onClose() {
_tasktypeListener.dispose();
_currentDurationSubscription?.cancel();
_playerStateSubscription?.cancel();
tabController.dispose();

9
lib/modules/meeting/controllers/meeting_mine_controller.dart

@ -14,6 +14,9 @@ class MeetingMineController extends GetxController {
final ScrollController scrollController = ScrollController();
late final Worker _pageIndexListener;
late final Worker _originalDataListener;
bool isStatistics = true;
Map statistics = {};
@ -38,18 +41,20 @@ class MeetingMineController extends GetxController {
}
});
_getStatistics();
ever(_meetingController.pageIndex, (value) {
_pageIndexListener = ever(_meetingController.pageIndex, (value) {
if (isStatistics && value == 2) {
_getStatistics();
}
});
ever(_homeController.originalDataList, (value) {
_originalDataListener = ever(_homeController.originalDataList, (value) {
isStatistics = true;
});
}
@override
void onClose() {
_pageIndexListener.dispose();
_originalDataListener.dispose();
scrollController.dispose();
super.onClose();
}

9
lib/modules/meeting/controllers/mind_map_controller.dart

@ -18,6 +18,8 @@ class MindMapController extends GetxController {
final double _width = 1.sw - 25.w;
bool isWebViewReady = false;
late final Worker _summaryNumberListener;
@override
void onInit() {
super.onInit();
@ -150,12 +152,19 @@ class MindMapController extends GetxController {
)
..setBackgroundColor(Colors.transparent)
..loadHtmlString(html);
_summaryNumberListener =
ever(_meetingDetailsController.summaryNumberModifications, (value) {
webViewController.runJavaScript(
'updateMarkmap(`${_meetingDetailsController.meetingDetails.value.summary}`)');
});
}
@override
void onClose() {
_summaryNumberListener.dispose();
super.onClose();
}
void _messageReceived(message) async {
final String dataUrl = message.message;
final String base64Str = dataUrl.split(',').last;

9
lib/modules/meeting/views/bottomSheet/more_bottom_sheet.dart

@ -64,7 +64,7 @@ class _MoreBottomSheetState extends State<MoreBottomSheet> {
return InkWell(
onTap: onTap,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 15.w),
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
margin: EdgeInsets.only(bottom: 10.w),
decoration: BoxDecoration(
color: onTap != null ? Colors.white : Colors.grey[200],
@ -72,17 +72,20 @@ class _MoreBottomSheetState extends State<MoreBottomSheet> {
),
child: Row(
children: [
Icon(
Opacity(
opacity: onTap != null ? 1.0 : 0.5,
child: Icon(
icon,
color: Colors.black87,
),
),
10.horizontalSpace,
Expanded(
child: Text(
title,
style: TextStyle(
fontSize: 14.sp,
color: Colors.black87,
color: Colors.black87.withOpacity(onTap != null ? 1 : 0.5),
),
),
),

10
lib/modules/meeting/views/bottomSheet/share_bottom_sheet.dart

@ -218,12 +218,13 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> {
return InkWell(
onTap: onTap,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 15.w),
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
decoration: BoxDecoration(
color: onTap != null ? null : Colors.grey[200],
border: isBorder
? Border(
bottom: BorderSide(
width: 0.5,
color: Colors.grey[300]!,
),
)
@ -231,17 +232,20 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> {
),
child: Row(
children: [
Icon(
Opacity(
opacity: onTap != null ? 1.0 : 0.5,
child: Icon(
icon,
color: Colors.black87,
),
),
10.horizontalSpace,
Expanded(
child: Text(
title,
style: TextStyle(
fontSize: 14.sp,
color: Colors.black87,
color: Colors.black87.withOpacity(onTap != null ? 1 : 0.5),
),
),
),

21
lib/modules/meeting/views/meeting_details_view.dart

@ -25,19 +25,20 @@ class MeetingDetailsView extends GetView<MeetingDetailsController> {
return PopScope(
onPopInvokedWithResult: controller.popInvokedWithResult,
child: Obx(
() => Scaffold(
child: Scaffold(
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50],
appBar: _buildAppBar(context, isDarkMode),
body: _buildBody(isDarkMode),
),
),
);
}
// 构建应用栏
PreferredSizeWidget _buildAppBar(BuildContext context, bool isDarkMode) {
return AppBar(
return PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight),
child: Obx(
() => AppBar(
backgroundColor:
controller.isTop.value ? Colors.grey[50] : Colors.grey[200],
surfaceTintColor: Colors.transparent,
@ -69,7 +70,8 @@ class MeetingDetailsView extends GetView<MeetingDetailsController> {
),
title: Obx(
() => Opacity(
opacity: (1 - (controller.dragOffset.value / 100.w)).clamp(0.0, 1.0),
opacity:
(1 - (controller.dragOffset.value / 100.w)).clamp(0.0, 1.0),
child: Container(
width: 170.w,
padding: EdgeInsets.symmetric(horizontal: 2.w, vertical: 3.w),
@ -104,10 +106,11 @@ class MeetingDetailsView extends GetView<MeetingDetailsController> {
width: 26.w,
height: 26.w,
child: CircularProgressIndicator(
value: controller.downloadProgress.value,
value:
controller.downloadProgress.value,
valueColor:
const AlwaysStoppedAnimation<Color>(
Colors.red),
const AlwaysStoppedAnimation<
Color>(Colors.red),
strokeWidth: 2.w,
),
),
@ -238,6 +241,8 @@ class MeetingDetailsView extends GetView<MeetingDetailsController> {
},
),
],
),
),
);
}

11
lib/modules/meeting/views/tabs/summary_tab.dart

@ -20,6 +20,9 @@ class SummaryTab extends StatefulWidget {
class _SummaryTabState extends State<SummaryTab> {
final _controller = Get.find<MeetingDetailsController>();
late final Worker _personnelListener;
final String _addressPrefix = '地点:';
String _addressText = '';
final String _personnelPrefix = '与会人员:';
@ -44,6 +47,7 @@ class _SummaryTabState extends State<SummaryTab> {
_hasFocus = _focusNode.hasFocus;
});
});
_personnelListener =
ever(_controller.personnelNumberModifications, (value) {
_initController();
});
@ -60,7 +64,9 @@ class _SummaryTabState extends State<SummaryTab> {
: '[输入与会人员]');
final markdown = const ParchmentMarkdownCodec()
.decode(_controller.meetingDetails.value.summary);
setState(() {
_fleatherController = FleatherController(document: markdown);
});
}
void _handleAddressChanged() {
@ -134,13 +140,14 @@ class _SummaryTabState extends State<SummaryTab> {
_controller.meetingDetails.value.summary = markdown;
_controller.summaryNumberModifications.value++;
}
_focusNode.dispose();
_fleatherController?.dispose();
}
@override
void dispose() {
_personnelListener.dispose();
_saveSummary();
_fleatherController?.dispose();
_focusNode.dispose();
_addressController.dispose();
_personnelController.dispose();
super.dispose();

54
local_plugins/ble_service/android/src/main/kotlin/com/yunqiinnovation/ble_service/BleService.kt

@ -106,6 +106,15 @@ object BleService {
// 初始化状态
private var isInitialized = false
private val replyTimeoutHandler = Handler(Looper.getMainLooper())
private val replyTimeoutRunnable = Runnable {
if (!isReply) {
Log.w(TAG, "命令响应超时,自动重置 isReply 为 true")
isReply = true
processNextCommand()
}
}
/**
* 初始化BLE服务
* @param appContext 应用上下文
@ -471,6 +480,8 @@ object BleService {
} catch (e: Exception) {
Log.e(TAG, "关闭GATT连接异常: ${e.message}", e)
}
isReply = true;
commandQueue.clear()
bluetoothGatt = null
notifyChar = null
writeChar = null
@ -520,6 +531,7 @@ object BleService {
newState == BluetoothProfile.STATE_DISCONNECTED -> {
updateConnectionState(BleConst.STATE_DISCONNECTED)
disconnectGatt()
// otaManager?.onBtDeviceConnection(g.device, StateCode.CONNECTION_CONNECTING)
// g.close()
// otaManager?.release();
@ -752,19 +764,10 @@ object BleService {
}
}"
)
isReply = true;
cmdReplyType = cmdType;
if (!commandQueue.isEmpty()) {
val nextCmd = commandQueue.poll()
writeChar!!.value = nextCmd
var isSeccess = bluetoothGatt?.writeCharacteristic(writeChar)
if (isSeccess == true) {
Log.d(
TAG,
"收到设备响应:"
)
}
}
isReply = true
cmdReplyType = cmdType
replyTimeoutHandler.removeCallbacks(replyTimeoutRunnable) // 移除超时回调
processNextCommand()
// 根据命令类型处理不同的响应
when (cmdType) {
BleConst.CMD_GET_VERSION -> {
@ -1385,13 +1388,16 @@ object BleService {
// 加入队列并触发发送
if (isReply) {
var isSeccess = bluetoothGatt?.writeCharacteristic(writeChar)
if (isSeccess == true) {
isReply = false;
cmdType;
val isSuccess = bluetoothGatt?.writeCharacteristic(writeChar)
if (isSuccess == true) {
isReply = false
replyTimeoutHandler.postDelayed(replyTimeoutRunnable, 1000) // 设置1秒超时
return true
} else
{
commandQueue.poll()
return false
}
} else {
commandQueue.offer(cmdPacket)
}
@ -1403,6 +1409,19 @@ object BleService {
}
}
private fun processNextCommand() {
if (!commandQueue.isEmpty()) {
val nextCmd = commandQueue.poll()
writeChar!!.value = nextCmd
val isSuccess = bluetoothGatt?.writeCharacteristic(writeChar)
if (isSuccess == true) {
isReply = false
replyTimeoutHandler.postDelayed(replyTimeoutRunnable, 1000) // 设置1秒超时
Log.d(TAG, "发送队列中的下一个命令")
}
}
}
/**
* 计算CRC8/MAXIM校验值
*/
@ -1588,4 +1607,3 @@ class RecordingFile(private val context: Context) {
}
}
}
Loading…
Cancel
Save