戴余标 2 years ago
commit edcb9a190f

@ -31,9 +31,11 @@
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
</application> </application>
<!-- 互联网权限-->
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<!--发送信息权限-->
<uses-permission android:name="android.permission.SEND_SMS"/> <uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/> <uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/> <uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.CALL_PHONE"/> <uses-permission android:name="android.permission.CALL_PHONE"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
android.jetifier.blacklist=bcprov-jdk15on

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:call_log/call_log.dart'; import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -7,7 +8,10 @@ import 'package:flutter/services.dart';
import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_sms/flutter_sms.dart'; import 'package:flutter_sms/flutter_sms.dart';
import 'package:fluwx/fluwx.dart';
import 'package:get/get_navigation/src/root/get_material_app.dart'; import 'package:get/get_navigation/src/root/get_material_app.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart';
import 'package:power_logger/power_logger.dart'; import 'package:power_logger/power_logger.dart';
import 'package:project_telephony/providers/user_provider.dart'; import 'package:project_telephony/providers/user_provider.dart';
@ -16,13 +20,15 @@ import 'package:provider/provider.dart';
import 'package:telephony/telephony.dart'; import 'package:telephony/telephony.dart';
import 'package:project_telephony/utils/hive_store.dart'; import 'package:project_telephony/utils/hive_store.dart';
void _sendSMS(String message, List<String> recipents) async { // void _sendSMS(String message, List<String> recipients) async {
String _result = await sendSMS(message: message, recipients: recipents) // try{
.catchError((onError) { // String result =
print(onError); // await sendSMS(message: message, recipients: recipients, sendDirect: true);
}); // print(result);
print(_result); // } on PlatformException catch(e){
} // print(e.toString());
// }
// }
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -30,81 +36,89 @@ void main() async {
LoggerData.addData(details); LoggerData.addData(details);
FlutterError.presentError(details); FlutterError.presentError(details);
}; };
await initializeService(); // await initializeService();
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp()); runApp(const MyApp());
} }
Future<void> initializeService() async { // Future<void> initializeService() async {
final service = FlutterBackgroundService(); // final service = FlutterBackgroundService();
service.setNotificationInfo(title: '短信助手', content: '正在后台运行'); // service.setNotificationInfo(title: '短信助手', content: '正在后台运行');
await service.configure( // await service.configure(
androidConfiguration: AndroidConfiguration( // androidConfiguration: AndroidConfiguration(
onStart: onStart, // onStart: onStart,
autoStart: true, // autoStart: true,
isForegroundMode: true, // isForegroundMode: true,
), // ),
iosConfiguration: IosConfiguration( // iosConfiguration: IosConfiguration(
autoStart: true, // autoStart: true,
onForeground: onStart, // onForeground: onStart,
onBackground: onIosBackground, // onBackground: onIosBackground,
), // ),
); // );
} // }
void onIosBackground() { // void onIosBackground() {
WidgetsFlutterBinding.ensureInitialized(); // WidgetsFlutterBinding.ensureInitialized();
// print('FLUTTER BACKGROUND FETCH'); // // print('FLUTTER BACKGROUND FETCH');
} // }
//
void onStart() { // void onStart() {
int flag = 0; // int flag = 0;
String? phoneNum, callState; // String phoneNum;
WidgetsFlutterBinding.ensureInitialized(); // String callState;
// WidgetsFlutterBinding.ensureInitialized();
Timer.periodic(const Duration(seconds: 1), (timer) async { // Timer.periodic(const Duration(seconds: 1), (timer) async {
CallState state = await Telephony.instance.callState; // CallState state = await Telephony.instance.callState;
callState = state.name; // callState = state.name;
print(callState!+" $flag"); // // print(callState!+" $flag");
if (callState == "IDLE") { // if (callState == "IDLE") {
if (flag != 0) { // if (flag != 0) {
flag = 0; // flag = 0;
// print("object"); // // print("object");
final Iterable<CallLogEntry> result = await CallLog.query(); // final Iterable<CallLogEntry> result = await CallLog.query();
phoneNum = result.first.number; // // print(phoneNum);
// print(phoneNum); // // String message = "This is a test message!";
// String message = "This is a test message!"; // // List<String> recipents = ["10000", "10086"];
// List<String> recipents = ["10000", "10086"]; // // String _result = await sendSMS(message: message, recipients: recipents, sendDirect: true)
// String _result = await sendSMS(message: message, recipients: recipents, sendDirect: true) // // .catchError((onError) {
// .catchError((onError) { // // print(onError);
// print(onError); // // });
// }); // // print(_result);
// print(_result); // phoneNum = result.first.number!;
phoneNum = result.first.number; // // List<String> recipents=[
print(phoneNum); // // phoneNum
final SmsSendStatusListener listener = (SendStatus status) { // // ];
print(status); // if(phoneNum.isEmpty){
}; // print("At Least 1 Person or Message Required");
Phone.telephony.sendSms( // }else{
to: phoneNum!, // print("你好"+phoneNum);
message: "hello", // _sendSMS("你好", [phoneNum]);
statusListener: listener, // print("你好"+phoneNum);
isMultipart: true, // }
// // final SmsSendStatusListener listener = (SendStatus status) {
); // // print(status);
} // // };
} else if (callState == "RINGING") { // // Phone.telephony.sendSms(
flag++; // // to: phoneNum!,
} else if (callState == "OFFHOOK") { // // message: "hello",
flag++; // // statusListener: listener,
} // // isMultipart: true,
}); // //
} // // );
// }
class Phone { // } else if (callState == "RINGING") {
static Telephony telephony = Telephony.instance; // flag++;
} // } else if (callState == "OFFHOOK") {
// flag++;
// }
// });
// }
//
// class Phone {
// static Telephony telephony = Telephony.instance;
// }
class MyApp extends StatefulWidget { class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key); const MyApp({Key? key}) : super(key: key);
@ -119,12 +133,20 @@ class _MyAppState extends State<MyApp> {
// the one in background. // the one in background.
final telephony = Telephony.instance; final telephony = Telephony.instance;
@override @override
Future<void> _Getpermission() async{
await [Permission.sms,Permission.phone,].request();
}
void initState() { void initState() {
super.initState(); super.initState();
final service = FlutterBackgroundService(); final service = FlutterBackgroundService();
Future.delayed(const Duration(milliseconds: 0), () async { Future.delayed(const Duration(milliseconds: 0), () async {
//Hive.initFlutter; //Hive.initFlutter;
_Getpermission();
await HiveStore.init(); await HiveStore.init();
registerWxApi(
appId: "wxd930ea5d5a228f5f",universalLink:"https://your.univerallink.com/link/ "
);
}); });
final inbox = Telephony.instance.getInboxSms(); final inbox = Telephony.instance.getInboxSms();
// JPush jPush=JPush(); // JPush jPush=JPush();

@ -0,0 +1,27 @@
import 'package:hive/hive.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
import 'content_list_model.dart';
part 'ContentHive.g.dart';
@JsonSerializable()
@HiveType(typeId:2)
class ContentHive extends Equatable{
@HiveField(0)
final int id;
@HiveField(1)
final String content;
@HiveField(2)
final List<ContentListModel> list;
factory ContentHive.fromJson(Map<String, dynamic> json) =>_$ContentHiveFromJson(json);
const ContentHive({
required this.id,
required this.content,
required this.list,
});
@override
List<Object?> get props => [id,content,list];
}

@ -0,0 +1,59 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'ContentHive.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class ContentHiveAdapter extends TypeAdapter<ContentHive> {
@override
final int typeId = 0;
@override
ContentHive read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return ContentHive(
id: fields[0] as int,
content: fields[1] as String,
list: (fields[3] as List).cast<ContentListModel>(),
);
}
@override
void write(BinaryWriter writer, ContentHive obj) {
writer
..writeByte(3)
..writeByte(0)
..write(obj.id)
..writeByte(1)
..write(obj.content)
..writeByte(3)
..write(obj.list);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ContentHiveAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ContentHive _$ContentHiveFromJson(Map<String, dynamic> json) => ContentHive(
id: json['id'] as int,
content: json['content'] as String,
list: (json['list'] as List<dynamic>)
.map((e) => ContentListModel.fromJson(e as Map<String, dynamic>))
.toList(),
);

@ -0,0 +1,19 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'content_list_model.g.dart';
@JsonSerializable()
class ContentListModel extends Equatable{
final int index;
final String content;
factory ContentListModel.fromJson(Map<String, dynamic> json) =>_$ContentListModelFromJson(json);
const ContentListModel({
required this.index,
required this.content,
});
@override
List<Object?> get props => [index,content];
}

@ -0,0 +1,13 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'content_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
ContentListModel _$ContentListModelFromJson(Map<String, dynamic> json) =>
ContentListModel(
index: json['index'] as int,
content: json['content'] as String,
);

@ -0,0 +1,14 @@
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import '../model/hive/ContentHive.dart';
class ContentListModel extends ChangeNotifier{
late Box _regionBox;
List<ContentHive> _regions=[];
List<ContentHive> get regions=>_regions;
Future init() async{}
// _regionBox = await Hive.openBox("ContentListBox");
// var
}

@ -1,9 +1,12 @@
import 'dart:async';
import 'dart:io';
import 'package:call_log/call_log.dart'; import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_sms/flutter_sms.dart'; import 'package:flutter_sms/flutter_sms.dart';
import 'package:get_phone_number/get_phone_number.dart'; import 'package:get_phone_number/get_phone_number.dart';
import 'package:hive/hive.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/home/content_details_page.dart'; import 'package:project_telephony/ui/home/content_details_page.dart';
@ -23,10 +26,14 @@ class ContentPage extends StatefulWidget {
_ContentPageState createState() => _ContentPageState(); _ContentPageState createState() => _ContentPageState();
} }
class _ContentPageState extends State<ContentPage> { class _ContentPageState extends State<ContentPage> {
int _select = 0; int _select = 0;
List<String> textList = ['欢迎你的来电', '祝您生活愉快', '感谢您的来电我们会尽快处理的', '自定义短信内容']; List<String> textList = ['欢迎你的来电', '祝您生活愉快', '感谢您的来电我们会尽快处理的', '自定义短信内容'];
List<String> textList1 = ['自定义短信内容']; List<String> textList1 = ['自定义短信内容'];
late String phoneNum;
late String callState;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -70,7 +77,7 @@ class _ContentPageState extends State<ContentPage> {
}, },
)); ));
} else { } else {
bool? permissionsGranted = await telephony.requestPhonePermissions; // bool? permissionsGranted = await telephony.requestPhonePermissions;
// print(permissionsGranted); // print(permissionsGranted);
// if(permissionsGranted!){ // if(permissionsGranted!){
// print(content); // print(content);
@ -89,20 +96,12 @@ class _ContentPageState extends State<ContentPage> {
// message: content, // message: content,
// isMultipart: true // isMultipart: true
// ); // );
List<String> recipents=["13395740386"]; // List<String> recipents=[
_sendSMS(content,recipents); // phoneNum
// CallState state = await telephony.callState; // ];
// print(state); // _sendSMS(content,recipents);
// DataState state1 = await telephony.cellularDataState; // String phoneNumber = await GetPhoneNumber().get();
// print(state1); // print('getPhoneNumber result: $phoneNumber');
// String? operatorName = await telephony.networkOperatorName;
// print(operatorName);
// NetworkType type = await telephony.dataNetworkType;
// print(type);
// PhoneType type1 = await telephony.phoneType;
// print(type1);
String phoneNumber = await GetPhoneNumber().get();
print('getPhoneNumber result: $phoneNumber');
} }
setState(() {}); setState(() {});
// print("这是数据" + textList[_s lect]); // print("这是数据" + textList[_s lect]);

