no message

This commit is contained in:
1147192855@qq.com 2024-05-13 14:50:07 +08:00
parent ad660bec11
commit e727cb3d20
10 changed files with 155 additions and 121 deletions

View File

@ -35,7 +35,14 @@
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
<!-- Provider -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
</provider>
</application> </application>
<!-- 访问电话状态 --> <!-- 访问电话状态 -->
@ -47,8 +54,10 @@
<!-- 获取当前WiFi接入的状态以及WLAN热点的信息 --> <!-- 获取当前WiFi接入的状态以及WLAN热点的信息 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- 获取当前设备存储权限 --> <!-- 获取当前设备存储权限 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACTION_MANAGE_UNKNOWN_APP_SOURCES"/>
<!-- 这个权限用于app安装 --> <!-- 这个权限用于app安装 -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- 屏幕常亮权限 --> <!-- 屏幕常亮权限 -->
@ -58,4 +67,6 @@
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/> <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY"/>
<!-- Permissions options for the `notification` group --> <!-- Permissions options for the `notification` group -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
</manifest> </manifest>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path path="Android/data/com.example.marking_app/" name="files_root" />
<external-path path="." name="external_storage_root" />
</paths>

View File

@ -13,9 +13,13 @@
<!-- 获取当前WiFi接入的状态以及WLAN热点的信息 --> <!-- 获取当前WiFi接入的状态以及WLAN热点的信息 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- 获取当前设备存储权限 --> <!-- 获取当前设备存储权限 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->
<!-- <uses-permission android:name="android.permission.INTERNET"/> --> <!-- <uses-permission android:name="android.permission.INTERNET"/> -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <!-- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<!-- 这个权限用于app安装 --> <!-- 这个权限用于app安装 -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.CAMERA"/>

View File

