Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0a7ab20d9 | ||
|
|
59a9e0e236 | ||
|
|
e83202ba29 | ||
|
|
d4489dd9d4 | ||
|
|
debb4cac5b | ||
|
|
acbdf2aecb | ||
|
|
5d9ea4311a | ||
|
|
8aa24d7a32 | ||
|
|
9fbcef357e | ||
|
|
e9423a8535 | ||
|
|
2a7265256d | ||
|
|
d5ba231fcc | ||
|
|
903cbba69a |
@@ -1,3 +1,3 @@
|
|||||||
- Haptikus visszajelzés
|
- Anoním analitika
|
||||||
- Animációk
|
- Hibabejelentő funkció
|
||||||
- Hibajavítások
|
- Hibajavítások
|
||||||
BIN
filcnaplo/assets/fonts/SpaceMono/SpaceMono-Bold.ttf
Normal file
BIN
filcnaplo/assets/fonts/SpaceMono/SpaceMono-Bold.ttf
Normal file
Binary file not shown.
BIN
filcnaplo/assets/fonts/SpaceMono/SpaceMono-BoldItalic.ttf
Normal file
BIN
filcnaplo/assets/fonts/SpaceMono/SpaceMono-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
filcnaplo/assets/fonts/SpaceMono/SpaceMono-Italic.ttf
Normal file
BIN
filcnaplo/assets/fonts/SpaceMono/SpaceMono-Italic.ttf
Normal file
Binary file not shown.
BIN
filcnaplo/assets/fonts/SpaceMono/SpaceMono-Regular.ttf
Normal file
BIN
filcnaplo/assets/fonts/SpaceMono/SpaceMono-Regular.ttf
Normal file
Binary file not shown.
@@ -3,15 +3,22 @@ import 'dart:convert';
|
|||||||
import 'package:filcnaplo/models/config.dart';
|
import 'package:filcnaplo/models/config.dart';
|
||||||
import 'package:filcnaplo/models/news.dart';
|
import 'package:filcnaplo/models/news.dart';
|
||||||
import 'package:filcnaplo/models/release.dart';
|
import 'package:filcnaplo/models/release.dart';
|
||||||
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
import 'package:filcnaplo/models/supporter.dart';
|
import 'package:filcnaplo/models/supporter.dart';
|
||||||
import 'package:filcnaplo_kreta_api/models/school.dart';
|
import 'package:filcnaplo_kreta_api/models/school.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
class FilcAPI {
|
class FilcAPI {
|
||||||
|
// Public API
|
||||||
static const SCHOOL_LIST = "https://filcnaplo.hu/v2/school_list.json";
|
static const SCHOOL_LIST = "https://filcnaplo.hu/v2/school_list.json";
|
||||||
static const CONFIG = "https://filcnaplo.hu/v2/config.json";
|
|
||||||
static const NEWS = "https://filcnaplo.hu/v2/news.json";
|
static const NEWS = "https://filcnaplo.hu/v2/news.json";
|
||||||
static const SUPPORTERS = "https://filcnaplo.hu/v2/supporters.json";
|
static const SUPPORTERS = "https://filcnaplo.hu/v2/supporters.json";
|
||||||
|
|
||||||
|
// Private API
|
||||||
|
static const CONFIG = "https://api.filcnaplo.hu/config";
|
||||||
|
static const REPORT = "https://api.filcnaplo.hu/report";
|
||||||
|
|
||||||
|
// Updates
|
||||||
static const REPO = "filc/naplo";
|
static const REPO = "filc/naplo";
|
||||||
static const RELEASES = "https://api.github.com/repos/$REPO/releases";
|
static const RELEASES = "https://api.github.com/repos/$REPO/releases";
|
||||||
|
|
||||||
@@ -35,15 +42,22 @@ class FilcAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<Config?> getConfig() async {
|
static Future<Config?> getConfig(SettingsProvider settings) async {
|
||||||
|
Map<String, String> headers = {
|
||||||
|
"x-filc-id": settings.xFilcId,
|
||||||
|
"user-agent": settings.config.userAgent,
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
http.Response res = await http.get(Uri.parse(CONFIG));
|
http.Response res = await http.get(Uri.parse(CONFIG), headers: headers);
|
||||||
|
|
||||||
if (res.statusCode == 200) {
|
if (res.statusCode == 200) {
|
||||||
return Config.fromJson(jsonDecode(res.body));
|
return Config.fromJson(jsonDecode(res.body));
|
||||||
} else {
|
} else if (res.statusCode == 429) {
|
||||||
throw "HTTP ${res.statusCode}: ${res.body}";
|
res = await http.get(Uri.parse(CONFIG));
|
||||||
|
if (res.statusCode == 200) return Config.fromJson(jsonDecode(res.body));
|
||||||
}
|
}
|
||||||
|
throw "HTTP ${res.statusCode}: ${res.body}";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print("ERROR: FilcAPI.getConfig: $error");
|
print("ERROR: FilcAPI.getConfig: $error");
|
||||||
}
|
}
|
||||||
@@ -104,4 +118,35 @@ class FilcAPI {
|
|||||||
|
|
||||||
return Future.value(null);
|
return Future.value(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<void> sendReport(ErrorReport report) async {
|
||||||
|
try {
|
||||||
|
http.Response res = await http.post(Uri.parse(REPORT), body: {
|
||||||
|
"os": report.os,
|
||||||
|
"version": report.version,
|
||||||
|
"error": report.error,
|
||||||
|
"stack_trace": report.stack,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res.statusCode != 200) {
|
||||||
|
throw "HTTP ${res.statusCode}: ${res.body}";
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
print("ERROR: FilcAPI.sendReport: $error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ErrorReport {
|
||||||
|
String stack;
|
||||||
|
String os;
|
||||||
|
String version;
|
||||||
|
String error;
|
||||||
|
|
||||||
|
ErrorReport({
|
||||||
|
required this.stack,
|
||||||
|
required this.os,
|
||||||
|
required this.version,
|
||||||
|
required this.error,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:filcnaplo/utils/jwt.dart';
|
import 'package:filcnaplo/utils/jwt.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/absence_provider.dart';
|
import 'package:filcnaplo_kreta_api/providers/absence_provider.dart';
|
||||||
import 'package:filcnaplo_kreta_api/providers/event_provider.dart';
|
import 'package:filcnaplo_kreta_api/providers/event_provider.dart';
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class App extends StatelessWidget {
|
|||||||
setSystemChrome(context);
|
setSystemChrome(context);
|
||||||
|
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((_) {
|
WidgetsBinding.instance?.addPostFrameCallback((_) {
|
||||||
FilcAPI.getConfig().then((Config? config) {
|
FilcAPI.getConfig(settings).then((Config? config) {
|
||||||
settings.update(context, database: database, config: config ?? Config.fromJson({}));
|
settings.update(context, database: database, config: config ?? Config.fromJson({}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ Future<DatabaseStruct> createSettingsTable(Database db) async {
|
|||||||
"grade_color1": int, "grade_color2": int, "grade_color3": int, "grade_color4": int, "grade_color5": int, // grade colors
|
"grade_color1": int, "grade_color2": int, "grade_color3": int, "grade_color4": int, "grade_color5": int, // grade colors
|
||||||
"vibration_strength": int, "ab_weeks": int, "swap_ab_weeks": int,
|
"vibration_strength": int, "ab_weeks": int, "swap_ab_weeks": int,
|
||||||
"notifications": int, "notifications_bitfield": int, "notification_poll_interval": int, // notifications
|
"notifications": int, "notifications_bitfield": int, "notification_poll_interval": int, // notifications
|
||||||
|
"x_filc_id": String,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create table Settings
|
// Create table Settings
|
||||||
@@ -42,7 +43,7 @@ Future<DatabaseStruct> createSettingsTable(Database db) async {
|
|||||||
|
|
||||||
Future<DatabaseStruct> createUsersTable(Database db) async {
|
Future<DatabaseStruct> createUsersTable(Database db) async {
|
||||||
var usersDB = DatabaseStruct(
|
var usersDB = DatabaseStruct(
|
||||||
{"id": String, "name": String, "username": String, "password": String, "institute_code": String, "student": String, "role": String});
|
{"id": String, "name": String, "username": String, "password": String, "institute_code": String, "student": String, "role": int});
|
||||||
|
|
||||||
// Create table Users
|
// Create table Users
|
||||||
await db.execute("CREATE TABLE IF NOT EXISTS users ($usersDB)");
|
await db.execute("CREATE TABLE IF NOT EXISTS users ($usersDB)");
|
||||||
@@ -57,7 +58,7 @@ Future<void> migrateDB(
|
|||||||
Map<String, Object?> defaultValues,
|
Map<String, Object?> defaultValues,
|
||||||
Future<DatabaseStruct> Function(Database) create,
|
Future<DatabaseStruct> Function(Database) create,
|
||||||
) async {
|
) async {
|
||||||
var originalRows = (await db.query(table));
|
var originalRows = await db.query(table);
|
||||||
|
|
||||||
if (originalRows.length == 0) {
|
if (originalRows.length == 0) {
|
||||||
await db.execute("drop table $table");
|
await db.execute("drop table $table");
|
||||||
@@ -65,6 +66,8 @@ Future<void> migrateDB(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Map<String, dynamic>> migrated = [];
|
||||||
|
|
||||||
await Future.forEach<Map<String, Object?>>(originalRows, (original) async {
|
await Future.forEach<Map<String, Object?>>(originalRows, (original) async {
|
||||||
bool migrationRequired = keys.any((key) => !original.containsKey(key) || original[key] == null);
|
bool migrationRequired = keys.any((key) => !original.containsKey(key) || original[key] == null);
|
||||||
|
|
||||||
@@ -72,9 +75,6 @@ Future<void> migrateDB(
|
|||||||
print("INFO: Migrating $table");
|
print("INFO: Migrating $table");
|
||||||
var copy = Map<String, dynamic>.from(original);
|
var copy = Map<String, dynamic>.from(original);
|
||||||
|
|
||||||
// Delete table
|
|
||||||
await db.execute("drop table $table");
|
|
||||||
|
|
||||||
// Fill missing columns
|
// Fill missing columns
|
||||||
keys.forEach((key) {
|
keys.forEach((key) {
|
||||||
if (!keys.contains(key)) {
|
if (!keys.contains(key)) {
|
||||||
@@ -88,11 +88,20 @@ Future<void> migrateDB(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Recreate table
|
migrated.add(copy);
|
||||||
await create(db);
|
|
||||||
await db.insert(table, copy);
|
|
||||||
|
|
||||||
print("INFO: Database migrated");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (migrated.length > 0) {
|
||||||
|
// Delete table
|
||||||
|
await db.execute("drop table $table");
|
||||||
|
|
||||||
|
// Recreate table
|
||||||
|
await create(db);
|
||||||
|
await Future.forEach(migrated, (Map<String, dynamic> copy) async {
|
||||||
|
await db.insert(table, copy);
|
||||||
|
});
|
||||||
|
|
||||||
|
print("INFO: Database migrated");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ import 'package:filcnaplo/api/providers/user_provider.dart';
|
|||||||
import 'package:filcnaplo/api/providers/database_provider.dart';
|
import 'package:filcnaplo/api/providers/database_provider.dart';
|
||||||
import 'package:filcnaplo/database/init.dart';
|
import 'package:filcnaplo/database/init.dart';
|
||||||
import 'package:filcnaplo/models/settings.dart';
|
import 'package:filcnaplo/models/settings.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:filcnaplo/app.dart';
|
import 'package:filcnaplo/app.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:filcnaplo_mobile_ui/screens/error_screen.dart';
|
import 'package:filcnaplo_mobile_ui/screens/error_screen.dart';
|
||||||
|
import 'package:filcnaplo_mobile_ui/screens/error_report_screen.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
// Initalize
|
// Initalize
|
||||||
@@ -39,12 +41,24 @@ class Startup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool errorShown = false;
|
||||||
|
String lastException = '';
|
||||||
|
|
||||||
Widget errorBuilder(FlutterErrorDetails details) {
|
Widget errorBuilder(FlutterErrorDetails details) {
|
||||||
return Builder(builder: (context) {
|
return Builder(builder: (context) {
|
||||||
if (Navigator.of(context).canPop()) Navigator.pop(context);
|
if (Navigator.of(context).canPop()) Navigator.pop(context);
|
||||||
|
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((_) {
|
WidgetsBinding.instance?.addPostFrameCallback((_) {
|
||||||
Navigator.of(context, rootNavigator: true).push(MaterialPageRoute(builder: (ctx) => ErrorScreen(details)));
|
if (!errorShown && details.exceptionAsString() != lastException) {
|
||||||
|
errorShown = true;
|
||||||
|
lastException = details.exceptionAsString();
|
||||||
|
Navigator.of(context, rootNavigator: true).push(MaterialPageRoute(builder: (context) {
|
||||||
|
if (kReleaseMode)
|
||||||
|
return ErrorReportScreen(details);
|
||||||
|
else
|
||||||
|
return ErrorScreen(details);
|
||||||
|
})).then((_) => errorShown = false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return Container();
|
return Container();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:filcnaplo/theme.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
enum Pages { home, grades, timetable, messages, absences }
|
enum Pages { home, grades, timetable, messages, absences }
|
||||||
enum UpdateChannel { stable, beta, dev }
|
enum UpdateChannel { stable, beta, dev }
|
||||||
@@ -47,6 +48,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
bool _swapABweeks;
|
bool _swapABweeks;
|
||||||
UpdateChannel _updateChannel;
|
UpdateChannel _updateChannel;
|
||||||
Config _config;
|
Config _config;
|
||||||
|
String _xFilcId;
|
||||||
|
|
||||||
SettingsProvider({
|
SettingsProvider({
|
||||||
required String language,
|
required String language,
|
||||||
@@ -66,6 +68,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
required bool swapABweeks,
|
required bool swapABweeks,
|
||||||
required UpdateChannel updateChannel,
|
required UpdateChannel updateChannel,
|
||||||
required Config config,
|
required Config config,
|
||||||
|
required String xFilcId,
|
||||||
}) : _language = language,
|
}) : _language = language,
|
||||||
_startPage = startPage,
|
_startPage = startPage,
|
||||||
_rounding = rounding,
|
_rounding = rounding,
|
||||||
@@ -82,7 +85,8 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
_ABweeks = ABweeks,
|
_ABweeks = ABweeks,
|
||||||
_swapABweeks = swapABweeks,
|
_swapABweeks = swapABweeks,
|
||||||
_updateChannel = updateChannel,
|
_updateChannel = updateChannel,
|
||||||
_config = config {
|
_config = config,
|
||||||
|
_xFilcId = xFilcId {
|
||||||
PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
|
PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
|
||||||
_packageInfo = packageInfo;
|
_packageInfo = packageInfo;
|
||||||
});
|
});
|
||||||
@@ -113,6 +117,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
swapABweeks: map["swap_ab_weeks"] == 1 ? true : false,
|
swapABweeks: map["swap_ab_weeks"] == 1 ? true : false,
|
||||||
updateChannel: UpdateChannel.values[map["update_channel"]],
|
updateChannel: UpdateChannel.values[map["update_channel"]],
|
||||||
config: Config.fromJson(jsonDecode(map["config"] ?? "{}")),
|
config: Config.fromJson(jsonDecode(map["config"] ?? "{}")),
|
||||||
|
xFilcId: map["x_filc_id"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,6 +144,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
"swap_ab_weeks": _swapABweeks ? 1 : 0,
|
"swap_ab_weeks": _swapABweeks ? 1 : 0,
|
||||||
"notification_poll_interval": _notificationPollInterval,
|
"notification_poll_interval": _notificationPollInterval,
|
||||||
"config": jsonEncode(config.json),
|
"config": jsonEncode(config.json),
|
||||||
|
"x_filc_id": _xFilcId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +173,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
swapABweeks: false,
|
swapABweeks: false,
|
||||||
updateChannel: UpdateChannel.stable,
|
updateChannel: UpdateChannel.stable,
|
||||||
config: Config.fromJson({}),
|
config: Config.fromJson({}),
|
||||||
|
xFilcId: Uuid().v4(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,6 +196,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
UpdateChannel get updateChannel => _updateChannel;
|
UpdateChannel get updateChannel => _updateChannel;
|
||||||
PackageInfo? get packageInfo => _packageInfo;
|
PackageInfo? get packageInfo => _packageInfo;
|
||||||
Config get config => _config;
|
Config get config => _config;
|
||||||
|
String get xFilcId => _xFilcId;
|
||||||
|
|
||||||
Future<void> update(
|
Future<void> update(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
@@ -210,6 +218,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
bool? swapABweeks,
|
bool? swapABweeks,
|
||||||
UpdateChannel? updateChannel,
|
UpdateChannel? updateChannel,
|
||||||
Config? config,
|
Config? config,
|
||||||
|
String? xFilcId,
|
||||||
}) async {
|
}) async {
|
||||||
if (language != null && language != _language) _language = language;
|
if (language != null && language != _language) _language = language;
|
||||||
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
if (startPage != null && startPage != _startPage) _startPage = startPage;
|
||||||
@@ -229,6 +238,7 @@ class SettingsProvider extends ChangeNotifier {
|
|||||||
if (swapABweeks != null && swapABweeks != _swapABweeks) _swapABweeks = swapABweeks;
|
if (swapABweeks != null && swapABweeks != _swapABweeks) _swapABweeks = swapABweeks;
|
||||||
if (updateChannel != null && updateChannel != _updateChannel) _updateChannel = updateChannel;
|
if (updateChannel != null && updateChannel != _updateChannel) _updateChannel = updateChannel;
|
||||||
if (config != null && config != _config) _config = config;
|
if (config != null && config != _config) _config = config;
|
||||||
|
if (xFilcId != null && xFilcId != _xFilcId) _xFilcId = xFilcId;
|
||||||
|
|
||||||
if (database == null) database = Provider.of<DatabaseProvider>(context, listen: false);
|
if (database == null) database = Provider.of<DatabaseProvider>(context, listen: false);
|
||||||
await database.store.storeSettings(this);
|
await database.store.storeSettings(this);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ description: "Nem hivatalos e-napló alkalmazás az e-Kréta rendszerhez"
|
|||||||
homepage: https://filcnaplo.hu
|
homepage: https://filcnaplo.hu
|
||||||
publish_to: "none"
|
publish_to: "none"
|
||||||
|
|
||||||
version: 3.0.4+133
|
version: 3.0.5+135
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
@@ -101,6 +101,17 @@ flutter:
|
|||||||
weight: 100
|
weight: 100
|
||||||
style: italic
|
style: italic
|
||||||
|
|
||||||
|
- family: SpaceMono
|
||||||
|
fonts:
|
||||||
|
- asset: assets/fonts/SpaceMono/SpaceMono-Regular.ttf
|
||||||
|
- asset: assets/fonts/SpaceMono/SpaceMono-Bold.ttf
|
||||||
|
weight: 700
|
||||||
|
- asset: assets/fonts/SpaceMono/SpaceMono-Italic.ttf
|
||||||
|
style: italic
|
||||||
|
- asset: assets/fonts/SpaceMono/SpaceMono-BoldItalic.ttf
|
||||||
|
weight: 700
|
||||||
|
style: italic
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
image_path: "assets/icons/ic_launcher.png"
|
image_path: "assets/icons/ic_launcher.png"
|
||||||
adaptive_icon_background: "#1F5B50"
|
adaptive_icon_background: "#1F5B50"
|
||||||
|
|||||||
Submodule filcnaplo_kreta_api updated: 08d802282c...d0392db10a
Submodule filcnaplo_mobile_ui updated: 29313fe1ee...fc84baee2f
Reference in New Issue
Block a user