|
|
@ -1,9 +1,11 @@
|
|
|
|
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.dart';
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.dart';
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
import 'package:project_telephony/ui/home/set/func/exclude_contacts_func.dart';
|
|
|
|
import 'package:project_telephony/ui/home/set/func/exclude_contacts_func.dart';
|
|
|
|
import 'package:project_telephony/ui/home/set/specify_phone_page.dart';
|
|
|
|
import 'package:project_telephony/ui/home/set/specify_phone_page.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
|
|
|
|
import 'package:project_telephony/utils/user_tool.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
|
|
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
|
|
|
import '../../../base/base_style.dart';
|
|
|
|
import '../../../base/base_style.dart';
|
|
|
@ -26,6 +28,7 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
List<Contact>? contact;
|
|
|
|
List<Contact>? contact;
|
|
|
|
List<String> numbers = [];
|
|
|
|
List<String> numbers = [];
|
|
|
|
List<String>? numList = [];
|
|
|
|
List<String>? numList = [];
|
|
|
|
|
|
|
|
DateTime? _lastTap;
|
|
|
|
final EasyRefreshController _refreshController = EasyRefreshController();
|
|
|
|
final EasyRefreshController _refreshController = EasyRefreshController();
|
|
|
|
List setList = [
|
|
|
|
List setList = [
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -75,10 +78,9 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
header: MaterialHeader(),
|
|
|
|
header: MaterialHeader(),
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
onRefresh: () async {
|
|
|
|
onRefresh: () async {
|
|
|
|
final SharedPreferences prefs =
|
|
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
await SharedPreferences.getInstance();
|
|
|
|
|
|
|
|
select = (prefs.getInt("numIndex"))!;
|
|
|
|
select = (prefs.getInt("numIndex"))!;
|
|
|
|
_viewLoading();
|
|
|
|
// _viewLoading();
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: ListView(
|
|
|
|
child: ListView(
|
|
|
@ -146,66 +148,61 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future _viewLoading() async {
|
|
|
|
// Future _viewLoading() async {
|
|
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
contact = await FlutterContacts.getContacts();
|
|
|
|
// contact = await FlutterContacts.getContacts();
|
|
|
|
for (var element in contact!) {
|
|
|
|
// for (var element in contact!) {
|
|
|
|
final full = await FlutterContacts.getContact(element.id);
|
|
|
|
// final full = await FlutterContacts.getContact(element.id);
|
|
|
|
numbers.add(full!.phones.first.number.replaceAll(" ", ""));
|
|
|
|
// numbers.add(full!.phones.first.number.replaceAll(" ", ""));
|
|
|
|
// status.add(false);
|
|
|
|
// // status.add(false);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
var numberList = await ExcludeFunc.getContacts();
|
|
|
|
// var numberList = await ExcludeFunc.getContacts();
|
|
|
|
for (int i = 0; i < numberList.length; i++) {
|
|
|
|
// for (int i = 0; i < numberList.length; i++) {
|
|
|
|
numList?.add(numberList[i].phone);
|
|
|
|
// numList?.add(numberList[i].phone);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
await prefs.setStringList("specified", numList!);
|
|
|
|
// await prefs.setStringList("specified", numList!);
|
|
|
|
await prefs.setStringList("addressList", numbers);
|
|
|
|
// await prefs.setStringList("addressList", numbers);
|
|
|
|
// phoneNum.clear();
|
|
|
|
// // phoneNum.clear();
|
|
|
|
// final Iterable<CallLogEntry> entries = await CallLog.query();
|
|
|
|
// // final Iterable<CallLogEntry> entries = await CallLog.query();
|
|
|
|
// numList= prefs.getStringList('addressList');
|
|
|
|
// // numList= prefs.getStringList('addressList');
|
|
|
|
// count=numList?.length;
|
|
|
|
// // count=numList?.length;
|
|
|
|
// for (CallLogEntry entrie in entries) {
|
|
|
|
// // for (CallLogEntry entrie in entries) {
|
|
|
|
// if (!numList2.contains(numList)) {
|
|
|
|
// // if (!numList2.contains(numList)) {
|
|
|
|
// numList2.add(entrie.number!);
|
|
|
|
// // numList2.add(entrie.number!);
|
|
|
|
// }
|
|
|
|
// // }
|
|
|
|
// }
|
|
|
|
// // }
|
|
|
|
// for(int i=0;i<count!;i++){
|
|
|
|
// // for(int i=0;i<count!;i++){
|
|
|
|
// numList2.remove(numList![i]);
|
|
|
|
// // numList2.remove(numList![i]);
|
|
|
|
// }
|
|
|
|
// // }
|
|
|
|
// print(numList2);
|
|
|
|
// // print(numList2);
|
|
|
|
// await prefs.setStringList("noAddressList", numList2);
|
|
|
|
// // await prefs.setStringList("noAddressList", numList2);
|
|
|
|
// for (int i = 0; i < phoneNum.length; i++) {
|
|
|
|
// // for (int i = 0; i < phoneNum.length; i++) {
|
|
|
|
// phoneNum2.add(PhoneNumModel(
|
|
|
|
// // phoneNum2.add(PhoneNumModel(
|
|
|
|
// num: phoneNum[i].num,
|
|
|
|
// // num: phoneNum[i].num,
|
|
|
|
// time: phoneNum[i].time,
|
|
|
|
// // time: phoneNum[i].time,
|
|
|
|
// name: phoneNum[i].name,
|
|
|
|
// // name: phoneNum[i].name,
|
|
|
|
// state: phoneNum[i].state,
|
|
|
|
// // state: phoneNum[i].state,
|
|
|
|
// ));
|
|
|
|
// // ));
|
|
|
|
// }
|
|
|
|
// // }
|
|
|
|
setState(() {});
|
|
|
|
// setState(() {});
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
_getListBox(List item, int index) {
|
|
|
|
_getListBox(List item, int index) {
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
return GestureDetector(
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
onTap: () async {
|
|
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
select = index;
|
|
|
|
// select = index;
|
|
|
|
await prefs.setInt("numIndex", index);
|
|
|
|
// await prefs.setInt("numIndex", index);
|
|
|
|
print(await service.isRunning());
|
|
|
|
// service.invoke("stopService");
|
|
|
|
if (await service.isRunning()) {
|
|
|
|
// if (prefs.getBool('kg')!) {
|
|
|
|
service.invoke("stopService");
|
|
|
|
// Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
// service.startService();
|
|
|
|
service.startService();
|
|
|
|
// });
|
|
|
|
});
|
|
|
|
// }
|
|
|
|
} else {
|
|
|
|
//
|
|
|
|
service.startService();
|
|
|
|
// UserTool.userProvider.viewLoading();
|
|
|
|
Future.delayed(const Duration(seconds: 2), () async {
|
|
|
|
// _refreshController.callRefresh();
|
|
|
|
service.invoke("stopService");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
print( prefs.getStringList("specified"));
|
|
|
|
|
|
|
|
_refreshController.callRefresh();
|
|
|
|
|
|
|
|
// print(_selectIndex);
|
|
|
|
// print(_selectIndex);
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -229,8 +226,19 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
width: 40.w,
|
|
|
|
width: 40.w,
|
|
|
|
height: 40.w,
|
|
|
|
height: 40.w,
|
|
|
|
child: Radio(
|
|
|
|
child: Radio(
|
|
|
|
onChanged: (int? value) {
|
|
|
|
onChanged: (int? value) async{
|
|
|
|
|
|
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
select = index;
|
|
|
|
select = index;
|
|
|
|
|
|
|
|
await prefs.setInt("numIndex", index);
|
|
|
|
|
|
|
|
service.invoke("stopService");
|
|
|
|
|
|
|
|
if (prefs.getBool('kg')!) {
|
|
|
|
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
|
|
|
|
service.startService();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UserTool.userProvider.viewLoading();
|
|
|
|
|
|
|
|
_refreshController.callRefresh();
|
|
|
|
|
|
|
|
// select = index;
|
|
|
|
// print(_selectIndex);
|
|
|
|
// print(_selectIndex);
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|