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

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

@ -14,6 +14,9 @@ class MeetingMineController extends GetxController {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
late final Worker _pageIndexListener;
late final Worker _originalDataListener;
bool isStatistics = true; bool isStatistics = true;
Map statistics = {}; Map statistics = {};
@ -38,18 +41,20 @@ class MeetingMineController extends GetxController {
} }
}); });
_getStatistics(); _getStatistics();
ever(_meetingController.pageIndex, (value) { _pageIndexListener = ever(_meetingController.pageIndex, (value) {
if (isStatistics && value == 2) { if (isStatistics && value == 2) {
_getStatistics(); _getStatistics();
} }
}); });
ever(_homeController.originalDataList, (value) { _originalDataListener = ever(_homeController.originalDataList, (value) {
isStatistics = true; isStatistics = true;
}); });
} }
@override @override
void onClose() { void onClose() {
_pageIndexListener.dispose();
_originalDataListener.dispose();
scrollController.dispose(); scrollController.dispose();
super.onClose(); 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; final double _width = 1.sw - 25.w;
bool isWebViewReady = false; bool isWebViewReady = false;
late final Worker _summaryNumberListener;
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
@ -150,12 +152,19 @@ class MindMapController extends GetxController {
) )
..setBackgroundColor(Colors.transparent) ..setBackgroundColor(Colors.transparent)
..loadHtmlString(html); ..loadHtmlString(html);
_summaryNumberListener =
ever(_meetingDetailsController.summaryNumberModifications, (value) { ever(_meetingDetailsController.summaryNumberModifications, (value) {
webViewController.runJavaScript( webViewController.runJavaScript(
'updateMarkmap(`${_meetingDetailsController.meetingDetails.value.summary}`)'); 'updateMarkmap(`${_meetingDetailsController.meetingDetails.value.summary}`)');
}); });
} }
@override
void onClose() {
_summaryNumberListener.dispose();
super.onClose();
}
void _messageReceived(message) async { void _messageReceived(message) async {
final String dataUrl = message.message; final String dataUrl = message.message;
final String base64Str = dataUrl.split(',').last; 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( return InkWell(
onTap: onTap, onTap: onTap,
child: Container( 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), margin: EdgeInsets.only(bottom: 10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: onTap != null ? Colors.white : Colors.grey[200], color: onTap != null ? Colors.white : Colors.grey[200],
@ -72,17 +72,20 @@ class _MoreBottomSheetState extends State<MoreBottomSheet> {
), ),
child: Row( child: Row(
children: [ children: [
Icon( Opacity(
opacity: onTap != null ? 1.0 : 0.5,
child: Icon(
icon, icon,
color: Colors.black87, color: Colors.black87,
), ),
),
10.horizontalSpace, 10.horizontalSpace,
Expanded( Expanded(
child: Text( child: Text(
title, title,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, 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( return InkWell(
onTap: onTap, onTap: onTap,
child: Container( child: Container(
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 15.w), padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: onTap != null ? null : Colors.grey[200], color: onTap != null ? null : Colors.grey[200],
border: isBorder border: isBorder
? Border( ? Border(
bottom: BorderSide( bottom: BorderSide(
width: 0.5,
color: Colors.grey[300]!, color: Colors.grey[300]!,
), ),
) )
@ -231,17 +232,20 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> {
), ),
child: Row( child: Row(
children: [ children: [
Icon( Opacity(
opacity: onTap != null ? 1.0 : 0.5,
child: Icon(
icon, icon,
color: Colors.black87, color: Colors.black87,
), ),
),
10.horizontalSpace, 10.horizontalSpace,
Expanded( Expanded(
child: Text( child: Text(
title, title,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, 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( return PopScope(
onPopInvokedWithResult: controller.popInvokedWithResult, onPopInvokedWithResult: controller.popInvokedWithResult,
child: Obx( child: Scaffold(
() => Scaffold(
backgroundColor: isDarkMode ? Colors.black : Colors.grey[50], backgroundColor: isDarkMode ? Colors.black : Colors.grey[50],
appBar: _buildAppBar(context, isDarkMode), appBar: _buildAppBar(context, isDarkMode),
body: _buildBody(isDarkMode), body: _buildBody(isDarkMode),
), ),
),
); );
} }
// 构建应用栏 // 构建应用栏
PreferredSizeWidget _buildAppBar(BuildContext context, bool isDarkMode) { PreferredSizeWidget _buildAppBar(BuildContext context, bool isDarkMode) {
return AppBar( return PreferredSize(
preferredSize: const Size.fromHeight(kToolbarHeight),
child: Obx(
() => AppBar(
backgroundColor: backgroundColor:
controller.isTop.value ? Colors.grey[50] : Colors.grey[200], controller.isTop.value ? Colors.grey[50] : Colors.grey[200],
surfaceTintColor: Colors.transparent, surfaceTintColor: Colors.transparent,
@ -69,7 +70,8 @@ class MeetingDetailsView extends GetView<MeetingDetailsController> {
), ),
title: Obx( title: Obx(
() => Opacity( () => 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( child: Container(
width: 170.w, width: 170.w,
padding: EdgeInsets.symmetric(horizontal: 2.w, vertical: 3.w), padding: EdgeInsets.symmetric(horizontal: 2.w, vertical: 3.w),
@ -104,10 +106,11 @@ class MeetingDetailsView extends GetView<MeetingDetailsController> {
width: 26.w, width: 26.w,
height: 26.w, height: 26.w,
child: CircularProgressIndicator( child: CircularProgressIndicator(
value: controller.downloadProgress.value, value:
controller.downloadProgress.value,
valueColor: valueColor:
const AlwaysStoppedAnimation<Color>( const AlwaysStoppedAnimation<
Colors.red), Color>(Colors.red),
strokeWidth: 2.w, 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> { class _SummaryTabState extends State<SummaryTab> {
final _controller = Get.find<MeetingDetailsController>(); final _controller = Get.find<MeetingDetailsController>();
late final Worker _personnelListener;
final String _addressPrefix = '地点:'; final String _addressPrefix = '地点:';
String _addressText = ''; String _addressText = '';
final String _personnelPrefix = '与会人员:'; final String _personnelPrefix = '与会人员:';
@ -44,6 +47,7 @@ class _SummaryTabState extends State<SummaryTab> {
_hasFocus = _focusNode.hasFocus; _hasFocus = _focusNode.hasFocus;
}); });
}); });
_personnelListener =
ever(_controller.personnelNumberModifications, (value) { ever(_controller.personnelNumberModifications, (value) {
_initController(); _initController();
}); });
@ -60,7 +64,9 @@ class _SummaryTabState extends State<SummaryTab> {
: '[输入与会人员]'); : '[输入与会人员]');
final markdown = const ParchmentMarkdownCodec() final markdown = const ParchmentMarkdownCodec()
.decode(_controller.meetingDetails.value.summary); .decode(_controller.meetingDetails.value.summary);
setState(() {
_fleatherController = FleatherController(document: markdown); _fleatherController = FleatherController(document: markdown);
});
} }
void _handleAddressChanged() { void _handleAddressChanged() {
@ -134,13 +140,14 @@ class _SummaryTabState extends State<SummaryTab> {
_controller.meetingDetails.value.summary = markdown; _controller.meetingDetails.value.summary = markdown;
_controller.summaryNumberModifications.value++; _controller.summaryNumberModifications.value++;
} }
_focusNode.dispose();
_fleatherController?.dispose();
} }
@override @override
void dispose() { void dispose() {
_personnelListener.dispose();
_saveSummary(); _saveSummary();
_fleatherController?.dispose();
_focusNode.dispose();
_addressController.dispose(); _addressController.dispose();
_personnelController.dispose(); _personnelController.dispose();
super.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 var isInitialized = false
private val replyTimeoutHandler = Handler(Looper.getMainLooper())
private val replyTimeoutRunnable = Runnable {
if (!isReply) {
Log.w(TAG, "命令响应超时,自动重置 isReply 为 true")
isReply = true
processNextCommand()
}
}
/** /**
* 初始化BLE服务 * 初始化BLE服务
* @param appContext 应用上下文 * @param appContext 应用上下文
@ -471,6 +480,8 @@ object BleService {
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "关闭GATT连接异常: ${e.message}", e) Log.e(TAG, "关闭GATT连接异常: ${e.message}", e)
} }
isReply = true;
commandQueue.clear()
bluetoothGatt = null bluetoothGatt = null
notifyChar = null notifyChar = null
writeChar = null writeChar = null
@ -520,6 +531,7 @@ object BleService {
newState == BluetoothProfile.STATE_DISCONNECTED -> { newState == BluetoothProfile.STATE_DISCONNECTED -> {
updateConnectionState(BleConst.STATE_DISCONNECTED) updateConnectionState(BleConst.STATE_DISCONNECTED)
disconnectGatt() disconnectGatt()
// otaManager?.onBtDeviceConnection(g.device, StateCode.CONNECTION_CONNECTING) // otaManager?.onBtDeviceConnection(g.device, StateCode.CONNECTION_CONNECTING)
// g.close() // g.close()
// otaManager?.release(); // otaManager?.release();
@ -752,19 +764,10 @@ object BleService {
} }
}" }"
) )
isReply = true; isReply = true
cmdReplyType = cmdType; cmdReplyType = cmdType
if (!commandQueue.isEmpty()) { replyTimeoutHandler.removeCallbacks(replyTimeoutRunnable) // 移除超时回调
val nextCmd = commandQueue.poll() processNextCommand()
writeChar!!.value = nextCmd
var isSeccess = bluetoothGatt?.writeCharacteristic(writeChar)
if (isSeccess == true) {
Log.d(
TAG,
"收到设备响应:"
)
}
}
// 根据命令类型处理不同的响应 // 根据命令类型处理不同的响应
when (cmdType) { when (cmdType) {
BleConst.CMD_GET_VERSION -> { BleConst.CMD_GET_VERSION -> {
@ -1385,13 +1388,16 @@ object BleService {
// 加入队列并触发发送 // 加入队列并触发发送
if (isReply) { if (isReply) {
var isSeccess = bluetoothGatt?.writeCharacteristic(writeChar) val isSuccess = bluetoothGatt?.writeCharacteristic(writeChar)
if (isSeccess == true) { if (isSuccess == true) {
isReply = false; isReply = false
cmdType; replyTimeoutHandler.postDelayed(replyTimeoutRunnable, 1000) // 设置1秒超时
return true return true
} else } else
{
commandQueue.poll()
return false return false
}
} else { } else {
commandQueue.offer(cmdPacket) 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校验值 * 计算CRC8/MAXIM校验值
*/ */
@ -1588,4 +1607,3 @@ class RecordingFile(private val context: Context) {
} }
} }
} }
Loading…
Cancel
Save