diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 8557b8b..150e027 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -9,7 +9,7 @@ on: env: flutter_channel: 'stable' - flutter_version: '3.22.2' + flutter_version: '3.27.1' jobs: build: @@ -29,5 +29,7 @@ jobs: distribution: 'zulu' - name: Install dependencies run: flutter pub get + - name: Run Flutter analysis + run: flutter analyze - name: Run tests run: flutter test \ No newline at end of file diff --git a/README.md b/README.md index 7a8a261..2a8783f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,6 @@ Android Badge - Download on the App Store + Download on the App Store - \ No newline at end of file + diff --git a/android/app/build.gradle b/android/app/build.gradle index 9ae8923..d2cbf02 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -34,12 +34,12 @@ android { ndkVersion flutter.ndkVersion compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } kotlinOptions { - jvmTarget = '17' + jvmTarget = "1.8" } sourceSets { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 6a4d0e3..4733f36 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -16,12 +16,6 @@ - - - - - - diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index e1ca574..8bc9958 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip diff --git a/android/settings.gradle b/android/settings.gradle index 6df3ae4..72f5760 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -22,7 +22,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.3.0" apply false + id "com.android.application" version "8.1.1" apply false } include ":app" diff --git a/lib/domain/controllers/dnd_controller.dart b/lib/domain/controllers/dnd_controller.dart index b4e62ea..afabe7d 100644 --- a/lib/domain/controllers/dnd_controller.dart +++ b/lib/domain/controllers/dnd_controller.dart @@ -1,4 +1,4 @@ -import 'package:flutter_dnd/flutter_dnd.dart'; +import 'package:do_not_disturb/do_not_disturb.dart'; import 'package:infinite_horizons/domain/controllers/controllers.dart'; import 'package:universal_io/io.dart'; @@ -18,4 +18,8 @@ abstract class DndController { Future isDnd(); Future disable(); + + Future isNotificationPolicyAccessGranted(); + + Future gotoPolicySettings(); } diff --git a/lib/domain/controllers/permissions_controller.dart b/lib/domain/controllers/permissions_controller.dart index 79ce7a4..ff074b6 100644 --- a/lib/domain/controllers/permissions_controller.dart +++ b/lib/domain/controllers/permissions_controller.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:awesome_notifications/awesome_notifications.dart'; import 'package:device_info_plus/device_info_plus.dart'; -import 'package:flutter_dnd/flutter_dnd.dart'; +import 'package:infinite_horizons/domain/controllers/controllers.dart'; import 'package:universal_io/io.dart'; part 'package:infinite_horizons/infrastructure/permissions_repository.dart'; diff --git a/lib/domain/controllers/vibration_controller.dart b/lib/domain/controllers/vibration_controller.dart index c9e5162..064abbd 100644 --- a/lib/domain/controllers/vibration_controller.dart +++ b/lib/domain/controllers/vibration_controller.dart @@ -1,5 +1,5 @@ -import 'package:flutter_vibrate/flutter_vibrate.dart'; import 'package:universal_io/io.dart'; +import 'package:vibration/vibration.dart'; part 'package:infinite_horizons/infrastructure/vibration_repository.dart'; diff --git a/lib/domain/objects/tip.dart b/lib/domain/objects/tip.dart index c686e30..a8c13dc 100644 --- a/lib/domain/objects/tip.dart +++ b/lib/domain/objects/tip.dart @@ -130,7 +130,7 @@ List tipsList = [ resourceLinks: [ Resource( 'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"', - "Go to Sleep to keep your sleep circle and brain in good state", + 'Go to Sleep to keep your sleep circle and brain in good state', link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'), ), ], @@ -211,7 +211,7 @@ List tipsList = [ resourceLinks: [ Resource( 'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"', - "Getting expose to sun in the first 30m-60m of the day going to facilitate focus, further release of dopamine and norepinephrine and healthy amounts of cortisol.", + 'Getting expose to sun in the first 30m-60m of the day going to facilitate focus, further release of dopamine and norepinephrine and healthy amounts of cortisol.', link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'), ), ], @@ -230,7 +230,7 @@ List tipsList = [ resourceLinks: [ Resource( 'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"', - "Work environment with strong light without hurting your eyes in the first 9 hours of wake to increase focus and for releasing dopamine, norepinephrine, and healthy amounts of cortisol", + 'Work environment with strong light without hurting your eyes in the first 9 hours of wake to increase focus and for releasing dopamine, norepinephrine, and healthy amounts of cortisol', link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'), ), ], @@ -249,7 +249,7 @@ List tipsList = [ resourceLinks: [ Resource( 'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"', - "After 9 hours of being awake your should reducing over the head light inorder to shift body production from dopamine and norepinephrine to serotonin and other neuromodulators.", + 'After 9 hours of being awake your should reducing over the head light inorder to shift body production from dopamine and norepinephrine to serotonin and other neuromodulators.', link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'), ), ], @@ -267,7 +267,7 @@ List tipsList = [ resourceLinks: [ Resource( 'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"', - "After 16 hours of being awake you should keep only the necessary light for the work, more than that will severely deplete your melatonin levels, going to severally shift your circadian clock like traveling to different time zone.", + 'After 16 hours of being awake you should keep only the necessary light for the work, more than that will severely deplete your melatonin levels, going to severally shift your circadian clock like traveling to different time zone.', link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'), ), ], @@ -311,7 +311,7 @@ List tipsList = [ resourceLinks: [ Resource( 'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"', - "In the first 9 hours after waking (around 8am-12pm) our brain enters state of high alertness and accurate thinking, which is good for working on analytical and accurate tasks.", + 'In the first 9 hours after waking (around 8am-12pm) our brain enters state of high alertness and accurate thinking, which is good for working on analytical and accurate tasks.', link: Uri.parse('https://www.youtube.com/watch?v=Ze2pc6NwsHQ'), ), ], diff --git a/lib/infrastructure/dnd_repository.dart b/lib/infrastructure/dnd_repository.dart index e4b0016..b45c2b3 100644 --- a/lib/infrastructure/dnd_repository.dart +++ b/lib/infrastructure/dnd_repository.dart @@ -1,8 +1,17 @@ part of 'package:infinite_horizons/domain/controllers/dnd_controller.dart'; class _DndRepository extends DndController { + // TODO: Switched packages for app to run, code not tested + late DoNotDisturbPlugin dnd; + @override - void init() => supported = Platform.isAndroid; + void init() { + supported = Platform.isAndroid; + if (!supported) { + return; + } + dnd = DoNotDisturbPlugin(); + } @override Future enable() async { @@ -13,9 +22,7 @@ class _DndRepository extends DndController { if (await PermissionsController.instance .isNotificationPolicyAccessGranted()) { // Turn on DND - All notifications are suppressed except priority. - await FlutterDnd.setInterruptionFilter( - FlutterDnd.INTERRUPTION_FILTER_PRIORITY, - ); + await dnd.setInterruptionFilter(InterruptionFilter.priority); } else { PermissionsController.instance.gotoPolicySettings(); } @@ -29,9 +36,7 @@ class _DndRepository extends DndController { if (await PermissionsController.instance .isNotificationPolicyAccessGranted()) { - await FlutterDnd.setInterruptionFilter( - FlutterDnd.INTERRUPTION_FILTER_ALL, - ); + await dnd.setInterruptionFilter(InterruptionFilter.all); } } @@ -41,7 +46,22 @@ class _DndRepository extends DndController { return false; } - return await FlutterDnd.getCurrentInterruptionFilter() == - FlutterDnd.INTERRUPTION_FILTER_PRIORITY; + return dnd.isDndEnabled(); + } + + @override + Future gotoPolicySettings() async { + if (!supported) { + return; + } + await dnd.openNotificationPolicyAccessSettings(); + } + + @override + Future isNotificationPolicyAccessGranted() async { + if (!supported) { + return false; + } + return dnd.isNotificationPolicyAccessGranted(); } } diff --git a/lib/infrastructure/notifications_repository.dart b/lib/infrastructure/notifications_repository.dart index 5cc1bea..e895273 100644 --- a/lib/infrastructure/notifications_repository.dart +++ b/lib/infrastructure/notifications_repository.dart @@ -86,25 +86,25 @@ class _NotificationsRepository extends NotificationsController { /// Use this method to detect when the user taps on a notification or action button /// Also capture when there is a message from firebase messaging - @pragma("vm:entry-point") + @pragma('vm:entry-point') static Future onActionReceivedMethod( ReceivedAction receivedAction, ) async {} /// Use this method to detect when a new notification or a schedule is created - @pragma("vm:entry-point") + @pragma('vm:entry-point') static Future onNotificationCreatedMethod( ReceivedNotification receivedNotification, ) async {} /// Use this method to detect every time that a new notification is displayed - @pragma("vm:entry-point") + @pragma('vm:entry-point') static Future onNotificationDisplayedMethod( ReceivedNotification receivedNotification, ) async {} /// Use this method to detect if the user dismissed a notification - @pragma("vm:entry-point") + @pragma('vm:entry-point') static Future onDismissActionReceivedMethod( ReceivedAction receivedAction, ) async {} diff --git a/lib/infrastructure/permissions_repository.dart b/lib/infrastructure/permissions_repository.dart index 396b117..e6f0b71 100644 --- a/lib/infrastructure/permissions_repository.dart +++ b/lib/infrastructure/permissions_repository.dart @@ -2,12 +2,11 @@ part of 'package:infinite_horizons/domain/controllers/permissions_controller.dar class _PermissionsRepository extends PermissionsController { @override - Future isNotificationPolicyAccessGranted() async => - Platform.isAndroid && - (await FlutterDnd.isNotificationPolicyAccessGranted ?? false); + Future isNotificationPolicyAccessGranted() => + DndController.instance.isNotificationPolicyAccessGranted(); @override - void gotoPolicySettings() => FlutterDnd.gotoPolicySettings(); + void gotoPolicySettings() => DndController.instance.gotoPolicySettings(); @override Future generalNotificationPermission() => diff --git a/lib/infrastructure/vibration_repository.dart b/lib/infrastructure/vibration_repository.dart index fea1362..9833ff5 100644 --- a/lib/infrastructure/vibration_repository.dart +++ b/lib/infrastructure/vibration_repository.dart @@ -1,6 +1,7 @@ part of 'package:infinite_horizons/domain/controllers/vibration_controller.dart'; class _VibrationRepository extends VibrationController { + // TODO: Switched packages for app to run, code not tested @override Future init() async => supported = Platform.isAndroid || Platform.isIOS; @@ -10,16 +11,14 @@ class _VibrationRepository extends VibrationController { return; } - FeedbackType feedbackType; + // TODO: Values are incorrect switch (type) { case VibrationType.light: - feedbackType = FeedbackType.success; + Vibration.vibrate(amplitude: 128); case VibrationType.medium: - feedbackType = FeedbackType.warning; + Vibration.vibrate(duration: 501); case VibrationType.heavy: - feedbackType = FeedbackType.error; + Vibration.vibrate(duration: 1000); } - - Vibrate.feedback(feedbackType); } } diff --git a/lib/main.dart b/lib/main.dart index 3f0c9d8..abd2934 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -27,7 +27,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - final TextTheme textTheme = createTextTheme(context, "Arya", "Arya"); + final TextTheme textTheme = createTextTheme(context, 'Arya', 'Arya'); final MaterialTheme theme = MaterialTheme(textTheme); return MaterialApp( diff --git a/lib/presentation/atoms/toggle_switch_atom.dart b/lib/presentation/atoms/toggle_switch_atom.dart index 587e16d..6afffa5 100644 --- a/lib/presentation/atoms/toggle_switch_atom.dart +++ b/lib/presentation/atoms/toggle_switch_atom.dart @@ -50,20 +50,21 @@ class _ToggleSwitchAtomState extends State { style: ToggleStyle( backgroundColor: toggle ? (widget.disable - ? colorScheme.onSurface.withOpacity(0.12) + ? colorScheme.onSurface.withAlpha((0.12 * 255).toInt()) : colorScheme.primary) : (widget.disable - ? colorScheme.surfaceContainerHighest.withOpacity(0.12) + ? colorScheme.surfaceContainerHighest + .withAlpha((0.12 * 255).toInt()) : colorScheme.surfaceContainerHighest), borderColor: widget.disable ? colorScheme.onSurface : (toggle ? colorScheme.primary : colorScheme.outline), indicatorColor: toggle ? (widget.disable - ? colorScheme.surface.withOpacity(1) + ? colorScheme.surface.withAlpha(1 * 255) : colorScheme.onPrimary) : (widget.disable - ? colorScheme.onSurface.withOpacity(0.38) + ? colorScheme.onSurface.withAlpha((0.38 * 255).toInt()) : colorScheme.outline), ), current: toggle, @@ -73,13 +74,14 @@ class _ToggleSwitchAtomState extends State { FaIcon( widget.offIcon, color: widget.disable - ? colorScheme.surfaceContainerHighest.withOpacity(0.38) + ? colorScheme.surfaceContainerHighest + .withAlpha((0.38 * 255).toInt()) : colorScheme.surfaceContainerHighest, ), FaIcon( widget.onIcon, color: widget.disable - ? colorScheme.onSurface.withOpacity(0.38) + ? colorScheme.onSurface.withAlpha((0.38 * 255).toInt()) : colorScheme.onPrimaryContainer, ), ], diff --git a/lib/presentation/molecules/pdf_viewer_molecule.dart b/lib/presentation/molecules/pdf_viewer_molecule.dart index 8a22217..d39e22f 100644 --- a/lib/presentation/molecules/pdf_viewer_molecule.dart +++ b/lib/presentation/molecules/pdf_viewer_molecule.dart @@ -47,7 +47,7 @@ class _PdfViewerMoleculeState extends State ); }, errorWidget: (error) => const Center( - child: TextAtom("error_pdf"), + child: TextAtom('error_pdf'), ), ); } diff --git a/lib/presentation/pages/activity_page.dart b/lib/presentation/pages/activity_page.dart index 5966486..71f324b 100644 --- a/lib/presentation/pages/activity_page.dart +++ b/lib/presentation/pages/activity_page.dart @@ -42,9 +42,10 @@ class _ActivityPageState extends State AppLifecycleState currentAppState = AppLifecycleState.resumed; Future notificationPermissionPopup() async { - final bool notificationPermissionRequested = PreferencesController.instance - .getBool(PreferenceKeys.notificationPermissionRequested) ?? - false; + // final bool notificationPermissionRequested = + PreferencesController.instance + .getBool(PreferenceKeys.notificationPermissionRequested); + // ?? false; final bool notificationGranted = await NotificationsController.instance.isPermissionGranted(); if ( diff --git a/lib/presentation/pages/tip_information_page.dart b/lib/presentation/pages/tip_information_page.dart index 09ca2ea..d50defb 100644 --- a/lib/presentation/pages/tip_information_page.dart +++ b/lib/presentation/pages/tip_information_page.dart @@ -146,7 +146,7 @@ class _TipInformationPageState extends State { if (link == null) { SnackBarService().show( context, - "no_link", + 'no_link', ); return; } diff --git a/lib/presentation/pages/tip_resources_page.dart b/lib/presentation/pages/tip_resources_page.dart index cb54297..1833375 100644 --- a/lib/presentation/pages/tip_resources_page.dart +++ b/lib/presentation/pages/tip_resources_page.dart @@ -12,9 +12,9 @@ class TipResourcePage extends StatelessWidget { @override Widget build(BuildContext context) { - if (url.endsWith(".pdf")) { + if (url.endsWith('.pdf')) { return PageEnclosureMolecule( - title: "resource", + title: 'resource', margin: false, topBarType: TopBarType.back, topBarRightOnTap: () => UrlLauncherController.instance.openUrl(url), @@ -24,13 +24,13 @@ class TipResourcePage extends StatelessWidget { url: url, ), ); - } else if (url.contains("youtube") || url.contains("youtu.be")) { + } else if (url.contains('youtube') || url.contains('youtu.be')) { return YoutubePlayerPage( url: url, ); } return PageEnclosureMolecule( - title: "resource", + title: 'resource', margin: false, topBarType: TopBarType.back, expendChild: false, diff --git a/pubspec.yaml b/pubspec.yaml index 4c6d05d..fdb73e2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -25,14 +25,13 @@ dependencies: custom_timer: ^0.2.3 device_info_plus: ^10.1.0 # Internationalization (Easy translations) + do_not_disturb: ^1.0.3 easy_localization: ^3.0.6 flutter: sdk: flutter flutter_cached_pdfview: ^0.4.2 - flutter_dnd: ^0.1.4+1 flutter_inappwebview: ^6.0.0 flutter_svg: ^2.0.10+1 - flutter_vibrate: ^1.3.0 # Font Awesome Icon pack available as Flutter Icons. font_awesome_flutter: ^10.7.0 google_fonts: ^6.2.1 @@ -52,7 +51,7 @@ dependencies: shared_preferences: ^2.2.3 universal_io: ^2.2.2 url_launcher: ^6.2.6 - vibration: ^1.8.4 + vibration: ^2.0.1 wakelock_plus: ^1.2.5 youtube_player_flutter: ^9.0.1 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index bfcd609..e6e13da 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -20,8 +19,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("AwesomeNotificationsPluginCApi")); AwesomeNotificationsCorePluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("AwesomeNotificationsCorePluginCApi")); - FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi")); PermissionHandlerWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); UrlLauncherWindowsRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 6497f48..4a0ea9c 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -6,7 +6,6 @@ list(APPEND FLUTTER_PLUGIN_LIST audioplayers_windows awesome_notifications awesome_notifications_core - flutter_inappwebview_windows permission_handler_windows url_launcher_windows )