Skip to content

Commit 2e9c094

Browse files
Android updates (#1641)
* Android updates * Format Android * fixed analyzer issues * update * update * update settings * change java version form 11 to 17 * update * update * cleanup * cleanup * cleanup * Update build.gradle * Update build.gradle * update * update * Update CHANGELOG.md * Update build.gradle * Update build.gradle * update * reverts breaking changes when you use Flutter 3.27.0 * updated build script * Temporary omit deprecation warnings.
1 parent 37d4d85 commit 2e9c094

File tree

13 files changed

+51
-36
lines changed

13 files changed

+51
-36
lines changed

.github/workflows/geolocator_android.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- uses: actions/setup-java@v4
3838
with:
3939
distribution: 'temurin'
40-
java-version: '11'
40+
java-version: '17'
4141

4242
# Make sure the stable version of Flutter is available
4343
- uses: subosito/flutter-action@v2

geolocator_android/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 4.6.2
2+
3+
* Updates compileSDKVersion to 35
4+
* Updates Fixed warnings in Android package and Android example project
5+
* Updates gradle version
6+
* Updates com.android.application version to 8.7.0
7+
18
## 4.6.1
29

310
* Fixes a bug where the plugin throws an exception while requesting locations updates with coarse location permission only.

geolocator_android/android/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:7.4.2'
11+
classpath 'com.android.tools.build:gradle:8.0.2'
1212
}
1313
}
1414

@@ -26,10 +26,10 @@ android {
2626
namespace("com.baseflow.geolocator")
2727
}
2828

29-
compileSdk 34
29+
compileSdk flutter.compileSdkVersion
3030

3131
defaultConfig {
32-
minSdkVersion 16
32+
minSdkVersion flutter.minSdkVersion
3333
}
3434
lintOptions {
3535
disable 'InvalidPackage'

geolocator_android/example/android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ android {
3232
compileSdkVersion flutter.compileSdkVersion
3333

3434
compileOptions {
35-
sourceCompatibility JavaVersion.VERSION_1_8
36-
targetCompatibility JavaVersion.VERSION_1_8
35+
sourceCompatibility JavaVersion.VERSION_17
36+
targetCompatibility JavaVersion.VERSION_17
3737
}
3838

3939
lintOptions {

geolocator_android/example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
7+

geolocator_android/example/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pluginManagement {
1818

1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
21-
id "com.android.application" version "7.4.2" apply false
21+
id "com.android.application" version "8.7.0" apply false
2222
}
2323

2424
include ":app"

geolocator_android/example/lib/main.dart

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,21 @@ void main() {
1717

1818
/// Example [Widget] showing the functionalities of the geolocator plugin.
1919
class GeolocatorWidget extends StatefulWidget {
20-
/// Creates a new GeolocatorWidget.
21-
const GeolocatorWidget({Key? key}) : super(key: key);
20+
/// Creates a [PermissionHandlerWidget].
21+
const GeolocatorWidget({
22+
super.key,
23+
});
2224

23-
/// Utility method to create a page with the Baseflow templating.
25+
/// Create a page containing the functionality of this plugin
2426
static ExamplePage createPage() {
2527
return ExamplePage(
2628
Icons.location_on, (context) => const GeolocatorWidget());
2729
}
2830

2931
@override
30-
_GeolocatorWidgetState createState() => _GeolocatorWidgetState();
32+
State<GeolocatorWidget> createState() {
33+
return _GeolocatorWidgetState();
34+
}
3135
}
3236

3337
class _GeolocatorWidgetState extends State<GeolocatorWidget> {
@@ -75,26 +79,26 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
7579
},
7680
itemBuilder: (context) => [
7781
const PopupMenuItem(
78-
child: Text("Get Location Accuracy"),
7982
value: 1,
83+
child: Text("Get Location Accuracy"),
8084
),
8185
if (Platform.isIOS)
8286
const PopupMenuItem(
83-
child: Text("Request Temporary Full Accuracy"),
8487
value: 2,
88+
child: Text("Request Temporary Full Accuracy"),
8589
),
8690
const PopupMenuItem(
87-
child: Text("Open App Settings"),
8891
value: 3,
92+
child: Text("Open App Settings"),
8993
),
9094
if (Platform.isAndroid)
9195
const PopupMenuItem(
92-
child: Text("Open Location Settings"),
9396
value: 4,
97+
child: Text("Open Location Settings"),
9498
),
9599
const PopupMenuItem(
96-
child: Text("Clear"),
97100
value: 5,
101+
child: Text("Clear"),
98102
),
99103
],
100104
);
@@ -150,27 +154,27 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
150154
mainAxisAlignment: MainAxisAlignment.end,
151155
children: [
152156
FloatingActionButton(
153-
child: (_positionStreamSubscription == null ||
154-
_positionStreamSubscription!.isPaused)
155-
? const Icon(Icons.play_arrow)
156-
: const Icon(Icons.pause),
157157
onPressed: _toggleListening,
158158
tooltip: (_positionStreamSubscription == null)
159159
? 'Start position updates'
160160
: _positionStreamSubscription!.isPaused
161161
? 'Resume'
162162
: 'Pause',
163163
backgroundColor: _determineButtonColor(),
164+
child: (_positionStreamSubscription == null ||
165+
_positionStreamSubscription!.isPaused)
166+
? const Icon(Icons.play_arrow)
167+
: const Icon(Icons.pause),
164168
),
165169
sizedBox,
166170
FloatingActionButton(
167-
child: const Icon(Icons.my_location),
168171
onPressed: _getCurrentPosition,
172+
child: const Icon(Icons.my_location),
169173
),
170174
sizedBox,
171175
FloatingActionButton(
172-
child: const Icon(Icons.bookmark),
173176
onPressed: _getLastKnownPosition,
177+
child: const Icon(Icons.bookmark),
174178
),
175179
],
176180
),

geolocator_android/example/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ description: Demonstrates how to use the geolocator_android plugin.
66
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
77

88
environment:
9-
sdk: ">=2.15.0 <3.0.0"
9+
sdk: ^3.5.0
1010

1111
dependencies:
1212
baseflow_plugin_template: ^2.1.2
1313
flutter:
1414
sdk: flutter
15+
geolocator_platform_interface: ^4.2.4
1516

1617
geolocator_android:
1718
# When depending on this package from a real application you should use:

geolocator_android/lib/src/types/android_position.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: use_super_parameters
2+
13
import 'package:geolocator_platform_interface/geolocator_platform_interface.dart';
24
// ignore: depend_on_referenced_packages
35
import 'package:meta/meta.dart';
@@ -21,7 +23,7 @@ class AndroidPosition extends Position {
2123
required headingAccuracy,
2224
required speed,
2325
required speedAccuracy,
24-
int? floor,
26+
super.floor,
2527
isMocked = false,
2628
}) : super(
2729
longitude: longitude,
@@ -34,7 +36,6 @@ class AndroidPosition extends Position {
3436
headingAccuracy: headingAccuracy,
3537
speed: speed,
3638
speedAccuracy: speedAccuracy,
37-
floor: floor,
3839
isMocked: isMocked,
3940
);
4041

geolocator_android/lib/src/types/android_settings.dart

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ class AndroidSettings extends LocationSettings {
1111
/// - forceLocationManager: false
1212
AndroidSettings({
1313
this.forceLocationManager = false,
14-
LocationAccuracy accuracy = LocationAccuracy.best,
15-
int distanceFilter = 0,
14+
super.accuracy,
15+
super.distanceFilter,
1616
this.intervalDuration,
17-
Duration? timeLimit,
17+
super.timeLimit,
1818
this.foregroundNotificationConfig,
1919
this.useMSLAltitude = false,
20-
}) : super(
21-
accuracy: accuracy,
22-
distanceFilter: distanceFilter,
23-
timeLimit: timeLimit);
20+
});
2421

2522
/// Forces the Geolocator plugin to use the legacy LocationManager instead of
2623
/// the FusedLocationProviderClient (Android only).

geolocator_android/lib/src/types/foreground_settings.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ class ForegroundNotificationConfig {
119119
'notificationText': notificationText,
120120
'notificationChannelName': notificationChannelName,
121121
'setOngoing': setOngoing,
122+
// Temporary ignored for release 4.6.1 (remove in future versions)
123+
// ignore: deprecated_member_use
122124
'color': color?.value,
123125
};
124126
}

geolocator_android/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: geolocator_android
22
description: Geolocation plugin for Flutter. This plugin provides the Android implementation for the geolocator.
33
repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_android
44
issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen
5-
version: 4.6.1
5+
version: 4.6.2
66

77
environment:
8-
sdk: ">=2.15.0 <4.0.0"
9-
flutter: ">=2.8.0"
8+
sdk: ^3.5.0
9+
flutter: ">=2.17.0"
1010

1111
flutter:
1212
plugin:

geolocator_android/test/geolocator_android_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,8 @@ void main() {
15111511
);
15121512
expect(
15131513
jsonMap['foregroundNotificationConfig']['color'],
1514+
// Temporary ignored for release 4.6.1 (remove in future versions)
1515+
// ignore: deprecated_member_use
15141516
settings.foregroundNotificationConfig!.color!.value,
15151517
);
15161518
});

0 commit comments

Comments
 (0)