Commit 0f670f196e55360082d02c4cf3b6c0efba8b0cc3

Authored by wdn127929
1 parent 96319ce5

华为权限同步告知用户使用目的

... ... @@ -16,6 +16,9 @@ class App {
// static GetIt getIt = GetIt.instance;
static bool isInstallWx = false;
static final GlobalKey<NavigatorState> navigatorKey =
new GlobalKey<NavigatorState>();
static initSp() async {
sp = await SharedPreferences.getInstance();
}
... ...
... ... @@ -142,6 +142,7 @@ Future<void> main() async {
});
}
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
... ... @@ -250,6 +251,7 @@ class MyAppState extends State<MyApp> {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: '周到安排商家',
navigatorKey: App.navigatorKey,
// navigatorKey: App.getIt<NavigateService>().key,
//国际化
localizationsDelegates: const [
... ...
... ... @@ -25,6 +25,7 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import '../../models/user_history_entity.dart';
import '../../utils/call_log_utils.dart';
import '../../utils/screen_util.dart';
import '../../widgets/MyDivider.dart';
import '../../widgets/special_text/my_extended_text_selection_controls.dart';
... ... @@ -213,23 +214,25 @@ class _EditReserverPageState extends State<EditReserverPage> {
}
_getCallLog() async {
Iterable<CallLogEntry> result = await CallLog.query();
detailModel.userHistorys = [];
Iterable<CallLogEntry> result = await CallLogUtils.getCallLog(context);
if (result != null) {
detailModel.userHistorys = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
object.forEach((element) {
UserHistoryEntity userHistoryEntity =
UserHistoryEntity(null, null, '', '', '', '', '', null);
userHistoryEntity.rname = element.name ?? '';
userHistoryEntity.phone = element.number ?? '';
detailModel.userHistorys.add(userHistoryEntity);
});
if (object.length > 0) {
//有记录
showPhoneHistory = true;
setState(() {});
print(object);
object.forEach((element) {
UserHistoryEntity userHistoryEntity =
UserHistoryEntity(null, null, '', '', '', '', '', null);
userHistoryEntity.rname = element.name ?? '';
userHistoryEntity.phone = element.number ?? '';
detailModel.userHistorys.add(userHistoryEntity);
});
if (object.length > 0) {
//有记录
showPhoneHistory = true;
setState(() {});
}
}
}
... ...
... ... @@ -38,6 +38,7 @@ import 'package:one_key/models/table_list.dart' as t;
import 'dart:convert' as convert;
import 'package:easy_contact_picker/easy_contact_picker.dart';
import '../../models/user_history_entity.dart';
import '../../utils/call_log_utils.dart';
import '../../utils/screen_util.dart';
import '../../widgets/special_text/my_extended_text_selection_controls.dart';
... ... @@ -1054,23 +1055,25 @@ class _NoteBookChangeFPageState extends State<NoteBookChangeFPage> {
}
_getCallLog() async {
Iterable<CallLogEntry> result = await CallLog.query();
_notebookDetailChangeModel.userHistorys = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
object.forEach((element) {
UserHistoryEntity userHistoryEntity =
UserHistoryEntity(null, null, '', '', '', '', '', null);
userHistoryEntity.rname = element.name ?? '';
userHistoryEntity.phone = element.number ?? '';
_notebookDetailChangeModel.userHistorys.add(userHistoryEntity);
});
if (object.length > 0) {
//有记录
showPhoneHistory = true;
setState(() {});
Iterable<CallLogEntry> result = await CallLogUtils.getCallLog(context);
if (result != null) {
_notebookDetailChangeModel.userHistorys = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
object.forEach((element) {
UserHistoryEntity userHistoryEntity =
UserHistoryEntity(null, null, '', '', '', '', '', null);
userHistoryEntity.rname = element.name ?? '';
userHistoryEntity.phone = element.number ?? '';
_notebookDetailChangeModel.userHistorys.add(userHistoryEntity);
});
if (object.length > 0) {
//有记录
showPhoneHistory = true;
setState(() {});
}
}
}
... ...
... ... @@ -267,7 +267,7 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
if (widget.initialIndex == 0 ||
widget.initialIndex == 1 && needRefreshTemp == false) return;
_initNotification();
Future.delayed(Duration(milliseconds: 30000), () {
Future.delayed(Duration(minutes: 5), () {
//30000
ContactModel.getInstance().uploadLocalContact(context);
UserModel usermodel = Provider.of<UserModel>(context, listen: false);
... ...
... ... @@ -54,6 +54,7 @@ import '../../provider/SmsModel.dart';
import '../../provider/customer_provider.dart';
import '../../provider/marketing_center_provider.dart';
import '../../provider/my_model.dart';
import '../../utils/call_log_utils.dart';
import '../../utils/screen_util.dart';
import '../../widgets/special_text/my_extended_text_selection_controls.dart';
... ... @@ -3912,23 +3913,25 @@ class InvicationPageState extends State<InvicationPage>
}
_getCallLog() async {
Iterable<CallLogEntry> result = await CallLog.query();
_baseIndoProvider.userHistorys = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
object.forEach((element) {
UserHistoryEntity userHistoryEntity =
UserHistoryEntity(null, null, '', '', '', '', '', null);
userHistoryEntity.rname = element.name ?? '';
userHistoryEntity.phone = element.number ?? '';
_baseIndoProvider.userHistorys.add(userHistoryEntity);
});
if (object.length > 0) {
//有记录
showPhoneHistory = true;
setState(() {});
Iterable<CallLogEntry> result = await CallLogUtils.getCallLog(context);
if (result != null) {
_baseIndoProvider.userHistorys = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
object.forEach((element) {
UserHistoryEntity userHistoryEntity =
UserHistoryEntity(null, null, '', '', '', '', '', null);
userHistoryEntity.rname = element.name ?? '';
userHistoryEntity.phone = element.number ?? '';
_baseIndoProvider.userHistorys.add(userHistoryEntity);
});
if (object.length > 0) {
//有记录
showPhoneHistory = true;
setState(() {});
}
}
}
... ...
... ... @@ -59,6 +59,7 @@ import '../../provider/SmsModel.dart';
import '../../provider/marketing_center_provider.dart';
import '../../provider/remark_manager_model.dart';
import '../../provider/store_base_info_provider.dart';
import '../../utils/call_log_utils.dart';
import '../../utils/screen_util.dart';
import '../../widgets/loading.dart';
import '../../widgets/special_text/my_extended_text_selection_controls.dart';
... ... @@ -660,23 +661,25 @@ class TableManagerPageState extends State<TableManagerPage> {
}
_getCallLog() async {
Iterable<CallLogEntry> result = await CallLog.query();
_baseIndoProvider.userHistorys = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
object.forEach((element) {
UserHistoryEntity userHistoryEntity =
UserHistoryEntity(null, null, '', '', '', '', '', null);
userHistoryEntity.rname = element.name ?? '';
userHistoryEntity.phone = element.number ?? '';
_baseIndoProvider.userHistorys.add(userHistoryEntity);
});
if (object.length > 0) {
//有记录
showPhoneHistory = true;
setState(() {});
Iterable<CallLogEntry> result = await CallLogUtils.getCallLog(context);
if (result != null) {
_baseIndoProvider.userHistorys = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
object.forEach((element) {
UserHistoryEntity userHistoryEntity =
UserHistoryEntity(null, null, '', '', '', '', '', null);
userHistoryEntity.rname = element.name ?? '';
userHistoryEntity.phone = element.number ?? '';
_baseIndoProvider.userHistorys.add(userHistoryEntity);
});
if (object.length > 0) {
//有记录
showPhoneHistory = true;
setState(() {});
}
}
}
... ...
import 'dart:io';
import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:permission_handler/permission_handler.dart';
import 'misc.dart';
class CallLogUtils {
static Future<Iterable<CallLogEntry>> getCallLog(context) async {
try {
if (!(await checkPermission(Permission.phone))) {
String title = '通话记录和电话';
PermissionStatus status = await permissionStatus(Permission.phone);
if (status == PermissionStatus.permanentlyDenied) {
//用户选择不在弹出权限提示框
print('never');
// Navigator.pop(context);
DialogUtil.openAlertDialog(context, '未获得${title}权限',
"请在手机的权限管理里,将${title}权限开启", '去设置', 340.0, onTap: () {
openSetting();
Navigator.pop(context, '');
});
} else {
// 申请权限
bool canPhone = await checkPermission(Permission.phone);
if (canPhone) {
try {
//全局提示权限使用目的
if (Platform.isAndroid) {
DialogUtil.showAuthorityDestination(context, 'h_call',
'通话记录和电话权限使用说明', '直接从通话记录中获得客户电话号码,快速录入预订信息。');
}
Iterable<CallLogEntry> result = await CallLog.query();
return result;
} catch (e) {
print(e);
}
} else {
// Navigator.pop(context);
//拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处
DialogUtil.openAlertDialog(context, '未获得${title}权限',
"请在手机的权限管理里,将${title}权限开启。", '去设置', 340.0, onTap: () {
openSetting();
Navigator.pop(context, '');
});
}
}
} else {
try {
//全局提示权限使用目的
if (Platform.isAndroid) {
DialogUtil.showAuthorityDestination(context, 'h_call',
'通话记录和电话权限使用说明', '直接从通话记录中获得客户电话号码,快速录入预订信息。');
}
Iterable<CallLogEntry> result = await CallLog.query();
return result;
} catch (e) {
print(e);
}
}
} catch (e) {
print(e);
return null;
}
}
}
... ...
... ... @@ -59,6 +59,64 @@ typedef ClickCallback = void Function(String value);
// };
class DialogUtil {
static showAuthorityDestination(
BuildContext context, String name, String title, String subTitle) {
Future.delayed(const Duration(seconds: 5), () {
Navigator.of(context).pop(true);
});
return showDialog(
context: context,
barrierDismissible: true,
anchorPoint:Offset(0,0),
builder: (BuildContext context) {
return StatefulBuilder(builder: (context, state) {
// locationState = state;
return Material(
color: Colors.transparent,
child: Column(mainAxisSize: MainAxisSize.min, children: [
VEmptyView(40),
Container(
// width: double.infinity,
margin: EdgeInsets.symmetric(horizontal: w(10)),
padding: EdgeInsets.symmetric(
horizontal: w(20), vertical: w(12)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius: BorderRadius.circular(
r(5),
)),
child: Row(children: <Widget>[
Image.asset(
Utils.getImgPath(
'$name',
),
width: w(30)),
HEmptyView(68),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('$title',
style: TextStyle(
fontSize: font(16),
fontWeight: FontWeight.bold,
color: MyColours.color_E6000000)),
VEmptyView(20),
Text('$subTitle',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_26000000))
])),
]))
]));
});
});
;
}
//模块快过期提醒
static showSellerVersionEdateDialog(BuildContext context,
List<SellerVersionSunModel> showData, CustomCallBack callback,
... ... @@ -5621,7 +5679,8 @@ class DialogUtil {
}
//显示消息弹框
static showMessageDialog(BuildContext context,CollectStoreProvider collectStoreProvider) async {
static showMessageDialog(
BuildContext context, CollectStoreProvider collectStoreProvider) async {
MessageDialogModel messageModel =
Provider.of<MessageDialogModel>(context, listen: false);
if (messageModel.messages.isEmpty) return null;
... ... @@ -5743,8 +5802,8 @@ class DialogUtil {
)
: ListView.builder(
itemBuilder: (context, index) {
return MessageDialogItemF(
model.messages[index],collectStoreProvider);
return MessageDialogItemF(model.messages[index],
collectStoreProvider);
},
itemCount: model.messages.length,
shrinkWrap: true)
... ...
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:permission_handler/permission_handler.dart';
import '../app.dart';
Future<bool> checkPermissionStorage() async {
var status = await Permission.storage.status;
if (!status.isGranted) {
... ... @@ -33,6 +39,22 @@ Future<bool> checkPermission(Permission permissionGroup) async {
}
Future<bool> requestPermission(Permission permissionGroup) async {
//全局提示权限使用目的
if (Platform.isAndroid) {
//全局提示权限使用目的
BuildContext context = App.navigatorKey.currentState.overlay.context;
if (permissionGroup == Permission.storage) {
DialogUtil.showAuthorityDestination(
context, 'h_storage', '相册权限使用说明', '用于上传店铺门头照,包间照片等。');
} else if (permissionGroup == Permission.camera) {
DialogUtil.showAuthorityDestination(
context, 'h_camera', '相机权限使用说明', '用于上传店铺门头照,包间照片等。');
} else if (permissionGroup == Permission.location) {
DialogUtil.showAuthorityDestination(
context, 'h_location', '位置权限使用说明', '用于创建店铺时,获取店铺在地图上的位置,方便客户导航到咱们店铺');
}
}
final permissions = await [permissionGroup].request();
if (await permissionGroup.request().isGranted) {
print(true);
... ... @@ -56,8 +78,13 @@ Future<PermissionStatus> contactPermissionStatus() async {
return permissionStatus;
}
Future<bool> requestContactPermission() async {
if (Platform.isAndroid) {
//全局提示权限使用目的
BuildContext context = App.navigatorKey.currentState.overlay.context;
DialogUtil.showAuthorityDestination(
context, 'h_contant', '通讯录权限使用说明', '直接从通讯录获得客户电话号码,快速录入预订信息。');
}
final permissions = await [Permission.contacts].request();
if (permissions[Permission.contacts] == PermissionStatus.granted) {
return true;
... ...