From aa2c40985d294a2c564dc3bdefb2210742c47037 Mon Sep 17 00:00:00 2001 From: Evan Song Date: Tue, 18 Apr 2023 15:01:48 +0900 Subject: [PATCH 1/7] fix: lint issue and remove lint-baseline --- .../android/lint-baseline.xml | 202 ------------------ .../googlemaps/GoogleMapController.java | 6 +- .../plugins/googlemaps/GoogleMapFactory.java | 5 +- .../plugins/googlemaps/GoogleMapsPlugin.java | 14 +- .../googlemaps/TileProviderController.java | 6 +- .../example/lib/scrolling_map.dart | 4 +- 6 files changed, 19 insertions(+), 218 deletions(-) delete mode 100644 packages/google_maps_flutter/google_maps_flutter_android/android/lint-baseline.xml diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/lint-baseline.xml b/packages/google_maps_flutter/google_maps_flutter_android/android/lint-baseline.xml deleted file mode 100644 index 092b2d57e77..00000000000 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/lint-baseline.xml +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java index a57cd1a34c9..ad654e2ad32 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java @@ -60,7 +60,7 @@ final class GoogleMapController private final int id; private final MethodChannel methodChannel; private final GoogleMapOptions options; - @Nullable private MapView mapView; + @Nullable MapView mapView; @Nullable private GoogleMap googleMap; private boolean trackCameraPosition = false; private boolean myLocationEnabled = false; @@ -135,7 +135,7 @@ private CameraPosition getCameraPosition() { return trackCameraPosition ? googleMap.getCameraPosition() : null; } - private boolean loadedCallbackPending = false; + boolean loadedCallbackPending = false; /** * Invalidates the map view after the map has finished rendering. @@ -176,7 +176,7 @@ public void onMapLoaded() { }); } - private static void postFrameCallback(Runnable f) { + public static void postFrameCallback(Runnable f) { Choreographer.getInstance() .postFrameCallback( new Choreographer.FrameCallback() { diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java index ffa2412f9c4..f7bf1f9d7ac 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java @@ -5,6 +5,8 @@ package io.flutter.plugins.googlemaps; import android.content.Context; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.google.android.gms.maps.model.CameraPosition; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.StandardMessageCodec; @@ -30,7 +32,8 @@ public class GoogleMapFactory extends PlatformViewFactory { @SuppressWarnings("unchecked") @Override - public PlatformView create(Context context, int id, Object args) { + @NonNull + public PlatformView create(@NonNull Context context, int id, @Nullable Object args) { Map params = (Map) args; final GoogleMapBuilder builder = new GoogleMapBuilder(); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java index 20fc15e72b6..5d0a5ebdda8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java @@ -26,13 +26,13 @@ */ public class GoogleMapsPlugin implements FlutterPlugin, ActivityAware { - @Nullable private Lifecycle lifecycle; + @Nullable Lifecycle lifecycle; private static final String VIEW_TYPE = "plugins.flutter.dev/google_maps_android"; @SuppressWarnings("deprecation") public static void registerWith( - final io.flutter.plugin.common.PluginRegistry.Registrar registrar) { + @NonNull final io.flutter.plugin.common.PluginRegistry.Registrar registrar) { final Activity activity = registrar.activity(); if (activity == null) { // When a background flutter view tries to register the plugin, the registrar has no activity. @@ -70,7 +70,7 @@ public GoogleMapsPlugin() {} // FlutterPlugin @Override - public void onAttachedToEngine(FlutterPluginBinding binding) { + public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) { binding .getPlatformViewRegistry() .registerViewFactory( @@ -88,12 +88,12 @@ public Lifecycle getLifecycle() { } @Override - public void onDetachedFromEngine(FlutterPluginBinding binding) {} + public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {} // ActivityAware @Override - public void onAttachedToActivity(ActivityPluginBinding binding) { + public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) { lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding); } @@ -103,7 +103,7 @@ public void onDetachedFromActivity() { } @Override - public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) { + public void onReattachedToActivityForConfigChanges(@NonNull ActivityPluginBinding binding) { onAttachedToActivity(binding); } @@ -124,7 +124,7 @@ private static final class ProxyLifecycleProvider private final LifecycleRegistry lifecycle = new LifecycleRegistry(this); private final int registrarActivityHashCode; - private ProxyLifecycleProvider(Activity activity) { + ProxyLifecycleProvider(Activity activity) { this.registrarActivityHashCode = activity.hashCode(); activity.getApplication().registerActivityLifecycleCallbacks(this); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/TileProviderController.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/TileProviderController.java index 73530d1b515..aaf5206395c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/TileProviderController.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/TileProviderController.java @@ -18,9 +18,9 @@ class TileProviderController implements TileProvider { private static final String TAG = "TileProviderController"; - private final String tileOverlayId; - private final MethodChannel methodChannel; - private final Handler handler = new Handler(Looper.getMainLooper()); + final String tileOverlayId; + final MethodChannel methodChannel; + final Handler handler = new Handler(Looper.getMainLooper()); TileProviderController(MethodChannel methodChannel, String tileOverlayId) { this.tileOverlayId = tileOverlayId; diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart index a4901f2ce5f..53619992acd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart @@ -95,8 +95,8 @@ class ScrollingMapBody extends StatelessWidget { ), ), }, - gestureRecognizers: >{ + gestureRecognizers: < + Factory>{ Factory( () => ScaleGestureRecognizer(), ), From 56fb7f0e9fe5ef97d663482b4cab87af1f56f0bb Mon Sep 17 00:00:00 2001 From: Evan Song Date: Tue, 18 Apr 2023 15:02:09 +0900 Subject: [PATCH 2/7] bump up version to 2.4.11 --- .../google_maps_flutter_android/CHANGELOG.md | 4 ++++ .../google_maps_flutter_android/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md index c16464fb4e6..5bf28ea321b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.4.11 + +* Fixes Java warnings. + ## 2.4.10 * Bump RoboElectric dependency to 4.4.1 to support AndroidX. diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml index 6ae316db6b6..4b9315bae22 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_android description: Android implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.4.10 +version: 2.4.11 environment: sdk: ">=2.17.0 <4.0.0" From 4e4c2585f0d92afeb936ec5e6fd0b06270a80681 Mon Sep 17 00:00:00 2001 From: Evan Song Date: Wed, 19 Apr 2023 10:26:51 +0900 Subject: [PATCH 3/7] fix: remove unnecessary line changes --- .../example/lib/scrolling_map.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart index 53619992acd..a4901f2ce5f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart @@ -95,8 +95,8 @@ class ScrollingMapBody extends StatelessWidget { ), ), }, - gestureRecognizers: < - Factory>{ + gestureRecognizers: >{ Factory( () => ScaleGestureRecognizer(), ), From 241ff6ff7b5fdd272e0f72b497c5aedfa395154f Mon Sep 17 00:00:00 2001 From: Evan Song Date: Wed, 19 Apr 2023 10:30:07 +0900 Subject: [PATCH 4/7] fix: remove baseline option from build.gradle --- .../google_maps_flutter_android/android/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/build.gradle b/packages/google_maps_flutter/google_maps_flutter_android/android/build.gradle index 61b79a90a37..5d3c5055aef 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/build.gradle +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/build.gradle @@ -32,7 +32,6 @@ android { checkAllWarnings true warningsAsErrors true disable 'AndroidGradlePluginVersion', 'InvalidPackage', 'GradleDependency' - baseline file("lint-baseline.xml") } dependencies { From 4cbbc06cd24f6d7077158fc5485a388a37d3c9d8 Mon Sep 17 00:00:00 2001 From: Evan Song Date: Tue, 25 Apr 2023 18:52:32 +0900 Subject: [PATCH 5/7] fix: apply private scope anonymous class `GoogleMap.OnMapLoadedCallback()` replace lambda expression. and resotred private scope --- .../googlemaps/GoogleMapController.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java index ad654e2ad32..84d9fa78230 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java @@ -60,7 +60,7 @@ final class GoogleMapController private final int id; private final MethodChannel methodChannel; private final GoogleMapOptions options; - @Nullable MapView mapView; + @Nullable private MapView mapView; @Nullable private GoogleMap googleMap; private boolean trackCameraPosition = false; private boolean myLocationEnabled = false; @@ -135,7 +135,7 @@ private CameraPosition getCameraPosition() { return trackCameraPosition ? googleMap.getCameraPosition() : null; } - boolean loadedCallbackPending = false; + private boolean loadedCallbackPending = false; /** * Invalidates the map view after the map has finished rendering. @@ -159,24 +159,21 @@ private void invalidateMapIfNeeded() { } loadedCallbackPending = true; googleMap.setOnMapLoadedCallback( - new GoogleMap.OnMapLoadedCallback() { - @Override - public void onMapLoaded() { - loadedCallbackPending = false; - postFrameCallback( - () -> { - postFrameCallback( - () -> { - if (mapView != null) { - mapView.invalidate(); - } - }); - }); - } + () -> { + loadedCallbackPending = false; + postFrameCallback( + () -> { + postFrameCallback( + () -> { + if (mapView != null) { + mapView.invalidate(); + } + }); + }); }); } - public static void postFrameCallback(Runnable f) { + private static void postFrameCallback(Runnable f) { Choreographer.getInstance() .postFrameCallback( new Choreographer.FrameCallback() { From 496560e669b1ee1f1949403f89ddf2d2bff20d61 Mon Sep 17 00:00:00 2001 From: Evan Song Date: Tue, 25 Apr 2023 18:57:20 +0900 Subject: [PATCH 6/7] fix: apply protected scope --- .../flutter/plugins/googlemaps/TileProviderController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/TileProviderController.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/TileProviderController.java index aaf5206395c..d1e89c3b94c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/TileProviderController.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/TileProviderController.java @@ -18,9 +18,9 @@ class TileProviderController implements TileProvider { private static final String TAG = "TileProviderController"; - final String tileOverlayId; - final MethodChannel methodChannel; - final Handler handler = new Handler(Looper.getMainLooper()); + protected final String tileOverlayId; + protected final MethodChannel methodChannel; + protected final Handler handler = new Handler(Looper.getMainLooper()); TileProviderController(MethodChannel methodChannel, String tileOverlayId) { this.tileOverlayId = tileOverlayId; From d9a0c49be7b03003c360f59a401a9f724ff5d91a Mon Sep 17 00:00:00 2001 From: Evan Song Date: Wed, 26 Apr 2023 01:08:41 +0900 Subject: [PATCH 7/7] bump version resolve conflict --- .../google_maps_flutter_android/CHANGELOG.md | 4 ++++ .../google_maps_flutter_android/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md index 5284648c8e7..0e91f2df16a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.4.12 + +* Fixes Java warnings. + ## 2.4.11 * Adds a namespace for compatibility with AGP 8.0. diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml index 4b9315bae22..03914708dcf 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_android description: Android implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.4.11 +version: 2.4.12 environment: sdk: ">=2.17.0 <4.0.0"