Compare commits

...

2 Commits

Author SHA1 Message Date
王亚玲 f75a5270fb Merge branch 'master' of https://git.oa00.com/austin_dai/project_telephony
2 years ago
王亚玲 2fa9d4339d 更改
2 years ago

@ -4,6 +4,7 @@ import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:velocity_x/velocity_x.dart';
import '../../constants/api.dart';
@ -21,15 +22,18 @@ class ExcludeContactsPage extends StatefulWidget {
class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
List<Contact>? contacts;
List<String> numbers = [];
List<String> numbers1 = [];
List<bool> status = [];
var flag = true;
@override
void initState() {
super.initState();
_viewLoading();
}
Future _viewLoading() async {
// final SharedPreferences prefs = await SharedPreferences.getInstance();
contacts = await FlutterContacts.getContacts();
for (var element in contacts!) {
final full = await FlutterContacts.getContact(element.id);
@ -40,6 +44,8 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
}
status.add(false);
}
// await prefs.setStringList("addressList", numbers);
print(contacts?.length);
setState(() {});
}
@ -52,9 +58,12 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
flag = false;
return Container();
} else {
return ListView.builder(
itemCount: contacts!.length,
itemBuilder: (context, i) => ListTile(
itemBuilder: (context, i) {
return ListTile(
title: Text(
contacts![i].displayName,
style: TextStyle(
@ -82,8 +91,8 @@ class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
//
checkColor: Colors.white,
),
).paddingOnly(left: 20.w),
);
).paddingOnly(left: 20.w);
});
}
},
);

@ -54,11 +54,10 @@ void onStart(ServiceInstance service) async {
// });
// Telephony.backgroundInstance.sendSms(to: "13486828191", message: "123123");
Timer.periodic(const Duration(seconds: 1), (timer) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
CallState state = await Telephony.instance.callState;
callState = state.name;
print("$callState$flag");
// print("$callState$flag");
// print(entry.first.duration);
String? ref = prefs.getString('refSms');
String? con = prefs.getString('conSms');
@ -66,7 +65,9 @@ void onStart(ServiceInstance service) async {
String? idle = prefs.getString('idleSms');
bool? callSw = prefs.getBool('callSwitch');
bool? idleSw = prefs.getBool('idleSwitch');
int? numberSet=prefs.getInt("numIndex");
List<String>? numberList=prefs.getStringList("addressList");
print("号码设置$numberSet 通讯列表$numberList");
if (callState == "IDLE") {
if (flag != 0) {
final Iterable<CallLogEntry> entry = await CallLog.query();

@ -1,9 +1,13 @@
import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:project_telephony/ui/home/set/specify_phone_page.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import '../../../base/base_style.dart';
import '../../../model/phone_num_model.dart';
import '../../widget/plone_back_button.dart';
// class setItem{
@ -20,6 +24,12 @@ class PhoneSetPage extends StatefulWidget {
class _PhoneSetPageState extends State<PhoneSetPage> {
int select = 0;
List<Contact>? contact;
List<String> numbers = [];
List<String>? numList=[];
List<String> numList2=[];
List<String>? numList3=[];
List setList = [
{
"icon": Assets.icons.rylyphone.path,
@ -40,7 +50,11 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
// "select": false,
},
];
@override
void initState() {
_viewLoading();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -111,11 +125,58 @@ class _PhoneSetPageState extends State<PhoneSetPage> {
),
);
}
Future _viewLoading() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
contact = await FlutterContacts.getContacts();
for (var element in contact!) {
final full = await FlutterContacts.getContact(element.id);
numbers.add(full!.phones.first.number.replaceAll(" ",""));
// status.add(false);
}
await prefs.setStringList("addressList", numbers);
// phoneNum.clear();
// final Iterable<CallLogEntry> entries = await CallLog.query();
// numList= prefs.getStringList('addressList');
// count=numList?.length;
// for (CallLogEntry entrie in entries) {
// if (!numList2.contains(numList)) {
// numList2.add(entrie.number!);
// }
// }
// for(int i=0;i<count!;i++){
// numList2.remove(numList![i]);
// }
// print(numList2);
// await prefs.setStringList("noAddressList", numList2);
// for (int i = 0; i < phoneNum.length; i++) {
// phoneNum2.add(PhoneNumModel(
// num: phoneNum[i].num,
// time: phoneNum[i].time,
// name: phoneNum[i].name,
// state: phoneNum[i].state,
// ));
// }
setState(() {});
}
_getListBox(List item, int index) {
final service = FlutterBackgroundService();
return GestureDetector(
onTap: () {
onTap: () async{
final SharedPreferences prefs = await SharedPreferences.getInstance();
select = index;
await prefs.setInt("numIndex", index);
if(await service.isRunning()){
service.invoke("stopService");
Future.delayed(const Duration(seconds: 1), () async {
service.startService();
});
}else{
service.startService();
Future.delayed(const Duration(seconds: 1), () async {
service.invoke("stopService");
});
}
// print(_selectIndex);
setState(() {});
},

Loading…
Cancel
Save