master
戴余标 2 years ago
parent 221820c0d8
commit f5d14e1060

@ -42,6 +42,8 @@
<uses-permission android:name="android.permission.CALL_PHONE"/> <uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<!-- Provide required visibility configuration for API level 30 and above --> <!-- Provide required visibility configuration for API level 30 and above -->
<queries> <queries>
<!-- If your app checks for SMS support --> <!-- If your app checks for SMS support -->

@ -1,4 +1,11 @@
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:get/get_utils/get_utils.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart'; import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
class ExcludeContactsPage extends StatefulWidget { class ExcludeContactsPage extends StatefulWidget {
@ -9,13 +16,87 @@ class ExcludeContactsPage extends StatefulWidget {
} }
class _ExcludeContactsPageState extends State<ExcludeContactsPage> { class _ExcludeContactsPageState extends State<ExcludeContactsPage> {
late List<Contact> contacts;
List<String> numbers = [];
List<bool> status = [];
var flag = true;
@override
void initState() {
super.initState();
_incrementCounter();
}
Future _incrementCounter() async {
contacts = await FlutterContacts.getContacts();
for (var element in contacts) {
final full = await FlutterContacts.getContact(element.id);
numbers.add(full!.phones.first.number);
status.add(false);
}
setState(() {});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var profileBuilder = FutureBuilder(
future: _incrementCounter(),
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting && flag) {
flag = false;
return Container();
} else {
return ListView.builder(
itemCount: contacts.length,
itemBuilder: (context, i) => ListTile(
title: Text(
contacts[i].displayName,
style: TextStyle(
fontSize: 32.sp,
fontWeight: FontWeight.w600,
),
),
subtitle: Text(
numbers[i],
style: TextStyle(
fontSize: 28.sp,
fontWeight: FontWeight.w300,
),
),
trailing: Checkbox(
value: status[i],
//
onChanged: (value) {
setState(() {
status[i] = !status[i];
});
},
//
activeColor: Colors.blue,
//
checkColor: Colors.white,
),
).paddingOnly(left: 20.w),
);
}
},
);
return ScaffoldThemeWidget( return ScaffoldThemeWidget(
title: "从通讯录添加", title: "从通讯录添加",
bottom: "添加", bottom: "添加",
onTap: () { }, onTap: () {
child: Container(), if(status.contains(true)){
// BotToast.showText(text: "");
Get.back();
}else{
BotToast.showText(text: "还未选中手机号");
}
},
isOpacity: status.contains(true),
isBorder: true,
child: profileBuilder,
); );
} }
} }