@ -1,6 +1,13 @@
import 'dart:async';
import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_sms/flutter_sms.dart';
import 'package:project_telephony/ui/home/content_page.dart'; import 'package:project_telephony/ui/home/content_page.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:telephony/telephony.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key); const HomePage({Key? key}) : super(key: key);
@ -8,8 +15,104 @@ class HomePage extends StatefulWidget {
@override @override
_HomePageState createState() => _HomePageState(); _HomePageState createState() => _HomePageState();
} }
void _sendSMS(String message, List<String> recipients) async {
try{
String result =
await sendSMS(message: message, recipients: recipients, sendDirect: true);
print(result);
} on PlatformException catch(e){
print(e.toString());
}
}
Future<void> initializeService() async {
final service = FlutterBackgroundService();
service.setNotificationInfo(title: '短信助手', content: '正在后台运行');
await service.configure(
androidConfiguration: AndroidConfiguration(
onStart: onStart,
autoStart: true,
isForegroundMode: true,
),
iosConfiguration: IosConfiguration(
autoStart: true,
onForeground: onStart,
onBackground: onIosBackground,
),
);
}
void onIosBackground() {
WidgetsFlutterBinding.ensureInitialized();
// print('FLUTTER BACKGROUND FETCH');
}
void onStart() {
int flag = 0;
String phoneNum;
String callState;
WidgetsFlutterBinding.ensureInitialized();
Timer.periodic(const Duration(seconds: 1), (timer) async {
CallState state = await Telephony.instance.callState;
callState = state.name;
// print(callState!+" $flag");
if (callState == "IDLE") {
if (flag != 0) {
flag = 0;
// print("object");
final Iterable<CallLogEntry> result = await CallLog.query();
// print(phoneNum);
// String message = "This is a test message!";
// List<String> recipents = ["10000", "10086"];
// String _result = await sendSMS(message: message, recipients: recipents, sendDirect: true)
// .catchError((onError) {
// print(onError);
// });
// print(_result);
phoneNum = result.first.number!;
// List<String> recipents=[
// phoneNum
// ];
if(phoneNum.isEmpty){
print("At Least 1 Person or Message Required");
}else{
print("你好"+phoneNum);
_sendSMS("你好", [phoneNum]);
print("你好"+phoneNum);
}
// final SmsSendStatusListener listener = (SendStatus status) {
// print(status);
// };
// Phone.telephony.sendSms(
// to: phoneNum!,
// message: "hello",
// statusListener: listener,
// isMultipart: true,
//
// );
}
} else if (callState == "RINGING") {
flag++;
} else if (callState == "OFFHOOK") {
flag++;
}
});
}
class Phone {
static Telephony telephony = Telephony.instance;
}
class _HomePageState extends State<HomePage> { class _HomePageState extends State<HomePage> {
@override
void initState() {
// TODO: implement initState
super.initState();
Future.delayed(const Duration(milliseconds: 0), () async {
//Hive.initFlutter;
await initializeService();
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(

@ -1,11 +1,16 @@
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/user/members_page.dart';
import 'package:project_telephony/ui/widget/check_radio.dart'; import 'package:project_telephony/ui/widget/check_radio.dart';
import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/ui/widget/plone_bottom.dart'; import 'package:project_telephony/ui/widget/plone_bottom.dart';
import 'package:project_telephony/ui/widget/putup_widget.dart'; import 'package:project_telephony/ui/widget/putup_widget.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:tobias/tobias.dart';
import 'package:fluwx/fluwx.dart' as fluwx;
import '../../model/pay/wx_pay_model.dart';
import '../../utils/pay_util.dart';
class MembersPage extends StatefulWidget { class MembersPage extends StatefulWidget {
const MembersPage({Key? key}) : super(key: key); const MembersPage({Key? key}) : super(key: key);
@ -34,10 +39,11 @@ List payWay = [
}, },
{'payName': '支付宝支付', 'payUrl': Assets.icons.zhifubao.path} {'payName': '支付宝支付', 'payUrl': Assets.icons.zhifubao.path}
]; ];
Map a = {};
class _MembersPageState extends State<MembersPage> { class _MembersPageState extends State<MembersPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: Stack( body: Stack(
@ -69,7 +75,28 @@ class _MembersPageState extends State<MembersPage> {
PloneBottom( PloneBottom(
border: true, border: true,
onTap: () async { onTap: () async {
if (_selectIndex == 0) {} if(_chooseItem == null){
Get.snackbar('提示', "请先选择充值月份");
}else{
if (_selectIndex == 0) {
_wxPayFunc();
}else{
var result = await isAliPayInstalled(); //
if(!result){
Get.snackbar('提示', "请先安装支付宝");
}else{
aliPay("paySign").then((payResult) {
// map["paySign"]
print("支付宝:" + payResult.toString());
if (payResult['resultStatus'] == '9000') {
Get.snackbar('提示', "充值成功");
} else {
Get.snackbar('提示', payResult['memo']);
}
});
}
}
}
}, },
textColor: const Color(0xFF333333), textColor: const Color(0xFF333333),
text: "立即开通", text: "立即开通",
@ -172,21 +199,61 @@ class _MembersPageState extends State<MembersPage> {
); );
} }
// Future _wxPayFunc() async {
// var base = await apiClient.request(API.user.wallet.assessRecharge, data: { Future _wxPayFunc() async{
// 'count': widget.count, bool isInstalled=await fluwx.isWeChatInstalled;
// 'payType': 2, if(!isInstalled){
BotToast.showText(text: "请先安装微信");
return ;
}
//
fluwx.payWithWeChat(
appId: "wxd930ea5d5a228f5f",
partnerId: "partnerId",
prepayId: "prepayId",
packageValue: "packageValue",
nonceStr: "nonceStr",
timeStamp: 1597927308,
sign: "sign");
fluwx.weChatResponseEventHandler.listen((event) { if(event.isSuccessful){
BotToast.showText(text: "微信支付成功");
}else{
BotToast.showText(text: "微信支付失败");
}
});
// var wxPayModel = WxPayModel.fromJson({
// "prepayId": "wx121434071826969924754d7d3309520000",
// "partnerId": "1622850618",
// "timeStamp": "1660286047",
// "nonceStr": "W14Z6RbKcHcI6QTETFyrxteD3m2P7ZaF",
// "package": "Sign=WXPay",
// "sign": "i4LDk+FlAfXukLPet6oFdtVkAXHv8aKkajO4i2tiXETBqudWJPzYAaziPH3eBo1yCvkMOyoVddWDKqHXhwrN2uvubz8YpSICt9yZBcndVaXOK+X9hY765sYoFV6sGHz5iuPljTRUWWrmc8GYMEs8TlLDB5Q50NenzJSChdfDtZRV4kXtVK6xY9b0y++eUo/snzpmq/X6GwS9n0auKkT0TKW1C30/Hzpw3SMziXPP02TvBvbqj57f6rHuGJS/LUX2ZwCR8iFZsfuiXo+7lyHHsimr4jVczdS6VtobeekrPq4vTe72d/HU/ECEZRSYxsL5DbyS2TvSNzFA6Z7wGDzkpQ=="
// }); // });
// if (base.code == 0) {
// var wxPayModel = WxPayModel.fromJson(base.data['content']);
// await PayUtil().callWxPay( // await PayUtil().callWxPay(
// payModel: wxPayModel, // payModel: wxPayModel,
// ); // );
}
// base ={
// "content": {
// "prepayId": "wx121434071826969924754d7d3309520000",
// "partnerId": "1622850618",
// "timeStamp": "1660286047",
// "nonceStr": "W14Z6RbKcHcI6QTETFyrxteD3m2P7ZaF",
// "package": "Sign=WXPay",
// "sign": "i4LDk+FlAfXukLPet6oFdtVkAXHv8aKkajO4i2tiXETBqudWJPzYAaziPH3eBo1yCvkMOyoVddWDKqHXhwrN2uvubz8YpSICt9yZBcndVaXOK+X9hY765sYoFV6sGHz5iuPljTRUWWrmc8GYMEs8TlLDB5Q50NenzJSChdfDtZRV4kXtVK6xY9b0y++eUo/snzpmq/X6GwS9n0auKkT0TKW1C30/Hzpw3SMziXPP02TvBvbqj57f6rHuGJS/LUX2ZwCR8iFZsfuiXo+7lyHHsimr4jVczdS6VtobeekrPq4vTe72d/HU/ECEZRSYxsL5DbyS2TvSNzFA6Z7wGDzkpQ=="
// }
// };
// await apiClient.request(API.user.wallet.assessRecharge, data: {
// 'count': widget.count,
// 'payType': 2,
// });
// if (base.code ==null) {
//
// } else { // } else {
// BotToast.showText(text: "${base.msg}"); // BotToast.showText(text: "${base.msg}");
// } // }
// } // }
//
// Future _aliPayFunc() async { // Future _aliPayFunc() async {
// var base = await apiClient.request(API.user.wallet.assessRecharge, data: { // var base = await apiClient.request(API.user.wallet.assessRecharge, data: {
// 'count': widget.count, // 'count': widget.count,

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'; import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart';
import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart';
@ -22,27 +23,29 @@ final Telephony telephony = Telephony.instance;
// initPlatformState(); // initPlatformState();
// } // }
class _PrivacyRightsPageState extends State<PrivacyRightsPage> { class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
final Permission _permission = Permission.phone; // final Permission _permission = ;
final PermissionHandlerPlatform _permissionHandler = // final PermissionHandlerPlatform _permissionHandler =
PermissionHandlerPlatform.instance; // PermissionHandlerPlatform.instance;
PermissionStatus _permissionStatus = PermissionStatus.denied; // PermissionStatus _permissionStatus = Permission.phone.request() as PermissionStatus;
// PermissionStatus _permissionStatus2 = Permission.sms.request() as PermissionStatus;
Future<void> requestPermission(Permission permission) async {
final status = await _permissionHandler.requestPermissions([permission]); // Future<void> requestPermission(Permission permission) async {
setState(() { // final status = await _permissionHandler.requestPermissions([permission]);
_permissionStatus = status[permission] ?? PermissionStatus.denied; // setState(() {
}); // _permissionStatus = status[permission] ?? PermissionStatus.denied;
} // });
// }
bool sms=false;
bool plone=false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_listenForPermissionStatus(); _listenForPermissionStatus();
} }
void _listenForPermissionStatus() async { Future<void> _listenForPermissionStatus() async {
final status = await _permissionHandler.checkPermissionStatus(_permission); sms=await Permission.sms.request().isGranted;
setState(() => _permissionStatus = status); plone =await Permission.phone.request().isGranted;
} }
@override @override
@ -61,144 +64,55 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
leading: const CloudBackButton(isSpecial: true), leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor), backgroundColor: kForeGroundColor),
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: widget.name == "隐私政策" ? null : _getRights(true), body: widget.name == "隐私政策" ? null : _getRights(),
); );
} }
// Color getPermissionColor() {
// onMessage(SmsMessage message) async { // if(true){
// setState(() { // return Colors.red;
// body = message.body ?? "error reading message body."; // }else{
// print(body); // return Colors.green;
// });
// } // }
//
// onSendStatus(SendStatus status) {
// setState(() {
// body = status == SendStatus.SENT ? "sent" : "delivered";
// });
// } // }
//
// Future<void> initPlatformState() async { // String getPermissionStu() {
// final bool? result = await telephony.requestPhoneAndSmsPermissions; // if (false) {
// if (result != null && result) { // return "未允许";
// telephony.listenIncomingSms( // } else {
// onNewMessage: onMessage, // return "已允许";
// onBackgroundMessage: onBackgroundMessage,
// listenInBackground: true);
// } // }
// if (!mounted) return;
// } // }
_getRights(bool pd) { _getRights(){
return ListView(
children: Permission.values
.where((permission) {
return permission == Permission.phone ||
permission == Permission.sms;
})
.map((permission) => PermissionWidget(permission))
.toList());
}
}
class PermissionWidget extends StatefulWidget {
const PermissionWidget(this._permission);
final Permission _permission;
@override
_PermissionState createState() => _PermissionState(_permission);
}
class _PermissionState extends State<PermissionWidget> {
_PermissionState(this._permission);
final Permission _permission;
final PermissionHandlerPlatform _permissionHandler =
PermissionHandlerPlatform.instance;
PermissionStatus _permissionStatus = PermissionStatus.denied;
List<String> title = [
"获取来电权限",
"获取短信权限",
];
List<String> sub = [
"用于监听来电状态",
"用于发送短信",
];
@override
void initState() {
super.initState();
_listenForPermissionStatus();
}
void _listenForPermissionStatus() async {
final status = await _permissionHandler.checkPermissionStatus(_permission);
setState(() => _permissionStatus = status);
}
Color getPermissionColor() {
switch (_permissionStatus) {
case PermissionStatus.denied:
return Colors.red;
case PermissionStatus.granted:
return Colors.green;
case PermissionStatus.limited:
return Colors.orange;
default:
return Colors.red;
}
}
String getPermissionStu() {
switch (_permissionStatus) {
case PermissionStatus.denied:
return "未允许";
case PermissionStatus.granted:
return "已允许";
default:
return "未允许";
}
}
@override
Widget build(BuildContext context) {
return ListTile( return ListTile(
onTap: ()async{
// await Permission.phone.request();
// await Permission.sms.request();
// Map<Permission, PermissionStatus> statuses = await [
// Permission.sms,
// Permission.phone,
// ].request();
//
// openAppSettings();
print(await Permission.phone.request().isGranted);
print(await Permission.sms.request().isGranted);
},
title: Text( title: Text(
_permission.value==8?title[0]:title[1], '获取设备来电',
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleMedium,
), ),
subtitle: Text( subtitle: const Text(
_permission.value==8?sub[0]:sub[1], "获取设备",
), ),
trailing: Wrap( trailing: Wrap(
children: [ children: [
Text(getPermissionStu(), Text(sms & plone ?"已允许":"未允许",
style: TextStyle(color: getPermissionColor())), style: TextStyle(color: sms & plone ?Colors.green:Colors.red)),
const Icon(Icons.arrow_forward_ios), const Icon(Icons.arrow_forward_ios),
], ],
), ),
onTap: () {
requestPermission(_permission);
},
);
}
void checkServiceStatus( );
BuildContext context, PermissionWithService permission) async { }
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
(await _permissionHandler.checkServiceStatus(permission)).toString()),
));
}
Future<void> requestPermission(Permission permission) async {
final status = await _permissionHandler.requestPermissions([permission]);
setState(() {
print(status);
_permissionStatus = status[permission] ?? PermissionStatus.denied;
print(_permissionStatus);
});
}
} }

@ -22,6 +22,7 @@ import '../../permission.dart';
import '../../providers/user_provider.dart'; import '../../providers/user_provider.dart';
import '../../utils/toast/cloud_toast.dart'; import '../../utils/toast/cloud_toast.dart';
import '../../utils/user_tool.dart'; import '../../utils/user_tool.dart';
import '../home/content_details_page.dart';
import '../home/home_page.dart'; import '../home/home_page.dart';
class UserPage extends StatefulWidget { class UserPage extends StatefulWidget {
@ -34,7 +35,7 @@ class UserPage extends StatefulWidget {
final Telephony telephony = Telephony.instance; final Telephony telephony = Telephony.instance;
class _UserPageState extends State<UserPage> { class _UserPageState extends State<UserPage> {
bool vle = false; bool vle =PermissionStatus.denied.isGranted;
final userProvider = Provider.of<UserProvider>(Get.context!, listen: false); final userProvider = Provider.of<UserProvider>(Get.context!, listen: false);
@override @override
@ -129,6 +130,7 @@ class _UserPageState extends State<UserPage> {
), ),
) )
], ],
), ),
); );
} }
@ -164,6 +166,7 @@ class _UserPageState extends State<UserPage> {
_getBotton() { _getBotton() {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
// print(vle);
Get.to(() => const MembersPage()); Get.to(() => const MembersPage());
}, },
child: Container( child: Container(
@ -235,7 +238,14 @@ class _UserPageState extends State<UserPage> {
onTap: () async { onTap: () async {
pd pd
? "" ? ""
: Get.to(() => PrivacyRightsPage( : name=="短信标签"?Get.to(()=> ContentDetailsPage(
content: "",
ploneBack: (String textContent) {
// print("这是数据" + textContent);
// textList.setAll(index, {textContent});
},
)):
Get.to(() => PrivacyRightsPage(
name: name, name: name,
)); ));
}, },
@ -259,22 +269,23 @@ class _UserPageState extends State<UserPage> {
trailing: pd trailing: pd
? Switch( ? Switch(
value: vle, value: vle,
onChanged: (value) { onChanged: (value) async{
List<Permission> permissions = [ await Permission.phone.request();
Permission.sms, // List<Permission> permissions = [
Permission.phone, // Permission.sms,
]; // Permission.phone,
PermissionHelper.check(permissions, onSuccess: () { // ];
print('onSuccess'); // PermissionHelper.check(permissions, onSuccess: () {
}, onFailed: () { // print('onSuccess');
print('onFailed'); // }, onFailed: () {
}, onOpenSetting: () { // print('onFailed');
print('onOpenSetting'); // }, onOpenSetting: () {
openAppSettings(); // print('onOpenSetting');
}); // openAppSettings();
setState(() { // });
vle = value; // setState(() {
}); // vle = value;
// });
}) })
: const Icon(Icons.keyboard_arrow_right)), : const Icon(Icons.keyboard_arrow_right)),
), ),

@ -7,14 +7,14 @@ packages:
name: _fe_analyzer_shared name: _fe_analyzer_shared
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "44.0.0" version: "46.0.0"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
name: analyzer name: analyzer
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.4.0" version: "4.6.0"
archive: archive:
dependency: transitive dependency: transitive
description: description:
@ -259,7 +259,7 @@ packages:
name: device_info_plus_platform_interface name: device_info_plus_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.3.0+1" version: "2.6.1"
device_info_plus_web: device_info_plus_web:
dependency: transitive dependency: transitive
description: description:
@ -743,7 +743,7 @@ packages:
name: path_provider_android name: path_provider_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.17" version: "2.0.19"
path_provider_ios: path_provider_ios:
dependency: transitive dependency: transitive
description: description:

@ -97,6 +97,7 @@ dev_dependencies:
#导入包整理 #导入包整理
import_sorter: ^4.5.1 import_sorter: ^4.5.1
hive_generator: ^1.1.0 hive_generator: ^1.1.0
#model自动生成 #model自动生成
json_serializable: ^6.1.3 json_serializable: ^6.1.3
build_runner: ^2.0.2 build_runner: ^2.0.2

Loading…
Cancel
Save