diff --git a/android/app/build.gradle b/android/app/build.gradle index 6ec0d534..0410d96b 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -73,10 +73,7 @@ android { storePassword keystoreProperties['storePassword'] } debug { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null - storePassword keystoreProperties['storePassword'] + } } diff --git a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart b/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart index 2525ec30..1d635544 100644 --- a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart +++ b/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart @@ -37,8 +37,7 @@ class _LocalProfileComponentWidgetState extends State await LocalizationService.processLocals(context).then((value) => value == true ? onUpdate() : null)); - LocalizationService.processLocals(context) - .then((value) => value == true ? onUpdate() : null); + // LocalizationService.processLocals(context).then((value) => value == true ? onUpdate() : null); } @override diff --git a/lib/main.dart b/lib/main.dart index ccda789a..1bd75c56 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -24,6 +24,8 @@ import 'package:hub/shared/services/localization/localization_service.dart'; import 'package:hub/shared/utils/device_util.dart'; import 'package:responsive_framework/responsive_framework.dart'; +import 'backend/notifications/firebase_messaging_service.dart'; + final GlobalKey navigatorKey = GlobalKey(); void main() async { @@ -251,7 +253,6 @@ class _AppState extends State with WidgetsBindingObserver { super.initState(); WidgetsBinding.instance.addObserver(this); - log('DeviceUtil: ${DeviceUtil.getDeviceOSVersion()}'); FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); _appStateNotifier = AppStateNotifier.instance; @@ -272,7 +273,10 @@ class _AppState extends State with WidgetsBindingObserver { @override void didChangeAppLifecycleState(AppLifecycleState state) async { - if(state == AppLifecycleState.resumed) await LocalizationService.processLocals(context); + if(state == AppLifecycleState.detached) { + await LocalizationService.processLocals(context); + FirebaseMessagingService().updateDeviceToken(); + } } @override diff --git a/lib/pages/home_page/home_page_widget.dart b/lib/pages/home_page/home_page_widget.dart index 9733580d..adb219c1 100644 --- a/lib/pages/home_page/home_page_widget.dart +++ b/lib/pages/home_page/home_page_widget.dart @@ -42,7 +42,7 @@ class _HomePageWidgetState extends State { _model = createModel(context, () => HomePageModel()); _model.updateOnChange = true; - FirebaseMessagingService().updateDeviceToken(); + _model.textController ??= TextEditingController(); _model.textFieldFocusNode ??= FocusNode(); diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index ed89a882..18016c98 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -60,7 +60,7 @@ class PreferencesPageModel with ChangeNotifier { onConfirm() async { String content; - String value = !isNotify ? 'N' : 'S'; + String value = !isNotify ? 'S' : 'N'; await PhpGroup.changeNotifica .call(notifica: value) .then((value) async { diff --git a/lib/shared/helpers/secure_storage.dart b/lib/shared/helpers/secure_storage.dart index 24181fc9..0313b583 100644 --- a/lib/shared/helpers/secure_storage.dart +++ b/lib/shared/helpers/secure_storage.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:hub/shared/helpers/base_storage.dart'; -class SecureStorage extends ChangeNotifier implements BaseStorage { +class SecureStorage implements BaseStorage { SecureStorage._(); static final SecureStorage instance = SecureStorage._(); @@ -22,18 +22,15 @@ class SecureStorage extends ChangeNotifier implements BaseStorage { @override Future set(String key, String value) async { await _secureStorage.write(key: key, value: value); - notifyListeners(); } @override Future delete(String key) async { await _secureStorage.delete(key: key); - notifyListeners(); } @override Future clearAll() async { await _secureStorage.deleteAll(); - notifyListeners(); } } diff --git a/lib/shared/helpers/shared_preferences_storage.dart b/lib/shared/helpers/shared_preferences_storage.dart index 0dd19da1..c7d10cd5 100644 --- a/lib/shared/helpers/shared_preferences_storage.dart +++ b/lib/shared/helpers/shared_preferences_storage.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:hub/shared/helpers/base_storage.dart'; import 'package:shared_preferences/shared_preferences.dart'; -class SharedPreferencesStorage extends ChangeNotifier implements BaseStorage { +class SharedPreferencesStorage implements BaseStorage { SharedPreferencesStorage._(); static final SharedPreferencesStorage instance = SharedPreferencesStorage._(); @@ -22,18 +22,15 @@ class SharedPreferencesStorage extends ChangeNotifier implements BaseStorage { @override Future set(String key, String value) async { await _prefs.setString(key, value); - notifyListeners(); } @override Future delete(String key) async { await _prefs.remove(key); - notifyListeners(); } @override Future clearAll() async { await _prefs.clear(); - notifyListeners(); } } diff --git a/lib/shared/helpers/sqlite_storage.dart b/lib/shared/helpers/sqlite_storage.dart index 6f387759..ed9af1da 100644 --- a/lib/shared/helpers/sqlite_storage.dart +++ b/lib/shared/helpers/sqlite_storage.dart @@ -1,21 +1,21 @@ -import 'package:flutter/material.dart'; import 'package:hub/shared/helpers/base_storage.dart'; import 'package:sqflite/sqflite.dart'; import 'package:sqflite/sqlite_api.dart'; import 'package:path/path.dart'; -class SQLiteStorage extends ChangeNotifier implements BaseStorage { +class SQLiteStorage implements BaseStorage { SQLiteStorage._(); - final String _dbName = 'database.db'; - final int _dbVersion = 1; + static final String _dbName = 'database.db'; + static final int _dbVersion = 1; + + static const String tableKeychain = 'keychain'; static final SQLiteStorage instance = SQLiteStorage._(); late final _database; - @override - Future init() async { + @override Future init() async { _database = await openDatabase( join(await getDatabasesPath(), _dbName), version: _dbVersion, @@ -23,30 +23,15 @@ class SQLiteStorage extends ChangeNotifier implements BaseStorage { onUpgrade: _onUpdate, onDowngrade: _onDowngrade, ); - - await _onInitLocalVariables(_database); + // await _onInitLocalVariables(_database); } _onCreate(Database database, int version) async { await database.execute(_tableKeychain); } - _onUpdate(Database database, int oldVersion, int newVersion) async {} - _onDowngrade(Database database, int oldVersion, int newVersion) async {} - _onInitLocalVariables(Database database) async { - // TODO: Talvez precise colocar um transaction aqui como o - // database.batch() para melhorar a performance - - for (var variable in _localVariables) { - var isConfig = await database.query('keychain', where: 'key = ?', whereArgs: [variable['key']]); - - if (isConfig.isEmpty) { - await database.insert('keychain', variable); - } - } - } String get _tableKeychain => ''' CREATE TABLE keychain ( @@ -81,22 +66,18 @@ class SQLiteStorage extends ChangeNotifier implements BaseStorage { {'key': SQLiteStorageKey.petAmount.value, 'value': '', 'type': 'local'}, ]; - @override - Future get(String key) async { + @override Future get(String key) async { var response = await _database.query('keychain', where: 'key = ?', whereArgs: [key]); - if (response.isEmpty) { return null; } - return response.first['value']; } - @override - Future set(String key, String value) async { + @override Future set(String key, String value) async { var date = DateTime.now().toIso8601String(); await _database.insert( - 'keychain', + tableKeychain, { 'key': key, 'value': value, @@ -105,24 +86,15 @@ class SQLiteStorage extends ChangeNotifier implements BaseStorage { 'resolvedAt': date, 'createdAt': date, }, - conflictAlgorithm: ConflictAlgorithm.replace); - notifyListeners(); + conflictAlgorithm: ConflictAlgorithm.replace + ); } - @override - Future delete(String key) async { - var isConfig = await _database.query('keychain', where: 'key = ?', whereArgs: [key]); - - if (isConfig.isNotEmpty) { - await _database.delete('keychain', where: 'key = ?', whereArgs: [key]); - } - - notifyListeners(); + @override Future delete(String key) async { + await _database.delete('keychain', where: 'key = ?', whereArgs: [key]); } - @override - Future clearAll() async { + @override Future clearAll() async { await _database.delete('keychain'); - notifyListeners(); } } diff --git a/lib/shared/helpers/storage_helper.dart b/lib/shared/helpers/storage_helper.dart index e245d468..5dc29a47 100644 --- a/lib/shared/helpers/storage_helper.dart +++ b/lib/shared/helpers/storage_helper.dart @@ -6,8 +6,6 @@ import 'package:hub/shared/helpers/sqlite_storage.dart'; class StorageHelper { - - static final StorageHelper _instance = StorageHelper._internal(); factory StorageHelper() => _instance; StorageHelper._internal(); diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index 4b1196c6..bfee18f3 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -210,16 +210,18 @@ class LocalizationService { enText: 'Error getting authentication credentials', ); await DialogUtil.error(context, errorMsg); + return; // await DialogUtil.error(context, errorMsg).whenComplete(() async => await AuthenticationService.signOut(context)); } - else if (isAuthenticated && !isDevLinked) { + if (!isDevLinked) { errorMsg = FFLocalizations.of(context).getVariableText( ptText: 'Não foi possível vincular o dispositivo, tente novamente.', enText: 'Unable to link device, try again', ); await DialogUtil.warning(context, errorMsg); + return; } - else if (isAuthenticated && isDevLinked) await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context)); + await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context)); }