Commit bf4ca5d69b8503229260cfeb3986e97cbc74f3bb

Authored by “gaiyaguang”
1 parent 1f2b73d8

通讯录

... ... @@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<application
android:name="io.flutter.app.FlutterApplication"
... ...
3c1231b5edf496b4919be0fb9a5d41be
\ No newline at end of file
7babc7873f8d177769b987ba4c6c2911
\ No newline at end of file
... ...
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
... ...
... ... @@ -9,6 +9,8 @@ PODS:
- Flutter
- device_info (0.0.1):
- Flutter
- easy_contact_picker (0.0.1):
- Flutter
- Flutter (1.0.0)
- flutter_bugly (0.0.1):
- Bugly
... ... @@ -34,9 +36,9 @@ PODS:
- Reachability (3.2)
- shared_preferences (0.0.1):
- Flutter
- sqflite (0.0.2):
- sqflite (0.0.1):
- Flutter
- FMDB (>= 2.7.5)
- FMDB (~> 2.7.2)
- TPNS-iOS (1.2.7.2)
- tpns_flutter_plugin (1.0.4):
- Flutter
... ... @@ -52,6 +54,7 @@ DEPENDENCIES:
- connectivity (from `.symlinks/plugins/connectivity/ios`)
- contacts_service (from `.symlinks/plugins/contacts_service/ios`)
- device_info (from `.symlinks/plugins/device_info/ios`)
- easy_contact_picker (from `.symlinks/plugins/easy_contact_picker/ios`)
- Flutter (from `Flutter`)
- flutter_bugly (from `.symlinks/plugins/flutter_bugly/ios`)
- flutter_statusbarcolor (from `.symlinks/plugins/flutter_statusbarcolor/ios`)
... ... @@ -84,6 +87,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/contacts_service/ios"
device_info:
:path: ".symlinks/plugins/device_info/ios"
easy_contact_picker:
:path: ".symlinks/plugins/easy_contact_picker/ios"
Flutter:
:path: Flutter
flutter_bugly:
... ... @@ -119,6 +124,7 @@ SPEC CHECKSUMS:
connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467
contacts_service: 849e1f84281804c8bfbec1b4c3eedcb23c5d3eca
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
easy_contact_picker: 9ab9dc70e8ddde6e76a19ffc482d7bf899868730
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_bugly: c9800f4d5bc5bdc27ffdde3417a26ba44266e0c3
flutter_statusbarcolor: 8afb1071ed8c58be929f1e32b36c629771fd2259
... ... @@ -131,13 +137,13 @@ SPEC CHECKSUMS:
permission_handler: 8278954f2382902f63f00dd8828769c0bd6d511b
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0
TPNS-iOS: 9b35473a4a0d07f2c2730ea1e66c6749c2b98095
tpns_flutter_plugin: 8dbbee157aab91a878f64d056c1383726a6c5c4d
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96
WechatOpenSDK: 6a4d1436c15b3b5fe2a0bd383f3046010186da44
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
PODFILE CHECKSUM: a75497545d4391e2d394c3668e20cfb1c2bbd4aa
COCOAPODS: 1.9.1
COCOAPODS: 1.9.3
... ...
... ... @@ -253,6 +253,7 @@
"${BUILT_PRODUCTS_DIR}/connectivity/connectivity.framework",
"${BUILT_PRODUCTS_DIR}/contacts_service/contacts_service.framework",
"${BUILT_PRODUCTS_DIR}/device_info/device_info.framework",
"${BUILT_PRODUCTS_DIR}/easy_contact_picker/easy_contact_picker.framework",
"${BUILT_PRODUCTS_DIR}/flutter_statusbarcolor/flutter_statusbarcolor.framework",
"${BUILT_PRODUCTS_DIR}/fluttertoast/fluttertoast.framework",
"${BUILT_PRODUCTS_DIR}/install_plugin/install_plugin.framework",
... ... @@ -272,6 +273,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/connectivity.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/contacts_service.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/easy_contact_picker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_statusbarcolor.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/fluttertoast.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/install_plugin.framework",
... ...
... ... @@ -23,4 +23,4 @@ class App{
getIt.registerSingleton(NavigateService());
}
}
\ No newline at end of file
}
... ...
import 'dart:io';
import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:fluro/fluro.dart';
... ... @@ -67,8 +66,7 @@ class MyApp extends StatefulWidget {
}
class MyAppState extends State<MyApp> {
int xgCount=1;//注册信鸽次数,最多5次
int xgCount = 1; //注册信鸽次数,最多5次
@override
void initState() {
... ...
... ... @@ -13,6 +13,7 @@ import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
... ... @@ -22,9 +23,11 @@ import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/new_table_item.dart';
import 'package:one_key/widgets/table_item.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:one_key/models/table_list.dart' as t;
import 'dart:convert' as convert;
import 'package:easy_contact_picker/easy_contact_picker.dart';
typedef clickCallback = void Function(String value);
... ... @@ -45,6 +48,7 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
FocusNode _nameNode = FocusNode();
FocusNode _needNode = FocusNode();
NotebookDetailModel detailModel = NotebookDetailModel();
EasyContactPicker _contactPicker = EasyContactPicker();
@override
void initState() {
... ... @@ -503,6 +507,19 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
HEmptyView(40),
InkWell(
onTap: () {
_openAddressBook();
},
child: Text(
'打开通讯录',
style: TextStyle(
color: MyColours.color_199095,
fontSize: ScreenUtil().setSp(34),
),
),
),
HEmptyView(40),
InkWell(
onTap: () {
_showDateChooseWidget(context);
},
child: Text(
... ... @@ -774,6 +791,35 @@ class _NoteBookChangePageState extends State<NoteBookChangePage> {
);
}
_openAddressBook() async {
if (!(await checkContactPermission())) {
PermissionStatus permissionStatus = await contactPermissionStatus();
if (permissionStatus == PermissionStatus.neverAskAgain) {
//用户选择不在弹出权限提示框
print('never');
} else {
// 申请权限
bool canContacts = await requestContactPermission();
if (canContacts) {
_getContactData();
} else {
//拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处
print(canContacts);
}
}
} else {
_getContactData();
}
}
_getContactData() async {
Contact contact = await _contactPicker.selectContactWithNative();
setState(() {
_notebookDetailChangeModel.phoneController.text = contact.phoneNumber;
_notebookDetailChangeModel.nameController.text = contact.fullName;
});
}
@override
Widget build(BuildContext context) {
_notebookDetailChangeModel =
... ...
... ... @@ -18,56 +18,60 @@ import '../app.dart';
/**
* 上传联系人
*/
class ContactModel{
class ContactModel {
ContactModel._();
static ContactModel _instance;
static ContactModel getInstance(){
if(_instance==null){
_instance=ContactModel._();
static ContactModel getInstance() {
if (_instance == null) {
_instance = ContactModel._();
}
return _instance;
}
uploadLocalContact(BuildContext context) async {
bool isUpload=App.sp.getBool("isUpload")??false;
if(isUpload)return;
bool authority=await requestContactPermission();
if(authority){
Iterable<Contact> contacts=await ContactsService.getContacts(withThumbnails: false);
List<Map<String,String>> callLogs=[];
bool isUpload = App.sp.getBool("isUpload") ?? false;
if (isUpload) return;
bool authority = await requestContactPermission();
if (authority) {
Iterable<Contact> contacts =
await ContactsService.getContacts(withThumbnails: false);
List<Map<String, String>> callLogs = [];
contacts.forEach((contact){
String phoneNum="";
if(contact.phones.isNotEmpty){
phoneNum=contact.phones.first.value.replaceAll(new RegExp(r"\s+\b|\b\s"), "");
contacts.forEach((contact) {
String phoneNum = "";
if (contact.phones.isNotEmpty) {
phoneNum = contact.phones.first.value
.replaceAll(new RegExp(r"\s+\b|\b\s"), "");
}
Map<String,String> callLog={
"phoneNum":"${phoneNum.trim()}",
"sid":Provider.of<UserModel>(context,listen: false).user.sellerid,
"deviceId":"dhgajkhdgahghsdghdkgahd",
"phoneDate":"${DateTime.now().millisecondsSinceEpoch}",
"callType":"2",
"callUser":"${contact.displayName}",
"account":Provider.of<UserModel>(context,listen: false).user.account
};
Map<String, String> callLog = {
"phoneNum": "${phoneNum.trim()}",
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
"deviceId": "dhgajkhdgahghsdghdkgahd",
"phoneDate": "${DateTime.now().millisecondsSinceEpoch}",
"callType": "2",
"callUser": "${contact.displayName}",
"account": Provider.of<UserModel>(context, listen: false).user.account
};
callLogs.add(callLog);
});
Map<String,String> params={
"data":jsonEncode(callLogs)
};
Map<String, String> params = {"data": jsonEncode(callLogs)};
BaseResp<String> baseResp = await DioUtil()
.request<String>(context, Method.get, HttpUrl.upload_contact,showLoading: false,
data: params,options: Options(method: Method.post,contentType: ContentType.parse("application/x-www-form-urlencoded")))
.request<String>(context, Method.get, HttpUrl.upload_contact,
showLoading: false,
data: params,
options: Options(
method: Method.post,
contentType:
ContentType.parse("application/x-www-form-urlencoded")))
.catchError((error) {
print(error.toString());
});
if(baseResp!=null&&baseResp.code == Constant.status_success){
if (baseResp != null && baseResp.code == Constant.status_success) {
LogUtil.v("联系人上传成功:${contacts.length}条");
App.sp.setBool("isUpload", true);
}
}
}
}
\ No newline at end of file
}
... ...
... ... @@ -199,7 +199,7 @@ class DialogUtil {
TableCalendar(
calendarController: _calendarController,
initialSelectedDay: selectDateTime,
onDaySelected: (day, events) {
onDaySelected: (day, events,holidays) {
Navigator.of(dialogContext).pop(day);
},
availableGestures: AvailableGestures.none,
... ...
import 'package:flutter/services.dart';
import 'package:permission_handler/permission_handler.dart';
Future<bool> checkContactPermission() async {
Future<bool> checkContactPermission() async {
PermissionStatus permissionStatus =
await PermissionHandler().checkPermissionStatus(PermissionGroup.contacts);
if (permissionStatus == PermissionStatus.granted) {
... ... @@ -11,10 +11,15 @@ import 'package:permission_handler/permission_handler.dart';
}
}
Future<PermissionStatus> contactPermissionStatus() async {
PermissionStatus permissionStatus =
await PermissionHandler().checkPermissionStatus(PermissionGroup.contacts);
return permissionStatus;
}
Future<bool> requestContactPermission() async {
final permissions =
await PermissionHandler().requestPermissions([PermissionGroup.contacts]);
if (permissions[PermissionGroup.contacts] == PermissionStatus.granted) {
return true;
} else {
... ... @@ -22,7 +27,6 @@ Future<bool> requestContactPermission() async {
}
}
Future<bool> openSetting() {
return PermissionHandler().openAppSettings();
}
... ...
... ... @@ -21,7 +21,7 @@ packages:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.5.0-nullsafety.1"
version: "2.4.2"
audioplayers:
dependency: "direct main"
description:
... ... @@ -35,7 +35,7 @@ packages:
name: boolean_selector
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.0.0"
build:
dependency: transitive
description:
... ... @@ -105,14 +105,14 @@ packages:
name: characters
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.1.3"
checked_yaml:
dependency: transitive
description:
... ... @@ -126,7 +126,7 @@ packages:
name: clock
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.0.1"
code_builder:
dependency: transitive
description:
... ... @@ -140,7 +140,7 @@ packages:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.15.0-nullsafety.3"
version: "1.14.13"
common_utils:
dependency: "direct main"
description:
... ... @@ -253,13 +253,20 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.17"
easy_contact_picker:
dependency: "direct main"
description:
name: easy_contact_picker
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.0.2"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.1.0"
ffi:
dependency: transitive
description:
... ... @@ -491,14 +498,14 @@ packages:
name: matcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.10-nullsafety.1"
version: "0.12.8"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.1.8"
mime:
dependency: transitive
description:
... ... @@ -519,7 +526,7 @@ packages:
name: node_interop
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.1"
version: "1.2.0"
node_io:
dependency: transitive
description:
... ... @@ -561,7 +568,7 @@ packages:
name: path
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0-nullsafety.1"
version: "1.7.0"
path_provider:
dependency: "direct main"
description:
... ... @@ -603,7 +610,7 @@ packages:
name: pedantic
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.2"
version: "1.9.0"
permission_handler:
dependency: "direct main"
description:
... ... @@ -769,14 +776,14 @@ packages:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0-nullsafety.2"
version: "1.7.0"
sqflite:
dependency: "direct main"
description:
name: sqflite
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.2+1"
version: "1.3.1+2"
sqflite_common:
dependency: transitive
description:
... ... @@ -790,14 +797,14 @@ packages:
name: stack_trace
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.10.0-nullsafety.1"
version: "1.9.5"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0-nullsafety.1"
version: "2.0.0"
stream_transform:
dependency: transitive
description:
... ... @@ -811,7 +818,7 @@ packages:
name: string_scanner
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0-nullsafety.1"
version: "1.0.5"
synchronized:
dependency: transitive
description:
... ... @@ -832,14 +839,14 @@ packages:
name: term_glyph
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0-nullsafety.1"
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.2.19-nullsafety.2"
version: "0.2.17"
timing:
dependency: transitive
description:
... ... @@ -862,14 +869,14 @@ packages:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0-nullsafety.3"
version: "1.2.0"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "5.7.8"
version: "5.7.6"
url_launcher_linux:
dependency: transitive
description:
... ... @@ -890,14 +897,14 @@ packages:
name: url_launcher_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.9"
version: "1.0.8"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.5"
version: "0.1.4+1"
url_launcher_windows:
dependency: transitive
description:
... ... @@ -918,7 +925,7 @@ packages:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.0.8"
watcher:
dependency: transitive
description:
... ... @@ -953,7 +960,7 @@ packages:
name: xdg_directories
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.2"
version: "0.1.0"
yaml:
dependency: transitive
description:
... ... @@ -962,5 +969,5 @@ packages:
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.10.2 <2.11.0"
flutter: ">=1.22.2 <2.0.0"
dart: ">=2.9.0 <3.0.0"
flutter: ">=1.20.0 <2.0.0"
... ...
... ... @@ -34,7 +34,7 @@ dependencies:
# 屏幕适配
flutter_screenutil: ^1.0.2
# 路由管理
fluro: ^1.6.0
fluro: ^1.6.3
# Toast提示
fluttertoast: ^3.1.3
# 权限管理
... ... @@ -86,6 +86,7 @@ dependencies:
# 获取通讯录
contacts_service: ^0.4.6
common_utils: ^1.1.3
easy_contact_picker: ^0.0.2
dev_dependencies:
... ...