Browse Source

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

newdev_shunjiawei
liwei1dao 1 year ago
parent
commit
24d1e1ded0
  1. 4
      lib/core/translations/app_translations.dart
  2. 4
      lib/data/services/bluetooth_manager.dart
  3. 2
      lib/modules/permissions/controllers/permissions_controller.dart
  4. 8
      lib/modules/settings/controllers/settings_controller.dart
  5. 46
      lib/modules/splash/views/splash_view.dart
  6. 17
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt

4
lib/core/translations/app_translations.dart

@ -186,11 +186,11 @@ class AppTranslations extends Translations {
return fallbackLocale; return fallbackLocale;
} }
return _getMatchedLocale(systemLocale); return getMatchedLocale(systemLocale);
} }
/// 智能匹配系统语言到支持的语言 /// 智能匹配系统语言到支持的语言
static Locale _getMatchedLocale(Locale systemLocale) { static Locale getMatchedLocale(Locale systemLocale) {
String languageCode = systemLocale.languageCode.toLowerCase(); String languageCode = systemLocale.languageCode.toLowerCase();
String? countryCode = systemLocale.countryCode?.toUpperCase(); String? countryCode = systemLocale.countryCode?.toUpperCase();
String? scriptCode = systemLocale.scriptCode; String? scriptCode = systemLocale.scriptCode;

4
lib/data/services/bluetooth_manager.dart

@ -76,7 +76,9 @@ class BluetoothManager extends GetxService {
currentDeviceRx.value = newDevice; currentDeviceRx.value = newDevice;
// 检查当前是否在OTA升级界面,如果是则不跳转 // 检查当前是否在OTA升级界面,如果是则不跳转
if (!_isInOtaUpgradePage() && !_bleManager.isConnected) { if (!_isInOtaUpgradePage() &&
!_bleManager.isConnected &&
Get.currentRoute != Routes.pairing) {
Get.toNamed(Routes.pairing, arguments: newDevice); Get.toNamed(Routes.pairing, arguments: newDevice);
} else { } else {
Logger.info('当前在OTA升级界面,跳过配对页面跳转'); Logger.info('当前在OTA升级界面,跳过配对页面跳转');

2
lib/modules/permissions/controllers/permissions_controller.dart

@ -184,7 +184,7 @@ class PermissionsController extends GetxController {
); );
if (hasPermission) { if (hasPermission) {
_showSuccessMessage(); // _showSuccessMessage();
if (Platform.isIOS && permission == Permission.calendarFullAccess) { if (Platform.isIOS && permission == Permission.calendarFullAccess) {
if (_isCalendarFullAccess == null) { if (_isCalendarFullAccess == null) {
_storage.write('record_permission_calendar', true); _storage.write('record_permission_calendar', true);

8
lib/modules/settings/controllers/settings_controller.dart

@ -301,9 +301,11 @@ class SettingsController extends GetxController {
} }
} }
/// 设置语言
Future<void> setLanguage(LanguageModel data) async { Future<void> setLanguage(LanguageModel data) async {
try { try {
Locale? targetLocale; Locale? targetLocale;
// print('lxm--设置语言: ${data.value}');
if (data.value != 'system') { if (data.value != 'system') {
// 用户手动选择的语言 // 用户手动选择的语言
@ -311,7 +313,11 @@ class SettingsController extends GetxController {
targetLocale = Locale(languageList[0], languageList[1]); targetLocale = Locale(languageList[0], languageList[1]);
} else { } else {
// 跟随系统语言,使用智能匹配 // 跟随系统语言,使用智能匹配
targetLocale = AppTranslations.deviceLocale(); targetLocale = Get.deviceLocale;
if (targetLocale != null) {
// 智能匹配系统语言到支持的语言
targetLocale = AppTranslations.getMatchedLocale(targetLocale);
}
} }
if (targetLocale != null) { if (targetLocale != null) {

46
lib/modules/splash/views/splash_view.dart

@ -225,7 +225,7 @@ class SplashView extends GetView<SplashController> {
children: [ children: [
// 将勾选框和文本包装在 GestureDetector 中 // 将勾选框和文本包装在 GestureDetector 中
GestureDetector( GestureDetector(
onTap: () => controller.togglePrivacyAcceptance(), //onTap: () => controller.togglePrivacyAcceptance(),
behavior: HitTestBehavior.opaque, // 确保透明区域也能响应点击 behavior: HitTestBehavior.opaque, // 确保透明区域也能响应点击
child: Row( child: Row(
children: [ children: [
@ -267,17 +267,17 @@ class SplashView extends GetView<SplashController> {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { // onTap: () {
String url = 'https://www.voitrans.net/doc/yhxy.html'; // 用户协议链接 // String url = 'https://www.voitrans.net/doc/yhxy.html'; // 用户协议链接
if (Get.locale?.languageCode != 'zh' || // if (Get.locale?.languageCode != 'zh' ||
Get.locale?.countryCode != 'CN') { // Get.locale?.countryCode != 'CN') {
url = 'https://www.voitrans.net/doc/yhxy_en.html'; // 用户协议英文链接 // url = 'https://www.voitrans.net/doc/yhxy_en.html'; // 用户协议英文链接
} // }
Get.to(() => WebViewPage( // Get.to(() => WebViewPage(
url: url, // url: url,
title: 'userAgreement'.tr, // title: 'userAgreement'.tr,
)); // ));
}, // },
child: Text( child: Text(
'userAgreement'.tr, // 《用户协议》 'userAgreement'.tr, // 《用户协议》
style: TextStyle( style: TextStyle(
@ -294,19 +294,19 @@ class SplashView extends GetView<SplashController> {
), ),
), ),
GestureDetector( GestureDetector(
onTap: () { // onTap: () {
String url = 'https://www.voitrans.net/doc/ysxy.html'; // 隐私政策链接 // String url = 'https://www.voitrans.net/doc/ysxy.html'; // 隐私政策链接
if (Get.locale?.languageCode != 'zh' || // if (Get.locale?.languageCode != 'zh' ||
Get.locale?.countryCode != 'CN') { // Get.locale?.countryCode != 'CN') {
url = 'https://www.voitrans.net/doc/ysxy_en.html'; // 隐私政策英文链接 // url = 'https://www.voitrans.net/doc/ysxy_en.html'; // 隐私政策英文链接
} // }
Get.to(() => WebViewPage( // Get.to(() => WebViewPage(
url: url, // url: url,
title: 'privacyPolicy'.tr, // title: 'privacyPolicy'.tr,
)); // ));
}, // },
child: Text( child: Text(
'privacyPolicy'.tr, // 《隐私政策》 'privacyPolicy'.tr, // 《隐私政策》
style: TextStyle( style: TextStyle(

17
local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureAsrHelper.kt

@ -547,19 +547,20 @@ class AzureAsrHelper(private val context: Context) {
Log.e(tag, "启动录音前台服务失败: ${e.message}") Log.e(tag, "启动录音前台服务失败: ${e.message}")
} }
} }
// Initialize if not already done
if (!audioStream.isInitialized()) {
audioStream.initAudioRecord()
}
audioStream.setupStream()
if (audioStream.recordfile == null) { if (audioStream.recordfile == null) {
audioStream.recordfile = RecordFile() audioStream.recordfile = RecordFile()
} }
if (!audioStream.isContinuousRecognitionActive) { if (!audioStream.isContinuousRecognitionActive) {
// 启动音频处理 // 启动音频处理
Log.i(tag, "开启录音:audioSourceType${audioSourceType}") Log.i(tag, "开启录音:audioSourceType${audioSourceType}")
// Initialize if not already done
if (!audioStream.isInitialized()) {
audioStream.initAudioRecord()
}
audioStream.setupStream()
audioStream.startAudioRecord( when (audioSourceType) { audioStream.startAudioRecord( when (audioSourceType) {
AudioSourceType.MICROPHONE -> SimpleAudioReceiver.AudioSourceType.MICROPHONE AudioSourceType.MICROPHONE -> SimpleAudioReceiver.AudioSourceType.MICROPHONE
AudioSourceType.EXTERNAL -> SimpleAudioReceiver.AudioSourceType.EXTERNAL AudioSourceType.EXTERNAL -> SimpleAudioReceiver.AudioSourceType.EXTERNAL
@ -635,7 +636,7 @@ class AzureAsrHelper(private val context: Context) {
} }
Log.i(tag, "关闭录音:") Log.i(tag, "关闭录音:")
audioStream.recordfile ?: return audioStream.recordfile ?: return
if (!audioStream.isContinuousRecognitionActive) { if (!audioStream.isContinuousRecognitionActive) {
audioStream.stopMicrophoneCapture() audioStream.stopMicrophoneCapture()

Loading…
Cancel
Save