[READ-ONLY] Mirror of https://github.com/probablykasper/notifier. Android app for scheduling notifications
android app flutter notifications
0

Configure Feed

Select the types of activity you want to include in your feed.

Logging changes

Kasper (Jul 9, 2019, 6:54 PM +0200) c325fc28 0dc6f3d4

+22 -30
+18 -19
lib/models/list.dart
··· 11 11 12 12 // This "Headless Task" is run when app is terminated. 13 13 void backgroundFetchHeadlessTask() async { 14 - print('[BackgroundFetch] Headless event received.'); 14 + print('[notifier] BackgroundFetch: headless event received.'); 15 15 BackgroundFetch.finish(); 16 16 } 17 17 ··· 48 48 } 49 49 50 50 checkForDisabledNotifications() async { 51 - print('Starting checkForDisabledNotifications()'); 51 + print('[notifier] ListModel checkForDisabledNotifications()'); 52 52 Timer.periodic( 53 53 Duration(milliseconds: 500), 54 54 (timer) { ··· 59 59 notificationItem['status'] = 'disabled'; 60 60 notificationItem['willDisable'] = false; 61 61 changedWereMade = true; 62 + print( 63 + "[notifier] ListModel checkForDisabledNotifications(): Disabling $id ('${notificationItem['title']}') due to it having fired ", 64 + ); 62 65 } 63 66 } 64 67 }); 65 68 if (changedWereMade) { 66 - print('changedWereMade'); 67 69 _save(); 68 70 rebuild(); 69 71 } ··· 72 74 } 73 75 74 76 _load({bool checkForDisabledNotifications: false}) async { 75 - print('[notifier] listModel _load()'); 77 + print('[notifier] ListModel _load()'); 76 78 SharedPreferences prefs = await SharedPreferences.getInstance(); 77 79 String notificationItems = prefs.getString('notificationItems') ?? '{}'; 78 80 _notificationItems = json.decode(notificationItems); ··· 82 84 // BackgroundFetch.registerHeadlessTask(backgroundFetchHeadlessTask); 83 85 configureBackgroundFetch(); 84 86 85 - print('[notifier] ListModel _load'); 86 87 notifyListeners(); 87 88 if (checkForDisabledNotifications) this.checkForDisabledNotifications(); 88 89 rebuild(); ··· 103 104 startOnBoot: true, 104 105 ), () async { 105 106 // This is the fetch-event callback. 106 - print('[BackgroundFetch] Event received'); 107 + print('[notifier] BackgroundFetch: Event received'); 107 108 108 109 SharedPreferences prefs = await SharedPreferences.getInstance(); 109 110 await prefs.setInt('lastBackgroundFetchDate', DateTime.now().millisecondsSinceEpoch); ··· 113 114 // for taking too long in the background. 114 115 BackgroundFetch.finish(); 115 116 }).then((int status) { 116 - print('[BackgroundFetch] SUCCESS: $status'); 117 + print('[notifier] BackgroundFetch: SUCCESS - Status: $status'); 117 118 }).catchError((e) { 118 - print('[BackgroundFetch] ERROR: $e'); 119 + print('[notifier] BackgroundFetch: ERROR: $e'); 119 120 }); 120 121 } 121 122 ··· 127 128 if (repeat == 'daily') { 128 129 newDay += repeatEvery; 129 130 } else if (repeat == 'weekly') { 130 - print('111'); 131 131 132 132 // get the zero-based weekday of date 133 133 int dateWeekday = date.weekday - 1; ··· 183 183 } 184 184 185 185 setNotifications({@required bool appIsOpen}) async { 186 - print('[notifier] _setNotifications'); 186 + print('[notifier] setNotifications()'); 187 187 188 188 var androidPlatformChannelSpecifics = AndroidNotificationDetails( 189 189 'scheduled_notifications', ··· 211 211 else 212 212 return null; 213 213 }).toList(); 214 - print('[notifier] ${pendingNotificationItemIds.length} items are currently scheduled:'); 215 - print('[notifier] $pendingNotificationItemIds'); 214 + print('[notifier] ListModel setNotifications(): ${pendingNotificationItemIds.length} items are currently scheduled: $pendingNotificationItemIds'); 216 215 _notificationItems.forEach((id, notificationItem) { 217 216 int next48h = DateTime.now().add(Duration(hours: 48)).millisecondsSinceEpoch; 218 217 if (!pendingNotificationItemIds.contains(notificationItem['id']) && ··· 257 256 platformChannelSpecifics, 258 257 ); 259 258 print( 260 - "[notifier] notification $id-$oneDigitFiredCount ('${notificationItem['title']}') has been scheduled for $date. Next date: $nextDate"); 259 + "[notifier] ListModel setNotifications(): notification $id-$oneDigitFiredCount ('${notificationItem['title']}') has been scheduled for $date. Next date: $nextDate"); 261 260 262 261 if (notificationItem['repeat'] == 'never') { 263 262 notificationItem['willDisable'] = true; ··· 269 268 } 270 269 271 270 _save() async { 271 + print('[notifier] ListModel _save()'); 272 272 SharedPreferences prefs = await SharedPreferences.getInstance(); 273 273 await prefs.setString('notificationItems', json.encode(_notificationItems)); 274 - print('[notifier] ListModel _save'); 275 274 } 276 275 277 276 Future<String> _generateId() async { ··· 288 287 _notificationItems[id] = notificationItem; 289 288 await _save(); 290 289 await setNotifications(appIsOpen: true); 291 - print('[notifier] ListModel add'); 290 + print('[notifier] ListModel add()'); 292 291 notifyListeners(); 293 292 } 294 293 295 294 delete(String id) async { 295 + print('[notifier] ListModel delete()'); 296 296 _notificationItems.remove(id); 297 297 298 298 List pastPendingNotifications = ··· 301 301 List currentPendingNotifications = 302 302 await flutterLocalNotificationsPlugin.pendingNotificationRequests(); 303 303 print( 304 - '[notifier] Cancelled ${pastPendingNotifications.length - currentPendingNotifications.length} scheduled notifications'); 304 + '[notifier] ListModel delete(): Cancelled ${pastPendingNotifications.length - currentPendingNotifications.length} scheduled notifications'); 305 305 306 306 await _save(); 307 - print('[notifier] ListModel delete'); 308 307 notifyListeners(); 309 308 } 310 309 311 310 update({String id, dynamic notificationItem}) async { 311 + print('[notifier] ListModel update()'); 312 312 notificationItem['id'] = id; 313 313 notificationItem['status'] = 'enabled'; 314 314 _notificationItems[id] = notificationItem; ··· 319 319 List currentPendingNotifications = 320 320 await flutterLocalNotificationsPlugin.pendingNotificationRequests(); 321 321 print( 322 - '[notifier] Cancelled ${pastPendingNotifications.length - currentPendingNotifications.length} scheduled notifications'); 322 + '[notifier] ListModel update(): Cancelled ${pastPendingNotifications.length - currentPendingNotifications.length} scheduled notifications'); 323 323 324 324 await _save(); 325 325 await setNotifications(appIsOpen: true); 326 326 rebuild(); 327 - print('[notifier] ListModel update'); 328 327 notifyListeners(); 329 328 } 330 329 }
+1 -6
lib/models/theme_model.dart
··· 3 3 import 'package:shared_preferences/shared_preferences.dart'; 4 4 5 5 SharedPreferences prefs; 6 - // loadPrefs() async { 7 - // prefs = await SharedPreferences.getInstance(); 8 - // print('prefs loaded'); 9 - // } 10 6 11 7 class ThemeModel extends Model { 12 8 bool _darkMode = true; ··· 50 46 51 47 static loadPrefs() async { 52 48 prefs = await SharedPreferences.getInstance(); 53 - print('prefs loaded'); 54 49 } 55 50 56 51 ThemeModel() { ··· 66 61 67 62 void _setDarkMode({bool darkMode}) { 68 63 _darkMode = darkMode; 69 - print('[notifier] darkMode set to $darkMode'); 64 + print('[notifier] ThemeModel _setDarkMode() to $darkMode'); 70 65 71 66 color = darkMode ? grey : white; 72 67 textColor = darkMode ? Colors.white : Colors.black;
+1 -2
lib/views/list.dart
··· 64 64 class List extends StatelessWidget { 65 65 @override 66 66 Widget build(BuildContext context) { 67 - print('[notifier] Building list ScopedModel'); 68 67 final themeModel = ScopedModel.of<ThemeModel>(context); 69 68 return ScopedModel<ListModel>( 70 69 model: listModel, 71 70 child: ScopedModelDescendant<ListModel>( 72 71 builder: (context, child, listModel) { 73 - print('[notifier] Building list ScopedModelDescendant'); 72 + print('[notifier] Building list (ScopedModelDescendant)'); 74 73 return SliverList( 75 74 delegate: SliverChildListDelegate( 76 75 listModel.itemsAsList.map((item) {
+2 -3
lib/views/notification_dialog.dart
··· 97 97 Widget build(BuildContext context) { 98 98 final themeModel = ScopedModel.of<ThemeModel>(context); 99 99 bool titleHasChanged = false; 100 - print('[notifier] Building dialog ScopedModel'); 101 100 return ScopedModel<NotificationDialogModel>( 102 101 model: NotificationDialogModel(initialItem: initialItem), 103 102 child: ScopedModelDescendant<NotificationDialogModel>( 104 103 builder: (context, child, model) { 105 - print('[notifier] Building dialog ScopedModelDescendant'); 104 + print('[notifier] Building dialog (ScopedModelDescendant)'); 106 105 bool noWeekdaySelected() => 107 106 model.item['repeat'] == 'weekly' && !model.item['weekdays'].contains(true); 108 107 bool timeHasPassed() => model.item['date'] < DateTime.now().millisecondsSinceEpoch; ··· 338 337 value: value, 339 338 onChanged: (bool newValue) { 340 339 model.item['weekdays'][index] = newValue; 341 - print(model.item['weekdays']); 340 + print('[notifier] Updated selected weekdays: '+model.item['weekdays'].toString()); 342 341 model.rebuild(); 343 342 }, 344 343 ),