From 523d66bdb7768cb7869a84c555dcd813f42a25c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20V=C3=A4limaa?= Date: Thu, 14 Nov 2024 12:56:15 +0800 Subject: [PATCH] refactor: carplay pigeon api refactoring --- .../GoogleMapsAutoViewMessageHandler.kt | 4 ---- .../maps/flutter/navigation/messages.g.kt | 24 ------------------- ios/Classes/GoogleMapsNavigationView.swift | 3 +-- ios/Classes/messages.g.swift | 20 ---------------- ...navigation_flutter_platform_interface.dart | 3 --- .../method_channel/common_auto_view_api.dart | 5 ---- lib/src/method_channel/messages.g.dart | 24 ------------------- pigeons/messages.dart | 3 --- 8 files changed, 1 insertion(+), 85 deletions(-) diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoViewMessageHandler.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoViewMessageHandler.kt index 10acb97..351a4fe 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoViewMessageHandler.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoViewMessageHandler.kt @@ -31,10 +31,6 @@ class GoogleMapsAutoViewMessageHandler(private val viewRegistry: GoogleMapsViewR } } - override fun awaitMapReady(callback: (Result) -> Unit) { - return getView().awaitMapReady(callback) - } - override fun isMyLocationEnabled(): Boolean { return getView().isMyLocationEnabled() } diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/messages.g.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/messages.g.kt index f5fb6c5..57ab185 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/messages.g.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/messages.g.kt @@ -6240,8 +6240,6 @@ private object AutoMapViewApiCodec : StandardMessageCodec() { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ interface AutoMapViewApi { - fun awaitMapReady(callback: (Result) -> Unit) - fun isMyLocationEnabled(): Boolean fun setMyLocationEnabled(enabled: Boolean) @@ -6420,28 +6418,6 @@ interface AutoMapViewApi { /** Sets up an instance of `AutoMapViewApi` to handle messages through the `binaryMessenger`. */ @Suppress("UNCHECKED_CAST") fun setUp(binaryMessenger: BinaryMessenger, api: AutoMapViewApi?) { - run { - val channel = - BasicMessageChannel( - binaryMessenger, - "dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.awaitMapReady", - codec, - ) - if (api != null) { - channel.setMessageHandler { _, reply -> - api.awaitMapReady() { result: Result -> - val error = result.exceptionOrNull() - if (error != null) { - reply.reply(wrapError(error)) - } else { - reply.reply(wrapResult(null)) - } - } - } - } else { - channel.setMessageHandler(null) - } - } run { val channel = BasicMessageChannel( diff --git a/ios/Classes/GoogleMapsNavigationView.swift b/ios/Classes/GoogleMapsNavigationView.swift index b31f34b..2d8bfa0 100644 --- a/ios/Classes/GoogleMapsNavigationView.swift +++ b/ios/Classes/GoogleMapsNavigationView.swift @@ -71,8 +71,7 @@ class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettledDelega mapConfiguration: MapConfiguration, imageRegistry: ImageRegistry, isCarPlayView: Bool) { - - if (!isCarPlayView && (viewId == nil || viewEventApi == nil)) { + if !isCarPlayView, viewId == nil || viewEventApi == nil { fatalError("For non-carplay map view viewId and viewEventApi is required") } diff --git a/ios/Classes/messages.g.swift b/ios/Classes/messages.g.swift index be361ee..4e73eef 100644 --- a/ios/Classes/messages.g.swift +++ b/ios/Classes/messages.g.swift @@ -5737,7 +5737,6 @@ class AutoMapViewApiCodec: FlutterStandardMessageCodec { /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol AutoMapViewApi { - func awaitMapReady(completion: @escaping (Result) -> Void) func isMyLocationEnabled() throws -> Bool func setMyLocationEnabled(enabled: Bool) throws func getMyLocation() throws -> LatLngDto? @@ -5826,25 +5825,6 @@ enum AutoMapViewApiSetup { static var codec: FlutterStandardMessageCodec { AutoMapViewApiCodec.shared } /// Sets up an instance of `AutoMapViewApi` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: AutoMapViewApi?) { - let awaitMapReadyChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.awaitMapReady", - binaryMessenger: binaryMessenger, - codec: codec - ) - if let api { - awaitMapReadyChannel.setMessageHandler { _, reply in - api.awaitMapReady { result in - switch result { - case .success: - reply(wrapResult(nil)) - case let .failure(error): - reply(wrapError(error)) - } - } - } - } else { - awaitMapReadyChannel.setMessageHandler(nil) - } let isMyLocationEnabledChannel = FlutterBasicMessageChannel( name: "dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.isMyLocationEnabled", binaryMessenger: binaryMessenger, diff --git a/lib/src/google_navigation_flutter_platform_interface.dart b/lib/src/google_navigation_flutter_platform_interface.dart index f79ad34..288f3f6 100644 --- a/lib/src/google_navigation_flutter_platform_interface.dart +++ b/lib/src/google_navigation_flutter_platform_interface.dart @@ -574,9 +574,6 @@ abstract mixin class MapViewAPIInterface { } abstract mixin class AutoMapViewAPIInterface { - /// Awaits the auto view to be ready for communication. - Future awaitMapReadyForAuto(); - /// Get the preference for whether the my location should be enabled or disabled. Future isMyLocationEnabledForAuto(); diff --git a/lib/src/method_channel/common_auto_view_api.dart b/lib/src/method_channel/common_auto_view_api.dart index 18e24fc..88d70b1 100644 --- a/lib/src/method_channel/common_auto_view_api.dart +++ b/lib/src/method_channel/common_auto_view_api.dart @@ -74,11 +74,6 @@ mixin CommonAutoMapViewAPI on AutoMapViewAPIInterface { } } - @override - Future awaitMapReadyForAuto() { - return _viewApi.awaitMapReady(); - } - @override Future isMyLocationEnabledForAuto() { return _viewApi.isMyLocationEnabled(); diff --git a/lib/src/method_channel/messages.g.dart b/lib/src/method_channel/messages.g.dart index 5ec0aae..6c19dba 100644 --- a/lib/src/method_channel/messages.g.dart +++ b/lib/src/method_channel/messages.g.dart @@ -6628,30 +6628,6 @@ class AutoMapViewApi { static const MessageCodec pigeonChannelCodec = _AutoMapViewApiCodec(); - Future awaitMapReady() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.awaitMapReady'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else { - return; - } - } - Future isMyLocationEnabled() async { const String __pigeon_channelName = 'dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.isMyLocationEnabled'; diff --git a/pigeons/messages.dart b/pigeons/messages.dart index f96b718..4e46937 100644 --- a/pigeons/messages.dart +++ b/pigeons/messages.dart @@ -1256,9 +1256,6 @@ abstract class NavigationSessionEventApi { @HostApi() abstract class AutoMapViewApi { - @async - void awaitMapReady(); - bool isMyLocationEnabled(); void setMyLocationEnabled(bool enabled); LatLngDto? getMyLocation();