@ -124,7 +124,8 @@ class PictureOverviewState extends ConsumerState<PictureOverview> with CommonMix
} }
if (value.scale < 1) { if (value.scale < 1) {
initScale = value.scale; initScale = value.scale;
Future.delayed(Duration(seconds: 5), () => ref.read(zoomHistoryProvider.notifier).setState(initScale!)); // 5
Future.delayed(Duration(seconds: 1), () => ref.read(zoomHistoryProvider.notifier).setState(initScale!));
} }
} }
}); });
@ -270,15 +271,15 @@ class PictureOverviewState extends ConsumerState<PictureOverview> with CommonMix
void onPanUpPosition(Offset val) async { void onPanUpPosition(Offset val) async {
// //
print('**************** 正在移动位置 YYY:${val.dy}'); // print('**************** 正在移动位置 YYY:${val.dy}');
print('**************** 正在移动位置 XXX:${val.dx}'); // print('**************** 正在移动位置 XXX:${val.dx}');
zoomOffset = val; zoomOffset = val;
} }
// ==> // ==>
void onScaleUpdate(double scale, double zoom) async { void onScaleUpdate(double scale, double zoom) async {
print('zoom$zoom'); // print('zoom$zoom');
print('scale${scale}'); // print('scale${scale}');
// MarkingHistoryZoomInfo? historyZoomInfo = await FastData.getInstance().getMarkingZoomInfo(); // MarkingHistoryZoomInfo? historyZoomInfo = await FastData.getInstance().getMarkingZoomInfo();
MarkingHistoryZoomInfo? historyZoomInfo = await FastData.getInstance().getMarkingZoomInfo(); MarkingHistoryZoomInfo? historyZoomInfo = await FastData.getInstance().getMarkingZoomInfo();
double positionX = historyZoomInfo?.positionX ?? 0; double positionX = historyZoomInfo?.positionX ?? 0;

View File

@ -44,10 +44,8 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
// //
setHttpsPEM() async { setHttpsPEM() async {
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (client) {
(client) { client.badCertificateCallback = (X509Certificate cert, String host, int port) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) {
return true; return true;
}; };
}; };
@ -75,7 +73,7 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
@override @override
void initState() { void initState() {
Future.delayed(Duration(seconds: 2), () => sysProtocol(context)); Future.delayed(Duration(seconds: 1), () => sysProtocol(context));
Future(() { Future(() {
// Provider // Provider
ref.read(userTokenProvider.notifier).clean(); // ref.read(userTokenProvider.notifier).clean(); //
@ -89,14 +87,12 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
receiveTimeout: 8000, receiveTimeout: 8000,
), ),
); );
dio.interceptors dio.interceptors.add(LogInterceptor(responseBody: true, requestBody: true)); //
.add(LogInterceptor(responseBody: true, requestBody: true)); //
setHttpsPEM(); setHttpsPEM();
client = RestClient(dio, baseUrl: RequestConfig().loginBaseUrl); client = RestClient(dio, baseUrl: RequestConfig().loginBaseUrl);
_userNameController = TextEditingController() _userNameController = TextEditingController()..addListener(userNameListener);
..addListener(userNameListener);
_passwordController = TextEditingController(); _passwordController = TextEditingController();
_pwdFocus = FocusNode(); _pwdFocus = FocusNode();
_theFocus = FocusNode(); _theFocus = FocusNode();
@ -114,11 +110,10 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
void getShowRegister() async { void getShowRegister() async {
RestClient client = await getClientLogin(); RestClient client = await getClientLogin();
BaseStructureResult<dynamic> resultData = await client.showRegister(); BaseStructureResult<dynamic> resultData = await client.showRegister();
if(resultData.success){ if (resultData.success) {
setState(() { setState(() {
showRegister = resultData.data; showRegister = resultData.data;
}); });
} }
} }
@ -126,8 +121,7 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
String userName = _userNameController.text; String userName = _userNameController.text;
int useNameLength = userName.length; int useNameLength = userName.length;
bool hasNameValNew = useNameLength > 0; bool hasNameValNew = useNameLength > 0;
if (hasNameValNew != hasNameVal) if (hasNameValNew != hasNameVal) toUpState(setState, () => hasNameVal = hasNameValNew, mounted);
toUpState(setState, () => hasNameVal = hasNameValNew, mounted);
const isProd = bool.fromEnvironment('dart.vm.product'); const isProd = bool.fromEnvironment('dart.vm.product');
if (!isProd && useNameLength == 11) { if (!isProd && useNameLength == 11) {
_passwordController.text = userName.substring(useNameLength - 6); _passwordController.text = userName.substring(useNameLength - 6);
@ -182,15 +176,12 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
child: SizedBox( child: SizedBox(
height: 86.w, height: 86.w,
width: 86.w, width: 86.w,
child: Image.asset('assets/images/logo.png', child: Image.asset('assets/images/logo.png', fit: BoxFit.cover),
fit: BoxFit.cover),
), ),
), ),
Container( Container(
margin: EdgeInsets.symmetric( margin: EdgeInsets.symmetric(horizontal: 32.w, vertical: 24.h),
horizontal: 32.w, vertical: 24.h), padding: EdgeInsets.only(top: 34.h, bottom: 16.h, left: 22.w, right: 22.w),
padding: EdgeInsets.only(
top: 34.h, bottom: 16.h, left: 22.w, right: 22.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
border: Border.all(width: 1.w, color: Colors.white), border: Border.all(width: 1.w, color: Colors.white),
@ -219,18 +210,13 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
), ),
decoration: InputDecoration( decoration: InputDecoration(
hintText: "请输入账号", hintText: "请输入账号",
hintStyle: TextStyle( hintStyle: TextStyle(fontSize: 16.sp, color: const Color.fromRGBO(153, 153, 153, 1)),
fontSize: 16.sp,
color: const Color.fromRGBO(153, 153, 153, 1)),
labelText: "账号", labelText: "账号",
labelStyle: TextStyle( labelStyle: TextStyle(fontSize: 16.sp, color: const Color.fromRGBO(148, 163, 182, 1)),
fontSize: 16.sp,
color: const Color.fromRGBO(148, 163, 182, 1)),
suffixIcon: !hasNameVal suffixIcon: !hasNameVal
? null ? null
: Transform.translate( : Transform.translate(
offset: offset: Offset(10, 10), // padding值来设置偏移量
Offset(10, 10), // padding值来设置偏移量
child: IconButton( child: IconButton(
alignment: Alignment.center, alignment: Alignment.center,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
@ -266,19 +252,13 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
onTap: _showPassword, onTap: _showPassword,
child: Icon( child: Icon(
Icons.remove_red_eye, Icons.remove_red_eye,
color: !_isShowPwd color: !_isShowPwd ? Theme.of(context).primaryColor : Colors.grey,
? Theme.of(context).primaryColor
: Colors.grey,
), ),
), ),
hintStyle: TextStyle( hintStyle: TextStyle(fontSize: 16.sp, color: const Color.fromRGBO(153, 153, 153, 1)),
fontSize: 16.sp,
color: const Color.fromRGBO(153, 153, 153, 1)),
labelText: "密码", labelText: "密码",
isDense: true, isDense: true,
labelStyle: TextStyle( labelStyle: TextStyle(fontSize: 16.sp, color: const Color.fromRGBO(148, 163, 182, 1)),
fontSize: 16.sp,
color: const Color.fromRGBO(148, 163, 182, 1)),
), ),
), ),
SizedBox( SizedBox(
@ -294,10 +274,8 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
checkColor: Colors.white, checkColor: Colors.white,
value: keepPwd, value: keepPwd,
onChanged: (value) { onChanged: (value) {
FocusScope.of(context) FocusScope.of(context).requestFocus(_pwdFocus);
.requestFocus(_pwdFocus); FocusScope.of(context).requestFocus(_theFocus);
FocusScope.of(context)
.requestFocus(_theFocus);
setState(() { setState(() {
keepPwd = value ?? false; keepPwd = value ?? false;
}); });
@ -322,15 +300,11 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
if (showRegister == true) if (showRegister == true)
InkWell( InkWell(
onTap: () { onTap: () {
RouterManager.router.navigateTo( RouterManager.router.navigateTo(context, RouterManager.registerPath);
context, RouterManager.registerPath);
}, },
child: Text( child: Text(
'注册', '注册',
style: TextStyle( style: TextStyle(fontSize: 14.sp, color: const Color.fromRGBO(148, 163, 182, 1)),
fontSize: 14.sp,
color: const Color.fromRGBO(
148, 163, 182, 1)),
)), )),
], ],
), ),
@ -339,9 +313,7 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
child: Container( child: Container(
margin: EdgeInsets.symmetric(vertical: 10.h), margin: EdgeInsets.symmetric(vertical: 10.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: canLogin color: canLogin ? const Color.fromRGBO(9, 105, 246, 1) : Colors.grey,
? const Color.fromRGBO(9, 105, 246, 1)
: Colors.grey,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: const Color.fromRGBO(46, 91, 255, 0.5), color: const Color.fromRGBO(46, 91, 255, 0.5),
@ -359,8 +331,7 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
height: 50.h, height: 50.h,
child: Text( child: Text(
'登 录', '登 录',
style: TextStyle( style: TextStyle(fontSize: 16.sp, color: Colors.white),
fontSize: 16.sp, color: Colors.white),
), ),
), ),
), ),
@ -374,10 +345,8 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
checkColor: Colors.white, checkColor: Colors.white,
value: readAgreement, value: readAgreement,
onChanged: (value) { onChanged: (value) {
FocusScope.of(context) FocusScope.of(context).requestFocus(_pwdFocus);
.requestFocus(_pwdFocus); FocusScope.of(context).requestFocus(_theFocus);
FocusScope.of(context)
.requestFocus(_theFocus);
setState(() { setState(() {
readAgreement = value ?? false; readAgreement = value ?? false;
}); });
@ -458,22 +427,16 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
print('userPwdMd5=$userPwdMd5'); print('userPwdMd5=$userPwdMd5');
EasyLoading.show(status: 'loading...'); EasyLoading.show(status: 'loading...');
try { try {
BaseStructureResult<dynamic> resultData = BaseStructureResult<dynamic> resultData = await client.toLogin(UserLoginParams(userName, userPwdMd5));
await client.toLogin(UserLoginParams(userName, userPwdMd5)); UserLogin? userData = resultData.code == 200 && resultData.data != null ? UserLogin.fromJson(resultData.data) : null;
UserLogin? userData = resultData.code == 200 && resultData.data != null if (resultData.code != 200 || userData?.accessToken == null || userData?.accessToken == '') {
? UserLogin.fromJson(resultData.data)
: null;
if (resultData.code != 200 ||
userData?.accessToken == null ||
userData?.accessToken == '') {
return toMsg(resultData.message ?? '登录失败,请重试'); return toMsg(resultData.message ?? '登录失败,请重试');
} }
FastData fastData = FastData.getInstance(); FastData fastData = FastData.getInstance();
fastData.setToken(userData!.accessToken); fastData.setToken(userData!.accessToken);
BaseStructureResult<UserInfo> userRes = BaseStructureResult<UserInfo> userRes = await client.getUserInfo('Bearer ${userData.accessToken}');
await client.getUserInfo('Bearer ${userData.accessToken}');
if (userRes.code != 200 || userRes.data == null) { if (userRes.code != 200 || userRes.data == null) {
throw Exception('登录失败,请重试'); throw Exception('登录失败,请重试');
@ -489,8 +452,7 @@ class _TheLoginState extends ConsumerState<TheLogin> with CommonMixin {
ref.read(userTokenProvider.notifier).initToken(); ref.read(userTokenProvider.notifier).initToken();
// //
RouterManager.router.navigateTo(context, RouterManager.root, RouterManager.router.navigateTo(context, RouterManager.root, clearStack: true, transition: getTransition());
clearStack: true, transition: getTransition());
}); });
} catch (e) { } catch (e) {
toPrint(val: e.toString()); toPrint(val: e.toString());

View File

@ -28,6 +28,7 @@ import 'package:marking_app/provider/user_provider.dart';
import 'package:marking_app/utils/index.dart'; import 'package:marking_app/utils/index.dart';
import 'package:marking_app/utils/request/rest_client.dart'; import 'package:marking_app/utils/request/rest_client.dart';
import 'package:package_info/package_info.dart'; import 'package:package_info/package_info.dart';
import 'package:url_launcher/url_launcher.dart';
import 'homework_correction/job_home.dart'; import 'homework_correction/job_home.dart';
@ -104,7 +105,7 @@ class TheMainPageState extends ConsumerState<TheMainPage> with CommonMixin {
} }
void getAppUpgrade(UserInfo user) async { void getAppUpgrade(UserInfo user) async {
if (!bool.fromEnvironment('dart.vm.product')) return; // if (!bool.fromEnvironment('dart.vm.product')) return;
try { try {
showUpgrade = true; showUpgrade = true;
if (['18888888888'].contains(user.loginName)) return; if (['18888888888'].contains(user.loginName)) return;

View File

@ -6,6 +6,7 @@
* @LastEditors: wangyang 1147192855@qq.com * @LastEditors: wangyang 1147192855@qq.com
* @LastEditTime: 2022-08-02 15:12:21 * @LastEditTime: 2022-08-02 15:12:21
*/ */
import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
@ -13,11 +14,10 @@ import 'package:flutter/cupertino.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:install_plugin/install_plugin.dart'; import 'package:install_plugin/install_plugin.dart';
import 'package:marking_app/provider/upgrade_provider.dart'; import 'package:marking_app/provider/upgrade_provider.dart';
// import 'package:install_plugin_v2/install_plugin_v2.dart';
import 'package:marking_app/utils/app_upgrade/model/UpdateAppEvent.dart'; import 'package:marking_app/utils/app_upgrade/model/UpdateAppEvent.dart';
import 'package:marking_app/utils/index.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:app_installer/app_installer.dart';
class DownloadApk { class DownloadApk {
/// ///
@ -58,9 +58,7 @@ class DownloadApk {
debugPrint('make sure the apk file is set'); debugPrint('make sure the apk file is set');
return false; return false;
} }
Map<Permission, PermissionStatus> statuses = await [Permission.storage].request(); Map<Permission, PermissionStatus> statuses = await [Permission.storage].request();
if (statuses[Permission.storage]!.isGranted) { if (statuses[Permission.storage]!.isGranted) {
// String? result = await InstallPlugin.installApk(_apkFilePath, appId: event.packageName).catchError((error) { // String? result = await InstallPlugin.installApk(_apkFilePath, appId: event.packageName).catchError((error) {
// debugPrint('install apk error: $error'); // debugPrint('install apk error: $error');
@ -68,16 +66,17 @@ class DownloadApk {
// debugPrint('install apk $result'); // debugPrint('install apk $result');
// ToastUtils.getFluttertoast(context: context, msg: 'install apk $result'); // ToastUtils.getFluttertoast(context: context, msg: 'install apk $result');
try { try {
final result = await InstallPlugin.installApk(_apkFilePath, appId: event.packageName); // InstallPlugin.install(filePathOrUrlString)com.example.marking_app
print('这是是执行安装的程序:' + result.runtimeType.toString()); await AppInstaller.installApk(_apkFilePath);
if (result['isSuccess'] ?? false) { // var result = await InstallPlugin.installApk(_apkFilePath, appId: event.packageName);
ToastUtils.showSuccess('install apk $result'); // print('这是是执行安装的程序:' + jsonEncode(result));
RestartWidget.restartApp(context); // APP // if (!(result?['isSuccess'] ?? false)) {}
return true; // Restadget.restartApp(context); // APP
} print('安装执行完成了..............0.0');
} catch (e) {} } catch (e) {
} else { print('安装进入报错....');
debugPrint('Permission request fail!'); print(e);
}
} }
return false; return false;
@ -87,7 +86,7 @@ class DownloadApk {
static void showDownloadProgress(context, num received, num total, WidgetRef ref) { static void showDownloadProgress(context, num received, num total, WidgetRef ref) {
if (total != -1) { if (total != -1) {
double progress = double.parse((received / total).toStringAsFixed(2)); double progress = double.parse((received / total).toStringAsFixed(2));
debugPrint('下载进度$progress'); // debugPrint('下载进度$progress');
ref.read(upgradeProvider.notifier).setVal(progress); ref.read(upgradeProvider.notifier).setVal(progress);
} }
} }

View File

@ -14,7 +14,6 @@
* @LastEditors: Please set LastEditors * @LastEditors: Please set LastEditors
* @LastEditTime: 2021-01-12 15:08:43 * @LastEditTime: 2021-01-12 15:08:43
*/ */
import 'dart:async';
import 'package:clipboard/clipboard.dart'; import 'package:clipboard/clipboard.dart';
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart'; import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
@ -27,6 +26,7 @@ import 'package:marking_app/utils/my_text.dart';
import 'package:percent_indicator/linear_percent_indicator.dart'; import 'package:percent_indicator/linear_percent_indicator.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:url_launcher/url_launcher_string.dart'; import 'package:url_launcher/url_launcher_string.dart';
class UpdateDialog extends Dialog { class UpdateDialog extends Dialog {
@ -145,6 +145,19 @@ class DownloadButton extends ConsumerWidget {
final String deviceInfo; final String deviceInfo;
const DownloadButton(this.updateAppEvent, {required this.deviceInfo, Key? key}) : super(key: key); const DownloadButton(this.updateAppEvent, {required this.deviceInfo, Key? key}) : super(key: key);
//
Future<bool> toLaunch(UpdateAppEvent data) async {
var uri = Uri.parse('market://details?id=com.example.marking_app');
if (await canLaunchUrl(uri)) {
//
return await launchUrl(uri);
}
//
uri = Uri.parse(data.link);
if (await canLaunchUrl(uri)) return await launchUrl(uri);
return false;
}
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final count = ref.watch(upgradeProvider); final count = ref.watch(upgradeProvider);
@ -163,7 +176,8 @@ class DownloadButton extends ConsumerWidget {
child: MaterialButton( child: MaterialButton(
onPressed: () => easyThrottle('DownloadButton_App_Upgrade', () async { onPressed: () => easyThrottle('DownloadButton_App_Upgrade', () async {
if (deviceInfo == "android" && updateAppEvent.equipment == Equipment.android) { if (deviceInfo == "android" && updateAppEvent.equipment == Equipment.android) {
bool flag = await UpgradePermission(updateAppEvent.deviceInfo).checkPermission(); //
bool flag = await UpgradePermission(updateAppEvent.deviceInfo).checkPermission(context);
if (flag) { if (flag) {
flag = await DownloadApk.installApk(context, updateAppEvent, ref); flag = await DownloadApk.installApk(context, updateAppEvent, ref);
@ -176,8 +190,10 @@ class DownloadButton extends ConsumerWidget {
} }
return; return;
} }
await FlutterClipboard.copy(updateAppEvent.link); //
setTimeOut(1000, () => ToastUtils.showInfo('下载链接已经复制到设备,可前往浏览器下载安装')); await toLaunch(updateAppEvent);
// await FlutterClipboard.copy(updateAppEvent.link);
// setTimeOut(1000, () => ToastUtils.showInfo('下载链接已经复制到设备,可前往浏览器下载安装'));
} else if (deviceInfo == "ios" && updateAppEvent.equipment == Equipment.ios) { } else if (deviceInfo == "ios" && updateAppEvent.equipment == Equipment.ios) {
try { try {
await launchUrlString(updateAppEvent.link); await launchUrlString(updateAppEvent.link);

View File

@ -6,6 +6,8 @@
* @LastEditors: wangyang 1147192855@qq.com * @LastEditors: wangyang 1147192855@qq.com
* @LastEditTime: 2022-08-01 14:08:57 * @LastEditTime: 2022-08-01 14:08:57
*/ */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:marking_app/utils/index.dart'; import 'package:marking_app/utils/index.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
@ -14,34 +16,65 @@ class UpgradePermission {
const UpgradePermission(this._flatform); const UpgradePermission(this._flatform);
/// ///
Future<bool> checkPermission() async { Future<bool> checkPermission(BuildContext context) async {
// if (_flatform == 'android') { if (_flatform != 'android') return true; //
var status = await Permission.storage.request();
if (status.isGranted) return true;
// return await Permission.storage.request().isGranted; if (status.isDenied) {
// } else { //
// return true; await showDialog<bool>(
// } context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("权限提示"),
content: const Text("无法获取存储权限,请同意获取设备存储权限"),
actions: [
MaterialButton(
color: Theme.of(context).primaryColor,
child: const Text("同意", style: TextStyle(color: Colors.white)),
onPressed: () => Navigator.of(context).pop(),
),
],
);
},
);
if (_flatform == 'android') { if (isPad()) {
final status = await Permission.storage.status; // APP权限设置页面
if (status != PermissionStatus.granted) { await openAppSettings();
final result = await Permission.storage.request(); return false;
if (result == PermissionStatus.granted) {
return true;
}
if (status == PermissionStatus.denied) {
ToastUtils.showError('拒绝了保存安装权限');
}
if (status == PermissionStatus.permanentlyDenied) {
ToastUtils.showError('用户永久拒绝保存安装权限,请前往设置权限');
}
} else {
return true;
} }
} else {
return true; return checkPermission(context);
} }
//
await showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("权限提示"),
content: const Text("储存权限被永久拒绝,并且不再提示。请前往设置页面同意储存权限"),
actions: [
MaterialButton(
color: Colors.green.shade900,
child: const Text("退出APP", style: TextStyle(color: Colors.white)),
onPressed: () => Navigator.of(context).pop(false),
),
MaterialButton(
color: Colors.green.shade900,
child: const Text("确定", style: TextStyle(color: Colors.white)),
onPressed: () => Navigator.of(context).pop(true),
),
],
);
},
);
await openAppSettings();
return false; return false;
} }
} }

View File

@ -114,6 +114,8 @@ dependencies:
flutter_staggered_grid_view: ^0.6.2 flutter_staggered_grid_view: ^0.6.2
# 饼图 # 饼图
flutter_echart: ^2.0.0 flutter_echart: ^2.0.0
app_installer: ^1.1.0
dev_dependencies: dev_dependencies: