Merge pull request #68 from FRE-Informatica/fix/fd-940
FIX/FD-940 - Deslogando após longos períodos em background
This commit is contained in:
commit
8f703d07de
|
@ -1,7 +1,124 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.freaccess.hub">
|
||||
<!-- Flutter needs it to communicate with the running application
|
||||
to allow setting breakpoints, to provide hot reload, etc.
|
||||
-->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
package="com.freaccess.hub"
|
||||
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE" />
|
||||
|
||||
<application
|
||||
android:label="FRE ACCESS HUB"
|
||||
tools:replace="android:label"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:usesCleartextTraffic="true">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:showWhenLocked="true"
|
||||
android:turnScreenOn="true">
|
||||
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
||||
android:resource="@drawable/launch_background"
|
||||
/>
|
||||
|
||||
<meta-data android:name="flutter_deeplinking_enabled" android:value="false" />
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" android:host="freaccess.com.br" android:pathPrefix="/freaccess/alterarSenha.php" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="freaccess" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="mensagem" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="frehub" android:host="frehub.com" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="visit_request" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="access" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="mensagem" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="enroll_cond" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||
android:resource="@drawable/notification_icon" />
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
|
||||
<!-- <receiver android:exported="false"
|
||||
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
|
||||
<receiver android:exported="false"
|
||||
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
|
||||
</intent-filter>
|
||||
</receiver> -->
|
||||
</application>
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
</manifest>
|
|
@ -1,118 +1,124 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.freaccess.hub"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
<application
|
||||
android:label="FRE ACCESS HUB"
|
||||
tools:replace="android:label"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:usesCleartextTraffic="true">
|
||||
package="com.freaccess.hub"
|
||||
|
||||
<activity
|
||||
android:name="io.flutter.embedding.android.FlutterFragmentActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:showWhenLocked="true"
|
||||
android:turnScreenOn="true">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE" />
|
||||
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
||||
android:resource="@drawable/launch_background"
|
||||
/>
|
||||
<meta-data android:name="flutter_deeplinking_enabled" android:value="false" />
|
||||
<application
|
||||
android:label="FRE ACCESS HUB"
|
||||
tools:replace="android:label"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:usesCleartextTraffic="true">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/LaunchTheme"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:showWhenLocked="true"
|
||||
android:turnScreenOn="true">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" android:host="freaccess.com.br" android:pathPrefix="/freaccess/alterarSenha.php" />
|
||||
</intent-filter>
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="freaccess" />
|
||||
</intent-filter>
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="mensagem" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="frehub" android:host="frehub.com" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="visit_request" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="access" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="mensagem" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="enroll_cond" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
|
||||
<meta-data
|
||||
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
||||
android:resource="@drawable/launch_background"
|
||||
/>
|
||||
|
||||
<meta-data android:name="flutter_deeplinking_enabled" android:value="false" />
|
||||
|
||||
</activity>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||
android:resource="@drawable/notification_icon" />
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" android:host="freaccess.com.br" android:pathPrefix="/freaccess/alterarSenha.php" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="freaccess" />
|
||||
</intent-filter>
|
||||
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="mensagem" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="frehub" android:host="frehub.com" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="visit_request" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<!-- <receiver android:exported="false"
|
||||
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
|
||||
<receiver android:exported="false"
|
||||
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
|
||||
</intent-filter>
|
||||
</receiver> -->
|
||||
<intent-filter>
|
||||
<action android:name="access" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="mensagem" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="enroll_cond" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||
android:resource="@drawable/notification_icon" />
|
||||
<!-- Don't delete the meta-data below.
|
||||
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
|
||||
<!-- <receiver android:exported="false"
|
||||
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
|
||||
<receiver android:exported="false"
|
||||
android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
|
||||
</intent-filter>
|
||||
</receiver> -->
|
||||
</application>
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
</application>
|
||||
<queries>
|
||||
<intent>
|
||||
<action android:name="android.intent.action.PROCESS_TEXT"/>
|
||||
<data android:mimeType="text/plain"/>
|
||||
</intent>
|
||||
</queries>
|
||||
</manifest>
|
|
@ -1,5 +1,29 @@
|
|||
package com.freaccess.hub
|
||||
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import io.flutter.embedding.android.FlutterFragmentActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
|
||||
class MainActivity: FlutterFragmentActivity() {}
|
||||
class MainActivity: FlutterFragmentActivity() {
|
||||
private val CHANNEL = "com.freaccess.hub/getAndroidId"
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL).setMethodCallHandler { call, result ->
|
||||
if (call.method == "getAndroidId") {
|
||||
val androidId = getAndroidId()
|
||||
if (androidId != null) {
|
||||
result.success(androidId)
|
||||
} else {
|
||||
result.error("UNAVAILABLE", "Android ID not available.", null)
|
||||
}
|
||||
} else {
|
||||
result.notImplemented()
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun getAndroidId(): String? {
|
||||
return Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID)
|
||||
}
|
||||
}
|
|
@ -14,7 +14,8 @@ import '/backend/api_requests/api_calls.dart';
|
|||
import '/flutter_flow/flutter_flow_theme.dart';
|
||||
|
||||
class BottomArrowLinkedLocalsComponentWidget extends StatefulWidget {
|
||||
const BottomArrowLinkedLocalsComponentWidget({super.key});
|
||||
const BottomArrowLinkedLocalsComponentWidget({super.key, required this.response});
|
||||
final ApiCallResponse? response;
|
||||
|
||||
@override
|
||||
State<BottomArrowLinkedLocalsComponentWidget> createState() => _BottomArrowLinkedLocalsComponentWidgetState();
|
||||
|
@ -71,16 +72,15 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
|
|||
Future<ApiCallResponse?> _fetchLocals() async {
|
||||
try {
|
||||
setState(() => _loading = true);
|
||||
var response = await PhpGroup.getLocalsCall.call();
|
||||
final bool isError = response.jsonBody['error'];
|
||||
final bool isError = widget.response?.jsonBody['error'];
|
||||
|
||||
if (isError) {
|
||||
final String errorMsg = response.jsonBody['error_msg'];
|
||||
final String errorMsg = widget.response?.jsonBody['error_msg'];
|
||||
_handleError(context, errorMsg);
|
||||
return response;
|
||||
return widget.response;
|
||||
}
|
||||
|
||||
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||
final List<dynamic> locals = widget.response?.jsonBody['locais'] ?? [];
|
||||
|
||||
final bool isEmpty = locals.isEmpty;
|
||||
final bool isUnique = locals.length == 1;
|
||||
|
@ -99,7 +99,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
|
|||
|
||||
if (isDisabled) {
|
||||
context.go('/receptionPage');
|
||||
return response;
|
||||
return widget.response;
|
||||
}
|
||||
if (isEnabled) {
|
||||
final local = locals[0];
|
||||
|
@ -109,10 +109,10 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
|
|||
await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage);
|
||||
|
||||
context.pop();
|
||||
return response;
|
||||
return widget.response;
|
||||
}
|
||||
|
||||
return response;
|
||||
return widget.response;
|
||||
}
|
||||
_showNoMoreDataSnackBar(context);
|
||||
setState(() {
|
||||
|
@ -131,7 +131,6 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State<BottomArrowLink
|
|||
}
|
||||
|
||||
static void _handleError(BuildContext context, String errorMsg) {
|
||||
AuthenticationService.signOut(context);
|
||||
DialogUtil.error(context, errorMsg);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ class LocalProfileComponentModel extends FlutterFlowModel<LocalProfileComponentW
|
|||
Future<void> getData() async {
|
||||
cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? '';
|
||||
cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? '';
|
||||
;
|
||||
setStateCallback?.call();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ import 'dart:developer';
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hub/shared/helpers/base_storage.dart';
|
||||
import 'package:hub/shared/helpers/storage_helper.dart';
|
||||
|
||||
import '/flutter_flow/custom_functions.dart' as functions;
|
||||
import '/flutter_flow/flutter_flow_theme.dart';
|
||||
|
@ -34,10 +36,15 @@ class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidge
|
|||
_model = createModel(context, () => LocalProfileComponentModel());
|
||||
_model.setOnUpdate(onUpdate: () => setState(() {}));
|
||||
_model.setStateCallback = () => safeSetState(() {});
|
||||
//
|
||||
// WidgetsBinding.instance
|
||||
// .addPostFrameCallback((_) async => await LocalizationService.processLocals(context).then((value) => value == true ? onUpdate() : null));
|
||||
// LocalizationService.processLocals(context).then((value) => value == true ? onUpdate() : null);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
bool initialized = false;
|
||||
bool isDevLinked = _model.cliUUID.isNotEmpty;
|
||||
if (!isDevLinked && !initialized) {
|
||||
initialized = true;
|
||||
await LocalizationService.processLocals(context).then((value) => value == true ? onUpdate() : null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -90,7 +97,8 @@ class _LocalProfileComponentWidgetState extends State<LocalProfileComponentWidge
|
|||
hoverColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
onTap: () async {
|
||||
await LocalizationService.selectLocal(context)
|
||||
await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage);
|
||||
await LocalizationService.processLocals(context)
|
||||
.then((value) => value == true ? onUpdate() : null);
|
||||
},
|
||||
child: ClipRRect(
|
||||
|
|
|
@ -3,9 +3,12 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/src/response.dart';
|
||||
import 'package:hub/backend/api_requests/api_manager.dart';
|
||||
import 'package:hub/flutter_flow/nav/nav.dart';
|
||||
import 'package:hub/shared/helpers/base_storage.dart';
|
||||
import 'package:hub/shared/helpers/storage_helper.dart';
|
||||
import 'package:hub/shared/utils/device_util.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
|
||||
import '../../../backend/api_requests/api_calls.dart';
|
||||
|
@ -20,12 +23,20 @@ class LocalizationService {
|
|||
try {
|
||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||
var response = await callback.call();
|
||||
final bool isError = response.jsonBody['error'];
|
||||
final bool? isError = response.jsonBody['error'];
|
||||
|
||||
if (isError) {
|
||||
if (isError == true) {
|
||||
_handleError(context, response.jsonBody['error_msg']);
|
||||
return;
|
||||
}
|
||||
if (response.jsonBody == null) {
|
||||
final String errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Verify your connection',
|
||||
ptText: 'Verifique sua conexão',
|
||||
);
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
return;
|
||||
}
|
||||
|
||||
final List<dynamic> locals = response.jsonBody['locais'] ?? [];
|
||||
final bool isEmpty = locals.isEmpty;
|
||||
|
@ -49,13 +60,21 @@ class LocalizationService {
|
|||
try {
|
||||
final GetLocalsCall callback = PhpGroup.getLocalsCall;
|
||||
final ApiCallResponse response = await callback.call();
|
||||
final bool isError = response.jsonBody['error'];
|
||||
final bool? isError = response.jsonBody['error'];
|
||||
|
||||
if (isError) {
|
||||
if (isError == true) {
|
||||
final String errorMsg = response.jsonBody['error_msg'];
|
||||
_handleError(context, errorMsg);
|
||||
return false;
|
||||
}
|
||||
if (response.jsonBody == null) {
|
||||
final String errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Verify your connection',
|
||||
ptText: 'Verifique sua conexão',
|
||||
);
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<dynamic> locals = response.jsonBody['locais'].toList() ?? [];
|
||||
_logLocalsStatus(locals);
|
||||
|
@ -81,7 +100,7 @@ class LocalizationService {
|
|||
return await _handleEnabled(context, locals[0]);
|
||||
} else if (isUnselected) {
|
||||
log('() => isUnselected');
|
||||
return await selectLocal(context);
|
||||
return await selectLocal(context, response);
|
||||
} else if (isSelected) {
|
||||
log('() => isSelected');
|
||||
return await processData(context);
|
||||
|
@ -94,7 +113,7 @@ class LocalizationService {
|
|||
if (!isUnique && isPending) log('() => not unique and pending');
|
||||
if (!isUnique && isBlocked) log('() => not unique and blocked');
|
||||
log('() => else');
|
||||
return await selectLocal(context);
|
||||
return await selectLocal(context, response);
|
||||
}
|
||||
} catch (e, s) {
|
||||
log('() => stack: $s');
|
||||
|
@ -104,7 +123,7 @@ class LocalizationService {
|
|||
enText: 'Error getting locals, verify your connection',
|
||||
ptText: 'Erro ao obter locais, verifique sua conexão',
|
||||
);
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -113,11 +132,18 @@ class LocalizationService {
|
|||
try {
|
||||
final GetDadosCall callback = PhpGroup.getDadosCall;
|
||||
var response = await callback.call();
|
||||
final bool error = response.jsonBody['error'];
|
||||
final bool? isError = response.jsonBody['error'];
|
||||
|
||||
if (error == true || error == 'true') {
|
||||
if (isError == true || isError == 'true') {
|
||||
final String errorMsg = response.jsonBody['error_msg'];
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
return false;
|
||||
} else if (response.jsonBody == null) {
|
||||
final String errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
enText: 'Verify your connection',
|
||||
ptText: 'Verifique sua conexão',
|
||||
);
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response));
|
||||
return false;
|
||||
} else {
|
||||
await _updateStorageUtil(response.jsonBody);
|
||||
|
@ -130,12 +156,12 @@ class LocalizationService {
|
|||
enText: 'Error getting data, verify your connection',
|
||||
ptText: 'Erro ao obter dados, verifique sua conexão',
|
||||
);
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
|
||||
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<bool> selectLocal(BuildContext context) async {
|
||||
static Future<bool> selectLocal(BuildContext context, ApiCallResponse? response) async {
|
||||
return await showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
|
@ -148,7 +174,7 @@ class LocalizationService {
|
|||
canPop: false,
|
||||
child: Padding(
|
||||
padding: MediaQuery.viewInsetsOf(context),
|
||||
child: const BottomArrowLinkedLocalsComponentWidget(),
|
||||
child: BottomArrowLinkedLocalsComponentWidget(response: response),
|
||||
),
|
||||
),
|
||||
).then((_) async => await processData(context));
|
||||
|
@ -204,6 +230,7 @@ class LocalizationService {
|
|||
final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty;
|
||||
final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario');
|
||||
log('() => isLinked: $errorMsg');
|
||||
log('() => isLinked: $errorMsg');
|
||||
if (!isAuthenticated) {
|
||||
errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Erro ao obter credenciais de autenticação',
|
||||
|
@ -221,7 +248,7 @@ class LocalizationService {
|
|||
await DialogUtil.warning(context, errorMsg);
|
||||
return;
|
||||
}
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context));
|
||||
await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, null));
|
||||
}
|
||||
|
||||
static Future<bool> _handleUnavailable(BuildContext context, List<dynamic> locals) async {
|
||||
|
@ -310,3 +337,4 @@ class LocalizationService {
|
|||
await StorageHelper().set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,42 +2,73 @@ import 'dart:io';
|
|||
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class DeviceUtil {
|
||||
static const MethodChannel _channel = MethodChannel("com.freaccess.hub/getAndroidId");
|
||||
|
||||
static Future<String?> getAndroidId() async {
|
||||
try {
|
||||
final String? androidId = await _channel.invokeMethod('getAndroidId');
|
||||
|
||||
return androidId;
|
||||
} on PlatformException catch (e) {
|
||||
print("Failed to get Android ID: '${e.message}'.");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<String?> getDevUUID() async {
|
||||
var deviceInfo = DeviceInfoPlugin();
|
||||
|
||||
if (Platform.isIOS) {
|
||||
// import 'dart:io'
|
||||
var iosDeviceInfo = await deviceInfo.iosInfo;
|
||||
return iosDeviceInfo.identifierForVendor; // unique ID on iOS
|
||||
return iosDeviceInfo.identifierForVendor;
|
||||
} else if (Platform.isAndroid) {
|
||||
var androidDeviceInfo = await deviceInfo.androidInfo;
|
||||
return androidDeviceInfo.id; // unique ID on Android
|
||||
try {
|
||||
final String? secureAndroidId = await getAndroidId();
|
||||
return secureAndroidId;
|
||||
} catch (e) {
|
||||
final build = await deviceInfo.androidInfo;
|
||||
return build.id;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<String?> getSerialNumber() async {
|
||||
var deviceInfo = DeviceInfoPlugin();
|
||||
|
||||
if (Platform.isIOS) {
|
||||
// import 'dart:io'
|
||||
|
||||
var iosDeviceInfo = await deviceInfo.iosInfo;
|
||||
|
||||
return iosDeviceInfo.identifierForVendor; // unique ID on iOS
|
||||
} else if (Platform.isAndroid) {
|
||||
var androidDeviceInfo = await deviceInfo.androidInfo;
|
||||
|
||||
return androidDeviceInfo.serialNumber; // unique ID on Android
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<String?> getDeviceOSVersion() async {
|
||||
var deviceInfo = DeviceInfoPlugin();
|
||||
|
||||
if (Platform.isIOS) {
|
||||
var iosDeviceInfo = await deviceInfo.iosInfo;
|
||||
|
||||
return iosDeviceInfo.systemVersion; // unique ID on iOS. e.g. 14.5
|
||||
} else if (Platform.isAndroid) {
|
||||
var androidDeviceInfo = await deviceInfo.androidInfo;
|
||||
|
||||
return androidDeviceInfo.version.release; // unique ID on Android. e.g . 11
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue