|
|
@ -1,13 +1,13 @@
|
|
|
|
import 'package:call_log/call_log.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: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: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';
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../model/phone_num_model.dart';
|
|
|
|
|
|
|
|
import '../../widget/plone_back_button.dart';
|
|
|
|
import '../../widget/plone_back_button.dart';
|
|
|
|
|
|
|
|
|
|
|
|
// class setItem{
|
|
|
|
// class setItem{
|
|
|
@ -15,7 +15,6 @@ import '../../widget/plone_back_button.dart';
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
class PhoneSetPage extends StatefulWidget {
|
|
|
|
class PhoneSetPage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
|
|
const PhoneSetPage({Key? key}) : super(key: key);
|
|
|
|
const PhoneSetPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -26,10 +25,8 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
int select = 0;
|
|
|
|
int select = 0;
|
|
|
|
List<Contact>? contact;
|
|
|
|
List<Contact>? contact;
|
|
|
|
List<String> numbers = [];
|
|
|
|
List<String> numbers = [];
|
|
|
|
List<String>? numList=[];
|
|
|
|
List<String>? numList = [];
|
|
|
|
List<String> numList2=[];
|
|
|
|
final EasyRefreshController _refreshController = EasyRefreshController();
|
|
|
|
List<String>? numList3=[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List setList = [
|
|
|
|
List setList = [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"icon": Assets.icons.rylyphone.path,
|
|
|
|
"icon": Assets.icons.rylyphone.path,
|
|
|
@ -50,11 +47,12 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
// "select": false,
|
|
|
|
// "select": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
@override
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
_viewLoading();
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
@ -71,16 +69,29 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
leading: const CloudBackButton(isSpecial: true),
|
|
|
|
leading: const CloudBackButton(isSpecial: true),
|
|
|
|
backgroundColor: kForeGroundColor),
|
|
|
|
backgroundColor: kForeGroundColor),
|
|
|
|
backgroundColor: kForeGroundColor,
|
|
|
|
backgroundColor: kForeGroundColor,
|
|
|
|
body: Column(
|
|
|
|
body: EasyRefresh(
|
|
|
|
|
|
|
|
firstRefresh: true,
|
|
|
|
|
|
|
|
controller: _refreshController,
|
|
|
|
|
|
|
|
header: MaterialHeader(),
|
|
|
|
|
|
|
|
// footer: MaterialFooter(),
|
|
|
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
|
|
|
final SharedPreferences prefs =
|
|
|
|
|
|
|
|
await SharedPreferences.getInstance();
|
|
|
|
|
|
|
|
select = (prefs.getInt("numIndex"))!;
|
|
|
|
|
|
|
|
_viewLoading();
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
_getList(),
|
|
|
|
_getList(),
|
|
|
|
24.hb,
|
|
|
|
24.hb,
|
|
|
|
GestureDetector(
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
onTap: () {
|
|
|
|
Get.to(()=>const SpecifyPhonePage());
|
|
|
|
Get.to(() => const SpecifyPhonePage());
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 32.w, vertical: 30.w),
|
|
|
|
padding:
|
|
|
|
|
|
|
|
EdgeInsets.symmetric(horizontal: 32.w, vertical: 30.w),
|
|
|
|
height: 144.w,
|
|
|
|
height: 144.w,
|
|
|
|
child: ListTile(
|
|
|
|
child: ListTile(
|
|
|
|
leading: SizedBox(
|
|
|
|
leading: SizedBox(
|
|
|
@ -93,8 +104,8 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
title: Text(
|
|
|
|
"指定号码不发送",
|
|
|
|
"指定号码不发送",
|
|
|
|
style:
|
|
|
|
style: TextStyle(
|
|
|
|
TextStyle(fontSize: 32.sp, fontWeight: FontWeight.bold),
|
|
|
|
fontSize: 32.sp, fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Text(
|
|
|
|
subtitle: Text(
|
|
|
|
"通过添加指定号码来设置不发送",
|
|
|
|
"通过添加指定号码来设置不发送",
|
|
|
@ -110,6 +121,15 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Column(
|
|
|
|
|
|
|
|
// children: [
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
// ),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -125,15 +145,20 @@ 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();
|
|
|
|
|
|
|
|
for (int i = 0; i < numberList.length; i++) {
|
|
|
|
|
|
|
|
numList?.add(numberList[i].phone);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
@ -159,24 +184,28 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
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);
|
|
|
|
if(await service.isRunning()){
|
|
|
|
print(await service.isRunning());
|
|
|
|
|
|
|
|
if (await service.isRunning()) {
|
|
|
|
service.invoke("stopService");
|
|
|
|
service.invoke("stopService");
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
service.startService();
|
|
|
|
service.startService();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
service.startService();
|
|
|
|
service.startService();
|
|
|
|
Future.delayed(const Duration(seconds: 1), () async {
|
|
|
|
Future.delayed(const Duration(seconds: 2), () async {
|
|
|
|
service.invoke("stopService");
|
|
|
|
service.invoke("stopService");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print( prefs.getStringList("specified"));
|
|
|
|
|
|
|
|
_refreshController.callRefresh();
|
|
|
|
// print(_selectIndex);
|
|
|
|
// print(_selectIndex);
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
},
|
|
|
|