Compare commits

...

11 Commits
4.0.3 ... 4.0.4

Author SHA1 Message Date
Márton Kiss
e31d0753d1 Merge pull request #8 from TMarccci/master
I think I fixed this
2023-06-09 16:55:05 +02:00
Tihanyi Marcell
526c66f358 I think I fixed this 2023-06-09 16:53:28 +02:00
Kima
d6833a952d changed version string 2023-06-09 16:40:53 +02:00
Kima
4760761bb7 Merge branch 'master' of github.com:refilc/naplo 2023-06-09 16:25:34 +02:00
Kima
a33e6dae3b fixed auto-update error bug 2023-06-09 16:25:31 +02:00
Márton Kiss
d393181f10 Update grade_provider.dart 2023-06-09 16:06:17 +02:00
Márton Kiss
12df8b82c7 Merge pull request #7 from TMarccci/master
Handle disabled Live Activity, i18n AverageSelector won't update, ...
2023-06-09 16:02:05 +02:00
Tihanyi Marcell
1c7eba7af3 Appgroup id: not refilc2 2023-06-09 15:44:37 +02:00
Tihanyi Marcell
d39cdaef10 Fixed i18n wont update to AverageSelector 2023-06-09 14:22:15 +02:00
Tihanyi Marcell
cc40fb9c0f Ignore disabled live activity 2023-06-09 11:13:35 +02:00
Tihanyi Marcell
85c6d548ad Ignore null and - i18n 2023-06-09 11:08:00 +02:00
6 changed files with 186 additions and 151 deletions

View File

