From 87a1ed5926bfa7537862d16ab175cc9f179d5ca4 Mon Sep 17 00:00:00 2001 From: WinUser01 Date: Fri, 14 Jan 2022 00:22:11 +0800 Subject: [PATCH] =?UTF-8?q?hyzp=5Fybqx-Commit080=EF=BC=9A=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E4=BB=A5=E4=B8=8B=E4=B8=A4=E4=B8=AA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9A=201=E3=80=81=E5=AF=B9=E9=95=BF=E5=BA=A6=E5=B0=8F?= =?UTF-8?q?=E4=BA=8E=E7=AD=89=E4=BA=8E2=E7=9A=84=E5=8C=BA=E5=8E=BF?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=EF=BC=88=E2=80=9C=E9=AB=98=E5=8E=BF=E2=80=9D?= =?UTF-8?q?=E3=80=81=E2=80=9C=E7=8F=99=E5=8E=BF=E2=80=9D=E7=AD=89=EF=BC=89?= =?UTF-8?q?=E4=B8=8D=E8=BF=9B=E8=A1=8C=E5=8E=BB=E5=B0=BE=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=202=E3=80=81=E5=9C=A8=E7=BA=BF=E5=8D=87=E7=BA=A7=E6=B5=8B?= =?UTF-8?q?=E8=AF=95OK=E3=80=82=E4=BD=BF=E7=94=A8app=5Finstaller:=200.5.0?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=EF=BC=8C=E5=87=86=E5=A4=87=E8=A7=A3=E5=86=B3?= =?UTF-8?q?Android11=E5=85=81=E8=AE=B8=E2=80=9C=E5=AE=89=E8=A3=85=E6=9C=AA?= =?UTF-8?q?=E7=9F=A5=E6=9D=A5=E6=BA=90=E2=80=9D=E5=90=8E=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E9=87=8D=E5=90=AF=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8Chttps://p?= =?UTF-8?q?ub.dev/packages/app=5Finstaller=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/components/UserInfo.dart | 6 ++- .../MyMsics/05_updated/MyUpdatedNew.dart | 15 ++++++- lib/pages/Works/TJXX/tj_data.dart | 39 ------------------- pubspec.lock | 7 ++++ pubspec.yaml | 3 ++ 5 files changed, 28 insertions(+), 42 deletions(-) diff --git a/lib/components/UserInfo.dart b/lib/components/UserInfo.dart index d4d5bbe..d6ef131 100644 --- a/lib/components/UserInfo.dart +++ b/lib/components/UserInfo.dart @@ -115,7 +115,11 @@ class UserInfo { // 去除末尾的区县 String trim_county(String _name) { - return _name.substring(0, _name.length - 1); + // 对长度小于等于2的区县名称(“高县”、“珙县”等)不进行去尾操作 + if (_name.length > 2) { + _name = _name.substring(0, _name.length - 1); + } + return _name; } Map mapUserInfoRet = { diff --git a/lib/pages/MyMsics/05_updated/MyUpdatedNew.dart b/lib/pages/MyMsics/05_updated/MyUpdatedNew.dart index 62a3a7c..0c1d1e9 100644 --- a/lib/pages/MyMsics/05_updated/MyUpdatedNew.dart +++ b/lib/pages/MyMsics/05_updated/MyUpdatedNew.dart @@ -6,12 +6,13 @@ import 'dart:io'; import 'dart:isolate'; import 'dart:ui'; +import 'package:app_installer/app_installer.dart'; import 'package:flutter/material.dart'; import 'package:flutter_downloader/flutter_downloader.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:hyzp_ybqx/components/dioFun.dart'; -import 'package:open_file/open_file.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:progress_dialog/progress_dialog.dart'; import '../../../components/commonFun.dart'; @@ -314,7 +315,17 @@ class MyUpdatedNew { /// 安装apk Future _installApk() async { - await OpenFile.open(appPath + '/' + apkName); + // await OpenFile.open(appPath + '/' + apkName); + // app_installer: 0.5.0 # Flutter 2.1,修复 Android 11 上允许权限后应用重启的问题,https://pub.dev/packages/app_installer + Map permissionStatuses = await [ + Permission.storage, + ].request(); + + if (permissionStatuses[Permission.storage] == PermissionStatus.granted) { + await AppInstaller.installApk(appPath + '/' + apkName); + } else { + print('Permission request fail!'); + } } /// 获取apk存储位置 diff --git a/lib/pages/Works/TJXX/tj_data.dart b/lib/pages/Works/TJXX/tj_data.dart index 5bb0322..1551eeb 100644 --- a/lib/pages/Works/TJXX/tj_data.dart +++ b/lib/pages/Works/TJXX/tj_data.dart @@ -606,45 +606,6 @@ Future getAllSumNew() async { ] */ -// 实现多个基于 Page1_Works 构建的页面共享统计数据 -Future startGetStatisDataOld() async { - ///获取点位信息数据 - //listDwinfoGetList2.clear(); - - if (listDwinfoGetList2.isEmpty) { - //若没有读取点位数据,便需要先读取 - getThePageList(theHyshlx: 'dwxx').then((value) { - listDwinfoGetList2 = value; - print('listDwinfoGetList2 = \n$listDwinfoGetList2'); - dwSum = listDwinfoGetList2.length; - getZptjStatisAlone(); - getTodayShtj(); - getClltjStatisAlone(); - }); - } else { - if (mapStatisInfo['今日抓拍'] < 0) { - getZptjStatisAlone(); - } else { - //发送统计数据已更新广播 - eventBus.fire(StatisDataUpdate('统计数据已更新')); - } - - if (mapStatisInfo['今日初审'] < 0) { - getTodayShtj(); - } else { - //发送统计数据已更新广播 - eventBus.fire(StatisDataUpdate('统计数据已更新')); - } - - if (mapStatisInfo['今日车流'] < 0) { - getClltjStatisAlone(); - } else { - //发送统计数据已更新广播 - eventBus.fire(StatisDataUpdate('统计数据已更新')); - } - } -} - //获取已审核黑烟车统计数据:App.Car_Statis.GetStaHyc //{ // "ret": 200, diff --git a/pubspec.lock b/pubspec.lock index 4c14e98..ee58270 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + app_installer: + dependency: "direct main" + description: + name: app_installer + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.5.0" archive: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6d5e8dc..41b73d8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -153,6 +153,9 @@ dependencies: flutter_downloader: ^1.5.2 # 下载文件 package_info: ^0.4.3+2 # 检测版本号 progress_dialog: ^1.2.0 # 显示进度对话框 + # app_installer: ^1.1.0 # Flutter 2.12,修复 Android 11 上允许权限后应用重启的问题 + app_installer: ^0.5.0 # Flutter 2.1,修复 Android 11 上允许权限后应用重启的问题,https://pub.dev/packages/app_installer + # install_plugin: ^2.0.1 # 不行,https://pub.dev/packages/install_plugin #flutter_app_badger and flutter_app_icon_badge Not working on android devices of Samsung Galaxy S7 and Samsung Galaxy S10 #flutter_app_badger: ^1.1.2 # 桌面App图标红点