|
|
@ -1,16 +1,18 @@
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:async';
|
|
|
|
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:flutter_background_service/flutter_background_service.dart';
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.dart';
|
|
|
|
import 'package:flutter_xupdate/flutter_xupdate.dart';
|
|
|
|
import 'package:package_info/package_info.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
import 'package:project_telephony/ui/home/content_connect_page.dart';
|
|
|
|
import 'package:project_telephony/ui/home/set/func/user_info_func.dart';
|
|
|
|
import 'package:project_telephony/ui/home/content_refuse_page.dart';
|
|
|
|
|
|
|
|
import 'package:project_telephony/ui/home/set/phone_set_page.dart';
|
|
|
|
import 'package:project_telephony/ui/home/set/phone_set_page.dart';
|
|
|
|
import 'package:project_telephony/ui/user/privacy_rights_page.dart';
|
|
|
|
import 'package:project_telephony/ui/user/privacy_rights_page.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
import 'package:project_telephony/utils/headers.dart';
|
|
|
|
import '../../utils/toast/cloud_toast.dart';
|
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import '../user/privacy_rights_page.dart';
|
|
|
|
import '../user/privacy_rights_page.dart';
|
|
|
|
|
|
|
|
import 'content_connect_page.dart';
|
|
|
|
|
|
|
|
import 'content_refuse_page.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
|
class HomePage extends StatefulWidget {
|
|
|
|
const HomePage({Key? key}) : super(key: key);
|
|
|
|
const HomePage({Key? key}) : super(key: key);
|
|
|
@ -23,7 +25,6 @@ bool sms = false;
|
|
|
|
bool plone = false;
|
|
|
|
bool plone = false;
|
|
|
|
bool addressBook = false;
|
|
|
|
bool addressBook = false;
|
|
|
|
bool kg = false;
|
|
|
|
bool kg = false;
|
|
|
|
|
|
|
|
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
final service = FlutterBackgroundService();
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -31,7 +32,8 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
initXUpdate();
|
|
|
|
getUpdate();
|
|
|
|
|
|
|
|
// initXUpdate();
|
|
|
|
//页面初始化的时候,添加一个状态的监听者
|
|
|
|
//页面初始化的时候,添加一个状态的监听者
|
|
|
|
WidgetsBinding.instance.addObserver(this);
|
|
|
|
WidgetsBinding.instance.addObserver(this);
|
|
|
|
_listenForPermissionStatus();
|
|
|
|
_listenForPermissionStatus();
|
|
|
@ -54,45 +56,63 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
setState(() {});
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///初始化
|
|
|
|
getUpdate() async {
|
|
|
|
void initXUpdate() {
|
|
|
|
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
|
|
FlutterXUpdate.init(
|
|
|
|
String version = packageInfo.version; //版本号
|
|
|
|
|
|
|
|
String buildNumber = packageInfo.buildNumber; //版本构建号
|
|
|
|
///是否输出日志
|
|
|
|
var res = await UserInfoFunc.getUpdate();
|
|
|
|
debug: true,
|
|
|
|
print("版本号$version");
|
|
|
|
|
|
|
|
print('版本构建号$buildNumber');
|
|
|
|
///是否使用post请求
|
|
|
|
print("服务器上的${res.versionCode}");
|
|
|
|
isPost: false,
|
|
|
|
print("服务器上的${res.versionName}");
|
|
|
|
|
|
|
|
if (res.versionCode > int.parse(buildNumber)) {
|
|
|
|
///post请求是否是上传json
|
|
|
|
// CloudToast.show("是否进行版本更新");
|
|
|
|
isPostJson: false,
|
|
|
|
showDialog(
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
///请求响应超时时间
|
|
|
|
builder: (context) {
|
|
|
|
timeout: 25000,
|
|
|
|
return AlertDialog(
|
|
|
|
|
|
|
|
title: Text("版本更新"),
|
|
|
|
///是否开启自动模式
|
|
|
|
content: Text(res.modifyContent),
|
|
|
|
isWifiOnly: false,
|
|
|
|
actions: [
|
|
|
|
|
|
|
|
_getBox('跳转官网下载', () async {
|
|
|
|
///是否开启自动模式
|
|
|
|
await launchUrl(Uri.parse('https://www.dxbs.vip/dxbs.apk'),
|
|
|
|
isAutoMode: false,
|
|
|
|
mode: LaunchMode.externalApplication);
|
|
|
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
_getBox('取消', () {
|
|
|
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///需要设置的公共参数
|
|
|
|
_getBox(String text, VoidCallback ontap) {
|
|
|
|
supportSilentInstall: false,
|
|
|
|
return GestureDetector(
|
|
|
|
|
|
|
|
onTap: ontap,
|
|
|
|
|
|
|
|
// () async {
|
|
|
|
|
|
|
|
// await launchUrl(Uri.parse('https://www.dxbs.vip/dxbs.apk'),
|
|
|
|
|
|
|
|
// mode: LaunchMode.externalApplication);
|
|
|
|
|
|
|
|
// Navigator.of(context).pop();
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
|
|
|
|
|
|
///在下载过程中,如果点击了取消的话,是否弹出切换下载方式的重试提示弹窗
|
|
|
|
padding: EdgeInsets.symmetric(horizontal:24.w, vertical: 24.w),
|
|
|
|
enableRetry: false)
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 20.w, vertical: 8.w),
|
|
|
|
.then((value) {
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
// CloudToast.show("初始化成功: $value");
|
|
|
|
borderRadius: BorderRadius.circular(8.w),
|
|
|
|
}).catchError((error) {
|
|
|
|
color: const Color(0xFF1890FF)),
|
|
|
|
print(error);
|
|
|
|
child: Container(
|
|
|
|
});
|
|
|
|
alignment: Alignment.center,
|
|
|
|
// FlutterXUpdate.setErrorHandler(
|
|
|
|
width: 175.w,
|
|
|
|
// onUpdateError: (Map<String, dynamic> message) async {
|
|
|
|
child: Text(
|
|
|
|
// print(message);
|
|
|
|
text,
|
|
|
|
// setState(() {
|
|
|
|
style:
|
|
|
|
// _message = "$message";
|
|
|
|
const TextStyle(color: Colors.white, fontWeight: FontWeight.w600),
|
|
|
|
// });
|
|
|
|
),
|
|
|
|
// });
|
|
|
|
)),
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -289,23 +309,32 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
|
|
|
// void checkUpdateDefault() {
|
|
|
|
// void checkUpdateDefault() {
|
|
|
|
// FlutterXUpdate.checkUpdate(url: 'https://gitee.com/xuexiangjys/XUpdate/raw/master/jsonapi/update_test.json');
|
|
|
|
// FlutterXUpdate.checkUpdate(url: 'https://gitee.com/xuexiangjys/XUpdate/raw/master/jsonapi/update_test.json');
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
_getContainer(String title, String text, String image, Color cl1, Color cl2) {
|
|
|
|
_getContainer(String title, String text, String image, Color cl1, Color cl2) {
|
|
|
|
return GestureDetector(
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () async {
|
|
|
|
onTap: () async {
|
|
|
|
FlutterXUpdate.checkUpdate(
|
|
|
|
// Get.to(()=>UpdatePage());
|
|
|
|
url:'');
|
|
|
|
// FlutterXUpdate.checkUpdate(
|
|
|
|
|
|
|
|
// // topImageRes:'vipbanner',
|
|
|
|
|
|
|
|
// widthRatio: 0.8,
|
|
|
|
|
|
|
|
// heightRatio: 0.8,
|
|
|
|
|
|
|
|
// themeColor:"#FF1890FF",
|
|
|
|
|
|
|
|
// // https://www.dxbs.vip/telephony.json
|
|
|
|
|
|
|
|
// // https://gitee.com/xuexiangjys/XUpdate/raw/master/jsonapi/update_test.json
|
|
|
|
|
|
|
|
// url:
|
|
|
|
|
|
|
|
// 'https://www.dxbs.vip/telephony.json',);
|
|
|
|
// PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
|
|
// PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
|
|
|
// String version = packageInfo.version;//版本号
|
|
|
|
// String version = packageInfo.version;//版本号
|
|
|
|
// String buildNumber = packageInfo.buildNumber;//版本构建号
|
|
|
|
// String buildNumber = packageInfo.buildNumber;//版本构建号
|
|
|
|
// print(version);
|
|
|
|
// print(version);
|
|
|
|
// print(buildNumber);
|
|
|
|
// print(buildNumber); supportSilentInstall:
|
|
|
|
// print(title);
|
|
|
|
// print(title);
|
|
|
|
// if (title == "接听后") {
|
|
|
|
if (title == "接听后") {
|
|
|
|
// Get.to(() => const ContentConnectPage());
|
|
|
|
Get.to(() => const ContentConnectPage());
|
|
|
|
// } else {
|
|
|
|
} else {
|
|
|
|
// Get.to(() => const ContentRefusePage());
|
|
|
|
Get.to(() => const ContentRefusePage());
|
|
|
|
// // print("未接听");
|
|
|
|
// print("未接听");
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|