Merge branch 'master' of https://gitee.com/starlock-cn/app-starlock
This commit is contained in:
commit
f71269fb3d
@ -4,6 +4,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.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';
|
||||
|
||||
@ -35,7 +36,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver, BaseWidget {
|
||||
}
|
||||
|
||||
GetMaterialApp _initMaterialApp() => GetMaterialApp(
|
||||
title: 'Star Lock',
|
||||
title: F.navTitle,
|
||||
navigatorObservers: [AppRouteObserver().routeObserver],
|
||||
translations: TranslationMessage(),
|
||||
supportedLocales: appDept.deptSupportedLocales,
|
||||
|
||||
@ -5,6 +5,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/mine/addLock/addLock/addLock_logic.dart';
|
||||
import 'package:star_lock/tools/appFirstEnterHandle.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
@ -79,19 +81,7 @@ class _AddLockPageState extends State<AddLockPage> with BaseWidget {
|
||||
btnName: TranslationLoader.lanKeys!.next!.tr,
|
||||
borderRadius: 20.w,
|
||||
onClick: () {
|
||||
if (Platform.isIOS) {
|
||||
Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||||
} else {
|
||||
getMicrophonePermission().then((value) {
|
||||
if (value) {
|
||||
// 有权限
|
||||
Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||||
} else {
|
||||
//没有权限
|
||||
openAppSettings(); //打开app系统设置
|
||||
}
|
||||
});
|
||||
}
|
||||
getNearByLimits();
|
||||
}),
|
||||
),
|
||||
],
|
||||
@ -99,6 +89,19 @@ class _AddLockPageState extends State<AddLockPage> with BaseWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void onShow() {}
|
||||
|
||||
void onHide() {}
|
||||
|
||||
//跳转到附近的锁页面先判断权限
|
||||
void getNearByLimits() {
|
||||
if (Platform.isIOS) {
|
||||
Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||||
} else {
|
||||
positionPermissionAlert();
|
||||
}
|
||||
}
|
||||
|
||||
///请求权限
|
||||
Future<bool> getMicrophonePermission() async {
|
||||
// You can request multiple permissions at once.
|
||||
@ -117,7 +120,28 @@ class _AddLockPageState extends State<AddLockPage> with BaseWidget {
|
||||
return false;
|
||||
}
|
||||
|
||||
void onShow() {}
|
||||
Future<void> positionPermissionAlert() async {
|
||||
//安卓平台下首次进入应用需向用户告知获取权限用途弹窗
|
||||
if (Platform.isAndroid) {
|
||||
AppFirstEnterHandle().getAppFirstEnter(context, isAgreePosition);
|
||||
var getFlag = await Storage.getString(isAgreePosition);
|
||||
if (getFlag == isAgreePosition) {
|
||||
onPermissionPush();
|
||||
}
|
||||
} else {
|
||||
onPermissionPush();
|
||||
}
|
||||
}
|
||||
|
||||
void onHide() {}
|
||||
void onPermissionPush() {
|
||||
getMicrophonePermission().then((value) {
|
||||
if (value) {
|
||||
// 有权限
|
||||
Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||||
} else {
|
||||
//没有权限
|
||||
openAppSettings(); //打开app系统设置
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/tools/appFirstEnterHandle.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../app_settings/app_colors.dart';
|
||||
@ -188,15 +190,16 @@ class _SelectLockTypePageState extends State<SelectLockTypePage>
|
||||
if (Platform.isIOS) {
|
||||
Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||||
} else {
|
||||
getMicrophonePermission().then((value) {
|
||||
if (value) {
|
||||
// 有权限
|
||||
Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||||
} else {
|
||||
//没有权限
|
||||
openAppSettings(); //打开app系统设置
|
||||
}
|
||||
});
|
||||
positionPermissionAlert();
|
||||
// getMicrophonePermission().then((value) {
|
||||
// if (value) {
|
||||
// // 有权限
|
||||
// Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||||
// } else {
|
||||
// //没有权限
|
||||
// openAppSettings(); //打开app系统设置
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,6 +221,31 @@ class _SelectLockTypePageState extends State<SelectLockTypePage>
|
||||
return false;
|
||||
}
|
||||
|
||||
Future<void> positionPermissionAlert() async {
|
||||
//安卓平台下首次进入应用需向用户告知获取权限用途弹窗
|
||||
if (Platform.isAndroid) {
|
||||
AppFirstEnterHandle().getAppFirstEnter(context, isAgreePosition);
|
||||
var getFlag = await Storage.getString(isAgreePosition);
|
||||
if (getFlag == isAgreePosition) {
|
||||
onPermissionPush();
|
||||
}
|
||||
} else {
|
||||
onPermissionPush();
|
||||
}
|
||||
}
|
||||
|
||||
void onPermissionPush() {
|
||||
getMicrophonePermission().then((value) {
|
||||
if (value) {
|
||||
// 有权限
|
||||
Navigator.pushNamed(context, Routers.nearbyLockPage);
|
||||
} else {
|
||||
//没有权限
|
||||
openAppSettings(); //打开app系统设置
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void onShow() {}
|
||||
|
||||
void onHide() {}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/flavors.dart';
|
||||
|
||||
import '../../appRouters.dart';
|
||||
import '../../app_settings/app_colors.dart';
|
||||
@ -144,11 +145,13 @@ class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.mineSetPage);
|
||||
}),
|
||||
mineItem('images/mine/icon_mine_main_vip.png',
|
||||
TranslationLoader.lanKeys!.valueAddedServices!.tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.valueAddedServicesPage);
|
||||
}),
|
||||
F.appFlavor == Flavor.sky
|
||||
? Container()
|
||||
: mineItem('images/mine/icon_mine_main_vip.png',
|
||||
TranslationLoader.lanKeys!.valueAddedServices!.tr, () {
|
||||
Get.back();
|
||||
Get.toNamed(Routers.valueAddedServicesPage);
|
||||
}),
|
||||
mineItem('images/mine/icon_mine_main_shoppingcart.png', "配件商城".tr,
|
||||
() {
|
||||
Get.back();
|
||||
|
||||
@ -8,7 +8,9 @@ import 'package:image_picker/image_picker.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart';
|
||||
import 'package:star_lock/tools/appFirstEnterHandle.dart';
|
||||
import 'package:star_lock/tools/custom_bottom_sheet.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
import '../../../appRouters.dart';
|
||||
import '../../../tools/commonItem.dart';
|
||||
import '../../../tools/titleAppBar.dart';
|
||||
@ -69,8 +71,18 @@ class _MinePersonInfoPageState extends State<MinePersonInfoPage> {
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
action: () {
|
||||
requestCameraPermission();
|
||||
action: () async {
|
||||
//安卓平台下首次进入应用需向用户告知获取权限用途弹窗
|
||||
if (Platform.isAndroid) {
|
||||
AppFirstEnterHandle()
|
||||
.getAppFirstEnter(context, isAgreeCamera);
|
||||
var getFlag = await Storage.getString(isAgreeCamera);
|
||||
if (getFlag == isAgreeCamera) {
|
||||
requestCameraPermission();
|
||||
}
|
||||
} else {
|
||||
requestCameraPermission();
|
||||
}
|
||||
},
|
||||
)),
|
||||
Obx(() => CommonItem(
|
||||
|
||||
@ -15,7 +15,7 @@ class StarLockApplication extends StatefulWidget {
|
||||
class _StarLockApplicationState extends State<StarLockApplication> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AppFirstEnterHandle().getAppFirstEnter(context);
|
||||
AppFirstEnterHandle().getAppFirstEnter(context, isAgreePrivacy);
|
||||
|
||||
return FutureBuilder<bool>(
|
||||
future: getLoginStatus(),
|
||||
|
||||
22
star_lock/lib/talk/call/audioPlayerTask.dart
Normal file
22
star_lock/lib/talk/call/audioPlayerTask.dart
Normal file
@ -0,0 +1,22 @@
|
||||
// Audio player task implementation
|
||||
import 'package:audio_service/audio_service.dart';
|
||||
|
||||
class AudioPlayerTask extends BackgroundAudioTask {
|
||||
@override
|
||||
Future<void> onStart(Map<String, dynamic>? params) async {
|
||||
// Load and play audio here
|
||||
// Example:
|
||||
// AudioPlayer audioPlayer = AudioPlayer();
|
||||
// await audioPlayer.play('path_to_audio.mp3');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onStop() async {
|
||||
// Stop audio playback and clean up resources
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onPause() async {
|
||||
// Pause audio playback
|
||||
}
|
||||
}
|
||||
@ -9,10 +9,30 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
class AppFirstEnterHandle {
|
||||
Future getAppFirstEnter(BuildContext widgetContext) async {
|
||||
var isFirstTime = await Storage.getString(isFirstEnter);
|
||||
if (isFirstTime != isFirstEnter) {
|
||||
showPrivacyAgreementAlert(widgetContext);
|
||||
Future getAppFirstEnter(BuildContext widgetContext, String flagStr) async {
|
||||
var getFlag = await Storage.getString(flagStr);
|
||||
switch (flagStr) {
|
||||
case isAgreePrivacy: // 隐私协议
|
||||
{
|
||||
if (getFlag != isAgreePrivacy)
|
||||
showPrivacyAgreementAlert(widgetContext);
|
||||
}
|
||||
break;
|
||||
case isAgreePosition: // 位置权限
|
||||
{
|
||||
if (getFlag != isAgreePosition) showPositionAlert(widgetContext);
|
||||
}
|
||||
break;
|
||||
case isAgreeCamera: // 相机权限
|
||||
{
|
||||
if (getFlag != isAgreeCamera) showCameraAlert(widgetContext);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
print('没有匹配的flagStr');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +97,63 @@ class AppFirstEnterHandle {
|
||||
style: TextStyle(color: Colors.blue),
|
||||
),
|
||||
onPressed: () {
|
||||
Storage.setString(isFirstEnter, isFirstEnter);
|
||||
Storage.setString(isAgreePrivacy, isAgreePrivacy);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
//位置权限弹窗
|
||||
void showPositionAlert(BuildContext widgetContext) {
|
||||
showCupertinoDialog(
|
||||
context: widgetContext,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text('位置权限'),
|
||||
content: const Text('请开启位置权限,应用需要位置权限才可以完成智能锁和网关的蓝牙操作'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: const Text('取消'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: const Text('确定'),
|
||||
onPressed: () {
|
||||
Storage.setString(isAgreePosition, isAgreePosition);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
//相机权限弹窗
|
||||
void showCameraAlert(BuildContext widgetContext) {
|
||||
showCupertinoDialog(
|
||||
context: widgetContext,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text('相机/相册权限'),
|
||||
content: const Text('请开启本地存储权限,允许应用读写设备上的照片及文件'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
child: const Text('取消'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: const Text('确定'),
|
||||
onPressed: () {
|
||||
Storage.setString(isAgreeCamera, isAgreeCamera);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
|
||||
@ -15,7 +15,9 @@ const saveBlueToken = "BlueGetToken";
|
||||
const currentConnectionLockId = "CurrentConnectionLockId";
|
||||
const currentConnectionMacAddress = "CurrentConnectionMacAddress";
|
||||
const ifIsDemoModeOrNot = "IfIsDemoModeOrNot";
|
||||
const isFirstEnter = "isFirstEnter"; //是否首次进入应用
|
||||
const isAgreePrivacy = "isAgreePrivacy"; //是否同意隐私协议弹窗
|
||||
const isAgreePosition = "isAgreePosition"; //是否同意获取位置弹窗
|
||||
const isAgreeCamera = "isAgreeCamera"; //是否同意获取相机/相册弹窗
|
||||
|
||||
const saveUserLoginData = "userLoginData";
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
|
||||
version: 1.0.14+20240311
|
||||
version: 1.0.11+20240309
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
@ -139,6 +139,7 @@ dependencies:
|
||||
timelines: ^0.1.0
|
||||
#侧滑删除
|
||||
flutter_slidable: ^3.0.1
|
||||
audio_service: ^0.18.12
|
||||
|
||||
system_settings: ^2.0.0
|
||||
dev_dependencies:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user