From 6eb6a0cf169619fbe771ccf1c080434277026fd8 Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sun, 12 Sep 2021 18:32:43 +0200 Subject: [PATCH 01/11] kreten --- filcnaplo_kreta_api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filcnaplo_kreta_api b/filcnaplo_kreta_api index 8b3ec15..136f132 160000 --- a/filcnaplo_kreta_api +++ b/filcnaplo_kreta_api @@ -1 +1 @@ -Subproject commit 8b3ec15500b0fb686c75383704c393c524d00878 +Subproject commit 136f132edfc7d6b6c6caa6dead8aae6a7c79c7fc From afd004b980edbdb3b6d56f857fce75dcbf260089 Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sun, 12 Sep 2021 20:24:39 +0200 Subject: [PATCH 02/11] migrate users db --- filcnaplo/lib/api/login.dart | 2 + filcnaplo/lib/database/init.dart | 88 +++++++++++++++++++----------- filcnaplo/lib/database/struct.dart | 2 +- 3 files changed, 60 insertions(+), 32 deletions(-) diff --git a/filcnaplo/lib/api/login.dart b/filcnaplo/lib/api/login.dart index 9b8abb1..140b045 100644 --- a/filcnaplo/lib/api/login.dart +++ b/filcnaplo/lib/api/login.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:filcnaplo/utils/jwt.dart'; import 'package:filcnaplo_kreta_api/providers/absence_provider.dart'; import 'package:filcnaplo_kreta_api/providers/event_provider.dart'; diff --git a/filcnaplo/lib/database/init.dart b/filcnaplo/lib/database/init.dart index ea6a653..3d27729 100644 --- a/filcnaplo/lib/database/init.dart +++ b/filcnaplo/lib/database/init.dart @@ -9,7 +9,7 @@ Future initDB() async { var settingsDB = await createSettingsTable(db); // Create table Users - await db.execute("CREATE TABLE IF NOT EXISTS users (id TEXT NOT NULL, name TEXT, username TEXT, password TEXT, institute_code TEXT, student TEXT)"); + var usersDB = await createUsersTable(db); await db.execute("CREATE TABLE IF NOT EXISTS user_data (" "id TEXT NOT NULL, grades TEXT, timetable TEXT, exams TEXT, homework TEXT, messages TEXT, notes TEXT, events TEXT, absences TEXT)"); @@ -18,7 +18,9 @@ Future initDB() async { await db.insert("settings", SettingsProvider.defaultSettings().toMap()); } - await migrateDB(db, settingsDB.struct.keys); + // Migrate Databases + await migrateDB(db, "settings", settingsDB.struct.keys, SettingsProvider.defaultSettings().toMap(), createSettingsTable); + await migrateDB(db, "users", usersDB.struct.keys, {"role": 0}, createUsersTable); return db; } @@ -38,35 +40,59 @@ Future createSettingsTable(Database db) async { return settingsDB; } -Future migrateDB(Database db, Iterable keys) async { - var settings = (await db.query("settings"))[0]; +Future createUsersTable(Database db) async { + var usersDB = DatabaseStruct( + {"id": String, "name": String, "username": String, "password": String, "institute_code": String, "student": String, "role": String}); - bool migrationRequired = keys.any((key) => !settings.containsKey(key) || settings[key] == null); + // Create table Users + await db.execute("CREATE TABLE IF NOT EXISTS users ($usersDB)"); - if (migrationRequired) { - var defaultSettings = SettingsProvider.defaultSettings(); - var settingsCopy = Map.from(settings); - - // Delete settings - await db.execute("drop table settings"); - - // Fill missing columns - keys.forEach((key) { - if (!keys.contains(key)) { - print("debug: dropping $key"); - settingsCopy.remove(key); - } - - if (!settings.containsKey(key) || settings[key] == null) { - print("DEBUG: migrating $key"); - settingsCopy[key] = defaultSettings.toMap()[key]; - } - }); - - // Recreate settings - await createSettingsTable(db); - await db.insert("settings", settingsCopy); - - print("INFO: Database migrated"); - } + return usersDB; +} + +Future migrateDB( + Database db, + String table, + Iterable keys, + Map defaultValues, + Future Function(Database) create, +) async { + var originalRows = (await db.query(table)); + + if (originalRows.length == 0) { + await db.execute("drop table $table"); + await create(db); + return; + } + + await Future.forEach>(originalRows, (original) async { + bool migrationRequired = keys.any((key) => !original.containsKey(key) || original[key] == null); + + if (migrationRequired) { + print("INFO: Migrating $table"); + var copy = Map.from(original); + + // Delete table + await db.execute("drop table $table"); + + // Fill missing columns + keys.forEach((key) { + if (!keys.contains(key)) { + print("DEBUG: dropping $key"); + copy.remove(key); + } + + if (!original.containsKey(key) || original[key] == null) { + print("DEBUG: migrating $key"); + copy[key] = defaultValues[key]; + } + }); + + // Recreate table + await create(db); + await db.insert(table, copy); + + print("INFO: Database migrated"); + } + }); } diff --git a/filcnaplo/lib/database/struct.dart b/filcnaplo/lib/database/struct.dart index 50b3355..cec8e48 100644 --- a/filcnaplo/lib/database/struct.dart +++ b/filcnaplo/lib/database/struct.dart @@ -15,7 +15,7 @@ class DatabaseStruct { break; } - return "${name} ${typeName.toUpperCase()}"; + return "${name} ${typeName.toUpperCase()} ${name == 'id' ? 'NOT NULL' : ''}"; } @override From 26be20ac28f8287cf2c7f9462fe4ea813c6051be Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sun, 12 Sep 2021 20:25:22 +0200 Subject: [PATCH 03/11] version bump --- filcnaplo/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filcnaplo/pubspec.yaml b/filcnaplo/pubspec.yaml index 01bab3a..66de915 100644 --- a/filcnaplo/pubspec.yaml +++ b/filcnaplo/pubspec.yaml @@ -3,7 +3,7 @@ description: "Nem hivatalos e-napló alkalmazás az e-Kréta rendszerhez" homepage: https://filcnaplo.hu publish_to: "none" -version: 3.0.2+130 +version: 3.0.3+131 environment: sdk: ">=2.12.0 <3.0.0" From 56b6eb3d2b06423b150295adae03c425ed729f4e Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sat, 18 Sep 2021 11:17:41 +0200 Subject: [PATCH 04/11] haptics --- filcnaplo_mobile_ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filcnaplo_mobile_ui b/filcnaplo_mobile_ui index 6ba35d8..44cf50b 160000 --- a/filcnaplo_mobile_ui +++ b/filcnaplo_mobile_ui @@ -1 +1 @@ -Subproject commit 6ba35d8050c65100ab71cb84012f012323c7e035 +Subproject commit 44cf50bb21108421b77d7489407b03c43bd02a92 From ab952daa1069e9a7837b73f2f340395d9e28ec33 Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sat, 18 Sep 2021 11:57:01 +0200 Subject: [PATCH 05/11] vibration cleanup --- filcnaplo/ios/Podfile.lock | 6 ------ filcnaplo_mobile_ui | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/filcnaplo/ios/Podfile.lock b/filcnaplo/ios/Podfile.lock index f3433fb..e36f8f5 100644 --- a/filcnaplo/ios/Podfile.lock +++ b/filcnaplo/ios/Podfile.lock @@ -58,8 +58,6 @@ PODS: - SwiftyGif (5.4.0) - url_launcher (0.0.1): - Flutter - - vibration (1.7.4-nullsafety.0): - - Flutter DEPENDENCIES: - file_picker (from `.symlinks/plugins/file_picker/ios`) @@ -72,7 +70,6 @@ DEPENDENCIES: - share_plus (from `.symlinks/plugins/share_plus/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) - - vibration (from `.symlinks/plugins/vibration/ios`) SPEC REPOS: trunk: @@ -103,8 +100,6 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/sqflite/ios" url_launcher: :path: ".symlinks/plugins/url_launcher/ios" - vibration: - :path: ".symlinks/plugins/vibration/ios" SPEC CHECKSUMS: DKImagePickerController: b5eb7f7a388e4643264105d648d01f727110fc3d @@ -122,7 +117,6 @@ SPEC CHECKSUMS: sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 SwiftyGif: 5d4af95df24caf1c570dbbcb32a3b8a0763bc6d7 url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef - vibration: 1ec279c4a1a7a646627b54039d812334b3f1114a PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c diff --git a/filcnaplo_mobile_ui b/filcnaplo_mobile_ui index 44cf50b..e2c7a60 160000 --- a/filcnaplo_mobile_ui +++ b/filcnaplo_mobile_ui @@ -1 +1 @@ -Subproject commit 44cf50bb21108421b77d7489407b03c43bd02a92 +Subproject commit e2c7a603887b30070da248b771f28feb0bb3ae63 From 593292e86005b3ced24fa26dc654bd49cd300a6e Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sat, 18 Sep 2021 12:24:36 +0200 Subject: [PATCH 06/11] kreten --- filcnaplo_kreta_api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filcnaplo_kreta_api b/filcnaplo_kreta_api index 136f132..08d8022 160000 --- a/filcnaplo_kreta_api +++ b/filcnaplo_kreta_api @@ -1 +1 @@ -Subproject commit 136f132edfc7d6b6c6caa6dead8aae6a7c79c7fc +Subproject commit 08d802282c044be666f7b7ae55ae88b334ba515b From 3ceb40ddb8c4aea294e064f9f73fe9bebd380120 Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sat, 18 Sep 2021 12:24:38 +0200 Subject: [PATCH 07/11] mobile --- filcnaplo_mobile_ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filcnaplo_mobile_ui b/filcnaplo_mobile_ui index e2c7a60..29313fe 160000 --- a/filcnaplo_mobile_ui +++ b/filcnaplo_mobile_ui @@ -1 +1 @@ -Subproject commit e2c7a603887b30070da248b771f28feb0bb3ae63 +Subproject commit 29313fe1ee789f824eee394cf96263e02798f4bd From c6021e7a691504b7e6f3fb4c46fea5da7ebc833a Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sat, 18 Sep 2021 12:24:56 +0200 Subject: [PATCH 08/11] version bump --- filcnaplo/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filcnaplo/pubspec.yaml b/filcnaplo/pubspec.yaml index 66de915..82ae9a4 100644 --- a/filcnaplo/pubspec.yaml +++ b/filcnaplo/pubspec.yaml @@ -3,7 +3,7 @@ description: "Nem hivatalos e-napló alkalmazás az e-Kréta rendszerhez" homepage: https://filcnaplo.hu publish_to: "none" -version: 3.0.3+131 +version: 3.0.4+133 environment: sdk: ">=2.12.0 <3.0.0" From a46f6130cbd315d50109b561363e1afcb14569d5 Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sat, 18 Sep 2021 14:25:20 +0200 Subject: [PATCH 09/11] ios dist fix --- filcnaplo/ios/Runner/Info.plist | 2 ++ 1 file changed, 2 insertions(+) diff --git a/filcnaplo/ios/Runner/Info.plist b/filcnaplo/ios/Runner/Info.plist index b635367..561f546 100644 --- a/filcnaplo/ios/Runner/Info.plist +++ b/filcnaplo/ios/Runner/Info.plist @@ -50,5 +50,7 @@ NSPhotoLibraryUsageDescription The app requires the photo library to set a custom profile picture. + ITSAppUsesNonExemptEncryption + \ No newline at end of file From 68d92c446200ec1de9d8114950c49593e0ea0672 Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sat, 18 Sep 2021 14:27:44 +0200 Subject: [PATCH 10/11] changelog --- changelog.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog.md diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..dc5a61a --- /dev/null +++ b/changelog.md @@ -0,0 +1,3 @@ +- Haptikus visszajelzés +- Animációk +- Hibajavítások \ No newline at end of file From d5ba231fcca4dde24d4950d9c09375d60057996e Mon Sep 17 00:00:00 2001 From: unknown <55nknown@pm.me> Date: Sat, 18 Sep 2021 16:30:17 +0200 Subject: [PATCH 11/11] fix database migration --- filcnaplo/lib/database/init.dart | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/filcnaplo/lib/database/init.dart b/filcnaplo/lib/database/init.dart index 3d27729..3590cf1 100644 --- a/filcnaplo/lib/database/init.dart +++ b/filcnaplo/lib/database/init.dart @@ -57,7 +57,7 @@ Future migrateDB( Map defaultValues, Future Function(Database) create, ) async { - var originalRows = (await db.query(table)); + var originalRows = await db.query(table); if (originalRows.length == 0) { await db.execute("drop table $table"); @@ -65,6 +65,8 @@ Future migrateDB( return; } + List> migrated = []; + await Future.forEach>(originalRows, (original) async { bool migrationRequired = keys.any((key) => !original.containsKey(key) || original[key] == null); @@ -72,9 +74,6 @@ Future migrateDB( print("INFO: Migrating $table"); var copy = Map.from(original); - // Delete table - await db.execute("drop table $table"); - // Fill missing columns keys.forEach((key) { if (!keys.contains(key)) { @@ -88,11 +87,20 @@ Future migrateDB( } }); - // Recreate table - await create(db); - await db.insert(table, copy); - - print("INFO: Database migrated"); + migrated.add(copy); } }); + + if (migrated.length > 0) { + // Delete table + await db.execute("drop table $table"); + + // Recreate table + await create(db); + await Future.forEach(migrated, (Map copy) async { + await db.insert(table, copy); + }); + + print("INFO: Database migrated"); + } }