Skip to content

Commit

Permalink
Merge pull request #531 from hpi-studyu/fix/main-hotfix-1123
Browse files Browse the repository at this point in the history
Fix: Hotfix for notification and Dashboard reload issues (main branch)
  • Loading branch information
johannesvedder authored Nov 29, 2023
2 parents fcd401e + 7d48088 commit 6cd8796
Show file tree
Hide file tree
Showing 22 changed files with 25,583 additions and 35,746 deletions.
15 changes: 15 additions & 0 deletions app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="health.studyu.app">

<!-- Begin flutter_local_notifications -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- End flutter_local_notifications -->

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

Expand Down Expand Up @@ -49,6 +53,17 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Begin flutter_local_notifications -->
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
</intent-filter>
</receiver>
<!-- End flutter_local_notifications -->
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
Expand Down
33 changes: 32 additions & 1 deletion app/lib/screens/study/dashboard/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,37 @@ class OverflowMenuItem {
OverflowMenuItem(this.name, this.icon, {this.routeName, this.onTap});
}

class _DashboardScreenState extends State<DashboardScreen> {
class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingObserver {
StudySubject? subject;
List<TaskInstance>? scheduleToday;

get showNextDay => (kDebugMode || context.read<AppState>().isPreview) && !subject!.completedStudy;

@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
case AppLifecycleState.resumed:
setState(() {
scheduleToday = subject!.scheduleFor(DateTime.now());
});
break;
case AppLifecycleState.inactive:
break;
case AppLifecycleState.paused:
break;
case AppLifecycleState.detached:
break;
case AppLifecycleState.hidden:
break;
}
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
Expand All @@ -57,6 +82,12 @@ class _DashboardScreenState extends State<DashboardScreen> {
}
}

@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

Future<bool> receivePermission() async {
return await Permission.ignoreBatteryOptimizations.request().isGranted;
}
Expand Down
296 changes: 148 additions & 148 deletions docs/uml/app/lib/screens/app_onboarding/uml.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6cd8796

Please sign in to comment.