fix: přidat info o baterii a odstranit zbytecny if
This commit is contained in:
parent
6bbc9c2d0a
commit
c95518c557
6 changed files with 63 additions and 36 deletions
|
@ -149,6 +149,8 @@ abstract class Languages {
|
||||||
|
|
||||||
String get notifyAt;
|
String get notifyAt;
|
||||||
|
|
||||||
|
String get notifyWarning;
|
||||||
|
|
||||||
// Offline
|
// Offline
|
||||||
String get offline;
|
String get offline;
|
||||||
|
|
||||||
|
|
|
@ -224,4 +224,8 @@ class LanguageCz extends Languages {
|
||||||
@override
|
@override
|
||||||
String get needRemember =>
|
String get needRemember =>
|
||||||
"Musíte své přihlašovací údaje uložit na přihlašovací obrazovce";
|
"Musíte své přihlašovací údaje uložit na přihlašovací obrazovce";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get notifyWarning =>
|
||||||
|
"Vaše zařízení může mít povolenou optimalizaci baterie, což může způsobovat neodesílání oznámení. Zkontrolujte nastavení ve vašem zařízení.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,4 +222,8 @@ class LanguageEn extends Languages {
|
||||||
@override
|
@override
|
||||||
String get needRemember =>
|
String get needRemember =>
|
||||||
"You need to save your login details on the login screen first";
|
"You need to save your login details on the login screen first";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get notifyWarning =>
|
||||||
|
"Your device may have battery optimization enabled. This may cause notifications to not be sent. Check the application info in your device's settings.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,44 +55,44 @@ void oznamitPredem(SharedPreferences prefs, tz.Location l) async {
|
||||||
title = LanguageEn().lunchNotif;
|
title = LanguageEn().lunchNotif;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefs.getBool("offline") ?? false) {
|
/*if (prefs.getBool("offline") ?? false) {
|
||||||
// TODO možnost brát z offline dat
|
// TODO možnost brát z offline dat
|
||||||
} else {
|
} else {*/
|
||||||
// bere online
|
// bere online
|
||||||
var d = await LoginManager.getDetails(); // získat údaje
|
var d = await LoginManager.getDetails(); // získat údaje
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
var c = Canteen(d["url"]!);
|
var c = Canteen(d["url"]!);
|
||||||
if (await c.login(d["user"]!, d["pass"]!)) {
|
if (await c.login(d["user"]!, d["pass"]!)) {
|
||||||
var jidla = await c.jidelnicekDen();
|
var jidla = await c.jidelnicekDen();
|
||||||
try {
|
try {
|
||||||
var jidlo = jidla.jidla.singleWhere((element) => element.objednano);
|
var jidlo = jidla.jidla.singleWhere((element) => element.objednano);
|
||||||
var kdy = DateTime.parse(prefs.getString("oznameni_cas")!);
|
var kdy = DateTime.parse(prefs.getString("oznameni_cas")!);
|
||||||
const AndroidNotificationDetails androidSpec =
|
const AndroidNotificationDetails androidSpec =
|
||||||
AndroidNotificationDetails('opencanteen', 'predobjedem',
|
AndroidNotificationDetails('opencanteen', 'predobjedem',
|
||||||
channelDescription: 'Oznámení o dnešním jídle',
|
channelDescription: 'Oznámení o dnešním jídle',
|
||||||
importance: Importance.max,
|
importance: Importance.max,
|
||||||
priority: Priority.high,
|
priority: Priority.high,
|
||||||
ticker: 'today meal');
|
ticker: 'today meal');
|
||||||
const IOSNotificationDetails iOSpec =
|
const IOSNotificationDetails iOSpec =
|
||||||
IOSNotificationDetails(presentAlert: true, presentBadge: true);
|
IOSNotificationDetails(presentAlert: true, presentBadge: true);
|
||||||
await flutterLocalNotificationsPlugin.zonedSchedule(
|
await flutterLocalNotificationsPlugin.zonedSchedule(
|
||||||
0,
|
0,
|
||||||
title,
|
title,
|
||||||
"${jidlo.nazev} - ${jidlo.varianta}",
|
"${jidlo.nazev} - ${jidlo.varianta}",
|
||||||
tz.TZDateTime.from(
|
tz.TZDateTime.from(
|
||||||
casNaDate(
|
casNaDate(
|
||||||
TimeOfDay(hour: kdy.hour, minute: kdy.minute),
|
TimeOfDay(hour: kdy.hour, minute: kdy.minute),
|
||||||
),
|
),
|
||||||
l),
|
l),
|
||||||
const NotificationDetails(android: androidSpec, iOS: iOSpec),
|
const NotificationDetails(android: androidSpec, iOS: iOSpec),
|
||||||
androidAllowWhileIdle: true,
|
androidAllowWhileIdle: true,
|
||||||
uiLocalNotificationDateInterpretation:
|
uiLocalNotificationDateInterpretation:
|
||||||
UILocalNotificationDateInterpretation.absoluteTime);
|
UILocalNotificationDateInterpretation.absoluteTime);
|
||||||
} on StateError catch (_) {
|
} on StateError catch (_) {
|
||||||
// nenalezeno
|
// nenalezeno
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,23 @@ class _NastaveniState extends State<Nastaveni> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_oznameniObed = value;
|
_oznameniObed = value;
|
||||||
if (_oznameniObed) {
|
if (_oznameniObed) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title:
|
||||||
|
Text(Languages.of(context)!.warning),
|
||||||
|
content: Text(
|
||||||
|
Languages.of(context)!.notifyWarning),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child:
|
||||||
|
Text(Languages.of(context)!.ok),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
));
|
||||||
vytvoritOznameni(casNaDate(_oznameniCas));
|
vytvoritOznameni(casNaDate(_oznameniCas));
|
||||||
}
|
}
|
||||||
zmenitNastaveni("oznamit", value);
|
zmenitNastaveni("oznamit", value);
|
||||||
|
|
|
@ -6,7 +6,7 @@ publish_to: 'none'
|
||||||
# The following defines the version and build number for your application.
|
# The following defines the version and build number for your application.
|
||||||
# A version number is three numbers separated by dots, like 1.2.43
|
# A version number is three numbers separated by dots, like 1.2.43
|
||||||
# followed by an optional build number separated by a +.
|
# followed by an optional build number separated by a +.
|
||||||
version: 1.3.0+15
|
version: 1.3.1+16
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.16.1 <3.0.0"
|
sdk: ">=2.16.1 <3.0.0"
|
||||||
|
|
Reference in a new issue