From 6dd8f5a5152ca8be4334f53f60d89db1a3efd2e6 Mon Sep 17 00:00:00 2001 From: Keshav Priyadarshi Date: Thu, 3 Nov 2022 02:03:47 +0530 Subject: [PATCH] prepare 2.0.1 release Signed-off-by: Keshav Priyadarshi --- android/app/src/main/AndroidManifest.xml | 4 +- .../metadata/android/en-US/changelogs/6.txt | 1 + .../android/en-US/full_description.txt | 22 +++++++---- lib/data/preference_and_config.dart | 10 +++++ lib/main.dart | 18 +++++++++ lib/views/settings/backup_setting.dart | 39 ++++++++++--------- pubspec.yaml | 2 +- 7 files changed, 66 insertions(+), 30 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/6.txt diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 1d78b09..166a20f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionCode="6" + android:versionName="2.0.1" > _preferences = await SharedPreferences.getInstance(); @@ -38,6 +39,13 @@ class PreferencesStorage { static String getPassPhraseHash() => _preferences?.getString(_keyPassPhraseHash) ?? ''; +// appVersionCode controls the one time code excution on version change + static int getAppVersionCode() => + _preferences?.getInt(_keyAppVersionCode) ?? 1; + + static Future setAppVersionCodeToCurrent() async => await _preferences + ?.setInt(_keyAppVersionCode, SafeNotesConfig.appVersionCode); + static int getColorfulNotesColorIndex() => _preferences?.getInt(_keyColorfulNotesColorIndex) ?? 0; @@ -190,6 +198,8 @@ class ImportPassPhraseHandler { } class SafeNotesConfig { + static String appVersion = '2.0.1'; + static int appVersionCode = 6; static String appName = 'Safe Notes'; static String appSlogan = 'Encrypted note manager!'; static String firstLoginPageName = 'Set Passphrase'; diff --git a/lib/main.dart b/lib/main.dart index 77ab99f..d08980c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,6 +9,7 @@ import 'package:flutter/services.dart'; // Package imports: import 'package:flutter_windowmanager/flutter_windowmanager.dart'; import 'package:local_session_timeout/local_session_timeout.dart'; +import 'package:safenotes/views/settings/backup_setting.dart'; import 'package:workmanager/workmanager.dart'; // Project imports: @@ -35,6 +36,9 @@ Future main() async { await PreferencesStorage.init(); if (Platform.isAndroid && PreferencesStorage.getIsFlagSecure()) await FlutterWindowManager.addFlags(FlutterWindowManager.FLAG_SECURE); + + onAppUpdate(); + runApp(SafeNotesApp()); } @@ -147,3 +151,17 @@ void callbackDispatcher() { return Future.value(true); }); } + +// run once every update +void onAppUpdate() async { + if (PreferencesStorage.getAppVersionCode() != + SafeNotesConfig.appVersionCode) { + // Re-register the background update + var backupDestination = await PreferencesStorage.getBackupDestination(); + if (PreferencesStorage.getIsBackupOn() && backupDestination.isNotEmpty) + backupRegister(); + + // insure onAppUpdate is run once each update + PreferencesStorage.setAppVersionCodeToCurrent(); + } +} diff --git a/lib/views/settings/backup_setting.dart b/lib/views/settings/backup_setting.dart index 7f9e714..7975858 100644 --- a/lib/views/settings/backup_setting.dart +++ b/lib/views/settings/backup_setting.dart @@ -269,25 +269,6 @@ class _BackupSettingState extends State { } } - void backupRegister() { - Workmanager().cancelByTag('com.trisven.safenotes.dailybackup'); - - Workmanager().registerPeriodicTask( - "safenotes-task", - "dailyBackup", - tag: 'com.trisven.safenotes.dailybackup', - frequency: Duration(hours: 15), - initialDelay: Duration(seconds: 1), - constraints: Constraints( - networkType: NetworkType.not_required, - requiresCharging: false, - requiresBatteryNotLow: false, - //requiresDeviceIdle: false, - requiresStorageNotLow: false, - ), - ); - } - Widget _buttonText(String text, double fontSize) { return Text( text, @@ -299,3 +280,23 @@ class _BackupSettingState extends State { ); } } + +void backupRegister() { + Workmanager().cancelByTag('com.trisven.safenotes.dailybackup'); + + Workmanager().registerPeriodicTask( + "safenotes-task", + "dailyBackup", + existingWorkPolicy: ExistingWorkPolicy.replace, + tag: 'com.trisven.safenotes.dailybackup', + frequency: Duration(hours: 15), + initialDelay: Duration(seconds: 1), + constraints: Constraints( + networkType: NetworkType.not_required, + requiresCharging: false, + requiresBatteryNotLow: false, + //requiresDeviceIdle: false, + requiresStorageNotLow: false, + ), + ); +} diff --git a/pubspec.yaml b/pubspec.yaml index 752e48e..7d8ac73 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.0.0+5 +version: 2.0.1+6 environment: sdk: ">=2.12.0 <3.0.0"