Merge branch 'autoburza' into autoburza-sync

This commit is contained in:
Matyáš Caras 2022-05-29 17:03:16 +02:00 committed by GitHub
commit 31b6091e8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 516 additions and 184 deletions

View file

@ -1,17 +1,25 @@
<component name="libraryTable">
<library name="Dart SDK">
<CLASSES>
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/async" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/collection" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/convert" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/core" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/developer" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/html" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/io" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/isolate" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/math" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/mirrors" />
<root url="file://C:\flutter/bin/cache/dart-sdk/lib/typed_data" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/async" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/cli" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/collection" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/convert" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/core" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/developer" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/ffi" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/html" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/indexed_db" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/io" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/isolate" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/js" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/js_util" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/math" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/mirrors" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/svg" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/typed_data" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/web_audio" />
<root url="file:///opt/flutter/bin/cache/dart-sdk/lib/web_gl" />
</CLASSES>
<JAVADOC />
<SOURCES />

View file

@ -1,17 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="main.dart" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/lib/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
</state>
</provider>
</entry>
</file>
</leaf>
<component name="AutoImportSettings">
<option name="autoReloadType" value="NONE" />
</component>
<component name="ChangeListManager">
<list default="true" id="fb812771-e9e7-4fce-b8f3-64af4c4831fd" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/libraries/Dart_SDK.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Dart_SDK.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/app/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/android/app/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/app/src/main/AndroidManifest.xml" beforeDir="false" afterPath="$PROJECT_DIR$/android/app/src/main/AndroidManifest.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/android/build.gradle" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/opencanteen_android.iml" beforeDir="false" afterPath="$PROJECT_DIR$/android/opencanteen_android.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ios/Runner/AppDelegate.swift" beforeDir="false" afterPath="$PROJECT_DIR$/ios/Runner/AppDelegate.swift" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/lang/lang.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/lang/lang.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/lang/lang_cz.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/lang/lang_cz.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/lang/lang_en.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/lang/lang_en.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/main.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/okna/about.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/okna/about.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/okna/nastaveni.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/okna/nastaveni.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.yaml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="29eu54xQdUiQHx3lTDIjSQh4nnl" />
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1" />
<panes>
<pane id="ProjectPane">
<option name="show-excluded-files" value="false" />
</pane>
</panes>
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.cidr.known.project.marker" value="true" />
<property name="cidr.known.project.marker" value="true" />
<property name="dart.analysis.tool.window.force.activate" value="true" />
<property name="dart.analysis.tool.window.visible" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="show.migrate.to.gradle.popup" value="false" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="fb812771-e9e7-4fce-b8f3-64af4c4831fd" name="Changes" comment="" />
<created>1653485695149</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1653485695149</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<editor active="true" />
@ -19,18 +68,4 @@
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
</layout>
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
</navigator>
<panes>
<pane id="ProjectPane">
<option name="show-excluded-files" value="false" />
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="dart.analysis.tool.window.force.activate" value="true" />
<property name="show.migrate.to.gradle.popup" value="false" />
</component>
</project>
</project>

View file

@ -1,3 +1,8 @@
# 1.3.0
- Přidat možnost automatického objednávání z burzy
- Odstranit "connectivity_plus" knihovnu
- Změnit launch na launchUrl kvůli změnám v knihovně
- Nepodporovat instance s HTTP
# 1.2.0
- Přidat možnost zobrazení oznámení v případě neobjednaného jídla na příští týden
- Přidat oznámení o rozbitých uložených údajích

View file

