compile time version definition

This commit is contained in:
unknown 2022-02-01 18:33:13 +01:00
parent 8673a9e42a
commit 0fca636311
No known key found for this signature in database
GPG Key ID: 1D070E0B09CFB257
14 changed files with 60 additions and 31 deletions

4
.vscode/launch.json vendored
View File

@ -7,8 +7,8 @@
{
"name": "filcnaplo",
"cwd": "filcnaplo",
"request": "launch",
"type": "dart"
"request": "attach",
"type": "dart",
}
]
}

View File

@ -1,4 +1,6 @@
- Órarendben dolgozatok javítása
- Kilógó félév jelző javítása a grafikonon
- Dicséretes jegyek jelzése
- Üzenet & Szellem jegy animációk
- Design javítások
- Kisebb hibajavítások
- Kisebb hibajavítások

View File

@ -8,7 +8,6 @@
.buildlog/
.history
.svn/
build.sh
# IntelliJ related
*.iml

19
filcnaplo/build.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/fish
# With build number
function get_version_bn
cat pubspec.yaml | grep version: | cut -d' ' -f2
end
function get_version
cat pubspec.yaml | grep version: | cut -d' ' -f2 | cut -d+ -f1
end
if test -e /mnt/enc/keys/filc3.properties
set -x ANDROID_SIGNING /mnt/enc/keys/filc3.properties
else
flutter build apk --dart-define=APPVER=(get_version)
cp -v "build/app/outputs/flutter-apk/app-release.apk" ~/"Desktop/hu.filc.naplo_"(get_version_bn).apk
notify-send "Flutter" "Apk build done."

View File