@@ -44,10 +44,20 @@ class LiveCardProvider extends ChangeNotifier {
required SettingsProvider settings, required SettingsProvider settings,
}) : _timetable = timetable, }) : _timetable = timetable,
_settings = settings { _settings = settings {
_liveActivitiesPlugin.init(appGroupId: "group.refilc.livecard"); // Check if live card is enabled .areActivitiesEnabled()
_liveActivitiesPlugin.getAllActivitiesIds().then((value) { _liveActivitiesPlugin.areActivitiesEnabled().then((value) {
_latestActivityId = value.isNotEmpty ? value.first : null; // Console log
print("Live card enabled: $value");
if (value) {
_liveActivitiesPlugin.init(appGroupId: "group.refilc.livecard");
_liveActivitiesPlugin.getAllActivitiesIds().then((value) {
_latestActivityId = value.isNotEmpty ? value.first : null;
});
}
}); });
_timer = Timer.periodic(const Duration(seconds: 1), (timer) => update()); _timer = Timer.periodic(const Duration(seconds: 1), (timer) => update());
_delay = settings.bellDelayEnabled _delay = settings.bellDelayEnabled
? Duration(seconds: settings.bellDelay) ? Duration(seconds: settings.bellDelay)
@@ -58,8 +68,15 @@ class LiveCardProvider extends ChangeNotifier {
@override @override
void dispose() { void dispose() {
_timer.cancel(); _timer.cancel();
if (_latestActivityId != null && Platform.isIOS) if (Platform.isIOS) {
_liveActivitiesPlugin.endActivity(_latestActivityId!); _liveActivitiesPlugin.areActivitiesEnabled().then((value) {
if (value) {
if (_latestActivityId != null) {
_liveActivitiesPlugin.endActivity(_latestActivityId!);
}
}
});
}
super.dispose(); super.dispose();
} }
@@ -146,30 +163,34 @@ class LiveCardProvider extends ChangeNotifier {
void update() async { void update() async {
if (Platform.isIOS) { if (Platform.isIOS) {
final cmap = toMap(); _liveActivitiesPlugin.areActivitiesEnabled().then((value) {
if (!mapEquals(cmap, _lastActivity)) { if (value) {
_lastActivity = cmap; final cmap = toMap();
try { if (!mapEquals(cmap, _lastActivity)) {
if (_lastActivity.isNotEmpty) { _lastActivity = cmap;
if (_latestActivityId == null) { try {
_liveActivitiesPlugin if (_lastActivity.isNotEmpty) {
.createActivity(_lastActivity) if (_latestActivityId == null) {
.then((value) => _latestActivityId = value); _liveActivitiesPlugin
} else { .createActivity(_lastActivity)
_liveActivitiesPlugin.updateActivity( .then((value) => _latestActivityId = value);
_latestActivityId!, _lastActivity); } else {
_liveActivitiesPlugin.updateActivity(
_latestActivityId!, _lastActivity);
}
} else {
if (_latestActivityId != null) {
_liveActivitiesPlugin.endActivity(_latestActivityId!);
}
}
} catch (e) {
if (kDebugMode) {
print('ERROR: Unable to create or update iOS LiveCard!');
}
} }
} else {
if (_latestActivityId != null) {
_liveActivitiesPlugin.endActivity(_latestActivityId!);
}
}
} catch (e) {
if (kDebugMode) {
print('ERROR: Unable to create or update iOS LiveCard!');
} }
} }
} });
} }
List<Lesson> today = _today(_timetable); List<Lesson> today = _today(_timetable);

View File

@@ -19,13 +19,15 @@ extension UpdateHelper on Release {
updateCallback!(-1, UpdateState.preparing); updateCallback!(-1, UpdateState.preparing);
String downloads = await StorageHelper.downloadsPath(); String downloads = await StorageHelper.downloadsPath();
File apk = File("$downloads/filcnaplo-$version.apk"); File apk = File("$downloads/refilc-$version.apk");
if (!await apk.exists()) { if (!await apk.exists()) {
updateCallback(-1, UpdateState.downloading); updateCallback(-1, UpdateState.downloading);
var bytes = await download(updateCallback: updateCallback); var bytes = await download(updateCallback: updateCallback);
if (!await StorageHelper.write(apk.path, bytes)) throw "failed to write apk: permission denied"; if (!await StorageHelper.write(apk.path, bytes)) {
throw "failed to write apk: permission denied";
}
} }
updateCallback(-1, UpdateState.installing); updateCallback(-1, UpdateState.installing);
@@ -50,7 +52,8 @@ extension UpdateHelper on Release {
var completer = Completer<Uint8List>(); var completer = Completer<Uint8List>();
response?.stream.listen((List<int> chunk) { response?.stream.listen((List<int> chunk) {
updateCallback!(downloaded / (response.contentLength ?? 0), UpdateState.downloading); updateCallback!(
downloaded / (response.contentLength ?? 0), UpdateState.downloading);
chunks.add(chunk); chunks.add(chunk);
downloaded += chunk.length; downloaded += chunk.length;

View File

@@ -3,7 +3,7 @@ description: "Nem hivatalos e-napló alkalmazás az e-Kréta rendszerhez"
homepage: https://refilc.hu homepage: https://refilc.hu
publish_to: "none" publish_to: "none"
version: 4.0.3+210 version: 4.0.4+212
environment: environment:
sdk: ">=2.17.0 <3.0.0" sdk: ">=2.17.0 <3.0.0"

View File

@@ -98,7 +98,9 @@ class GradeProvider with ChangeNotifier {
.i18n; .i18n;
grade.value.shortName = _settings.goodStudent grade.value.shortName = _settings.goodStudent
? "Jeles".i18n ? "Jeles".i18n
: '${grade.json!["SzovegesErtekelesRovidNev"]}'.i18n; : '${grade.json!["SzovegesErtekelesRovidNev"]}' != "null" && '${grade.json!["SzovegesErtekelesRovidNev"]}' != "-" && '${grade.json!["SzovegesErtekelesRovidNev"]}'.replaceAll(RegExp(r'[0123456789]+[%]?'), '') != ""
? '${grade.json!["SzovegesErtekelesRovidNev"]}'.i18n
: grade.value.valueName;
} }
notifyListeners(); notifyListeners();

View File

@@ -9,44 +9,55 @@ import 'package:flutter_feather_icons/flutter_feather_icons.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
final Map<int, String> avgDropItems = { final Map<int, String> avgDropItems = {
0: "annual_average".i18n, 0: "annual_average",
90: "3_months_average".i18n, 90: "3_months_average",
30: "30_days_average".i18n, 30: "30_days_average",
14: "14_days_average".i18n, 14: "14_days_average",
7: "7_days_average".i18n, 7: "7_days_average",
}; };
class PremiumAverageSelector extends StatelessWidget { class PremiumAverageSelector extends StatefulWidget {
const PremiumAverageSelector({Key? key, this.onChanged, required this.value}) : super(key: key); const PremiumAverageSelector({Key? key, this.onChanged, required this.value}) : super(key: key);
final Function(int?)? onChanged; final Function(int?)? onChanged;
final int value; final int value;
@override
_PremiumAverageSelectorState createState() => _PremiumAverageSelectorState();
}
class _PremiumAverageSelectorState extends State<PremiumAverageSelector> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
List<DropdownMenuItem<int>> dropdownItems = avgDropItems.keys.map((item) {
return DropdownMenuItem<int>(
value: item,
child: Text(
avgDropItems[item]!.i18n,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: AppColors.of(context).text,
),
overflow: TextOverflow.ellipsis,
),
);
}).toList();
return DropdownButton2<int>( return DropdownButton2<int>(
items: avgDropItems.keys items: dropdownItems,
.map((item) => DropdownMenuItem<int>(
value: item,
child: Text(
avgDropItems[item] ?? "",
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: AppColors.of(context).text,
),
overflow: TextOverflow.ellipsis,
),
))
.toList(),
onChanged: (int? value) { onChanged: (int? value) {
if (Provider.of<PremiumProvider>(context, listen: false).hasScope(PremiumScopes.gradeStats)) { if (Provider.of<PremiumProvider>(context, listen: false).hasScope(PremiumScopes.gradeStats)) {
if (onChanged != null) onChanged!(value); if (widget.onChanged != null) {
setState(() {
widget.onChanged!(value);
});
}
} else { } else {
PremiumLockedFeatureUpsell.show(context: context, feature: PremiumFeature.gradestats); PremiumLockedFeatureUpsell.show(context: context, feature: PremiumFeature.gradestats);
} }
}, },
value: value, value: widget.value,
iconSize: 14, iconSize: 14,
iconEnabledColor: AppColors.of(context).text, iconEnabledColor: AppColors.of(context).text,
iconDisabledColor: AppColors.of(context).text, iconDisabledColor: AppColors.of(context).text,
@@ -71,11 +82,13 @@ class PremiumAverageSelector extends StatelessWidget {
height: 30, height: 30,
child: Row( child: Row(
children: [ children: [
Text(avgDropItems[value] ?? "", Text(
style: Theme.of(context) avgDropItems[widget.value]!.i18n,
.textTheme style: Theme.of(context)
.titleSmall! .textTheme
.copyWith(fontWeight: FontWeight.w600, color: AppColors.of(context).text.withOpacity(0.65))), .titleSmall!
.copyWith(fontWeight: FontWeight.w600, color: AppColors.of(context).text.withOpacity(0.65)),
),
const SizedBox( const SizedBox(
width: 4, width: 4,
), ),

View File

@@ -27,7 +27,6 @@ class _PremiumFSTimetableState extends State<PremiumFSTimetable> {
SystemChrome.setPreferredOrientations([ SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]); ]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
@@ -51,10 +50,6 @@ class _PremiumFSTimetableState extends State<PremiumFSTimetable> {
(a, b) => math.max( (a, b) => math.max(
a, b.where((l) => l.subject.id != "" || l.isEmpty).length)); a, b.where((l) => l.subject.id != "" || l.isEmpty).length));
final int minIndex = int.tryParse(everyLesson.first.lessonIndex) ?? 0;
final int maxIndex =
int.tryParse(everyLesson.last.lessonIndex) ?? maxLessonCount;
const prefixw = 40; const prefixw = 40;
const padding = prefixw + 6 * 2; const padding = prefixw + 6 * 2;
final colw = (MediaQuery.of(context).size.width - padding) / days.length; final colw = (MediaQuery.of(context).size.width - padding) / days.length;
@@ -68,26 +63,19 @@ class _PremiumFSTimetableState extends State<PremiumFSTimetable> {
body: ListView.builder( body: ListView.builder(
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 24.0), padding: const EdgeInsets.symmetric(horizontal: 6.0, vertical: 24.0),
itemCount: maxIndex + 1, itemCount: maxLessonCount + 1,
itemBuilder: (context, index) { itemBuilder: (context, index) {
List<Widget> columns = []; List<Widget> columns = [];
for (int dayIndex = -1; dayIndex < days.length; dayIndex++) { for (int dayIndex = -1; dayIndex < days.length; dayIndex++) {
final dayOffset = dayIndex == -1
? 0
: (int.tryParse(days[dayIndex].first.lessonIndex) ?? 0) -
minIndex;
final lessonIndex = index - 1;
if (dayIndex == -1) { if (dayIndex == -1) {
if (lessonIndex >= 0) { if (index >= 1) {
columns.add(SizedBox( columns.add(SizedBox(
width: prefixw.toDouble(), width: prefixw.toDouble(),
height: 40.0, height: 40.0,
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Text( child: Text(
"${minIndex + lessonIndex}.", (index).toString()+".",
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.secondary), color: Theme.of(context).colorScheme.secondary),
@@ -105,104 +93,112 @@ class _PremiumFSTimetableState extends State<PremiumFSTimetable> {
.toList(); .toList();
if (lessons.isEmpty) continue; if (lessons.isEmpty) continue;
if (lessonIndex >= lessons.length) continue;
if (dayIndex >= days.length || final dayOffset = int.tryParse(lessons.first.lessonIndex) ?? 0;
(lessonIndex + dayOffset) >= lessons.length) {
columns.add(SizedBox(width: colw)); if (index == 0 && dayIndex >= 0) {
columns.add(
SizedBox(
width: colw,
height: 40.0,
child: Text(
DateFormat("EEEE", I18n.of(context).locale.languageCode)
.format(lessons.first.date)
.capital(),
style: const TextStyle(
fontSize: 24.0,
fontWeight: FontWeight.bold,
),
),
),
);
continue; continue;
} }
if (lessonIndex == -1 && dayIndex >= 0) { final lessonIndex = index - dayOffset;
columns.add(SizedBox(
width: colw, if (lessonIndex < 0 || lessonIndex >= lessons.length) {
height: 40.0, columns.add(SizedBox(width: colw));
child: Text(
DateFormat("EEEE", I18n.of(context).locale.languageCode)
.format(lessons.first.date)
.capital(),
style: const TextStyle(
fontSize: 24.0, fontWeight: FontWeight.bold),
),
));
continue; continue;
} }
if (lessons[lessonIndex].isEmpty) { if (lessons[lessonIndex].isEmpty) {
columns.add(SizedBox( columns.add(
width: colw, SizedBox(
child: Row( width: colw,
crossAxisAlignment: CrossAxisAlignment.start, child: Row(
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Icon(FeatherIcons.slash,
size: 18.0,
color: AppColors.of(context).text.withOpacity(.3)),
const SizedBox(width: 8.0),
Text(
"Lyukas óra",
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.3)),
),
],
),
));
continue;
}
if (dayOffset > 0 && lessonIndex < dayOffset) {
columns.add(SizedBox(width: colw));
continue;
}
columns.add(SizedBox(
width: colw,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [ children: [
Icon( Icon(
SubjectIcon.resolveVariant( FeatherIcons.slash,
context: context,
subject: lessons[lessonIndex - dayOffset].subject),
size: 18.0, size: 18.0,
color: AppColors.of(context).text.withOpacity(.7), color: AppColors.of(context).text.withOpacity(.3),
), ),
const SizedBox(width: 8.0), const SizedBox(width: 8.0),
Expanded( Text(
child: Text( "Lyukas óra",
lessons[lessonIndex - dayOffset].subject.renamedTo ?? style: TextStyle(
lessons[lessonIndex - dayOffset] color: AppColors.of(context).text.withOpacity(.3),
.subject ),
.name ),
.capital(), ],
maxLines: 1, ),
style: TextStyle( ),
fontStyle: lessons[lessonIndex - dayOffset] );
continue;
}
columns.add(
SizedBox(
width: colw,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
SubjectIcon.resolveVariant(
context: context,
subject: lessons[lessonIndex].subject,
),
size: 18.0,
color: AppColors.of(context).text.withOpacity(.7),
),
const SizedBox(width: 8.0),
Expanded(
child: Text(
lessons[lessonIndex].subject.renamedTo ??
lessons[lessonIndex].subject.name.capital(),
maxLines: 1,
style: TextStyle(
fontStyle: lessons[lessonIndex]
.subject .subject
.isRenamed .isRenamed
? FontStyle.italic ? FontStyle.italic
: null), : null,
overflow: TextOverflow.clip, ),
softWrap: false, overflow: TextOverflow.clip,
softWrap: false,
),
),
const SizedBox(width: 15),
],
),
Padding(
padding: const EdgeInsets.only(left: 26.0),
child: Text(
lessons[lessonIndex].room,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.5),
overflow: TextOverflow.ellipsis,
), ),
), ),
const SizedBox(width: 15),
],
),
Padding(
padding: const EdgeInsets.only(left: 26.0),
child: Text(
lessons[lessonIndex - dayOffset].room,
style: TextStyle(
color: AppColors.of(context).text.withOpacity(.5),
overflow: TextOverflow.ellipsis),
), ),
), ],
], ),
), ),
)); );
} }
return Row( return Row(