Browse Source

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

newdev_shunjiawei
tanlongsheng 1 year ago
parent
commit
ba2af36b45
  1. 3
      lib/core/translations/language/en_us.dart
  2. 2
      lib/core/translations/language/zh_cn.dart
  3. 66
      lib/data/services/novice_guide_service.dart
  4. 49
      lib/modules/agent/controllers/agent_controller.dart

3
lib/core/translations/language/en_us.dart

@ -518,6 +518,9 @@ const Map<String, String> enUS = {
'smsPermissionDetailDesc': 'SMS functionality requires SMS permission', 'smsPermissionDetailDesc': 'SMS functionality requires SMS permission',
'alarmPermissionDetailDesc': 'alarmPermissionDetailDesc':
'This permission is required to set exact alarms and ensure reminders trigger on time', 'This permission is required to set exact alarms and ensure reminders trigger on time',
'contactsPermissionDesc': 'Used for accessing contact information',
'contactsPermissionDetailDesc':
'Phone call and SMS functionality requires contacts permission to select contacts',
'calendarWritePermissionDetailDesc': 'calendarWritePermissionDetailDesc':
'Creating calendar events requires calendar write permission', 'Creating calendar events requires calendar write permission',
'calendarFullAccessPermissionDetailDesc': 'calendarFullAccessPermissionDetailDesc':

2
lib/core/translations/language/zh_cn.dart

@ -484,6 +484,8 @@ const Map<String, String> zhCN = {
'calendarWritePermissionDetailDesc': '创建日历事件需要日历写入权限', 'calendarWritePermissionDetailDesc': '创建日历事件需要日历写入权限',
'calendarFullAccessPermissionDetailDesc': '管理日历事件需要完整日历权限', 'calendarFullAccessPermissionDetailDesc': '管理日历事件需要完整日历权限',
'locationPermissionDetailDesc': '获取位置信息需要位置权限', 'locationPermissionDetailDesc': '获取位置信息需要位置权限',
'contactsPermissionDesc': '用于访问联系人信息',
'contactsPermissionDetailDesc': '拨打电话和发送短信功能需要联系人权限以选择联系人',
'appNeedsPermissionForFullFunction': '应用需要此权限以提供完整功能', 'appNeedsPermissionForFullFunction': '应用需要此权限以提供完整功能',
'permanentDenialText': '您已永久拒绝{permission}权限,请前往应用设置开启', 'permanentDenialText': '您已永久拒绝{permission}权限,请前往应用设置开启',
'goToSettings': '去设置', 'goToSettings': '去设置',

66
lib/data/services/novice_guide_service.dart

@ -4,6 +4,8 @@ import 'package:ble_service/ble_service.dart';
import 'package:flutter_intro/flutter_intro.dart'; import 'package:flutter_intro/flutter_intro.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart'; import 'package:get_storage/get_storage.dart';
import 'package:permission_handler/permission_handler.dart';
import '../../core/utils/permission_util.dart';
class NoviceGuideService extends GetxService { class NoviceGuideService extends GetxService {
final GetStorage _storage = GetStorage(); final GetStorage _storage = GetStorage();
@ -25,7 +27,15 @@ class NoviceGuideService extends GetxService {
'send': '小言会为你实时为你播报天气', 'send': '小言会为你实时为你播报天气',
'end': '小言能实时为你播报天气,试试其他指令吧', 'end': '小言能实时为你播报天气,试试其他指令吧',
'method': () async { 'method': () async {
print('-----1------'); // 天气查询需要位置权限
await PermissionUtil.instance.requestPermission(
permissionType: Permission.location,
permissionName: 'locationInfo'.tr, // 位置信息
explanationText: 'locationPermissionDesc'.tr, // 用于获取当前位置信息
permanentDenialText:
'locationPermissionDetailDesc'.tr, // 获取位置信息需要位置权限
);
}, },
}, },
{ {
@ -33,9 +43,7 @@ class NoviceGuideService extends GetxService {
'input': '请播放一组摇滚乐', 'input': '请播放一组摇滚乐',
'send': '小言会为你搜寻到一组音乐', 'send': '小言会为你搜寻到一组音乐',
'end': '小言已成功为您搜寻到一组音乐,试试其他指令吧', 'end': '小言已成功为您搜寻到一组音乐,试试其他指令吧',
'method': () async { 'method': () async {},
print('-----2------');
},
}, },
{ {
'start': '对小言说:“导航到深圳机场”', 'start': '对小言说:“导航到深圳机场”',
@ -43,7 +51,14 @@ class NoviceGuideService extends GetxService {
'send': '小言会为你规划路线', 'send': '小言会为你规划路线',
'end': '小言已成功为您导航到深圳机场,试试其他指令吧', 'end': '小言已成功为您导航到深圳机场,试试其他指令吧',
'method': () async { 'method': () async {
print('-----3------'); // 导航功能需要位置权限
await PermissionUtil.instance.requestPermission(
permissionType: Permission.location,
permissionName: 'locationInfo'.tr, // 位置信息
explanationText: 'locationPermissionDesc'.tr, // 用于获取当前位置信息
permanentDenialText:
'locationPermissionDetailDesc'.tr, // 获取位置信息需要位置权限
);
}, },
}, },
{ {
@ -52,7 +67,14 @@ class NoviceGuideService extends GetxService {
'send': '小言会为你创建会议提醒', 'send': '小言会为你创建会议提醒',
'end': '小言已成功为您创建会议提醒,试试其他指令吧', 'end': '小言已成功为您创建会议提醒,试试其他指令吧',
'method': () async { 'method': () async {
print('-----4------'); //创建会议提醒需要日历权限
await PermissionUtil.instance.requestPermission(
permissionType: Permission.calendarWriteOnly,
permissionName: 'calendarWrite'.tr, // 日历写入
explanationText: 'calendarWritePermissionDesc'.tr, // 用于创建日历事件和提醒
permanentDenialText:
'calendarWritePermissionDetailDesc'.tr, // 创建日历事件需要日历写入权限
);
}, },
}, },
{ {
@ -61,7 +83,21 @@ class NoviceGuideService extends GetxService {
'send': '小言会为你拨打电话', 'send': '小言会为你拨打电话',
'end': '小言已成功为您拨打电话,试试其他指令吧', 'end': '小言已成功为您拨打电话,试试其他指令吧',
'method': () async { 'method': () async {
print('-----5------'); // 拨打电话需要电话权限
await PermissionUtil.instance.requestPermission(
permissionType: Permission.phone,
permissionName: 'phone'.tr, // 电话
explanationText: 'phonePermissionDesc'.tr, // 用于拨打电话功能
permanentDenialText: 'phonePermissionDetailDesc'.tr, // 拨打电话功能需要电话权限
);
//拨打电话还需要联系人权限
await PermissionUtil.instance.requestPermission(
permissionType: Permission.contacts,
permissionName: 'contacts'.tr, // 联系人
explanationText: 'contactsPermissionDesc'.tr, // 用于访问联系人信息
permanentDenialText:
'contactsPermissionDetailDesc'.tr, // 拨打电话功能需要联系人权限
);
}, },
}, },
{ {
@ -70,7 +106,21 @@ class NoviceGuideService extends GetxService {
'send': '小言会为你发送短信', 'send': '小言会为你发送短信',
'end': '短信已发送,语音操控更便捷', 'end': '短信已发送,语音操控更便捷',
'method': () async { 'method': () async {
print('-----6------'); // 发送短信需要短信权限
await PermissionUtil.instance.requestPermission(
permissionType: Permission.sms,
permissionName: 'sms'.tr, // 短信
explanationText: 'smsPermissionDesc'.tr, // 用于发送短信功能
permanentDenialText: 'smsPermissionDetailDesc'.tr, // 发送短信功能需要短信权限
);
//发送短信还需要联系人权限
await PermissionUtil.instance.requestPermission(
permissionType: Permission.contacts,
permissionName: 'contacts'.tr, // 联系人
explanationText: 'contactsPermissionDesc'.tr, // 用于访问联系人信息
permanentDenialText:
'contactsPermissionDetailDesc'.tr, // 发送短信功能需要联系人权限
);
}, },
}, },
]; ];

49
lib/modules/agent/controllers/agent_controller.dart

@ -1761,21 +1761,52 @@ class AgentController extends GetxController {
// 打开图片查看器 // 打开图片查看器
void openImageViewer(BuildContext context, String imagePath) { void openImageViewer(BuildContext context, String imagePath) {
// 构建完整的图片路径
String fullImagePath;
if (imagePath.startsWith('/')) {
// 如果是相对路径(以/开头),需要拼接AppDir.value
fullImagePath = '${AppDir.value}$imagePath';
} else {
// 如果已经是完整路径,直接使用
fullImagePath = imagePath;
}
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => Scaffold( builder: (context) => Scaffold(
appBar: AppBar( // appBar: AppBar(
backgroundColor: Colors.black, // backgroundColor: Colors.black,
iconTheme: IconThemeData(color: Colors.white), // leading: IconButton(
), // icon: Icon(Icons.arrow_back_ios, color: Colors.white),
// onPressed: () => Navigator.of(context).pop(),
// ),
// iconTheme: IconThemeData(color: Colors.white),
// //title: Text('图片预览', style: TextStyle(color: Colors.white)),
// ),
body: Container( body: Container(
color: Colors.black, color: Colors.black,
child: PhotoView( child: GestureDetector(
imageProvider: FileImage(File(imagePath)), onTap: () => Navigator.of(context).pop(), // 点击退出
minScale: PhotoViewComputedScale.contained,
maxScale: PhotoViewComputedScale.covered * 2, child: PhotoView(
backgroundDecoration: BoxDecoration(color: Colors.black), imageProvider: FileImage(File(fullImagePath)),
minScale: PhotoViewComputedScale.contained,
maxScale: PhotoViewComputedScale.covered * 2,
backgroundDecoration: BoxDecoration(color: Colors.black),
// errorBuilder: (context, error, stackTrace) {
// return const Center(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// Icon(Icons.error, color: Colors.white, size: 64),
// SizedBox(height: 16),
// Text('图片加载失败', style: TextStyle(color: Colors.white)),
// ],
// ),
// );
// },
),
), ),
), ),
), ),

Loading…
Cancel
Save