@ -1,6 +1,7 @@
// ignore_for_file: avoid_print
import 'dart:convert';
import 'dart:developer';
import 'package:filcnaplo/models/config.dart';
import 'package:filcnaplo/models/news.dart';
@ -45,14 +46,20 @@ class FilcAPI {
} catch (error) {
print("ERROR: FilcAPI.getSchools: $error");
}
return null;
}
static Future<Config?> getConfig(SettingsProvider settings) async {
final userAgent = SettingsProvider.defaultSettings().config.userAgent;
Map<String, String> headers = {
"x-filc-id": settings.xFilcId,
"user-agent": SettingsProvider.defaultSettings().config.userAgent,
"user-agent": userAgent,
};
log("[CONFIG] x-filc-id: \"${settings.xFilcId}\"");
log("[CONFIG] user-agent: \"$userAgent\"");
try {
http.Response res = await http.get(Uri.parse(config), headers: headers);
@ -66,6 +73,7 @@ class FilcAPI {
} catch (error) {
print("ERROR: FilcAPI.getConfig: $error");
}
return null;
}
static Future<List<News>?> getNews() async {
@ -80,6 +88,7 @@ class FilcAPI {
} catch (error) {
print("ERROR: FilcAPI.getNews: $error");
}
return null;
}
static Future<Supporters?> getSupporters() async {
@ -94,6 +103,7 @@ class FilcAPI {
} catch (error) {
print("ERROR: FilcAPI.getSupporters: $error");
}
return null;
}
static Future<List<Release>?> getReleases() async {
@ -108,6 +118,7 @@ class FilcAPI {
} catch (error) {
print("ERROR: FilcAPI.getReleases: $error");
}
return null;
}
static Future<http.StreamedResponse?> downloadRelease(Release release) {

View File

@ -3,14 +3,12 @@ import 'dart:io';
import 'package:filcnaplo/api/client.dart';
import 'package:filcnaplo/models/release.dart';
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
class UpdateProvider extends ChangeNotifier {
// Private
late List<Release> _releases;
bool _available = false;
bool get available => _available && _releases.isNotEmpty;
PackageInfo? _packageInfo;
// Public
List<Release> get releases => _releases;
@ -20,10 +18,9 @@ class UpdateProvider extends ChangeNotifier {
required BuildContext context,
}) {
_releases = List.castFrom(initialReleases);
PackageInfo.fromPlatform().then((value) => _packageInfo = value);
}
String get currentVersion => _packageInfo?.version ?? "";
static const currentVersion = String.fromEnvironment("APPVER", defaultValue: "1.0");
Future<void> fetch() async {
if (!Platform.isAndroid) return;
@ -33,7 +30,7 @@ class UpdateProvider extends ChangeNotifier {
// Check for new releases
if (_releases.isNotEmpty) {
_available = _packageInfo != null && _releases.first.version.compareTo(Version.fromString(currentVersion)) == 1;
_available = _releases.first.version.compareTo(Version.fromString(currentVersion)) == 1;
// ignore: avoid_print
if (_available) print("INFO: New update: ${releases.first.version}");
notifyListeners();

View File

@ -143,6 +143,7 @@ class App extends StatelessWidget {
case "settings":
return settingsRoute(const SettingsScreen());
}
return null;
// else if platform == windows || ...
}

View File

@ -1,15 +1,11 @@
import 'dart:io';
import 'package:package_info_plus/package_info_plus.dart';
class Config {
String _userAgent;
String? _version;
Map? json;
static const String _version = String.fromEnvironment("APPVER", defaultValue: "2.2.0");
Config({required String userAgent, this.json}) : _userAgent = userAgent {
PackageInfo.fromPlatform().then((value) => _version = value.version);
}
Config({required String userAgent, this.json}) : _userAgent = userAgent;
factory Config.fromJson(Map json) {
return Config(
@ -18,7 +14,7 @@ class Config {
);
}
String get userAgent => _userAgent.replaceAll("\$0", _version ?? "0").replaceAll("\$1", platform).replaceAll("\$2", "0");
String get userAgent => _userAgent.replaceAll("\$0", _version).replaceAll("\$1", platform).replaceAll("\$2", "0");
static String get platform {
if (Platform.isAndroid) {

View File

@ -4,7 +4,6 @@ import 'package:filcnaplo/api/providers/database_provider.dart';
import 'package:filcnaplo/models/config.dart';
import 'package:filcnaplo/theme.dart';
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:provider/provider.dart';
import 'package:uuid/uuid.dart';
@ -13,8 +12,6 @@ enum UpdateChannel { stable, beta, dev }
enum VibrationStrength { off, light, medium, strong }
class SettingsProvider extends ChangeNotifier {
PackageInfo? _packageInfo;
// en_en, hu_hu, de_de
String _language;
Pages _startPage;
@ -86,11 +83,7 @@ class SettingsProvider extends ChangeNotifier {
_swapABweeks = swapABweeks,
_updateChannel = updateChannel,
_config = config,
_xFilcId = xFilcId {
PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
_packageInfo = packageInfo;
});
}
_xFilcId = xFilcId;
factory SettingsProvider.fromMap(Map map) {
return SettingsProvider(
@ -194,7 +187,6 @@ class SettingsProvider extends ChangeNotifier {
bool get abWeeks => _abWeeks;
bool get swapABweeks => _swapABweeks;
UpdateChannel get updateChannel => _updateChannel;
PackageInfo? get packageInfo => _packageInfo;
Config get config => _config;
String get xFilcId => _xFilcId;

View File

@ -20,6 +20,7 @@ class JwtUtils {
// ignore: avoid_print
print("ERROR: JwtUtils.decodeJwt: $error");
}
return null;
}
static String? getNameFromJWT(String jwt) {
@ -36,5 +37,6 @@ class JwtUtils {
case "Gondviselo":
return Role.parent;
}
return null;
}
}

View File

@ -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.2.3+147
version: 3.2.3+148
environment:
sdk: ">=2.16.0-80.1.beta <3.0.0"
@ -34,13 +34,11 @@ dependencies:
path_provider: ^2.0.2
permission_handler: ^8.3.0
share_plus: ^3.0.4
package_info_plus: ^1.0.6
connectivity_plus: ^2.0.2
flutter_displaymode: ^0.3.2
quick_actions: ^0.6.0
implicitly_animated_reorderable_list: ^0.4.2
dev_dependencies:
flutter_test:
sdk: flutter

12
filcnaplo/run.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/fish
function get_version
cat pubspec.yaml | grep version: | cut -d' ' -f2 | cut -d+ -f1
end
if test -e /mnt/enc/keys/filc3.properties
set -x ANDROID_SIGNING /mnt/enc/keys/filc3.properties
end
flutter run --debug --dart-define=APPVER=(get_version)

@ -1 +1 @@
Subproject commit bab39c9eb4160b4140b63b6a95b8679b441aabee
Subproject commit a5b02cc2c8dc6ea65291fdba0f8f7d35a50b2cd5

@ -1 +1 @@
Subproject commit e1dced5d35fcd0dbb9974f2f39fb9dc3b3d2e28b
Subproject commit ac16642564f7e715fb39c43c0eb5b130b80874cc