From bbeb5d42563d25dfb6a0b02e702715e976519e5c Mon Sep 17 00:00:00 2001 From: Hesham Date: Mon, 27 Nov 2023 16:06:23 +0200 Subject: [PATCH] remove notification title --- geolocator_android/example/lib/main.dart | 6 +---- .../lib/src/types/foreground_settings.dart | 17 +++--------- .../test/geolocator_android_test.dart | 26 ++----------------- 3 files changed, 7 insertions(+), 42 deletions(-) diff --git a/geolocator_android/example/lib/main.dart b/geolocator_android/example/lib/main.dart index ced77bbd..cb5f4a22 100644 --- a/geolocator_android/example/lib/main.dart +++ b/geolocator_android/example/lib/main.dart @@ -298,12 +298,8 @@ class _GeolocatorWidgetState extends State { useMSLAltitude: true, foregroundNotificationConfig: const ForegroundNotificationConfig( // Explain to the user why we are showing this notification. - notificationText: - "Example app will continue to receive your location even when you aren't using it", - // Tell the user what we are doing. - notificationTitle: "Running in Background", // Keep the system awake to receive background location information. - enableWakeLock: false, + enableWakeLock: true, // Give the notification an amber color. color: Colors.amber, ), diff --git a/geolocator_android/lib/src/types/foreground_settings.dart b/geolocator_android/lib/src/types/foreground_settings.dart index 3ec3d392..94ab90cb 100644 --- a/geolocator_android/lib/src/types/foreground_settings.dart +++ b/geolocator_android/lib/src/types/foreground_settings.dart @@ -28,13 +28,13 @@ class AndroidResource { /// Configuration for the foreground notification. When this is provided the location service will run as a foreground service. class ForegroundNotificationConfig { /// The title used for the foreground service notification. - final String notificationTitle; + /// The body used for the foreground service notification. - final String notificationText; + /// The resource name of the icon to be used for the foreground notification. - final AndroidResource notificationIcon; + /// When enabled, a WifiLock is acquired when background execution is started. /// This allows the application to keep the Wi-Fi radio awake, even when the @@ -70,9 +70,7 @@ class ForegroundNotificationConfig { /// Creates an Android specific configuration for the [FlutterBackground] plugin. /// - /// [notificationTitle] is the title used for the foreground service - /// notification. - /// [notificationText] is the body used for the foreground service + /// notification. /// [notificationIcon] must be a drawable resource. /// E. g. if the icon with name "background_icon" is in the "drawable" @@ -89,10 +87,6 @@ class ForegroundNotificationConfig { /// persistent and the user cannot dismiss it. /// [color] is the accent color that is applied to the [notificationIcon]. const ForegroundNotificationConfig({ - required this.notificationTitle, - required this.notificationText, - this.notificationIcon = - const AndroidResource(name: 'ic_launcher', defType: 'mipmap'), this.enableWifiLock = false, this.enableWakeLock = false, this.setOngoing = false, @@ -104,9 +98,6 @@ class ForegroundNotificationConfig { return { 'enableWakeLock': enableWakeLock, 'enableWifiLock': enableWifiLock, - 'notificationTitle': notificationTitle, - 'notificationIcon': notificationIcon.toJson(), - 'notificationText': notificationText, 'setOngoing': setOngoing, 'color': color?.value, }; diff --git a/geolocator_android/test/geolocator_android_test.dart b/geolocator_android/test/geolocator_android_test.dart index 447401d1..37fb82c5 100644 --- a/geolocator_android/test/geolocator_android_test.dart +++ b/geolocator_android/test/geolocator_android_test.dart @@ -1442,14 +1442,8 @@ void main() { useMSLAltitude: false, foregroundNotificationConfig: const ForegroundNotificationConfig( color: Colors.amber, - enableWakeLock: false, + enableWakeLock: true, enableWifiLock: false, - notificationIcon: AndroidResource( - name: 'name', - defType: 'defType', - ), - notificationText: 'text', - notificationTitle: 'title', setOngoing: true, ), ); @@ -1486,23 +1480,7 @@ void main() { jsonMap['foregroundNotificationConfig']['enableWifiLock'], settings.foregroundNotificationConfig!.enableWifiLock, ); - expect( - jsonMap['foregroundNotificationConfig']['notificationIcon']['name'], - settings.foregroundNotificationConfig!.notificationIcon.name, - ); - expect( - jsonMap['foregroundNotificationConfig']['notificationIcon'] - ['defType'], - settings.foregroundNotificationConfig!.notificationIcon.defType, - ); - expect( - jsonMap['foregroundNotificationConfig']['notificationText'], - settings.foregroundNotificationConfig!.notificationText, - ); - expect( - jsonMap['foregroundNotificationConfig']['notificationTitle'], - settings.foregroundNotificationConfig!.notificationTitle, - ); + expect( jsonMap['foregroundNotificationConfig']['setOngoing'], settings.foregroundNotificationConfig!.setOngoing,