Device info package eltávolítva, google megszorítás miatt.
Helyette UUID használva.
This commit is contained in:
parent
8ea1190b4c
commit
af41592029
|
|
@ -22,6 +22,7 @@ import 'package:simple_barcode_scanner/simple_barcode_scanner.dart';
|
|||
import 'dart:io';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:lite_rolling_switch/lite_rolling_switch.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
//AutoUpdateApk aua = new AutoUpdateApk(getApplicationContext(), UPDATE_URL);
|
||||
|
||||
|
||||
|
|
@ -68,8 +69,9 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
String currentWorkState="";
|
||||
QRCodeModel currentQRcode=QRCodeModel();
|
||||
WorkStateModel workState=WorkStateModel();
|
||||
late EmployeeArguments ea;
|
||||
EmployeeArguments? ea;
|
||||
EmployeePageArguments employeePageArgs = EmployeePageArguments();
|
||||
|
||||
//device_info.DeviceInfo di=device_info.DeviceInfo();
|
||||
//late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
|
||||
//var deviceData = <String, dynamic>{};
|
||||
|
|
@ -148,19 +150,19 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
setState(() {
|
||||
_reportButtonDisabled = false;
|
||||
});
|
||||
if (ea.mobilePortalAccessEnabled == false) {
|
||||
if (ea?.mobilePortalAccessEnabled == false) {
|
||||
_showAccessDeniedDialog();
|
||||
}
|
||||
employeePageArgs = EmployeePageArguments(
|
||||
name: ea.name,
|
||||
id: ea.id,
|
||||
name: ea?.name,
|
||||
id: ea?.id,
|
||||
apiKey: userApiKey,
|
||||
isForeman: ea.isForeman,
|
||||
mobilePortalAccessEnabled: ea.mobilePortalAccessEnabled);
|
||||
isForeman: ea?.isForeman,
|
||||
mobilePortalAccessEnabled: ea?.mobilePortalAccessEnabled);
|
||||
setState(() {
|
||||
_reportButtonDisabled = !ea.isForeman!;
|
||||
_reportButtonDisabled = employeePageArgs.isForeman!;
|
||||
});
|
||||
if (ea.id!.isNotEmpty) {
|
||||
if (employeePageArgs.id!.isNotEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -186,6 +188,7 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
}
|
||||
Future<bool> getDeviceUUID() async{
|
||||
storage.SecureStorage sc= storage.SecureStorage();
|
||||
|
||||
deviceUUID1= await sc.readSecureData('UUID1');
|
||||
deviceUUID2= await sc.readSecureData('UUID2');
|
||||
if (deviceUUID1!.startsWith("No data found!") || deviceUUID2!.startsWith("No data found!")) {
|
||||
|
|
@ -195,6 +198,21 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
}
|
||||
}
|
||||
|
||||
Future<bool> _checkUUIDS() async {
|
||||
storage.SecureStorage sc= storage.SecureStorage();
|
||||
//sc.deleteSecureData('API');
|
||||
bool resAPI= await storage.SecureStorage().checkContainsKey('API');// sc.checkContainsKey('API');
|
||||
bool resUUID1= await storage.SecureStorage().checkContainsKey('UUID1') ;
|
||||
bool resUUID2= await storage.SecureStorage().checkContainsKey('UUID2') ;
|
||||
if (resAPI==false || resUUID1==false || resUUID2==false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Future<void> _registerDevicePage() async {
|
||||
|
||||
}
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initStateA
|
||||
|
|
@ -204,49 +222,40 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
|
||||
getDeviceUUID().then((value)
|
||||
//di.initPlatformState().then((value)
|
||||
{
|
||||
// deviceData = value;
|
||||
if (value==false) {
|
||||
Navigator.pushNamed(context, '/register', arguments: DeviceArguments(
|
||||
//deviceData['id'], deviceData['device'], deviceData['brand'])).then((value)
|
||||
"", "", ""));
|
||||
}
|
||||
//checkApiKey();
|
||||
//saveApiKey();
|
||||
storage.SecureStorage sc= storage.SecureStorage();
|
||||
//sc.deleteSecureData('API');
|
||||
Future<bool> res= storage.SecureStorage().checkContainsKey('API');// sc.checkContainsKey('API');
|
||||
res.then((value) {
|
||||
//Future<bool> resAPI= storage.SecureStorage().checkContainsKey('API');// sc.checkContainsKey('API');
|
||||
//Future<bool> resUUID1= storage.SecureStorage().checkContainsKey('UUID1') ;
|
||||
//Future<bool> resUUID2= storage.SecureStorage().checkContainsKey('UUID2') ;
|
||||
|
||||
//_isApiKeyValid=value;
|
||||
//apiKeyValid=value;
|
||||
if (value==false)
|
||||
_checkUUIDS().then((val){
|
||||
if (val==false)
|
||||
{
|
||||
Navigator.pushNamed(context, '/register', arguments: DeviceArguments(
|
||||
|
||||
Navigator.pushNamed(
|
||||
context, '/register', arguments: DeviceArguments(
|
||||
//deviceData['id'], deviceData['device'], deviceData['brand'])).then((value)
|
||||
deviceUUID1!, deviceUUID2!, deviceBrand!)).then((value)
|
||||
{
|
||||
//deviceUUID1!, deviceUUID2!, deviceBrand!)).then((value) {
|
||||
"", "", "")).then((value) {
|
||||
Future<String> userApiKey = sc.readSecureData("API");
|
||||
userApiKey.then((apiKey) => checkApiKeyValidity(apiKey).then((apiKeyState) {
|
||||
userApiKey.then((apiKey) =>
|
||||
checkApiKeyValidity(apiKey).then((apiKeyState) {
|
||||
// print("API key State: $apiKeyState");
|
||||
|
||||
setState(() {
|
||||
_isApiKeyValid = apiKeyState;
|
||||
if (ea.isForeman==true)
|
||||
{
|
||||
if (ea?.isForeman == true) {
|
||||
_reportButtonDisabled = false;
|
||||
}
|
||||
if (ea.mobilePortalAccessEnabled==true)
|
||||
{
|
||||
if (ea?.mobilePortalAccessEnabled == true) {
|
||||
NfcManager.instance.isAvailable().then((nfcState) {
|
||||
if (_isApiKeyValid && !_isLocationMocked)
|
||||
{
|
||||
if (_isApiKeyValid && !_isLocationMocked) {
|
||||
_showNFClogo = true;
|
||||
_tagRead();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
_showNFClogo = false;
|
||||
}
|
||||
});
|
||||
|
|
@ -261,21 +270,23 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
)
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
getDeviceUUID();
|
||||
Future<String> userApiKey=sc.readSecureData("API");
|
||||
userApiKey.then((apiKey) => checkApiKeyValidity(apiKey).then((apiKeyState) {
|
||||
// print("API key State: $apiKeyState");
|
||||
|
||||
setState(() {
|
||||
_isApiKeyValid = apiKeyState;
|
||||
if (ea.isForeman==true)
|
||||
if (ea == null) return;
|
||||
if (ea?.isForeman==true)
|
||||
{
|
||||
_reportButtonDisabled=false;
|
||||
}
|
||||
if (ea.mobilePortalAccessEnabled==true)
|
||||
if (ea?.mobilePortalAccessEnabled==true)
|
||||
{
|
||||
NfcManager.instance.isAvailable().then((nfcState){
|
||||
if (_isApiKeyValid && !_isLocationMocked)
|
||||
|
|
@ -300,12 +311,12 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
//sc.writeSecureData("API", deviceData['id']);
|
||||
//sc.checkContainsKey('API');
|
||||
//sc.readSecureData("API");
|
||||
});
|
||||
//);
|
||||
|
||||
_getLocation();
|
||||
PackageInfo.fromPlatform().then((value) => {
|
||||
|
|
@ -355,6 +366,34 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
}
|
||||
}
|
||||
|
||||
/*Future<void> _showMyDialog(String message1) async {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false, // user must tap button!
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Figyelmeztetés'),
|
||||
content: const SingleChildScrollView(
|
||||
child: ListBody(
|
||||
children: <Widget>[
|
||||
Text(message1 as String),
|
||||
Text('Would you like to approve of this message?'),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Bezár'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}*/
|
||||
|
||||
|
||||
Widget nfcLogo() {
|
||||
if (_location?.isMock==true) {
|
||||
|
|
@ -380,48 +419,17 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
);
|
||||
}
|
||||
}
|
||||
Future _scanQR() async {
|
||||
/*try {
|
||||
String qrResult = await BarcodeScanner.scan();
|
||||
setState(() {
|
||||
_login(qrResult);
|
||||
/* result = qrResult;
|
||||
TcpClient a = new TcpClient(socket, 'iotechnic.eu', 8080);
|
||||
|
||||
_getId();
|
||||
a.sendAccess(
|
||||
deviceId,
|
||||
result,
|
||||
_currentAddress,
|
||||
_currentPosition.latitude.toString(),
|
||||
_currentPosition.longitude.toString());*/
|
||||
});
|
||||
} on PlatformException catch (ex) {
|
||||
if (ex.code == BarcodeScanner.CameraAccessDenied) {
|
||||
setState(() {
|
||||
result = "Camera permission was denied";
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
result = "Unknown Error $ex";
|
||||
});
|
||||
}
|
||||
} on FormatException {
|
||||
setState(() {
|
||||
result = "You pressed the back button before scanning anything";
|
||||
});
|
||||
} catch (ex) {
|
||||
setState(() {
|
||||
result = "Unknown Error $ex";
|
||||
});
|
||||
}*/
|
||||
}
|
||||
_loginQR(qrCode) {
|
||||
_loginQR(qrCode) async {
|
||||
setState(() {
|
||||
_showNFClogo = false;
|
||||
});
|
||||
//DeviceInfo devInfo = _getDeviceInfo() as DeviceInfo;
|
||||
|
||||
bool r=await getDeviceUUID();
|
||||
if (!r) return;
|
||||
// _showMyDialog();
|
||||
//DeviceInfo devInfo = _getDeviceInfo() as DeviceInfo;
|
||||
_getLocation();
|
||||
String indexRequest = '{'
|
||||
'"cmd":"ACCESSNOGEOQR",'
|
||||
'"CID1":"$deviceUUID1",' //$"{deviceData['id']}",'
|
||||
|
|
@ -497,12 +505,13 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
socket.flush();
|
||||
});
|
||||
}
|
||||
_login(rfid) {
|
||||
_login(rfid) async {
|
||||
setState(() {
|
||||
_showNFClogo = false;
|
||||
});
|
||||
//DeviceInfo devInfo = _getDeviceInfo() as DeviceInfo;
|
||||
|
||||
bool r=await getDeviceUUID();
|
||||
if (!r) return;
|
||||
String indexRequest = '{'
|
||||
'"cmd":"ACCESSNOGEO",'
|
||||
// '"CID1":"${deviceData['id']}",'
|
||||
|
|
@ -581,30 +590,6 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
});
|
||||
}
|
||||
|
||||
/*Future<void> _showNotification() async {
|
||||
var dateTime = DateTime(DateTime.now().year, DateTime.now().month,
|
||||
DateTime.now().day, 10, 46, 0);
|
||||
const AndroidNotificationDetails androidNotificationDetails =
|
||||
AndroidNotificationDetails('your channel id', 'your channel name',
|
||||
channelDescription: 'your channel description',
|
||||
importance: Importance.max,
|
||||
priority: Priority.high,
|
||||
ticker: 'ticker');
|
||||
const NotificationDetails notificationDetails =
|
||||
NotificationDetails(android: androidNotificationDetails);
|
||||
/*await flutterLocalNotificationsPlugin.show(
|
||||
1234, 'plain title', 'plain body', notificationDetails,
|
||||
payload: 'item x');*/
|
||||
await flutterLocalNotificationsPlugin.zonedSchedule(
|
||||
0,
|
||||
'title',
|
||||
'body',
|
||||
tz.TZDateTime.from(dateTime, tz.local),
|
||||
notificationDetails,
|
||||
uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime,
|
||||
matchDateTimeComponents: DateTimeComponents.time);
|
||||
}*/
|
||||
|
||||
_getAddressFromLatLng(lat,lon) async {
|
||||
try {
|
||||
List<geocoding.Placemark> placemarks = await geocoding.placemarkFromCoordinates(
|
||||
|
|
@ -694,9 +679,7 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
style: const TextStyle(fontSize: 24.0),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
content: Container(
|
||||
//height: 400,
|
||||
child: SingleChildScrollView(
|
||||
content: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
|
@ -764,7 +747,6 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
@ -858,7 +840,7 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(14.0),
|
||||
child: _initOK
|
||||
child: _initOK || _loading
|
||||
? Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
|
@ -875,7 +857,7 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
|
||||
Column(
|
||||
children: <Widget>[
|
||||
Text(currentWorkState ?? ""),
|
||||
Text(currentWorkState),
|
||||
Text(currentQRcode.name ?? "",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
|
|
@ -1055,7 +1037,8 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
result,
|
||||
'Location: ${_error ?? result}',
|
||||
// result,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 30.0,
|
||||
|
|
|
|||
|
|
@ -109,24 +109,24 @@ class _reportCreateState extends State<reportCreate> {
|
|||
|
||||
Container gridList(BuildContext context) {
|
||||
//List<ModelReportList> _reportList = [];
|
||||
List<WorkListModel> workList = [];
|
||||
List<WorkListModel> workList2 = [];
|
||||
if (_showFaworites) {
|
||||
workList = workList
|
||||
workList2 = workList
|
||||
.where((element) => favoriteWorks.contains(element.sId))
|
||||
.toList();
|
||||
} else {
|
||||
workList = workList;
|
||||
workList2 = workList;
|
||||
}
|
||||
return Container(
|
||||
color: const Color(0xffECF0F1),
|
||||
child: ListView.builder(
|
||||
itemCount: workList.length, // The length Of the array
|
||||
itemCount: workList2.length, // The length Of the array
|
||||
|
||||
padding: const EdgeInsets.all(5),
|
||||
shrinkWrap: true,
|
||||
|
||||
itemBuilder: (context, index) => Container(
|
||||
child: reportCard(context, workList[index]),
|
||||
child: reportCard(context, workList2[index]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
/*import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
|
|
@ -180,4 +180,4 @@ class DeviceInfo{
|
|||
'deviceId': data.deviceId,
|
||||
};
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
|
|||
|
|
@ -50,8 +50,9 @@ class _dailyReportListState extends State<dailyReportList> {
|
|||
for (var item in data) {
|
||||
reportList.add(ModelReportList.fromJson(item));
|
||||
}
|
||||
_isData = true;
|
||||
|
||||
setState(() {
|
||||
_isData = true;
|
||||
debugPrint('Fetch ok.');
|
||||
});
|
||||
} else {
|
||||
|
|
@ -210,25 +211,25 @@ Container page(BuildContext context) {
|
|||
}
|
||||
|
||||
Container gridList(BuildContext context) {
|
||||
List<ModelReportList> reportList = [];
|
||||
List<ModelReportList> reportList2 = [];
|
||||
if (_showFaworites) {
|
||||
reportList = reportList
|
||||
reportList2 = reportList
|
||||
.where((element) => favoriteWorks.contains(element.sId))
|
||||
.toList();
|
||||
} else {
|
||||
reportList = reportList;
|
||||
reportList2 = reportList;
|
||||
}
|
||||
return Container(
|
||||
color: const Color(0xffECF0F1),
|
||||
child: ListView.builder(
|
||||
itemCount: reportList.length, // The length Of the array
|
||||
itemCount: reportList2.length, // The length Of the array
|
||||
|
||||
padding: const EdgeInsets.all(5),
|
||||
shrinkWrap: true,
|
||||
|
||||
itemBuilder: (context, index) => Container(
|
||||
child: reportCardWidget(
|
||||
reportList[index]) //reportCard(context, _reportList[index]),
|
||||
reportList2[index]) //reportCard(context, _reportList[index]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.3+1
|
||||
version: 1.0.4+1
|
||||
|
||||
environment:
|
||||
sdk: '>=3.2.0 <4.0.0'
|
||||
|
|
@ -56,6 +56,8 @@ dependencies:
|
|||
lite_rolling_switch: ^1.0.1
|
||||
permission_handler: ^11.3.1
|
||||
uuid: ^4.4.2
|
||||
fluttertoast: ^8.1.1
|
||||
|
||||
#flutter_local_notifications: ^17.1.2
|
||||
|
||||
dev_dependencies:
|
||||
|
|
|
|||
Loading…
Reference in New Issue