diff --git a/.fossa.yml b/.fossa.yml new file mode 100644 index 0000000..13a4f89 --- /dev/null +++ b/.fossa.yml @@ -0,0 +1,4 @@ +version: 3 +targets: + only: + - type: pub \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a1addc..5f390ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +# 0.2.0 # 0.1.1 - Přidán RefreshIndicator na obrazovku s jídelníčkem - Přidáno odsazení od okrajů u jídelníčku diff --git a/PRIVACY.md b/PRIVACY.md index 1b2ec6e..4a8c033 100644 --- a/PRIVACY.md +++ b/PRIVACY.md @@ -1,5 +1,7 @@ ## Zásady používání a ochrany soukromí aplikace OpenCanteen -Platí od 5. 4. 2022 +Platí od 26. 4. 2022 + +[Předchozí verze](https://github.com/hernikplays/opencanteen/blob/0.1.1/PRIVACY.md) ### Používání - Tato aplikace není vyvíjena nebo podporována firmou Z-WARE s.r.o. a není oficiální klient pro systém iCanteen - Uživatel aplikace sám zodpovídá za svůj účet a údaje @@ -11,7 +13,7 @@ Platí od 5. 4. 2022 - Aplikace odesílá data pouze na URL instance systému iCanteen, kterou uživatel aplikace sám zadá - V případě, že tato instance není zabezpečena protokolem HTTPS, neručí vývojář aplikace za vzniklá nebezpečí - Aplikace neobsahuje reklamy -- Aplikace dlouhodobě ukládá údaje uživatele (přihlašovací jméno, heslo, URL k instanci) pouze v případě, že uživatel při přihlašování povolí možnost `Zapamatovat si mě`. V tom případě jsou data zašifrována a uložena na zařízení uživatele +- Aplikace dlouhodobě ukládá do zařízení údaje uživatele (přihlašovací jméno, heslo, URL k instanci, jídelníček na aktuální den pro offline zobrazení) pouze v případě, že uživatel při přihlašování povolí možnost `Zapamatovat si mě`. V tom případě jsou data zašifrována a uložena na zařízení uživatele - V opačném případě jsou údaje uložené v mezipaměti jen na dobu nezbytně nutnou a následně smazány operačním systémem ### Kontakt diff --git a/lib/loginmanager.dart b/lib/loginmanager.dart index a0a3b64..0e00e60 100644 --- a/lib/loginmanager.dart +++ b/lib/loginmanager.dart @@ -17,4 +17,9 @@ class LoginManager { await storage.write(key: "oc_pass", value: pass); await storage.write(key: "oc_url", value: url); } + + static Future zapamatovat() async { + const storage = FlutterSecureStorage(); + return await storage.containsKey(key: "oc_pass"); + } } diff --git a/lib/main.dart b/lib/main.dart index 7699afc..60a3fae 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -219,7 +219,11 @@ class _LoginPageState extends State { if (!d!) return; await storage.write(key: "oc_souhlas", value: "ano"); } - + if (!canteenControl.text.startsWith("https://") && + !canteenControl.text.startsWith("http://")) { + canteenControl.text = + "https://" + canteenControl.text; + } var canteen = Canteen(canteenControl.text); var l = await canteen.login( userControl.text, passControl.text); diff --git a/lib/okna/about.dart b/lib/okna/about.dart index 0a8dedd..4816505 100644 --- a/lib/okna/about.dart +++ b/lib/okna/about.dart @@ -20,7 +20,10 @@ class _AboutPageState extends State { child: Column(mainAxisSize: MainAxisSize.min, children: [ const Text("OpenCanteen", style: TextStyle(fontSize: 30)), const Text("© 2022 Matyáš Caras a přispěvatelé"), - const Text("Vydáno pod licencí GNU GPLv3"), + InkWell( + onTap: () => launch( + "https://github.com/hernikplays/opencanteen/blob/main/LICENSE"), + child: const Text("Vydáno pod licencí GNU GPLv3")), const SizedBox(height: 15), const Text("Použité knihovny:", style: TextStyle(fontSize: 19)), const SizedBox(height: 10), @@ -47,7 +50,12 @@ class _AboutPageState extends State { cudlik( "canteenlib", "Copyright (c) 2022 Matyáš Caras and contributors, licence MIT", - "https://github.com/hernikplays/canteenlib/blob/main/LICENSE") + "https://github.com/hernikplays/canteenlib/blob/main/LICENSE"), + const SizedBox(height: 10), + cudlik( + "path_provider", + "Copyright 2013 The Flutter Authors. All rights reserved., licence BSD-3-Clause", + "https://github.com/flutter/plugins/blob/main/packages/path_provider/path_provider/LICENSE") ]), ), ); diff --git a/lib/okna/jidelnicek.dart b/lib/okna/jidelnicek.dart index 7b70ba1..af3fbc0 100644 --- a/lib/okna/jidelnicek.dart +++ b/lib/okna/jidelnicek.dart @@ -1,9 +1,14 @@ +import 'dart:convert'; +import 'dart:io'; + import 'package:canteenlib/canteenlib.dart'; import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:opencanteen/util.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../loginmanager.dart'; import '../main.dart'; import 'about.dart'; @@ -47,7 +52,7 @@ class _JidelnicekPageState extends State { } widget.canteen.ziskejUzivatele().then((kr) { kredit = kr.kredit; - widget.canteen.jidelnicekDen(den: den).then((jd) { + widget.canteen.jidelnicekDen(den: den).then((jd) async { setState(() { obsah = []; if (jd.jidla.isEmpty) { @@ -205,9 +210,39 @@ class _JidelnicekPageState extends State { } } + /// uložení jídelníčku pro dnešek offline + void ulozitDnesekOffline() async { + if (await LoginManager.zapamatovat()) { + Directory appDocDir = await getApplicationDocumentsDirectory(); + for (var f in appDocDir.listSync()) { + // Vymažeme obsah + if (f.path.contains("jidelnicek")) { + f.deleteSync(); + } + } + // Uložíme nová data + var j = await widget.canteen.jidelnicekDen(); + var soubor = File(appDocDir.path + + "/jidelnicek_${den.year}-${den.month}-${den.day}.json"); + soubor.createSync(); + var jidla = []; + for (var jidlo in j.jidla) { + jidla.add({ + "nazev": jidlo.nazev, + "varianta": jidlo.varianta, + "objednano": jidlo.objednano, + "cena": jidlo.cena, + "naBurze": jidlo.naBurze + }); + } + await soubor.writeAsString(json.encode(jidla)); + } + } + @override void initState() { super.initState(); + ulozitDnesekOffline(); nactiJidlo(); } diff --git a/pubspec.lock b/pubspec.lock index 9eaa68b..01c6997 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -120,6 +120,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.2" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -261,6 +268,55 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + path_provider: + dependency: "direct main" + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.9" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.12" + path_provider_ios: + dependency: transitive + description: + name: path_provider_ios + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.8" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.5" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.3" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" petitparser: dependency: transitive description: @@ -268,6 +324,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.4.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" plugin_platform_interface: dependency: transitive description: @@ -275,6 +338,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.2" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.2.4" sky_engine: dependency: transitive description: flutter @@ -371,6 +441,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.5.2" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+1" xml: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 5913cbf..3d28314 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: 'none' # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. -version: 0.1.1+2 +version: 0.2.0+3 environment: sdk: ">=2.16.1 <3.0.0" @@ -20,6 +20,7 @@ dependencies: connectivity_plus: ^2.2.1 flutter_secure_storage: ^5.0.2 url_launcher: ^6.0.20 + path_provider: ^2.0.9 dev_dependencies: flutter_lints: ^1.0.0 diff --git a/screenshots/01.png b/screenshots/01.png deleted file mode 100644 index ca8baee..0000000 Binary files a/screenshots/01.png and /dev/null differ diff --git a/screenshots/02.png b/screenshots/02.png deleted file mode 100644 index beb8f3b..0000000 Binary files a/screenshots/02.png and /dev/null differ diff --git a/screenshots/03.png b/screenshots/03.png deleted file mode 100644 index f23d093..0000000 Binary files a/screenshots/03.png and /dev/null differ diff --git a/screenshots/04.png b/screenshots/04.png deleted file mode 100644 index 4f18be3..0000000 Binary files a/screenshots/04.png and /dev/null differ