From 5e80090a35b523c8063b0235a357eb583fa880ae Mon Sep 17 00:00:00 2001 From: otopba Date: Sat, 6 Jul 2019 17:57:28 +0300 Subject: [PATCH 01/18] My location button and my location fixes --- packages/google_maps_flutter/example/lib/map_ui.dart | 2 +- .../google_maps_flutter/ios/Classes/GoogleMapController.m | 1 - packages/google_maps_flutter/test/google_map_test.dart | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/google_maps_flutter/example/lib/map_ui.dart b/packages/google_maps_flutter/example/lib/map_ui.dart index e3772478408c..99d85c8add40 100644 --- a/packages/google_maps_flutter/example/lib/map_ui.dart +++ b/packages/google_maps_flutter/example/lib/map_ui.dart @@ -178,7 +178,7 @@ class MapUiBodyState extends State { Widget _myLocationToggler() { return FlatButton( child: Text( - '${_myLocationButtonEnabled ? 'disable' : 'enable'} my location button'), + '${_myLocationEnabled ? 'disable' : 'enable'} my location'), onPressed: () { setState(() { _myLocationEnabled = !_myLocationEnabled; diff --git a/packages/google_maps_flutter/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/ios/Classes/GoogleMapController.m index a9058d1f2668..879a29eefaca 100644 --- a/packages/google_maps_flutter/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/ios/Classes/GoogleMapController.m @@ -317,7 +317,6 @@ - (void)setZoomGesturesEnabled:(BOOL)enabled { - (void)setMyLocationEnabled:(BOOL)enabled { _mapView.myLocationEnabled = enabled; - _mapView.settings.myLocationButton = enabled; } - (void)setMyLocationButtonEnabled:(BOOL)enabled { diff --git a/packages/google_maps_flutter/test/google_map_test.dart b/packages/google_maps_flutter/test/google_map_test.dart index 7ebebccc488b..01bfcc42c222 100644 --- a/packages/google_maps_flutter/test/google_map_test.dart +++ b/packages/google_maps_flutter/test/google_map_test.dart @@ -391,7 +391,7 @@ void main() { textDirection: TextDirection.ltr, child: GoogleMap( initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)), - myLocationEnabled: false, + myLocationButtonEnabled: false, ), ), ); @@ -399,19 +399,19 @@ void main() { final FakePlatformGoogleMap platformGoogleMap = fakePlatformViewsController.lastCreatedView; - expect(platformGoogleMap.myLocationButtonEnabled, true); + expect(platformGoogleMap.myLocationButtonEnabled, false); await tester.pumpWidget( const Directionality( textDirection: TextDirection.ltr, child: GoogleMap( initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)), - myLocationButtonEnabled: false, + myLocationButtonEnabled: true, ), ), ); - expect(platformGoogleMap.myLocationButtonEnabled, false); + expect(platformGoogleMap.myLocationButtonEnabled, true); }); testWidgets('Is default padding 0', (WidgetTester tester) async { From fe6327e468ae431940258ae7547865a1a62faccf Mon Sep 17 00:00:00 2001 From: otopba Date: Sat, 6 Jul 2019 17:59:15 +0300 Subject: [PATCH 02/18] Bump version --- packages/google_maps_flutter/CHANGELOG.md | 4 ++++ packages/google_maps_flutter/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md index 484226649e7e..d9eb1324cf9b 100644 --- a/packages/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.5.19+3 + +* Fix some confusions with my location and my location button + ## 0.5.19+2 * Fix polygons for iOS diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml index 11e70eaf34f6..154934bd338f 100644 --- a/packages/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter -version: 0.5.19+2 +version: 0.5.19+3 dependencies: flutter: From bacb1168f694803072d83e427f0fcad31f98f748 Mon Sep 17 00:00:00 2001 From: otopba Date: Sat, 6 Jul 2019 18:11:15 +0300 Subject: [PATCH 03/18] Fix format --- packages/google_maps_flutter/example/lib/map_ui.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/example/lib/map_ui.dart b/packages/google_maps_flutter/example/lib/map_ui.dart index 99d85c8add40..f05182c5c34f 100644 --- a/packages/google_maps_flutter/example/lib/map_ui.dart +++ b/packages/google_maps_flutter/example/lib/map_ui.dart @@ -177,8 +177,7 @@ class MapUiBodyState extends State { Widget _myLocationToggler() { return FlatButton( - child: Text( - '${_myLocationEnabled ? 'disable' : 'enable'} my location'), + child: Text('${_myLocationEnabled ? 'disable' : 'enable'} my location'), onPressed: () { setState(() { _myLocationEnabled = !_myLocationEnabled; From d48e03fcc6abd97136b9bd22243f5e3e4f1be6bb Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Wed, 24 Jul 2019 16:46:27 -0700 Subject: [PATCH 04/18] Update CHANGELOG --- .../example/test/cloud_functions.dart | 22 +++++++++++++++++++ packages/google_maps_flutter/CHANGELOG.md | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/cloud_functions/example/test/cloud_functions.dart b/packages/cloud_functions/example/test/cloud_functions.dart index 4bccc1f0aed0..2925f65d9e97 100644 --- a/packages/cloud_functions/example/test/cloud_functions.dart +++ b/packages/cloud_functions/example/test/cloud_functions.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'package:firebase_core/firebase_core.dart'; import 'package:cloud_functions/cloud_functions.dart'; void main() { @@ -34,5 +35,26 @@ void main() { expect(response2.data['repeat_message'], 'bar'); expect(response2.data['repeat_count'], 43); }); + + test('useFunctionsEmulator', () async { + FirebaseApp app = FirebaseApp(name: FirebaseApp.defaultAppName); + FirebaseOptions options = await app.options; + // Sends the request to the actual Firebase backend + CloudFunctions functions = CloudFunctions(app: app) + ..useEmulatorFunctions( + origin: 'https://us-central1-${options.projectID}.cloudfunctions.net' + ); + final HttpsCallable callable = functions.getHttpsCallable( + functionName: 'repeat', + ); + final HttpsCallableResult response = + await callable.call({ + 'message': 'foo', + 'count': 1, + }); + expect(response.data['repeat_message'], 'foo'); + expect(response.data['repeat_count'], 2); + }); + }); } diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md index 658a5548ace5..398210e52552 100644 --- a/packages/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.5.20+1 -* Fix some confusions with my location and my location button +* Fix references to `myLocationButtonEnabled` in test and example app. ## 0.5.20 From 98293d85b3b369d89f6b0d4ed10f74f668b273c4 Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Wed, 24 Jul 2019 16:50:19 -0700 Subject: [PATCH 05/18] Remove unrelated file --- .../example/test/cloud_functions.dart | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/packages/cloud_functions/example/test/cloud_functions.dart b/packages/cloud_functions/example/test/cloud_functions.dart index 2925f65d9e97..4bccc1f0aed0 100644 --- a/packages/cloud_functions/example/test/cloud_functions.dart +++ b/packages/cloud_functions/example/test/cloud_functions.dart @@ -5,7 +5,6 @@ import 'dart:async'; import 'package:flutter_driver/driver_extension.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:firebase_core/firebase_core.dart'; import 'package:cloud_functions/cloud_functions.dart'; void main() { @@ -35,26 +34,5 @@ void main() { expect(response2.data['repeat_message'], 'bar'); expect(response2.data['repeat_count'], 43); }); - - test('useFunctionsEmulator', () async { - FirebaseApp app = FirebaseApp(name: FirebaseApp.defaultAppName); - FirebaseOptions options = await app.options; - // Sends the request to the actual Firebase backend - CloudFunctions functions = CloudFunctions(app: app) - ..useEmulatorFunctions( - origin: 'https://us-central1-${options.projectID}.cloudfunctions.net' - ); - final HttpsCallable callable = functions.getHttpsCallable( - functionName: 'repeat', - ); - final HttpsCallableResult response = - await callable.call({ - 'message': 'foo', - 'count': 1, - }); - expect(response.data['repeat_message'], 'foo'); - expect(response.data['repeat_count'], 2); - }); - }); } From 9aacc826dc961cc97fe6122d3c961f92d97efa58 Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Wed, 24 Jul 2019 17:35:45 -0700 Subject: [PATCH 06/18] Add `isMyLocationEnabled` support with test. --- packages/google_maps_flutter/CHANGELOG.md | 4 ++- .../googlemaps/GoogleMapController.java | 5 ++++ .../test_driver/google_map_inspector.dart | 4 +++ .../example/test_driver/google_maps.dart | 28 +++++++++++++++++++ .../ios/Classes/GoogleMapController.m | 3 ++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md index 398210e52552..e273b9e8c674 100644 --- a/packages/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/CHANGELOG.md @@ -1,6 +1,8 @@ -## 0.5.20+1 +## 0.5.21 * Fix references to `myLocationButtonEnabled` in test and example app. +* On iOS, `myLocationEnabled` no longer affects the value of `myLocationButtonEnabled` +* Added `isMyLocationEnabled` to `GoogleMapsInspector`. ## 0.5.20 diff --git a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java index fe0d3d7c3e48..e502c0faef50 100644 --- a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java +++ b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java @@ -320,6 +320,11 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) { result.success(googleMap.getUiSettings().isRotateGesturesEnabled()); break; } + case "map#isMyLocationEnabled": + { + result.success(googleMap.isMyLocationEnabled()); + break; + } case "map#isMyLocationButtonEnabled": { result.success(googleMap.getUiSettings().isMyLocationButtonEnabled()); diff --git a/packages/google_maps_flutter/example/test_driver/google_map_inspector.dart b/packages/google_maps_flutter/example/test_driver/google_map_inspector.dart index b8758dcf8c22..ffd45ad7896b 100644 --- a/packages/google_maps_flutter/example/test_driver/google_map_inspector.dart +++ b/packages/google_maps_flutter/example/test_driver/google_map_inspector.dart @@ -46,6 +46,10 @@ class GoogleMapInspector { return await _channel.invokeMethod('map#isScrollGesturesEnabled'); } + Future isMyLocationEnabled() async { + return await _channel.invokeMethod('map#isMyLocationEnabled'); + } + Future isMyLocationButtonEnabled() async { return await _channel.invokeMethod('map#isMyLocationButtonEnabled'); } diff --git a/packages/google_maps_flutter/example/test_driver/google_maps.dart b/packages/google_maps_flutter/example/test_driver/google_maps.dart index 2e037603d7ca..163180a56b77 100644 --- a/packages/google_maps_flutter/example/test_driver/google_maps.dart +++ b/packages/google_maps_flutter/example/test_driver/google_maps.dart @@ -375,6 +375,34 @@ void main() { expect(secondVisibleRegion.contains(newCenter), isTrue); }); + test('testMyLocation', () async { + final Key key = GlobalKey(); + final Completer inspectorCompleter = + Completer(); + + await pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + myLocationEnabled: true, + myLocationButtonEnabled: false, + onMapCreated: (GoogleMapController controller) { + final GoogleMapInspector inspector = + // ignore: invalid_use_of_visible_for_testing_member + GoogleMapInspector(controller.channel); + inspectorCompleter.complete(inspector); + }, + ), + )); + + final GoogleMapInspector inspector = await inspectorCompleter.future; + bool myLocationEnabled = await inspector.isMyLocationEnabled(); + expect(myLocationEnabled, true); + bool myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled(); + expect(myLocationButtonEnabled, false); + }); + test('testMyLocationButtonToggle', () async { final Key key = GlobalKey(); final Completer inspectorCompleter = diff --git a/packages/google_maps_flutter/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/ios/Classes/GoogleMapController.m index e58344dad398..f17c2f808a29 100644 --- a/packages/google_maps_flutter/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/ios/Classes/GoogleMapController.m @@ -226,6 +226,9 @@ - (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } else if ([call.method isEqualToString:@"map#isScrollGesturesEnabled"]) { NSNumber* isScrollGesturesEnabled = @(_mapView.settings.scrollGestures); result(isScrollGesturesEnabled); + } else if ([call.method isEqualToString:@"map#isMyLocationEnabled"]) { + NSNumber* isMyLocationEnabled = @(_mapView.myLocationEnabled); + result(isMyLocationEnabled); } else if ([call.method isEqualToString:@"map#isMyLocationButtonEnabled"]) { NSNumber* isMyLocationButtonEnabled = @(_mapView.settings.myLocationButton); result(isMyLocationButtonEnabled); From a78f3e10b8079632cfe05c4f262dd660c5f98352 Mon Sep 17 00:00:00 2001 From: otopba Date: Fri, 26 Jul 2019 15:21:44 +0300 Subject: [PATCH 07/18] fix format --- .../example/test_driver/google_maps.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/example/test_driver/google_maps.dart b/packages/google_maps_flutter/example/test_driver/google_maps.dart index 163180a56b77..566ed466f4ce 100644 --- a/packages/google_maps_flutter/example/test_driver/google_maps.dart +++ b/packages/google_maps_flutter/example/test_driver/google_maps.dart @@ -378,7 +378,7 @@ void main() { test('testMyLocation', () async { final Key key = GlobalKey(); final Completer inspectorCompleter = - Completer(); + Completer(); await pumpWidget(Directionality( textDirection: TextDirection.ltr, @@ -389,8 +389,8 @@ void main() { myLocationButtonEnabled: false, onMapCreated: (GoogleMapController controller) { final GoogleMapInspector inspector = - // ignore: invalid_use_of_visible_for_testing_member - GoogleMapInspector(controller.channel); + // ignore: invalid_use_of_visible_for_testing_member + GoogleMapInspector(controller.channel); inspectorCompleter.complete(inspector); }, ), From 6063035457d5c1b9fe26711c93599703878e2fbf Mon Sep 17 00:00:00 2001 From: otopba Date: Fri, 26 Jul 2019 15:30:21 +0300 Subject: [PATCH 08/18] Update authors --- AUTHORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 855e3a4569f2..c047c3fd3eaa 100644 --- a/AUTHORS +++ b/AUTHORS @@ -41,4 +41,5 @@ Jose Sanchez Debkanchan Samadder Audrius Karosevicius Lukasz Piliszczuk -SoundReply Solutions GmbH \ No newline at end of file +SoundReply Solutions GmbH +Iurii Dorofeev \ No newline at end of file From b139041aff6eb497ed95d94f32effa2b0f71df62 Mon Sep 17 00:00:00 2001 From: otopba Date: Fri, 26 Jul 2019 17:17:18 +0300 Subject: [PATCH 09/18] final vars --- .../google_maps_flutter/example/test_driver/google_maps.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/example/test_driver/google_maps.dart b/packages/google_maps_flutter/example/test_driver/google_maps.dart index 566ed466f4ce..7b5a2000b14b 100644 --- a/packages/google_maps_flutter/example/test_driver/google_maps.dart +++ b/packages/google_maps_flutter/example/test_driver/google_maps.dart @@ -397,9 +397,10 @@ void main() { )); final GoogleMapInspector inspector = await inspectorCompleter.future; - bool myLocationEnabled = await inspector.isMyLocationEnabled(); + final bool myLocationEnabled = await inspector.isMyLocationEnabled(); expect(myLocationEnabled, true); - bool myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled(); + final bool myLocationButtonEnabled = + await inspector.isMyLocationButtonEnabled(); expect(myLocationButtonEnabled, false); }); From 45b417edc1267fa463df4ceb729060ed227b5a97 Mon Sep 17 00:00:00 2001 From: otopba Date: Wed, 7 Aug 2019 02:41:27 +0300 Subject: [PATCH 10/18] version: 0.5.21 --- packages/google_maps_flutter/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml index dcd2b3eb4ed3..f8a852998d42 100644 --- a/packages/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter -version: 0.5.20+2 +version: 0.5.21 dependencies: flutter: From 29e2e6672a7e52287d85a6b0cb9b4cf8ca6a2c5d Mon Sep 17 00:00:00 2001 From: otopba Date: Sun, 8 Sep 2019 05:04:37 +0300 Subject: [PATCH 11/18] fixes --- .../google_maps_flutter/example/test_driver/google_maps.dart | 2 +- packages/google_maps_flutter/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/example/test_driver/google_maps.dart b/packages/google_maps_flutter/example/test_driver/google_maps.dart index b9066a4464b9..6ae7192a02f4 100644 --- a/packages/google_maps_flutter/example/test_driver/google_maps.dart +++ b/packages/google_maps_flutter/example/test_driver/google_maps.dart @@ -570,7 +570,7 @@ void main() { fail('expected MapStyleException'); } on MapStyleException catch (e) { expect(e.cause, - 'The data couldn’t be read because it isn’t in the correct format.'); + 'Unable to set the map style. Please check console logs for errors.'); } }); diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml index f8a852998d42..4d05d47a77e2 100644 --- a/packages/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter -version: 0.5.21 +version: 0.5.22 dependencies: flutter: From ab77709f5bd60e7b4162b14a1067d343cd3b9585 Mon Sep 17 00:00:00 2001 From: otopba Date: Sun, 19 Jan 2020 16:27:56 +0300 Subject: [PATCH 12/18] format --- .../example/test_driver/google_maps_e2e.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart b/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart index 97e8aff48a7e..bca1253fec59 100644 --- a/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart +++ b/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart @@ -379,7 +379,7 @@ void main() { testWidgets('testMyLocation', () async { final Key key = GlobalKey(); final Completer inspectorCompleter = - Completer(); + Completer(); await pumpWidget(Directionality( textDirection: TextDirection.ltr, @@ -390,8 +390,8 @@ void main() { myLocationButtonEnabled: false, onMapCreated: (GoogleMapController controller) { final GoogleMapInspector inspector = - // ignore: invalid_use_of_visible_for_testing_member - GoogleMapInspector(controller.channel); + // ignore: invalid_use_of_visible_for_testing_member + GoogleMapInspector(controller.channel); inspectorCompleter.complete(inspector); }, ), @@ -401,7 +401,7 @@ void main() { final bool myLocationEnabled = await inspector.isMyLocationEnabled(); expect(myLocationEnabled, true); final bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(); + await inspector.isMyLocationButtonEnabled(); expect(myLocationButtonEnabled, false); }); From e038a3ee111ff7f047d301ef637b5e988a4e1cc8 Mon Sep 17 00:00:00 2001 From: otopba Date: Wed, 22 Jan 2020 00:19:46 +0300 Subject: [PATCH 13/18] Add dummy map initialization --- .../plugins/googlemaps/GoogleMapsPlugin.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java index b27fea425ba5..9888b5ff8d93 100644 --- a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java +++ b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java @@ -6,7 +6,12 @@ import android.app.Activity; import android.app.Application; +import android.app.FragmentManager; import android.os.Bundle; +import androidx.annotation.NonNull; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.MapFragment; +import com.google.android.gms.maps.OnMapReadyCallback; import io.flutter.plugin.common.PluginRegistry.Registrar; import java.util.concurrent.atomic.AtomicInteger; @@ -25,6 +30,7 @@ public class GoogleMapsPlugin implements Application.ActivityLifecycleCallbacks static final int DESTROYED = 6; private final AtomicInteger state = new AtomicInteger(0); private final int registrarActivityHashCode; + private boolean dummyMapInitialized; public static void registerWith(Registrar registrar) { if (registrar.activity() == null) { @@ -94,5 +100,34 @@ public void onActivityDestroyed(Activity activity) { private GoogleMapsPlugin(Registrar registrar) { this.registrarActivityHashCode = registrar.activity().hashCode(); + if (dummyMapInitialized) { + return; + } + Activity activity = registrar.activity(); + if (activity == null) { + return; + } + FragmentManager fragmentManager = activity.getFragmentManager(); + if (fragmentManager == null) { + return; + } + initDummyMap(fragmentManager); + dummyMapInitialized = true; + } + + /** + * This method creates dummy map. This call will initialize all services needed by GoogleMaps This + * will speed up next GoogleMap view initialization + */ + private static void initDummyMap(@NonNull final FragmentManager fragmentManager) { + final MapFragment mapFragment = new MapFragment(); + fragmentManager.beginTransaction().add(mapFragment, "DummyMap").commit(); + mapFragment.getMapAsync( + new OnMapReadyCallback() { + @Override + public void onMapReady(GoogleMap googleMap) { + fragmentManager.beginTransaction().remove(mapFragment).commit(); + } + }); } } From 4345ed504c7d6042fa04b429d97d9f0dad68a28a Mon Sep 17 00:00:00 2001 From: otopba Date: Wed, 22 Jan 2020 00:21:30 +0300 Subject: [PATCH 14/18] Revert "Add dummy map initialization" This reverts commit e038a3ee --- .../plugins/googlemaps/GoogleMapsPlugin.java | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java index 9888b5ff8d93..b27fea425ba5 100644 --- a/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java +++ b/packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapsPlugin.java @@ -6,12 +6,7 @@ import android.app.Activity; import android.app.Application; -import android.app.FragmentManager; import android.os.Bundle; -import androidx.annotation.NonNull; -import com.google.android.gms.maps.GoogleMap; -import com.google.android.gms.maps.MapFragment; -import com.google.android.gms.maps.OnMapReadyCallback; import io.flutter.plugin.common.PluginRegistry.Registrar; import java.util.concurrent.atomic.AtomicInteger; @@ -30,7 +25,6 @@ public class GoogleMapsPlugin implements Application.ActivityLifecycleCallbacks static final int DESTROYED = 6; private final AtomicInteger state = new AtomicInteger(0); private final int registrarActivityHashCode; - private boolean dummyMapInitialized; public static void registerWith(Registrar registrar) { if (registrar.activity() == null) { @@ -100,34 +94,5 @@ public void onActivityDestroyed(Activity activity) { private GoogleMapsPlugin(Registrar registrar) { this.registrarActivityHashCode = registrar.activity().hashCode(); - if (dummyMapInitialized) { - return; - } - Activity activity = registrar.activity(); - if (activity == null) { - return; - } - FragmentManager fragmentManager = activity.getFragmentManager(); - if (fragmentManager == null) { - return; - } - initDummyMap(fragmentManager); - dummyMapInitialized = true; - } - - /** - * This method creates dummy map. This call will initialize all services needed by GoogleMaps This - * will speed up next GoogleMap view initialization - */ - private static void initDummyMap(@NonNull final FragmentManager fragmentManager) { - final MapFragment mapFragment = new MapFragment(); - fragmentManager.beginTransaction().add(mapFragment, "DummyMap").commit(); - mapFragment.getMapAsync( - new OnMapReadyCallback() { - @Override - public void onMapReady(GoogleMap googleMap) { - fragmentManager.beginTransaction().remove(mapFragment).commit(); - } - }); } } From 0af73b6f6716d0977f814f4cb8abe01485ab46f5 Mon Sep 17 00:00:00 2001 From: otopba Date: Sat, 1 Feb 2020 16:35:50 +0300 Subject: [PATCH 15/18] merge --- packages/google_maps_flutter/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml index b2ea9a193812..d3e751e9a52d 100644 --- a/packages/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/pubspec.yaml @@ -1,7 +1,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter -version: 0.5.22 +version: 0.5.23 dependencies: flutter: From 7039a40dda97ae5f62903139a662b8a53e4c4de3 Mon Sep 17 00:00:00 2001 From: otopba Date: Sat, 1 Feb 2020 18:06:06 +0300 Subject: [PATCH 16/18] Add todo --- .../example/test_driver/google_maps_e2e.dart | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart b/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart index 2737438ec721..6f4ac179b718 100644 --- a/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart +++ b/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart @@ -413,18 +413,18 @@ void main() { expect(secondVisibleRegion.contains(newCenter), isTrue); }); - testWidgets('testMyLocation', () async { + testWidgets('testMyLocation', (WidgetTester tester) async { final Key key = GlobalKey(); final Completer inspectorCompleter = Completer(); - await pumpWidget(Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, child: GoogleMap( key: key, initialCameraPosition: _kInitialCameraPosition, myLocationEnabled: true, - myLocationButtonEnabled: false, + myLocationButtonEnabled: true, onMapCreated: (GoogleMapController controller) { final GoogleMapInspector inspector = // ignore: invalid_use_of_visible_for_testing_member @@ -434,13 +434,34 @@ void main() { ), )); - final GoogleMapInspector inspector = await inspectorCompleter.future; - final bool myLocationEnabled = await inspector.isMyLocationEnabled(); + GoogleMapInspector inspector = await inspectorCompleter.future; + bool myLocationEnabled = await inspector.isMyLocationEnabled(); expect(myLocationEnabled, true); - final bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(); + bool myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled(); + expect(myLocationButtonEnabled, true); + + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + myLocationEnabled: false, + myLocationButtonEnabled: false, + onMapCreated: (GoogleMapController controller) { + final GoogleMapInspector inspector = + // ignore: invalid_use_of_visible_for_testing_member + GoogleMapInspector(controller.channel); + inspectorCompleter.complete(inspector); + }, + ), + )); + + inspector = await inspectorCompleter.future; + myLocationEnabled = await inspector.isMyLocationEnabled(); + expect(myLocationEnabled, false); + myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled(); expect(myLocationButtonEnabled, false); - }); + }, skip: true); //TODO: Remove `skip' when https://github.com/flutter/flutter/issues/12561 will be fixed testWidgets('testTraffic', (WidgetTester tester) async { final Key key = GlobalKey(); From 49e510fc9f5fd7248f2e88c687f8b8f38b15c743 Mon Sep 17 00:00:00 2001 From: otopba Date: Sat, 1 Feb 2020 18:33:41 +0300 Subject: [PATCH 17/18] format --- .../example/test_driver/google_maps_e2e.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart b/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart index 6f4ac179b718..80941eedbe4c 100644 --- a/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart +++ b/packages/google_maps_flutter/example/test_driver/google_maps_e2e.dart @@ -449,8 +449,8 @@ void main() { myLocationButtonEnabled: false, onMapCreated: (GoogleMapController controller) { final GoogleMapInspector inspector = - // ignore: invalid_use_of_visible_for_testing_member - GoogleMapInspector(controller.channel); + // ignore: invalid_use_of_visible_for_testing_member + GoogleMapInspector(controller.channel); inspectorCompleter.complete(inspector); }, ), @@ -461,7 +461,8 @@ void main() { expect(myLocationEnabled, false); myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled(); expect(myLocationButtonEnabled, false); - }, skip: true); //TODO: Remove `skip' when https://github.com/flutter/flutter/issues/12561 will be fixed + }, skip: true); + //TODO: Remove `skip' when https://github.com/flutter/flutter/issues/12561 will be fixed testWidgets('testTraffic', (WidgetTester tester) async { final Key key = GlobalKey(); From d4bfe37d0c472abad1556173421377712ce5e5f8 Mon Sep 17 00:00:00 2001 From: otopba Date: Sun, 22 Mar 2020 13:00:23 +0300 Subject: [PATCH 18/18] merge --- packages/google_maps_flutter/google_maps_flutter/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index e6dfb6bea412..507343e6a7ac 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -1,7 +1,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter -version: 0.5.25 +version: 0.5.26 dependencies: flutter: