From a401ff32d9144508bff507a6f4fa02edc7346c52 Mon Sep 17 00:00:00 2001 From: Kima Date: Mon, 4 Sep 2023 20:17:38 +0200 Subject: [PATCH 1/4] something --- .vscode/launch.json | 29 ++++++++++++------- filcnaplo/ios/Flutter/Generated 2.xcconfig | 15 ---------- filcnaplo/ios/Flutter/Generated 3.xcconfig | 15 ---------- filcnaplo/ios/Flutter/Generated 4.xcconfig | 15 ---------- filcnaplo/ios/Flutter/Generated 5.xcconfig | 14 --------- .../Flutter/flutter_export_environment 2.sh | 14 --------- .../Flutter/flutter_export_environment 3.sh | 13 --------- .../Flutter/flutter_export_environment 5.sh | 13 --------- 8 files changed, 18 insertions(+), 110 deletions(-) delete mode 100644 filcnaplo/ios/Flutter/Generated 2.xcconfig delete mode 100644 filcnaplo/ios/Flutter/Generated 3.xcconfig delete mode 100644 filcnaplo/ios/Flutter/Generated 4.xcconfig delete mode 100644 filcnaplo/ios/Flutter/Generated 5.xcconfig delete mode 100755 filcnaplo/ios/Flutter/flutter_export_environment 2.sh delete mode 100755 filcnaplo/ios/Flutter/flutter_export_environment 3.sh delete mode 100755 filcnaplo/ios/Flutter/flutter_export_environment 5.sh diff --git a/.vscode/launch.json b/.vscode/launch.json index 40d57a6..3c003e4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,17 +10,16 @@ "--dart-define=APPVER=$(cat pubspec.yaml | grep version: | cut -d' ' -f2 | cut -d+ -f1)" ] }, - { - "name": "filcnaplo release", - "cwd": "filcnaplo release", - "request": "launch", - "type": "dart", - "flutterMode": "release", - "program": "lib/main.dart", - "toolArgs": [ - "--dart-define=APPVER=$(cat pubspec.yaml | grep version: | cut -d' ' -f2 | cut -d+ -f1)" - ] - }, + // { + // "name": "filcnaplo release", + // "cwd": "filcnaplo release", + // "request": "launch", + // "type": "dart", + // "program": "lib/main.dart", + // "toolArgs": [ + // "--dart-define=APPVER=$(cat pubspec.yaml | grep version: | cut -d' ' -f2 | cut -d+ -f1)" + // ] + // }, { "name": "Flutter", "program": "lib/main.dart", @@ -28,6 +27,14 @@ "request": "launch", "type": "dart", "flutterMode": "debug" + }, + { + "name": "Flutter (release)", + "program": "lib/main.dart", + "cwd": "filcnaplo", + "request": "launch", + "type": "dart", + "flutterMode": "release" } ] } \ No newline at end of file diff --git a/filcnaplo/ios/Flutter/Generated 2.xcconfig b/filcnaplo/ios/Flutter/Generated 2.xcconfig deleted file mode 100644 index f54bc25..0000000 --- a/filcnaplo/ios/Flutter/Generated 2.xcconfig +++ /dev/null @@ -1,15 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/kima/development/flutter -FLUTTER_APPLICATION_PATH=/Users/kima/Documents/refilc/app/naplo/filcnaplo -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_TARGET=/Users/kima/Documents/refilc/app/naplo/filcnaplo/lib/main.dart -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=3.5.1 -FLUTTER_BUILD_NUMBER=197 -EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 -EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 -DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC9iNGZiMTEyMTRkZDJkZGE2Y2UwMTJkZDk4ZWE0OThlOWU4YjkxMjYyLw== -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=true -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=/Users/kima/Documents/refilc/app/naplo/filcnaplo/.dart_tool/package_config.json diff --git a/filcnaplo/ios/Flutter/Generated 3.xcconfig b/filcnaplo/ios/Flutter/Generated 3.xcconfig deleted file mode 100644 index e1e5847..0000000 --- a/filcnaplo/ios/Flutter/Generated 3.xcconfig +++ /dev/null @@ -1,15 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/kima/development/flutter -FLUTTER_APPLICATION_PATH=/Users/kima/Documents/refilc/app/naplo/filcnaplo -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_TARGET=/Users/kima/Documents/refilc/app/naplo/filcnaplo/lib/main.dart -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=4.1.0 -FLUTTER_BUILD_NUMBER=213 -EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 -EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 -DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC8yYTM0MDFjOWJiYjVhOWE5YWVjNzRkNGY3MzVkMThhOWRkM2ViZjJkLw== -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=true -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=/Users/kima/Documents/refilc/app/naplo/filcnaplo/.dart_tool/package_config.json diff --git a/filcnaplo/ios/Flutter/Generated 4.xcconfig b/filcnaplo/ios/Flutter/Generated 4.xcconfig deleted file mode 100644 index 394c5b3..0000000 --- a/filcnaplo/ios/Flutter/Generated 4.xcconfig +++ /dev/null @@ -1,15 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/kima/src/flutter -FLUTTER_APPLICATION_PATH=/Users/kima/Documents/refilc/app/naplo/filcnaplo -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_TARGET=/Users/kima/Documents/refilc/app/naplo/filcnaplo/lib/main.dart -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=4.1.1 -FLUTTER_BUILD_NUMBER=216 -EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 -EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 -DART_DEFINES=QVBQVkVSPTQuMS4x,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC9jZGJlZGE3ODhhMjkzZmEyOTY2NWRjM2ZhM2Q2ZTYzYmQyMjFjYjBkLw== -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=true -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=/Users/kima/Documents/refilc/app/naplo/filcnaplo/.dart_tool/package_config.json diff --git a/filcnaplo/ios/Flutter/Generated 5.xcconfig b/filcnaplo/ios/Flutter/Generated 5.xcconfig deleted file mode 100644 index 194436b..0000000 --- a/filcnaplo/ios/Flutter/Generated 5.xcconfig +++ /dev/null @@ -1,14 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/kima/src/flutter -FLUTTER_APPLICATION_PATH=/Users/kima/Documents/refilc/app/naplo/filcnaplo -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_TARGET=lib/main.dart -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=4.2.0 -FLUTTER_BUILD_NUMBER=220 -EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 -EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=true -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/filcnaplo/ios/Flutter/flutter_export_environment 2.sh b/filcnaplo/ios/Flutter/flutter_export_environment 2.sh deleted file mode 100755 index 77cf62f..0000000 --- a/filcnaplo/ios/Flutter/flutter_export_environment 2.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/kima/development/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/kima/Documents/refilc/app/naplo/filcnaplo" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=/Users/kima/Documents/refilc/app/naplo/filcnaplo/lib/main.dart" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=4.1.0" -export "FLUTTER_BUILD_NUMBER=213" -export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC8yYTM0MDFjOWJiYjVhOWE5YWVjNzRkNGY3MzVkMThhOWRkM2ViZjJkLw==" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=true" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=/Users/kima/Documents/refilc/app/naplo/filcnaplo/.dart_tool/package_config.json" diff --git a/filcnaplo/ios/Flutter/flutter_export_environment 3.sh b/filcnaplo/ios/Flutter/flutter_export_environment 3.sh deleted file mode 100755 index 276363d..0000000 --- a/filcnaplo/ios/Flutter/flutter_export_environment 3.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/kima/src/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/kima/Documents/refilc/app/naplo/filcnaplo" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=lib/main.dart" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=4.2.0" -export "FLUTTER_BUILD_NUMBER=220" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=true" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/filcnaplo/ios/Flutter/flutter_export_environment 5.sh b/filcnaplo/ios/Flutter/flutter_export_environment 5.sh deleted file mode 100755 index 276363d..0000000 --- a/filcnaplo/ios/Flutter/flutter_export_environment 5.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/kima/src/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/kima/Documents/refilc/app/naplo/filcnaplo" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=lib/main.dart" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=4.2.0" -export "FLUTTER_BUILD_NUMBER=220" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=true" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" From 939e4f4d48184ef290ae219160cbe81e33f6ad25 Mon Sep 17 00:00:00 2001 From: hihihaha Date: Mon, 4 Sep 2023 21:31:50 +0200 Subject: [PATCH 2/4] widget fix --- .../widget_timetable/WidgetTimetable.java | 87 +++++++++---------- .../WidgetTimetableDataProvider.java | 4 +- 2 files changed, 44 insertions(+), 47 deletions(-) diff --git a/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetable.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetable.java index 80413c3..b433ec7 100644 --- a/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetable.java +++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetable.java @@ -26,6 +26,11 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Locale; +import java.util.Map; +import java.util.HashMap; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import hu.refilc.naplo.database.DBManager; import hu.refilc.naplo.MainActivity; @@ -247,71 +252,61 @@ public class WidgetTimetable extends HomeWidgetProvider { } public static List genJsonDays(Context context) { - List gen_days = new ArrayList<>(); + List genDays = new ArrayList<>(); + Map dayMap = new HashMap<>(); DBManager dbManager = new DBManager(context.getApplicationContext()); + try { dbManager.open(); Cursor ct = dbManager.fetchTimetable(); - dbManager.close(); - if(ct.getCount() == 0) { - return gen_days; + if (ct.getCount() == 0) { + return genDays; } - JSONObject fecthtt = new JSONObject(ct.getString(0)); + JSONObject fetchedTimetable = new JSONObject(ct.getString(0)); + String currentWeek = String.valueOf(Week.current().id()); + JSONArray week = fetchedTimetable.getJSONArray(currentWeek); - JSONArray dayArray = new JSONArray(); - String currday = ""; - - String currweek = String.valueOf(Week.current().id()); - - JSONArray week = fecthtt.getJSONArray(currweek); - - for (int i=0; i < week.length(); i++) - { + // Organize lessons into dates + for (int i = 0; i < week.length(); i++) { try { - if(i == 0) currday = week.getJSONObject(0).getString("Datum"); - JSONObject oraObj = week.getJSONObject(i); - - if(!currday.equals(oraObj.getString("Datum"))) { - gen_days.add(dayArray); - currday = week.getJSONObject(i).getString("Datum"); - dayArray = new JSONArray(); - } - - dayArray.put(oraObj); - if(i == week.length() - 1) { - gen_days.add(dayArray); - } - } catch (Exception e) { + JSONObject entry = week.getJSONObject(i); + String date = entry.getString("Datum"); + dayMap.computeIfAbsent(date, k -> new JSONArray()).put(entry); + } catch (JSONException e) { e.printStackTrace(); } } + + genDays.addAll(dayMap.values()); + + // Sort the 'genDays' list of JSON based on the start time of the first entry + genDays.sort((day1, day2) -> { + try { + // Extract the start time of the first entry in each day's JSON + String startTime1 = day1.getJSONObject(0).getString("KezdetIdopont"); + String startTime2 = day2.getJSONObject(0).getString("KezdetIdopont"); + // Compare the start times and return the result for sorting + return startTime1.compareTo(startTime2); + } catch (JSONException e) { + e.printStackTrace(); + return 0; + } + }); + } catch (Exception e) { e.printStackTrace(); + } finally { + dbManager.close(); } - Collections.sort(gen_days, new Comparator() { - - public int compare(JSONArray a, JSONArray b) { - long valA = 0; - long valB = 0; - - try { - valA = (long) new DateTime( a.getJSONObject(0).getString("Datum")).getMillis(); - valB = (long) new DateTime( b.getJSONObject(0).getString("Datum")).getMillis(); - } - catch (JSONException ignored) { - } - - return (int) (valA - valB); - } - }); - - return gen_days; + return genDays; } + + public static String zeroPad(int value, int padding){ StringBuilder b = new StringBuilder(); b.append(value); diff --git a/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableDataProvider.java b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableDataProvider.java index 9ce41dd..55eaa98 100644 --- a/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableDataProvider.java +++ b/filcnaplo/android/app/src/main/java/hu/refilc/naplo/widget_timetable/WidgetTimetableDataProvider.java @@ -335,10 +335,12 @@ public class WidgetTimetableDataProvider implements RemoteViewsService.RemoteVie public Lesson jsonToLesson(JSONObject json) { try { + String name = json.getString("Nev"); + name = name.substring(0, 1).toUpperCase() + name.substring(1); // Capitalize name return new Lesson( json.getJSONObject("Allapot").getString("Nev"), !json.getString("Oraszam").equals("null") ? json.getString("Oraszam") : "+", - json.getString("Nev"), + name, json.getString("Tema"), json.getString("TeremNeve"), new DateTime(json.getString("KezdetIdopont")).getMillis(), From 8feea02f68b8a15d941f06f98c8032d8f05a10e7 Mon Sep 17 00:00:00 2001 From: Kima Date: Mon, 4 Sep 2023 21:45:11 +0200 Subject: [PATCH 3/4] added api endpoint and auto update fix --- .../Flutter/flutter_export_environment 2.sh | 13 ++++++++ filcnaplo/lib/api/login.dart | 30 +++++++++---------- filcnaplo/lib/helpers/update_helper.dart | 15 ++++++---- filcnaplo/pubspec.yaml | 2 +- filcnaplo_kreta_api/lib/client/api.dart | 7 +++++ .../lib/providers/homework_provider.dart | 12 ++++++-- .../common/widgets/update/updates_view.dart | 29 +++++++++++++----- 7 files changed, 77 insertions(+), 31 deletions(-) create mode 100755 filcnaplo/ios/Flutter/flutter_export_environment 2.sh diff --git a/filcnaplo/ios/Flutter/flutter_export_environment 2.sh b/filcnaplo/ios/Flutter/flutter_export_environment 2.sh new file mode 100755 index 0000000..276363d --- /dev/null +++ b/filcnaplo/ios/Flutter/flutter_export_environment 2.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/kima/src/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/kima/Documents/refilc/app/naplo/filcnaplo" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=4.2.0" +export "FLUTTER_BUILD_NUMBER=220" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/filcnaplo/lib/api/login.dart b/filcnaplo/lib/api/login.dart index 961eece..4afc7ce 100644 --- a/filcnaplo/lib/api/login.dart +++ b/filcnaplo/lib/api/login.dart @@ -101,21 +101,21 @@ Future loginAPI({ Provider.of(context, listen: false).setUser(user.id); // Get user data - // try { - await Future.wait([ - Provider.of(context, listen: false).fetch(), - Provider.of(context, listen: false) - .fetch(week: Week.current()), - Provider.of(context, listen: false).fetch(), - Provider.of(context, listen: false).fetch(), - Provider.of(context, listen: false).fetchAll(), - Provider.of(context, listen: false).fetch(), - Provider.of(context, listen: false).fetch(), - Provider.of(context, listen: false).fetch(), - ]); - // } catch (error) { - // print("WARNING: failed to fetch user data: $error"); - // } + try { + await Future.wait([ + Provider.of(context, listen: false).fetch(), + Provider.of(context, listen: false) + .fetch(week: Week.current()), + Provider.of(context, listen: false).fetch(), + Provider.of(context, listen: false).fetch(), + Provider.of(context, listen: false).fetchAll(), + Provider.of(context, listen: false).fetch(), + Provider.of(context, listen: false).fetch(), + Provider.of(context, listen: false).fetch(), + ]); + } catch (error) { + print("WARNING: failed to fetch user data: $error"); + } if (onSuccess != null) onSuccess(); diff --git a/filcnaplo/lib/helpers/update_helper.dart b/filcnaplo/lib/helpers/update_helper.dart index 5aec576..52be719 100644 --- a/filcnaplo/lib/helpers/update_helper.dart +++ b/filcnaplo/lib/helpers/update_helper.dart @@ -25,18 +25,23 @@ extension UpdateHelper on Release { if (!await apk.exists()) { updateCallback(-1, UpdateState.downloading); - var bytes = await download(updateCallback: updateCallback); - if (!await StorageHelper.write(apk.path, bytes)) { - throw "failed to write apk: permission denied"; + var storagePerms = await Permission.storage.request().isGranted; + if (storagePerms) { + var bytes = await download(updateCallback: updateCallback); + if (!await StorageHelper.write(apk.path, bytes)) { + throw "failed to write apk: permission denied"; + } + } else { + throw storagePerms; } } updateCallback(-1, UpdateState.installing); - var permStatus = + var installPerms = (await Permission.manageExternalStorage.request().isGranted && await Permission.requestInstallPackages.request().isGranted); - if (permStatus) { + if (installPerms) { var result = await OpenFile.open(apk.path); if (result.type != ResultType.done) { diff --git a/filcnaplo/pubspec.yaml b/filcnaplo/pubspec.yaml index 3fa9e11..5ee5c56 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://refilc.hu publish_to: "none" -version: 4.2.1+221 +version: 4.2.0+220 environment: sdk: ">=2.17.0 <3.0.0" diff --git a/filcnaplo_kreta_api/lib/client/api.dart b/filcnaplo_kreta_api/lib/client/api.dart index cb8674b..4060961 100644 --- a/filcnaplo_kreta_api/lib/client/api.dart +++ b/filcnaplo_kreta_api/lib/client/api.dart @@ -24,6 +24,11 @@ class KretaAPI { KretaApiEndpoints.groupAverages + "?oktatasiNevelesiFeladatUid=" + uid; + static String averages(String iss, String uid) => + BaseKreta.kreta(iss) + + KretaApiEndpoints.averages + + "?oktatasiNevelesiFeladatUid=" + + uid; static String timetable(String iss, {DateTime? start, DateTime? end}) => BaseKreta.kreta(iss) + KretaApiEndpoints.timetable + @@ -90,6 +95,8 @@ class KretaApiEndpoints { static const groups = "/ellenorzo/V3/Sajat/OsztalyCsoportok"; static const groupAverages = "/ellenorzo/V3/Sajat/Ertekelesek/Atlagok/OsztalyAtlagok"; + static const averages = + "/ellenorzo/V3/Sajat/Ertekelesek/Atlagok/TantargyiAtlagok"; static const timetable = "/ellenorzo/V3/Sajat/OrarendElemek"; static const exams = "/ellenorzo/V3/Sajat/BejelentettSzamonkeresek"; static const homework = "/ellenorzo/V3/Sajat/HaziFeladatok"; diff --git a/filcnaplo_kreta_api/lib/providers/homework_provider.dart b/filcnaplo_kreta_api/lib/providers/homework_provider.dart index 3a20e1f..58c697b 100644 --- a/filcnaplo_kreta_api/lib/providers/homework_provider.dart +++ b/filcnaplo_kreta_api/lib/providers/homework_provider.dart @@ -73,8 +73,16 @@ class HomeworkProvider with ChangeNotifier { if (user == null) throw "Cannot fetch Homework for User null"; String iss = user.instituteCode; - List? homeworkJson = await Provider.of(_context, listen: false) - .getAPI(KretaAPI.homework(iss, start: from)); + + List? homeworkJson = []; + + try { + homeworkJson = await Provider.of(_context, listen: false) + .getAPI(KretaAPI.homework(iss, start: from)); + } catch (e) { + // error fetcing homework (unknown error) + } + if (homeworkJson == null) throw "Cannot fetch Homework for User ${user.id}"; List homework = []; diff --git a/filcnaplo_mobile_ui/lib/common/widgets/update/updates_view.dart b/filcnaplo_mobile_ui/lib/common/widgets/update/updates_view.dart index 07386a1..7463ce5 100755 --- a/filcnaplo_mobile_ui/lib/common/widgets/update/updates_view.dart +++ b/filcnaplo_mobile_ui/lib/common/widgets/update/updates_view.dart @@ -18,7 +18,8 @@ class UpdateView extends StatefulWidget { final Release release; - static void show(Release release, {required BuildContext context}) => showBottomCard(context: context, child: UpdateView(release)); + static void show(Release release, {required BuildContext context}) => + showBottomCard(context: context, child: UpdateView(release)); @override _UpdateViewState createState() => _UpdateViewState(); @@ -45,7 +46,8 @@ class _UpdateViewState extends State { children: [ Text( "new_update".i18n, - style: const TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0), + style: const TextStyle( + fontWeight: FontWeight.w700, fontSize: 18.0), ), Text( "${widget.release.version}", @@ -75,7 +77,7 @@ class _UpdateViewState extends State { borderRadius: BorderRadius.circular(12.0), ), child: SizedBox( - height: 125.0, + height: 200.0, child: Markdown( padding: const EdgeInsets.symmetric(horizontal: 12.0), physics: const BouncingScrollPhysics(), @@ -91,21 +93,30 @@ class _UpdateViewState extends State { child: Row( mainAxisSize: MainAxisSize.min, children: [ - if (state == UpdateState.downloading || state == UpdateState.preparing) + if (state == UpdateState.downloading || + state == UpdateState.preparing) Container( height: 18.0, width: 18.0, margin: const EdgeInsets.only(right: 8.0), child: CircularProgressIndicator( value: progress > 0.05 ? progress : null, - color: ColorUtils.foregroundColor(AppColors.of(context).filc), + color: ColorUtils.foregroundColor( + AppColors.of(context).filc), ), ), - Text(["download".i18n, "downloading".i18n, "downloading".i18n, "installing".i18n][state.index].toUpperCase()), + Text([ + "download".i18n, + "downloading".i18n, + "downloading".i18n, + "installing".i18n + ][state.index] + .toUpperCase()), ], ), backgroundColor: AppColors.of(context).filc, - onPressed: state == UpdateState.none ? () => downloadPrecheck() : null, + onPressed: + state == UpdateState.none ? () => downloadPrecheck() : null, ), ), ], @@ -113,7 +124,8 @@ class _UpdateViewState extends State { ); } - String fmtSize() => "${(widget.release.downloads.first.size / 1024 / 1024).toStringAsFixed(1)} MB"; + String fmtSize() => + "${(widget.release.downloads.first.size / 1024 / 1024).toStringAsFixed(1)} MB"; void downloadPrecheck() { final status = Provider.of(context, listen: false); @@ -157,6 +169,7 @@ class _UpdateViewState extends State { .then((_) => Navigator.of(context).maybePop()) .catchError((error, stackTrace) { if (mounted) { + Navigator.of(context).maybePop(); ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar( context: context, content: Text("error".i18n), From fceb4e050f2e3e52a28d3a9146f903654b9be063 Mon Sep 17 00:00:00 2001 From: Kima Date: Mon, 4 Sep 2023 23:13:54 +0200 Subject: [PATCH 4/4] FINALLY FIXED AUTO UPDATE --- filcnaplo/lib/helpers/storage_helper.dart | 3 ++- filcnaplo/lib/helpers/update_helper.dart | 11 +++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/filcnaplo/lib/helpers/storage_helper.dart b/filcnaplo/lib/helpers/storage_helper.dart index 7780611..349a3c4 100644 --- a/filcnaplo/lib/helpers/storage_helper.dart +++ b/filcnaplo/lib/helpers/storage_helper.dart @@ -9,7 +9,7 @@ import 'package:permission_handler/permission_handler.dart'; class StorageHelper { static Future write(String path, Uint8List data) async { try { - if (await Permission.storage.request().isGranted) { + if (await Permission.manageExternalStorage.request().isGranted) { await File(path).writeAsBytes(data); return true; } else { @@ -34,5 +34,6 @@ class StorageHelper { } return downloads; + // return (await getTemporaryDirectory()).path; } } diff --git a/filcnaplo/lib/helpers/update_helper.dart b/filcnaplo/lib/helpers/update_helper.dart index 52be719..0c33860 100644 --- a/filcnaplo/lib/helpers/update_helper.dart +++ b/filcnaplo/lib/helpers/update_helper.dart @@ -25,14 +25,9 @@ extension UpdateHelper on Release { if (!await apk.exists()) { updateCallback(-1, UpdateState.downloading); - var storagePerms = await Permission.storage.request().isGranted; - if (storagePerms) { - var bytes = await download(updateCallback: updateCallback); - if (!await StorageHelper.write(apk.path, bytes)) { - throw "failed to write apk: permission denied"; - } - } else { - throw storagePerms; + var bytes = await download(updateCallback: updateCallback); + if (!await StorageHelper.write(apk.path, bytes)) { + throw "failed to write apk: permission denied"; } }