@ -0,0 +1,68 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:project_telephony/ui/widget/scaffold_theme_widget.dart';
import 'package:velocity_x/velocity_x.dart';
class ExcludeSinglePage extends StatefulWidget {
const ExcludeSinglePage({Key? key}) : super(key: key);
@override
_ExcludeSinglePageState createState() => _ExcludeSinglePageState();
}
class _ExcludeSinglePageState extends State<ExcludeSinglePage> {
@override
Widget build(BuildContext context) {
return ScaffoldThemeWidget(
title: '添加单个或批量号码',
bottom: "添加",
onTap: () {},
child: Container(
padding: EdgeInsets.only(top: 25.h, left: 50.w, right: 50.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
addNumber("号码", "请输入号码"),
15.heightBox,
addNumber("名称", "请输入名称"),
15.heightBox,
RichText(
text: const TextSpan(
children: [
TextSpan(text: "使用说明:"),
TextSpan(text: "如输入000*可屏蔽所有000开头的号码")
],
),
),
],
),
),
);
}
addNumber(String title, content) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 18,
color: Colors.black38,
fontWeight: FontWeight.w600,
),
),
15.heightBox,
TextField(
decoration: InputDecoration(
hintText: content,
border: const OutlineInputBorder(
),
),
),
],
);
}
}

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/ui/exclude/exclude_contacts_page.dart'; import 'package:project_telephony/ui/exclude/exclude_contacts_page.dart';
import 'package:project_telephony/ui/exclude/exclude_single_page.dart';
import 'package:project_telephony/ui/home/home_page.dart'; import 'package:project_telephony/ui/home/home_page.dart';
import 'package:project_telephony/ui/home/set/phone_num_list/call_records_list.dart'; import 'package:project_telephony/ui/home/set/phone_num_list/call_records_list.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
@ -29,7 +30,10 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ScaffoldThemeWidget(title: "发送号码设置", bottom: '添加', onTap: () { return ScaffoldThemeWidget(
title: "发送号码设置",
bottom: '添加',
onTap: () {
showModalBottomSheet( showModalBottomSheet(
builder: (BuildContext context) { builder: (BuildContext context) {
return Container( return Container(
@ -42,8 +46,7 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
Text( Text(
"添加号码", "添加号码",
style: TextStyle( style: TextStyle(
fontSize: 34.w, fontSize: 34.w, fontWeight: FontWeight.bold),
fontWeight: FontWeight.bold),
), ),
Expanded( Expanded(
child: ListView( child: ListView(
@ -55,14 +58,14 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
isBorder: true, isBorder: true,
isOpacity: false, isOpacity: false,
onTap: () {}, onTap: () {},
child: const CallRecordsList() child: const CallRecordsList()));
));
}), }),
_getAddPhone("通迅录添加", "通过本机通讯录添加号码", () { _getAddPhone("通迅录添加", "通过本机通讯录添加号码", () {
Get.to(() => (const ExcludeContactsPage())); Get.to(() => (const ExcludeContactsPage()));
}), }),
_getAddPhone( _getAddPhone("添加单个或批量号码", "通过输入号码段添加批量号码", () {
"添加单个或批量号码", "通过输入号码段添加批量号码", () {}), Get.to(() => (const ExcludeSinglePage()));
}),
], ],
)), )),
PloneBottom( PloneBottom(
@ -96,9 +99,9 @@ class _SpecifyPhonePageState extends State<SpecifyPhonePage> {
child: ListView( child: ListView(
children: [ children: [
_getNullList(), _getNullList(),
], ],
)),); )),
);
// PloneBottom( // PloneBottom(
// onTap: () { // onTap: () {
// showModalBottomSheet( // showModalBottomSheet(

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
@ -8,8 +7,6 @@ import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
class PrivacyRightsPage extends StatefulWidget { class PrivacyRightsPage extends StatefulWidget {
final String name; final String name;
@ -30,6 +27,7 @@ final Uri _url = Uri.parse('https://www.dxbs.vip//explain.html');
bool sms = false; bool sms = false;
bool plone = false; bool plone = false;
bool callLog = false; bool callLog = false;
bool contacts = false;
@override @override
class _PrivacyRightsPageState extends State<PrivacyRightsPage> { class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
@ -45,6 +43,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
sms = await Permission.sms.request().isGranted; sms = await Permission.sms.request().isGranted;
plone = await Permission.phone.request().isGranted; plone = await Permission.phone.request().isGranted;
callLog = await Permission.callLog.request().isGranted; callLog = await Permission.callLog.request().isGranted;
contacts = await Permission.contacts.request().isGranted;
setState(() {}); setState(() {});
} }
@ -69,6 +68,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
_getRights("获取设备来电状态", "用于获取来电状态", plone), _getRights("获取设备来电状态", "用于获取来电状态", plone),
_getRights("获取设备短信权限", "用于发送短信", sms), _getRights("获取设备短信权限", "用于发送短信", sms),
_getRights("获取设备通话记录", "用于获取来电", callLog), _getRights("获取设备通话记录", "用于获取来电", callLog),
_getRights("获取设备通讯录", "用于插入排除手机号", contacts),
], ],
), ),
bottomNavigationBar: GestureDetector( bottomNavigationBar: GestureDetector(
@ -121,6 +121,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
onTap: () async { onTap: () async {
if (!state) { if (!state) {
openAppSettings(); openAppSettings();
setState(() {});
} }
// if(!(sms && plone)){ // if(!(sms && plone)){
// // print(sms); // // print(sms);

@ -23,20 +23,22 @@ class ScaffoldThemeWidget extends StatefulWidget {
final bool isBorder; final bool isBorder;
final bool isOpacity; final bool isOpacity;
final VoidCallback onTap; final VoidCallback onTap;
const ScaffoldThemeWidget(
{Key? key, required this.title, required this.child, required this.bottom, this.isBorder = false, this.isOpacity = true,required this.onTap const ScaffoldThemeWidget({
}) Key? key,
: super(key: key); required this.title,
required this.child,
required this.bottom,
this.isBorder = false,
this.isOpacity = true,
required this.onTap,
}) : super(key: key);
@override @override
_ScaffoldThemeWidgetState createState() => _ScaffoldThemeWidgetState(); _ScaffoldThemeWidgetState createState() => _ScaffoldThemeWidgetState();
} }
class _ScaffoldThemeWidgetState extends State<ScaffoldThemeWidget> { class _ScaffoldThemeWidgetState extends State<ScaffoldThemeWidget> {
@override
void initState() {
super.initState();
}
// final userProvider = Provider.of<UserProvider>(Get.context!, listen: false); // final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@override @override

@ -360,6 +360,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.0"
flutter_contacts:
dependency: "direct main"
description:
name: flutter_contacts
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.5"
flutter_easyrefresh: flutter_easyrefresh:
dependency: "direct main" dependency: "direct main"
description: description:

@ -93,6 +93,8 @@ dependencies:
url_launcher: ^6.1.5 url_launcher: ^6.1.5
#tabBar样式切换 #tabBar样式切换
tab_indicator_styler: ^2.0.0 tab_indicator_styler: ^2.0.0
#手机通讯录
flutter_contacts: ^1.1.5
# # jdk # # jdk
# jverify: ^2.2.5 # jverify: ^2.2.5

Loading…
Cancel
Save