@ -53,6 +53,7 @@ android {
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
signingConfigs {
@ -76,4 +77,5 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}

32
android/app/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,32 @@
##---------------Begin: proguard configuration for Gson ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# For using GSON @Expose annotation
-keepattributes *Annotation*
# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { <fields>; }
# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
##---------------End: proguard configuration for Gson ----------

View file

@ -1,7 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="cz.hernikplays.opencanteen">
<uses-permission android:name="android.permission.INTERNET"/>
<application
tools:replace="android:label"
android:label="OpenCanteen"
android:name="${applicationName}"
android:icon="@mipmap/launcher_icon"

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M8.25,42 L6.15,39.9 27.15,18.9Q26.05,16.5 26.65,13.925Q27.25,11.35 29.5,9.1Q31.75,6.9 34.95,6.275Q38.15,5.65 40.2,7.7Q42.3,9.8 41.625,12.95Q40.95,16.1 38.6,18.5Q36.55,20.6 34.025,21.25Q31.5,21.9 29.3,20.95L25.95,24.3L41.55,39.9L39.45,42L23.85,26.4ZM14.5,24.45 L8.55,18.5Q6,15.95 5.9,12.45Q5.8,8.95 8.2,6.25L20.45,18.5Z"/>
</vector>

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@drawable/notif_icon"/>

View file

@ -15,6 +15,10 @@ allprojects {
repositories {
google()
mavenCentral()
maven {
// [required] background_fetch
url "${project(':background_fetch').projectDir}/libs"
}
}
}

View file

@ -20,10 +20,11 @@
<sourceFolder url="file://$MODULE_DIR$/app/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/app/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/app/src/main/res" type="java-resource" />
</content>
<orderEntry type="jdk" jdkName="Android API 29 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Flutter for Android" level="project" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>
</module>

View file

@ -7,6 +7,9 @@ import Flutter
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

View file

@ -145,8 +145,15 @@ abstract class Languages {
String get checkOrdered;
String get autoBurza;
String get autoburzaNeeds;
// Offline
String get offline;
String get mustLogout;
// Autoburza
String get autoFound;
}

View file

@ -207,4 +207,14 @@ class LanguageCz extends Languages {
@override
String get corrupted =>
"Nastal problém s dešifrováním uložených údajů, prosím zkuste vyčistit veškerá data této aplikace.";
String get autoBurza =>
"Automaticky objednat jídlo z burzy, pokud žádné nemám";
@override
String get autoburzaNeeds =>
"Tato funkcionalita vyžaduje stálé internetové připojení a vaše údaje musí být uložené (pomocí přepínače 'Zapamatovat si mě' na přihlašovací obrazovce)";
@override
String get autoFound => "Objednáno jídlo z burzy";
}

View file

@ -206,4 +206,14 @@ class LanguageEn extends Languages {
@override
String get corrupted =>
"The saved credentials seem to be corrupted, please try clearing the application's data.";
String get autoBurza =>
"Automatically order food from exchange when I didn't order one";
@override
String get autoburzaNeeds =>
"This function requires constant network connection and you need to have saved login details (using the 'Remember me' switch on the login page).";
@override
String get autoFound => "Successfully ordered food from exchange";
}

View file

@ -1,18 +1,22 @@
import 'dart:convert';
import 'dart:io';
import 'package:background_fetch/background_fetch.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
=======
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:opencanteen/lang/lang_cz.dart';
import 'package:opencanteen/loginmanager.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:canteenlib/canteenlib.dart';
import 'package:opencanteen/okna/offline_jidelnicek.dart';
import 'package:opencanteen/okna/welcome.dart';
import 'package:opencanteen/util.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:intl/intl.dart';
import 'lang/lang.dart';
import 'lang/lang_en.dart';
@ -35,8 +39,112 @@ Copyright (C) 2022 Matyáš Caras a přispěvatelé
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
void main() {
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
// Pouze pro Android
void backgroundFetchHeadlessTask(HeadlessTask task) async {
String taskId = task.taskId;
bool isTimeout = task.timeout;
if (isTimeout) {
// Timeout
debugPrint("[BackgroundFetch] Headless task má time-out: $taskId");
BackgroundFetch.finish(taskId);
return;
}
debugPrint('[BackgroundFetch] Přišel headless event.');
var d = await LoginManager.getDetails(); // získat údaje
if (d != null) {
var c = Canteen(d["url"]!);
await c.login(d["user"]!, d["pass"]!); // přihlásit se
var burza = await c.ziskatBurzu(); // získat burzu
for (var jidlo in burza) {
try {
String locale = Intl.getCurrentLocale();
String title;
switch (locale) {
case "cs_CZ":
title = LanguageCz().autoFound;
break;
default:
title = LanguageEn().autoFound;
}
var r = await c.objednatZBurzy(jidlo); // objednat
if (r) {
const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails('opencanteen', 'autoburza',
channelDescription: 'Oznámení o objednání jídla z burzy',
importance: Importance.max,
priority: Priority.high,
ticker: 'burza success');
const NotificationDetails platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0, title, null, platformChannelSpecifics);
break; // ukončit pokud objednáno
}
} catch (e) {
const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails('opencanteen', 'autoburza',
channelDescription: 'Oznámení o objednání jídla z burzy',
importance: Importance.max,
priority: Priority.high,
ticker: 'burza fail');
const NotificationDetails platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0,
"CHYBA PŘI OBJEDNÁVÁNÍ ${jidlo.nazev}",
e.toString(),
platformChannelSpecifics);
}
}
}
BackgroundFetch.finish(taskId);
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('notif_icon');
/// Note: permissions aren't requested here just to demonstrate that can be
/// done later
final IOSInitializationSettings initializationSettingsIOS =
IOSInitializationSettings(
requestAlertPermission: false,
requestBadgePermission: false,
requestSoundPermission: false,
onDidReceiveLocalNotification: (
int id,
String? title,
String? body,
String? payload,
) async {
debugPrint(body);
});
final InitializationSettings initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsIOS,
);
await flutterLocalNotificationsPlugin.initialize(initializationSettings,
onSelectNotification: (String? payload) async {
if (payload != null) {
debugPrint('notification payload: $payload');
}
});
runApp(const MyApp());
var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("autoburza") ?? false) {
debugPrint("Nastavuji");
BackgroundFetch.registerHeadlessTask(backgroundFetchHeadlessTask);
}
}
class MyApp extends StatelessWidget {
@ -78,21 +186,97 @@ class _LoginPageState extends State<LoginPage> {
TextEditingController canteenControl = TextEditingController();
bool rememberMe = false;
void nastavitPozadi() async {
// Configure BackgroundFetch.
int status = await BackgroundFetch.configure(
BackgroundFetchConfig(
minimumFetchInterval: 15,
stopOnTerminate: false,
enableHeadless: true,
requiresBatteryNotLow: false,
requiresCharging: false,
requiresStorageNotLow: false,
requiresDeviceIdle: false,
requiredNetworkType: NetworkType.ANY), (String taskId) async {
// Callback
debugPrint("[BackgroundFetch] Event získán $taskId");
var d = await LoginManager.getDetails();
if (d != null) {
var c = Canteen(d["url"]!);
await c.login(d["user"]!, d["pass"]!);
var burza = await c.ziskatBurzu();
for (var jidlo in burza) {
// DEBUG
var debugge = const AndroidNotificationDetails(
'opencanteen', 'debugge',
channelDescription: 'Debug opencanteen',
importance: Importance.max,
priority: Priority.high,
ticker: 'burza debug');
await flutterLocalNotificationsPlugin.show(
0,
"Nalezeno jídlo ${jidlo.nazev}",
null,
NotificationDetails(android: debugge)); // TODO debug
try {
var r = await c.objednatZBurzy(jidlo); // objednat
if (r) {
const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails('opencanteen', 'autoburza',
channelDescription: 'Oznámení o objednání jídla z burzy',
importance: Importance.max,
priority: Priority.high,
ticker: 'burza success');
const NotificationDetails platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0,
Languages.of(context)!.autoFound,
null,
platformChannelSpecifics);
break; // ukončit pokud objednáno
}
} catch (e) {
const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails('opencanteen', 'autoburza',
channelDescription: 'Oznámení o objednání jídla z burzy',
importance: Importance.max,
priority: Priority.high,
ticker: 'burza fail');
const NotificationDetails platformChannelSpecifics =
NotificationDetails(android: androidPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(
0,
"CHYBA PŘI OBJEDNÁVÁNÍ ${jidlo.nazev}",
e.toString(),
platformChannelSpecifics);
}
}
}
BackgroundFetch.finish(taskId);
}, (String taskId) async {
debugPrint("[BackgroundFetch] TASK TIMEOUT taskId: $taskId");
BackgroundFetch.finish(taskId);
});
debugPrint('[BackgroundFetch] úspěšně nakonfigurováno: $status');
}
@override
void initState() {
super.initState();
LoginManager.getDetails().then((r) async {
var connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult == ConnectivityResult.none) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(Languages.of(context)!.errorContacting),
),
);
goOffline();
if (Platform.isIOS) {
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
IOSFlutterLocalNotificationsPlugin>()
?.requestPermissions(
alert: true,
badge: true,
sound: true,
) ??
false;
}
if (r != null) {
showDialog(
context: context,
@ -121,6 +305,10 @@ class _LoginPageState extends State<LoginPage> {
);
return;
}
var prefs = await SharedPreferences.getInstance();
if (prefs.getBool("autoburza") ?? false) {
nastavitPozadi();
}
const storage = FlutterSecureStorage();
var odsouhlasil = await storage.read(key: "oc_souhlas");
if (odsouhlasil == null || odsouhlasil != "ano") {
@ -144,7 +332,13 @@ class _LoginPageState extends State<LoginPage> {
content: Text(Languages.of(context)!.corrupted),
),
);
} catch (_) {
} catch (e) {
// DEBUG ODSTRANIT
showDialog(
context: context,
builder: (c) => SimpleDialog(
title: Text("Chyba"), children: [Text(e.toString())]));
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
@ -213,30 +407,6 @@ class _LoginPageState extends State<LoginPage> {
]),
TextButton(
onPressed: () async {
if (canteenControl.text.contains("http://")) {
// kontrolujeme šifrované spojení
var d = await showDialog<bool>(
context: context,
builder: (c) => AlertDialog(
title: Text(Languages.of(context)!.warning),
content: SingleChildScrollView(
child: Text(
Languages.of(context)!.httpLogin)),
actions: [
TextButton(
onPressed: () =>
Navigator.pop(c, true),
child:
Text(Languages.of(context)!.yes)),
TextButton(
onPressed: () =>
Navigator.pop(c, false),
child: Text(
Languages.of(context)!.noChange))
],
));
if (!d!) return;
}
if (!canteenControl.text.startsWith("https://") &&
!canteenControl.text.startsWith("http://")) {
canteenControl.text =
@ -274,9 +444,10 @@ class _LoginPageState extends State<LoginPage> {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => JidelnicekPage(
canteen: canteen,
)),
builder: (context) => JidelnicekPage(
canteen: canteen,
),
),
);
}
} on PlatformException {
@ -286,7 +457,14 @@ class _LoginPageState extends State<LoginPage> {
content: Text(Languages.of(context)!.corrupted),
),
);
} on Exception catch (_) {
} on Exception catch (e) {
// TODO: DEBUG ODSTRANIT
showDialog(
context: context,
builder: (c) => SimpleDialog(
title: Text("Chyba"),
children: [Text(e.toString())]));
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(

View file

@ -26,8 +26,8 @@ class _AboutPageState extends State<AboutPage> {
const Text("OpenCanteen", style: TextStyle(fontSize: 30)),
Text(Languages.of(context)!.copyright),
InkWell(
onTap: () => launch(
"https://github.com/hernikplays/opencanteen/blob/main/LICENSE"),
onTap: () => launchUrl(Uri.parse(
"https://github.com/hernikplays/opencanteen/blob/main/LICENSE")),
child: Text(Languages.of(context)!.license)),
const SizedBox(height: 15),
Text(Languages.of(context)!.usedLibs,
@ -44,9 +44,9 @@ class _AboutPageState extends State<AboutPage> {
"https://github.com/mogol/flutter_secure_storage/blob/develop/flutter_secure_storage/LICENSE"),
const SizedBox(height: 10),
cudlik(
"connectivity_plus",
"Copyright 2017 The Chromium Authors. All rights reserved, licence BSD 3-Clause",
"https://github.com/fluttercommunity/plus_plugins/blob/main/packages/connectivity_plus/connectivity_plus/LICENSE"),
"Material Icons",
"Copyright Google. All rights reserved, licence Apache 2.0",
"https://github.com/google/material-design-icons/blob/master/LICENSE"),
const SizedBox(height: 10),
cudlik(
"url_launcher",
@ -60,18 +60,32 @@ class _AboutPageState extends State<AboutPage> {
const SizedBox(height: 10),
cudlik(
"path_provider",
"Copyright 2013 The Flutter Authors. All rights reserved., licence BSD-3-Clause",
"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"),
const SizedBox(height: 10),
cudlik(
"shared_preferences",
"Copyright 2013 The Flutter Authors. All rights reserved., licence BSD-3-Clause",
"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"),
const SizedBox(height: 10),
cudlik(
"introduction_screen",
"Copyright 2019 Jean-Charles Moussé, licence MIT",
"https://github.com/Pyozer/introduction_screen/blob/master/LICENSE")
"https://github.com/Pyozer/introduction_screen/blob/master/LICENSE"),
const SizedBox(
height: 10,
),
cudlik(
"flutter_local_notifications",
"Copyright 2018 Michael Bui. All rights reserved, licence BSD 3-Clause",
"https://github.com/MaikuB/flutter_local_notifications/blob/master/flutter_local_notifications/LICENSE"),
const SizedBox(
height: 10,
),
cudlik(
"background_fetch",
"Copyright (c) 2018 Transistor Software, licence MIT",
"https://github.com/transistorsoft/flutter_background_fetch/blob/master/LICENSE")
]),
),
),
@ -81,7 +95,7 @@ class _AboutPageState extends State<AboutPage> {
Widget cudlik(String nazev, String copyright, String licence) {
return InkWell(
onTap: () => launch(licence),
onTap: () => launchUrl(Uri.parse(licence)),
child: Column(children: [
Text(
nazev,

View file

@ -17,6 +17,7 @@ class _NastaveniState extends State<Nastaveni> {
bool _ukladatOffline = false;
bool _preskakovatVikend = false;
bool _kontrolovatTyden = false;
bool _autoBurza = false;
void najitNastaveni() async {
var preferences = await SharedPreferences.getInstance();
@ -24,6 +25,7 @@ class _NastaveniState extends State<Nastaveni> {
_ukladatOffline = preferences.getBool("offline") ?? false;
_preskakovatVikend = preferences.getBool("skip") ?? false;
_kontrolovatTyden = preferences.getBool("tyden") ?? false;
_autoBurza = preferences.getBool("autoburza") ?? false;
});
}
@ -88,6 +90,31 @@ class _NastaveniState extends State<Nastaveni> {
setState(() {
_kontrolovatTyden = value;
zmenitNastaveni("tyden", value);
Flexible(
child: Text(Languages.of(context)!.autoBurza),
),
Switch(
value: _autoBurza,
onChanged: (value) {
if (value) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(Languages.of(context)!.warning),
content:
Text(Languages.of(context)!.autoburzaNeeds),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: Text(Languages.of(context)!.ok))
],
),
);
}
setState(() {
_autoBurza = value;
zmenitNastaveni("autoburza", value);
});
})
],

View file

@ -14,21 +14,28 @@ packages:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "2.3.1"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
background_fetch:
dependency: "direct main"
description:
name: background_fetch
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
canteenlib:
dependency: "direct main"
description:
name: canteenlib
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0-alpha.16"
version: "0.1.0-alpha.17"
characters:
dependency: transitive
description:
@ -36,13 +43,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
clock:
dependency: transitive
description:
@ -57,62 +57,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
connectivity_plus:
dependency: "direct main"
description:
name: connectivity_plus
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
connectivity_plus_linux:
dependency: transitive
description:
name: connectivity_plus_linux
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
connectivity_plus_macos:
dependency: transitive
description:
name: connectivity_plus_macos
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
connectivity_plus_platform_interface:
dependency: transitive
description:
name: connectivity_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
connectivity_plus_web:
dependency: transitive
description:
name: connectivity_plus_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
connectivity_plus_windows:
dependency: transitive
description:
name: connectivity_plus_windows
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
dbus:
dependency: transitive
description:
name: dbus
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.2"
version: "0.7.3"
dots_indicator:
dependency: transitive
description:
@ -126,7 +84,7 @@ packages:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "1.2.1"
file:
dependency: transitive
description:
@ -153,6 +111,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
url: "https://pub.dartlang.org"
source: hosted
version: "9.5.3+1"
flutter_local_notifications_linux:
dependency: transitive
description:
name: flutter_local_notifications_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
flutter_localizations:
dependency: "direct main"
description: flutter
@ -218,7 +197,7 @@ packages:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
version: "4.0.1"
image:
dependency: transitive
description:
@ -268,13 +247,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
nm:
dependency: transitive
description:
name: nm
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
path:
dependency: transitive
description:
@ -288,56 +260,56 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.10"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
version: "2.0.14"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.0.9"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
version: "2.1.6"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.0.6"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.0.6"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "4.4.0"
version: "5.0.0"
platform:
dependency: transitive
description:
@ -365,35 +337,35 @@ packages:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
version: "2.0.15"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.12"
shared_preferences_ios:
dependency: transitive
description:
name: shared_preferences_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.1"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.1"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.4"
shared_preferences_platform_interface:
dependency: transitive
description:
@ -407,14 +379,14 @@ packages:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.4"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.1"
sky_engine:
dependency: transitive
description: flutter
@ -426,14 +398,14 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.9.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
@ -441,48 +413,55 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
timezone:
dependency: transitive
description:
name: timezone
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.20"
version: "6.1.2"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
version: "6.0.17"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.15"
version: "6.0.17"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
url_launcher_platform_interface:
dependency: transitive
description:
@ -496,14 +475,14 @@ packages:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.11"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
vector_math:
dependency: transitive
description:
@ -517,7 +496,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.2"
version: "2.6.1"
xdg_directories:
dependency: transitive
description:
@ -531,14 +510,14 @@ packages:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.3.1"
version: "5.4.1"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
version: "3.1.1"
sdks:
dart: ">=2.17.0-0 <3.0.0"
dart: ">=2.17.0 <3.0.0"
flutter: ">=2.10.0"

View file

@ -8,21 +8,23 @@ publish_to: 'none'
# followed by an optional build number separated by a +.
version: 1.2.0+14
environment:
sdk: ">=2.16.1 <3.0.0"
sdk: ">=2.16.1 <4.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
canteenlib: ^0.1.0-alpha.16
connectivity_plus: ^2.2.1
canteenlib: ^0.1.0-alpha.17
flutter_secure_storage: ^5.0.2
url_launcher: ^6.0.20
path_provider: ^2.0.9
shared_preferences: ^2.0.13
introduction_screen: ^3.0.1
flutter_local_notifications: ^9.5.3+1
background_fetch: ^1.1.0
dev_dependencies:
flutter_lints: ^1.0.0