Commit a1a2ea566eb8866f1fed57debae5bd36341abc39

Authored by wdn127929
1 parent 8ffd0ac2

捕捉通话记录获取崩溃

... ... @@ -214,91 +214,93 @@ class _EditReserverPageState extends State<EditReserverPage> {
}
_getCallLog() async {
Iterable<CallLogEntry> result = await CallLog.query();
List<Picker.PickerItem<dynamic>> data = [];
try {
Iterable<CallLogEntry> result = await CallLog.query();
List<Picker.PickerItem<dynamic>> data = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
print(object);
detailModel.userHistorys = [];
showPhoneHistory = false;
// setState(() {});
object.forEach((element) {
detailModel.userHistorys.add(UserHistoryEntity(
'', '', element.name ?? '', '1', element.number, '', '', ''));
detailModel.userHistorys = [];
showPhoneHistory = false;
// setState(() {});
String title = '';
title += ' ${element.number ?? ''}';
if (element.name != null && element.name != '') {
title += ' ${element.name}';
}
object.forEach((element) {
detailModel.userHistorys.add(UserHistoryEntity(
'', '', element.name ?? '', '1', element.number, '', '', ''));
String stateStr = ''; //状态
if (element.callType.name == 'incoming' ||
element.callType.name == 'wifiIncoming' ||
element.callType.name == 'answeredExternally') {
stateStr = ' 呼入';
} else if (element.callType.name == 'outgoing' ||
element.callType.name == 'wifiOutgoing' ||
element.callType.name == 'voiceMail') {
stateStr = ' 呼出';
} else if (element.callType.name == 'missed') {
stateStr = ' 未接';
} else if (element.callType.name == 'rejected') {
stateStr = ' 拒接';
} else if (element.callType.name == 'blocked') {
stateStr = ' 拦截';
}
String title = '';
title += ' ${element.number ?? ''}';
if (element.name != null && element.name != '') {
title += ' ${element.name}';
}
String sunString =
Utils.formatCallLogFromMill(element.timestamp.toString());
data.add(Picker.PickerItem(
text: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
HEmptyView(30),
Text(title ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)),
Expanded(
child: Text(stateStr ?? '',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_26000000))),
],
)),
Container(
margin: EdgeInsets.only(right: w(15)),
child: Text(sunString ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)))
],
)));
});
if (data.length > 0) {
//有记录,底部弹窗展示
// showPhoneHistory = true;
// setState(() {});
DialogUtil.showSelectCusmanWidgetDialog(context, data, (value) {
if (value != null) {
_byValueToReqeust(value[0]);
String stateStr = ''; //状态
if (element.callType.name == 'incoming' ||
element.callType.name == 'wifiIncoming' ||
element.callType.name == 'answeredExternally') {
stateStr = ' 呼入';
} else if (element.callType.name == 'outgoing' ||
element.callType.name == 'wifiOutgoing' ||
element.callType.name == 'voiceMail') {
stateStr = ' 呼出';
} else if (element.callType.name == 'missed') {
stateStr = ' 未接';
} else if (element.callType.name == 'rejected') {
stateStr = ' 拒接';
} else if (element.callType.name == 'blocked') {
stateStr = ' 拦截';
}
}, title: '从通话记录选择客人电话', selecteds: [
// _getFirSelected(hourAndMinute, data),
// _getSecSelected(hourAndMinute)
]).then((value) {
print(value);
String sunString =
Utils.formatCallLogFromMill(element.timestamp.toString());
data.add(Picker.PickerItem(
text: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
HEmptyView(30),
Text(title ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)),
Expanded(
child: Text(stateStr ?? '',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_26000000))),
],
)),
Container(
margin: EdgeInsets.only(right: w(15)),
child: Text(sunString ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)))
],
)));
});
} else {
Utils.showToast('暂无通话记录!');
}
if (data.length > 0) {
//有记录,底部弹窗展示
// showPhoneHistory = true;
// setState(() {});
DialogUtil.showSelectCusmanWidgetDialog(context, data, (value) {
if (value != null) {
_byValueToReqeust(value[0]);
}
}, title: '从通话记录选择客人电话', selecteds: [
// _getFirSelected(hourAndMinute, data),
// _getSecSelected(hourAndMinute)
]).then((value) {
print(value);
});
} else {
Utils.showToast('暂无通话记录!');
}
} catch (e) {}
}
_byValueToReqeust(int index) {
... ...
... ... @@ -1075,90 +1075,95 @@ class _NoteBookChangeFPageState extends State<NoteBookChangeFPage> {
// }
// }
_getCallLog() async {
Iterable<CallLogEntry> result = await CallLog.query();
List<Picker.PickerItem<dynamic>> data = [];
try {
Iterable<CallLogEntry> result = await CallLog.query();
List<Picker.PickerItem<dynamic>> data = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
print(object);
_notebookDetailChangeModel.userHistorys = [];
showPhoneHistory = false;
// setState(() {});
_notebookDetailChangeModel.userHistorys = [];
showPhoneHistory = false;
// setState(() {});
object.forEach((element) {
_notebookDetailChangeModel.userHistorys.add(UserHistoryEntity(
'', '', element.name ?? '', '1', element.number, '', '', ''));
object.forEach((element) {
_notebookDetailChangeModel.userHistorys.add(UserHistoryEntity(
'', '', element.name ?? '', '1', element.number, '', '', ''));
String title = '';
title += ' ${element.number ?? ''}';
if (element.name != null && element.name != '') {
title += ' ${element.name}';
}
String title = '';
title += ' ${element.number ?? ''}';
if (element.name != null && element.name != '') {
title += ' ${element.name}';
}
String stateStr = ''; //状态
if (element.callType.name == 'incoming' ||
element.callType.name == 'wifiIncoming' ||
element.callType.name == 'answeredExternally') {
stateStr = ' 呼入';
} else if (element.callType.name == 'outgoing' ||
element.callType.name == 'wifiOutgoing' ||
element.callType.name == 'voiceMail') {
stateStr = ' 呼出';
} else if (element.callType.name == 'missed') {
stateStr = ' 未接';
} else if (element.callType.name == 'rejected') {
stateStr = ' 拒接';
} else if (element.callType.name == 'blocked') {
stateStr = ' 拦截';
}
String stateStr = ''; //状态
if (element.callType.name == 'incoming' ||
element.callType.name == 'wifiIncoming' ||
element.callType.name == 'answeredExternally') {
stateStr = ' 呼入';
} else if (element.callType.name == 'outgoing' ||
element.callType.name == 'wifiOutgoing' ||
element.callType.name == 'voiceMail') {
stateStr = ' 呼出';
} else if (element.callType.name == 'missed') {
stateStr = ' 未接';
} else if (element.callType.name == 'rejected') {
stateStr = ' 拒接';
} else if (element.callType.name == 'blocked') {
stateStr = ' 拦截';
}
String sunString =
Utils.formatCallLogFromMill(element.timestamp.toString());
String sunString =
Utils.formatCallLogFromMill(element.timestamp.toString());
data.add(Picker.PickerItem(
text: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
HEmptyView(30),
Text(title ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)),
Expanded(
child: Text(stateStr ?? '',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_26000000))),
],
)),
Container(
margin: EdgeInsets.only(right: w(15)),
child: Text(sunString ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)))
],
)));
});
if (data.length > 0) {
//有记录,底部弹窗展示
// showPhoneHistory = true;
// setState(() {});
DialogUtil.showSelectCusmanWidgetDialog(context, data, (value) {
if (value != null) {
_byValueToReqeust(value[0]);
}
}, title: '从通话记录选择客人电话', selecteds: [
// _getFirSelected(hourAndMinute, data),
// _getSecSelected(hourAndMinute)
]).then((value) {
print(value);
data.add(Picker.PickerItem(
text: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
HEmptyView(30),
Text(title ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)),
Expanded(
child: Text(stateStr ?? '',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_26000000))),
],
)),
Container(
margin: EdgeInsets.only(right: w(15)),
child: Text(sunString ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)))
],
)));
});
} else {
Utils.showToast('暂无通话记录!');
if (data.length > 0) {
//有记录,底部弹窗展示
// showPhoneHistory = true;
// setState(() {});
DialogUtil.showSelectCusmanWidgetDialog(context, data, (value) {
if (value != null) {
_byValueToReqeust(value[0]);
}
}, title: '从通话记录选择客人电话', selecteds: [
// _getFirSelected(hourAndMinute, data),
// _getSecSelected(hourAndMinute)
]).then((value) {
print(value);
});
} else {
Utils.showToast('暂无通话记录!');
}
} catch (e) {
print(e);
}
}
... ...
... ... @@ -3930,7 +3930,8 @@ class InvicationPageState extends State<InvicationPage>
}
_getCallLog() async {
Iterable<CallLogEntry> result = await CallLog.query();
try {
Iterable<CallLogEntry> result = await CallLog.query();
List<Picker.PickerItem<dynamic>> data = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
... ... @@ -4056,6 +4057,10 @@ class InvicationPageState extends State<InvicationPage>
} else {
_getContactData();
}
} catch (e) {
}
}
_getContactData() async {
... ...
... ... @@ -682,91 +682,93 @@ class TableManagerPageState extends State<TableManagerPage> {
// }
_getCallLog() async {
Iterable<CallLogEntry> result = await CallLog.query();
List<Picker.PickerItem<dynamic>> data = [];
try {
Iterable<CallLogEntry> result = await CallLog.query();
List<Picker.PickerItem<dynamic>> data = [];
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
List<CallLogEntry> object = Utils.removeDuplicates(result.toList());
print(object);
print(object);
_baseIndoProvider.userHistorys = [];
showPhoneHistory = false;
// setState(() {});
_baseIndoProvider.userHistorys = [];
showPhoneHistory = false;
// setState(() {});
object.forEach((element) {
_baseIndoProvider.userHistorys.add(UserHistoryEntity(
'', '', element.name ?? '', '1', element.number, '', '', ''));
object.forEach((element) {
_baseIndoProvider.userHistorys.add(UserHistoryEntity(
'', '', element.name ?? '', '1', element.number, '', '', ''));
String title = '';
title += ' ${element.number ?? ''}';
if (element.name != null && element.name != '') {
title += ' ${element.name}';
}
String title = '';
title += ' ${element.number ?? ''}';
if (element.name != null && element.name != '') {
title += ' ${element.name}';
}
String stateStr = ''; //状态
if (element.callType.name == 'incoming' ||
element.callType.name == 'wifiIncoming' ||
element.callType.name == 'answeredExternally') {
stateStr = ' 呼入';
} else if (element.callType.name == 'outgoing' ||
element.callType.name == 'wifiOutgoing' ||
element.callType.name == 'voiceMail') {
stateStr = ' 呼出';
} else if (element.callType.name == 'missed') {
stateStr = ' 未接';
} else if (element.callType.name == 'rejected') {
stateStr = ' 拒接';
} else if (element.callType.name == 'blocked') {
stateStr = ' 拦截';
}
String stateStr = ''; //状态
if (element.callType.name == 'incoming' ||
element.callType.name == 'wifiIncoming' ||
element.callType.name == 'answeredExternally') {
stateStr = ' 呼入';
} else if (element.callType.name == 'outgoing' ||
element.callType.name == 'wifiOutgoing' ||
element.callType.name == 'voiceMail') {
stateStr = ' 呼出';
} else if (element.callType.name == 'missed') {
stateStr = ' 未接';
} else if (element.callType.name == 'rejected') {
stateStr = ' 拒接';
} else if (element.callType.name == 'blocked') {
stateStr = ' 拦截';
}
String sunString =
Utils.formatCallLogFromMill(element.timestamp.toString());
String sunString =
Utils.formatCallLogFromMill(element.timestamp.toString());
data.add(Picker.PickerItem(
text: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
HEmptyView(30),
Text(title ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)),
Expanded(
child: Text(stateStr ?? '',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_26000000))),
],
)),
Container(
margin: EdgeInsets.only(right: w(15)),
child: Text(sunString ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)))
],
)));
});
if (data.length > 0) {
//有记录,底部弹窗展示
// showPhoneHistory = true;
// setState(() {});
DialogUtil.showSelectCusmanWidgetDialog(context, data, (value) {
if (value != null) {
_byValueToReqeust(value[0]);
}
}, title: '从通话记录选择客人电话', selecteds: [
// _getFirSelected(hourAndMinute, data),
// _getSecSelected(hourAndMinute)
]).then((value) {
print(value);
data.add(Picker.PickerItem(
text: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Row(
children: [
HEmptyView(30),
Text(title ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)),
Expanded(
child: Text(stateStr ?? '',
style: TextStyle(
fontSize: font(16),
color: MyColours.color_26000000))),
],
)),
Container(
margin: EdgeInsets.only(right: w(15)),
child: Text(sunString ?? '',
style: TextStyle(
fontSize: font(16), color: MyColours.color_515151)))
],
)));
});
} else {
Utils.showToast('暂无通话记录!');
}
if (data.length > 0) {
//有记录,底部弹窗展示
// showPhoneHistory = true;
// setState(() {});
DialogUtil.showSelectCusmanWidgetDialog(context, data, (value) {
if (value != null) {
_byValueToReqeust(value[0]);
}
}, title: '从通话记录选择客人电话', selecteds: [
// _getFirSelected(hourAndMinute, data),
// _getSecSelected(hourAndMinute)
]).then((value) {
print(value);
});
} else {
Utils.showToast('暂无通话记录!');
}
} catch (e) {}
}
_byValueToReqeust(int index) {
... ...
... ... @@ -56,7 +56,6 @@ Future<PermissionStatus> contactPermissionStatus() async {
return permissionStatus;
}
Future<bool> requestContactPermission() async {
final permissions = await [Permission.contacts].request();
if (permissions[Permission.contacts] == PermissionStatus.granted) {
... ...
... ... @@ -213,10 +213,18 @@ class Utils {
} else if (Utils.isOneDay(_strtimes, dateNow.add(Duration(days: 2)))) {
date = "后天 ";
} else {
date = Utils.addZeroNumber(_strtimes.month) +
"月" +
Utils.addZeroNumber(_strtimes.day) +
"日";
if (_strtimes.year == dateNow.year) {
date = Utils.addZeroNumber(_strtimes.month) +
"月" +
Utils.addZeroNumber(_strtimes.day) +
"日";
} else {
date = _strtimes.year.toString() +
Utils.addZeroNumber(_strtimes.month) +
"月" +
Utils.addZeroNumber(_strtimes.day) +
"日";
}
}
return date;
}
... ...
... ... @@ -986,35 +986,35 @@ packages:
name: permission_handler
url: "https://pub.flutter-io.cn"
source: hosted
version: "10.0.0"
version: "11.0.1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
url: "https://pub.flutter-io.cn"
source: hosted
version: "10.0.0"
version: "11.1.0"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
url: "https://pub.flutter-io.cn"
source: hosted
version: "9.0.4"
version: "9.1.4"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.7.0"
version: "3.12.0"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.0"
version: "0.1.3"
petitparser:
dependency: transitive
description:
... ...
... ... @@ -51,7 +51,8 @@ dependencies:
# fluttertoast: ^3.1.3
fluttertoast: ^8.0.9
# 权限管理
permission_handler: ^10.0.0
# permission_handler: ^10.0.0
permission_handler: ^11.0.1
# permission_handler: ^5.0.1
# permission_handler: ^5.0.1+1 ^6.1.1 4.4.0
# 文件系统访问
... ...