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 0731f6f7e5a1..fa6f77a4219e 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.14.9 + +* Adds `PlatformCap` for `PlatformPolyline.startCap` and `endCap`. + ## 2.14.8 * Updates Java compatibility version to 11. diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java index 6c7c103e4bdd..b8617c8fa564 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java @@ -703,8 +703,8 @@ static String interpretPolylineOptions( float density) { sink.setConsumeTapEvents(polyline.getConsumesTapEvents()); sink.setColor(polyline.getColor().intValue()); - sink.setEndCap(toCap(polyline.getEndCap(), assetManager, density)); - sink.setStartCap(toCap(polyline.getStartCap(), assetManager, density)); + sink.setEndCap(capFromPigeon(polyline.getEndCap(), assetManager, density)); + sink.setStartCap(capFromPigeon(polyline.getStartCap(), assetManager, density)); sink.setGeodesic(polyline.getGeodesic()); sink.setJointType(jointTypeFromPigeon(polyline.getJointType())); sink.setVisible(polyline.getVisible()); @@ -874,25 +874,24 @@ private static List patternFromPigeon( return pattern; } - private static Cap toCap(Object o, AssetManager assetManager, float density) { - final List data = toList(o); - switch (toString(data.get(0))) { - case "buttCap": + private static Cap capFromPigeon( + Messages.PlatformCap cap, AssetManager assetManager, float density) { + switch (cap.getType()) { + case BUTT_CAP: return new ButtCap(); - case "roundCap": + case ROUND_CAP: return new RoundCap(); - case "squareCap": + case SQUARE_CAP: return new SquareCap(); - case "customCap": - if (data.size() == 2) { - return new CustomCap(toBitmapDescriptor(data.get(1), assetManager, density)); - } else { - return new CustomCap( - toBitmapDescriptor(data.get(1), assetManager, density), toFloat(data.get(2))); + case CUSTOM_CAP: + if (cap.getRefWidth() == null) { + throw new IllegalArgumentException("A Custom Cap must specify a refWidth value."); } - default: - throw new IllegalArgumentException("Cannot interpret " + o + " as Cap"); + return new CustomCap( + toBitmapDescriptor(cap.getBitmapDescriptor(), assetManager, density), + cap.getRefWidth().floatValue()); } + throw new IllegalArgumentException("Unrecognized Cap type: " + cap.getType()); } static String interpretTileOverlayOptions( diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java index a258aea0cfce..1227826382ca 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v22.3.0), do not edit directly. +// Autogenerated from Pigeon (v22.4.0), do not edit directly. // See also: https://pub.dev/packages/pigeon package io.flutter.plugins.googlemaps; @@ -113,6 +113,24 @@ public enum PlatformJointType { } } + /** + * Enumeration of possible types of PlatformCap, corresponding to the subclasses of Cap in the + * Google Maps Android SDK. See + * https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/Cap. + */ + public enum PlatformCapType { + BUTT_CAP(0), + ROUND_CAP(1), + SQUARE_CAP(2), + CUSTOM_CAP(3); + + final int index; + + PlatformCapType(final int index) { + this.index = index; + } + } + /** Enumeration of possible types for PatternItem. */ public enum PlatformPatternItemType { DOT(0), @@ -2481,29 +2499,29 @@ public void setPoints(@NonNull List setterArg) { } /** - * The start and end cap data, as JSON. These should be set only from Cap.toJson, and the native - * code must interpret it according to the internal implementation details of that method. + * The cap at the start and end vertex of a polyline. See + * https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/Cap. */ - private @NonNull Object startCap; + private @NonNull PlatformCap startCap; - public @NonNull Object getStartCap() { + public @NonNull PlatformCap getStartCap() { return startCap; } - public void setStartCap(@NonNull Object setterArg) { + public void setStartCap(@NonNull PlatformCap setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"startCap\" is null."); } this.startCap = setterArg; } - private @NonNull Object endCap; + private @NonNull PlatformCap endCap; - public @NonNull Object getEndCap() { + public @NonNull PlatformCap getEndCap() { return endCap; } - public void setEndCap(@NonNull Object setterArg) { + public void setEndCap(@NonNull PlatformCap setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"endCap\" is null."); } @@ -2650,18 +2668,18 @@ public static final class Builder { return this; } - private @Nullable Object startCap; + private @Nullable PlatformCap startCap; @CanIgnoreReturnValue - public @NonNull Builder setStartCap(@NonNull Object setterArg) { + public @NonNull Builder setStartCap(@NonNull PlatformCap setterArg) { this.startCap = setterArg; return this; } - private @Nullable Object endCap; + private @Nullable PlatformCap endCap; @CanIgnoreReturnValue - public @NonNull Builder setEndCap(@NonNull Object setterArg) { + public @NonNull Builder setEndCap(@NonNull PlatformCap setterArg) { this.endCap = setterArg; return this; } @@ -2743,9 +2761,9 @@ ArrayList toList() { Object points = pigeonVar_list.get(6); pigeonResult.setPoints((List) points); Object startCap = pigeonVar_list.get(7); - pigeonResult.setStartCap(startCap); + pigeonResult.setStartCap((PlatformCap) startCap); Object endCap = pigeonVar_list.get(8); - pigeonResult.setEndCap(endCap); + pigeonResult.setEndCap((PlatformCap) endCap); Object visible = pigeonVar_list.get(9); pigeonResult.setVisible((Boolean) visible); Object width = pigeonVar_list.get(10); @@ -2756,6 +2774,125 @@ ArrayList toList() { } } + /** + * Pigeon equivalent of Cap from the platform interface. + * https://github.com/flutter/packages/blob/main/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static final class PlatformCap { + private @NonNull PlatformCapType type; + + public @NonNull PlatformCapType getType() { + return type; + } + + public void setType(@NonNull PlatformCapType setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"type\" is null."); + } + this.type = setterArg; + } + + /** The JSON data returned by BitmapDescriptor.toJson. */ + private @Nullable Object bitmapDescriptor; + + public @Nullable Object getBitmapDescriptor() { + return bitmapDescriptor; + } + + public void setBitmapDescriptor(@Nullable Object setterArg) { + this.bitmapDescriptor = setterArg; + } + + private @Nullable Double refWidth; + + public @Nullable Double getRefWidth() { + return refWidth; + } + + public void setRefWidth(@Nullable Double setterArg) { + this.refWidth = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + PlatformCap() {} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlatformCap that = (PlatformCap) o; + return type.equals(that.type) + && Objects.equals(bitmapDescriptor, that.bitmapDescriptor) + && Objects.equals(refWidth, that.refWidth); + } + + @Override + public int hashCode() { + return Objects.hash(type, bitmapDescriptor, refWidth); + } + + public static final class Builder { + + private @Nullable PlatformCapType type; + + @CanIgnoreReturnValue + public @NonNull Builder setType(@NonNull PlatformCapType setterArg) { + this.type = setterArg; + return this; + } + + private @Nullable Object bitmapDescriptor; + + @CanIgnoreReturnValue + public @NonNull Builder setBitmapDescriptor(@Nullable Object setterArg) { + this.bitmapDescriptor = setterArg; + return this; + } + + private @Nullable Double refWidth; + + @CanIgnoreReturnValue + public @NonNull Builder setRefWidth(@Nullable Double setterArg) { + this.refWidth = setterArg; + return this; + } + + public @NonNull PlatformCap build() { + PlatformCap pigeonReturn = new PlatformCap(); + pigeonReturn.setType(type); + pigeonReturn.setBitmapDescriptor(bitmapDescriptor); + pigeonReturn.setRefWidth(refWidth); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(3); + toListResult.add(type); + toListResult.add(bitmapDescriptor); + toListResult.add(refWidth); + return toListResult; + } + + static @NonNull PlatformCap fromList(@NonNull ArrayList pigeonVar_list) { + PlatformCap pigeonResult = new PlatformCap(); + Object type = pigeonVar_list.get(0); + pigeonResult.setType((PlatformCapType) type); + Object bitmapDescriptor = pigeonVar_list.get(1); + pigeonResult.setBitmapDescriptor(bitmapDescriptor); + Object refWidth = pigeonVar_list.get(2); + pigeonResult.setRefWidth((Double) refWidth); + return pigeonResult; + } + } + /** * Pigeon equivalent of the PatternItem class. * @@ -4899,75 +5036,82 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { return value == null ? null : PlatformJointType.values()[((Long) value).intValue()]; } case (byte) 132: + { + Object value = readValue(buffer); + return value == null ? null : PlatformCapType.values()[((Long) value).intValue()]; + } + case (byte) 133: { Object value = readValue(buffer); return value == null ? null : PlatformPatternItemType.values()[((Long) value).intValue()]; } - case (byte) 133: - return PlatformCameraPosition.fromList((ArrayList) readValue(buffer)); case (byte) 134: - return PlatformCameraUpdate.fromList((ArrayList) readValue(buffer)); + return PlatformCameraPosition.fromList((ArrayList) readValue(buffer)); case (byte) 135: + return PlatformCameraUpdate.fromList((ArrayList) readValue(buffer)); + case (byte) 136: return PlatformCameraUpdateNewCameraPosition.fromList( (ArrayList) readValue(buffer)); - case (byte) 136: - return PlatformCameraUpdateNewLatLng.fromList((ArrayList) readValue(buffer)); case (byte) 137: + return PlatformCameraUpdateNewLatLng.fromList((ArrayList) readValue(buffer)); + case (byte) 138: return PlatformCameraUpdateNewLatLngBounds.fromList( (ArrayList) readValue(buffer)); - case (byte) 138: - return PlatformCameraUpdateNewLatLngZoom.fromList((ArrayList) readValue(buffer)); case (byte) 139: - return PlatformCameraUpdateScrollBy.fromList((ArrayList) readValue(buffer)); + return PlatformCameraUpdateNewLatLngZoom.fromList((ArrayList) readValue(buffer)); case (byte) 140: - return PlatformCameraUpdateZoomBy.fromList((ArrayList) readValue(buffer)); + return PlatformCameraUpdateScrollBy.fromList((ArrayList) readValue(buffer)); case (byte) 141: - return PlatformCameraUpdateZoom.fromList((ArrayList) readValue(buffer)); + return PlatformCameraUpdateZoomBy.fromList((ArrayList) readValue(buffer)); case (byte) 142: - return PlatformCameraUpdateZoomTo.fromList((ArrayList) readValue(buffer)); + return PlatformCameraUpdateZoom.fromList((ArrayList) readValue(buffer)); case (byte) 143: - return PlatformCircle.fromList((ArrayList) readValue(buffer)); + return PlatformCameraUpdateZoomTo.fromList((ArrayList) readValue(buffer)); case (byte) 144: - return PlatformHeatmap.fromList((ArrayList) readValue(buffer)); + return PlatformCircle.fromList((ArrayList) readValue(buffer)); case (byte) 145: - return PlatformClusterManager.fromList((ArrayList) readValue(buffer)); + return PlatformHeatmap.fromList((ArrayList) readValue(buffer)); case (byte) 146: - return PlatformOffset.fromList((ArrayList) readValue(buffer)); + return PlatformClusterManager.fromList((ArrayList) readValue(buffer)); case (byte) 147: - return PlatformInfoWindow.fromList((ArrayList) readValue(buffer)); + return PlatformOffset.fromList((ArrayList) readValue(buffer)); case (byte) 148: - return PlatformMarker.fromList((ArrayList) readValue(buffer)); + return PlatformInfoWindow.fromList((ArrayList) readValue(buffer)); case (byte) 149: - return PlatformPolygon.fromList((ArrayList) readValue(buffer)); + return PlatformMarker.fromList((ArrayList) readValue(buffer)); case (byte) 150: - return PlatformPolyline.fromList((ArrayList) readValue(buffer)); + return PlatformPolygon.fromList((ArrayList) readValue(buffer)); case (byte) 151: - return PlatformPatternItem.fromList((ArrayList) readValue(buffer)); + return PlatformPolyline.fromList((ArrayList) readValue(buffer)); case (byte) 152: - return PlatformTile.fromList((ArrayList) readValue(buffer)); + return PlatformCap.fromList((ArrayList) readValue(buffer)); case (byte) 153: - return PlatformTileOverlay.fromList((ArrayList) readValue(buffer)); + return PlatformPatternItem.fromList((ArrayList) readValue(buffer)); case (byte) 154: - return PlatformEdgeInsets.fromList((ArrayList) readValue(buffer)); + return PlatformTile.fromList((ArrayList) readValue(buffer)); case (byte) 155: - return PlatformLatLng.fromList((ArrayList) readValue(buffer)); + return PlatformTileOverlay.fromList((ArrayList) readValue(buffer)); case (byte) 156: - return PlatformLatLngBounds.fromList((ArrayList) readValue(buffer)); + return PlatformEdgeInsets.fromList((ArrayList) readValue(buffer)); case (byte) 157: - return PlatformCluster.fromList((ArrayList) readValue(buffer)); + return PlatformLatLng.fromList((ArrayList) readValue(buffer)); case (byte) 158: - return PlatformCameraTargetBounds.fromList((ArrayList) readValue(buffer)); + return PlatformLatLngBounds.fromList((ArrayList) readValue(buffer)); case (byte) 159: - return PlatformMapViewCreationParams.fromList((ArrayList) readValue(buffer)); + return PlatformCluster.fromList((ArrayList) readValue(buffer)); case (byte) 160: - return PlatformMapConfiguration.fromList((ArrayList) readValue(buffer)); + return PlatformCameraTargetBounds.fromList((ArrayList) readValue(buffer)); case (byte) 161: - return PlatformPoint.fromList((ArrayList) readValue(buffer)); + return PlatformMapViewCreationParams.fromList((ArrayList) readValue(buffer)); case (byte) 162: - return PlatformTileLayer.fromList((ArrayList) readValue(buffer)); + return PlatformMapConfiguration.fromList((ArrayList) readValue(buffer)); case (byte) 163: + return PlatformPoint.fromList((ArrayList) readValue(buffer)); + case (byte) 164: + return PlatformTileLayer.fromList((ArrayList) readValue(buffer)); + case (byte) 165: return PlatformZoomRange.fromList((ArrayList) readValue(buffer)); default: return super.readValueOfType(type, buffer); @@ -4985,101 +5129,107 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { } else if (value instanceof PlatformJointType) { stream.write(131); writeValue(stream, value == null ? null : ((PlatformJointType) value).index); - } else if (value instanceof PlatformPatternItemType) { + } else if (value instanceof PlatformCapType) { stream.write(132); + writeValue(stream, value == null ? null : ((PlatformCapType) value).index); + } else if (value instanceof PlatformPatternItemType) { + stream.write(133); writeValue(stream, value == null ? null : ((PlatformPatternItemType) value).index); } else if (value instanceof PlatformCameraPosition) { - stream.write(133); + stream.write(134); writeValue(stream, ((PlatformCameraPosition) value).toList()); } else if (value instanceof PlatformCameraUpdate) { - stream.write(134); + stream.write(135); writeValue(stream, ((PlatformCameraUpdate) value).toList()); } else if (value instanceof PlatformCameraUpdateNewCameraPosition) { - stream.write(135); + stream.write(136); writeValue(stream, ((PlatformCameraUpdateNewCameraPosition) value).toList()); } else if (value instanceof PlatformCameraUpdateNewLatLng) { - stream.write(136); + stream.write(137); writeValue(stream, ((PlatformCameraUpdateNewLatLng) value).toList()); } else if (value instanceof PlatformCameraUpdateNewLatLngBounds) { - stream.write(137); + stream.write(138); writeValue(stream, ((PlatformCameraUpdateNewLatLngBounds) value).toList()); } else if (value instanceof PlatformCameraUpdateNewLatLngZoom) { - stream.write(138); + stream.write(139); writeValue(stream, ((PlatformCameraUpdateNewLatLngZoom) value).toList()); } else if (value instanceof PlatformCameraUpdateScrollBy) { - stream.write(139); + stream.write(140); writeValue(stream, ((PlatformCameraUpdateScrollBy) value).toList()); } else if (value instanceof PlatformCameraUpdateZoomBy) { - stream.write(140); + stream.write(141); writeValue(stream, ((PlatformCameraUpdateZoomBy) value).toList()); } else if (value instanceof PlatformCameraUpdateZoom) { - stream.write(141); + stream.write(142); writeValue(stream, ((PlatformCameraUpdateZoom) value).toList()); } else if (value instanceof PlatformCameraUpdateZoomTo) { - stream.write(142); + stream.write(143); writeValue(stream, ((PlatformCameraUpdateZoomTo) value).toList()); } else if (value instanceof PlatformCircle) { - stream.write(143); + stream.write(144); writeValue(stream, ((PlatformCircle) value).toList()); } else if (value instanceof PlatformHeatmap) { - stream.write(144); + stream.write(145); writeValue(stream, ((PlatformHeatmap) value).toList()); } else if (value instanceof PlatformClusterManager) { - stream.write(145); + stream.write(146); writeValue(stream, ((PlatformClusterManager) value).toList()); } else if (value instanceof PlatformOffset) { - stream.write(146); + stream.write(147); writeValue(stream, ((PlatformOffset) value).toList()); } else if (value instanceof PlatformInfoWindow) { - stream.write(147); + stream.write(148); writeValue(stream, ((PlatformInfoWindow) value).toList()); } else if (value instanceof PlatformMarker) { - stream.write(148); + stream.write(149); writeValue(stream, ((PlatformMarker) value).toList()); } else if (value instanceof PlatformPolygon) { - stream.write(149); + stream.write(150); writeValue(stream, ((PlatformPolygon) value).toList()); } else if (value instanceof PlatformPolyline) { - stream.write(150); + stream.write(151); writeValue(stream, ((PlatformPolyline) value).toList()); + } else if (value instanceof PlatformCap) { + stream.write(152); + writeValue(stream, ((PlatformCap) value).toList()); } else if (value instanceof PlatformPatternItem) { - stream.write(151); + stream.write(153); writeValue(stream, ((PlatformPatternItem) value).toList()); } else if (value instanceof PlatformTile) { - stream.write(152); + stream.write(154); writeValue(stream, ((PlatformTile) value).toList()); } else if (value instanceof PlatformTileOverlay) { - stream.write(153); + stream.write(155); writeValue(stream, ((PlatformTileOverlay) value).toList()); } else if (value instanceof PlatformEdgeInsets) { - stream.write(154); + stream.write(156); writeValue(stream, ((PlatformEdgeInsets) value).toList()); } else if (value instanceof PlatformLatLng) { - stream.write(155); + stream.write(157); writeValue(stream, ((PlatformLatLng) value).toList()); } else if (value instanceof PlatformLatLngBounds) { - stream.write(156); + stream.write(158); writeValue(stream, ((PlatformLatLngBounds) value).toList()); } else if (value instanceof PlatformCluster) { - stream.write(157); + stream.write(159); writeValue(stream, ((PlatformCluster) value).toList()); } else if (value instanceof PlatformCameraTargetBounds) { - stream.write(158); + stream.write(160); writeValue(stream, ((PlatformCameraTargetBounds) value).toList()); } else if (value instanceof PlatformMapViewCreationParams) { - stream.write(159); + stream.write(161); writeValue(stream, ((PlatformMapViewCreationParams) value).toList()); } else if (value instanceof PlatformMapConfiguration) { - stream.write(160); + stream.write(162); writeValue(stream, ((PlatformMapConfiguration) value).toList()); } else if (value instanceof PlatformPoint) { - stream.write(161); + stream.write(163); writeValue(stream, ((PlatformPoint) value).toList()); } else if (value instanceof PlatformTileLayer) { - stream.write(162); + stream.write(164); writeValue(stream, ((PlatformTileLayer) value).toList()); } else if (value instanceof PlatformZoomRange) { - stream.write(163); + stream.write(165); writeValue(stream, ((PlatformZoomRange) value).toList()); } else { super.writeValue(stream, value); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart index 10fb6ece7558..c3e86cb1014b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart @@ -775,8 +775,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { polylineId: polyline.polylineId.value, consumesTapEvents: polyline.consumeTapEvents, color: polyline.color.value, - startCap: polyline.startCap.toJson(), - endCap: polyline.endCap.toJson(), + startCap: platformCapFromCap(polyline.startCap), + endCap: platformCapFromCap(polyline.endCap), geodesic: polyline.geodesic, visible: polyline.visible, width: polyline.width, @@ -1219,6 +1219,35 @@ PlatformJointType platformJointTypeFromJointType(JointType jointType) { return PlatformJointType.mitered; } +/// Converts platform interface's [Cap] to Pigeon's [PlatformCap]. +@visibleForTesting +PlatformCap platformCapFromCap(Cap cap) { + // TODO(schectman): Convert Cap to structured data. + // https://github.com/flutter/flutter/issues/155121 + final List json = cap.toJson() as List; + final String tag = json[0] as String; + switch (tag) { + case 'buttCap': + return PlatformCap(type: PlatformCapType.buttCap); + case 'roundCap': + return PlatformCap(type: PlatformCapType.roundCap); + case 'squareCap': + return PlatformCap(type: PlatformCapType.squareCap); + case 'customCap': + final Object bitmapDescriptor = json[1]; + final double refWidth = json[2] as double; + return PlatformCap( + type: PlatformCapType.customCap, + bitmapDescriptor: bitmapDescriptor, + refWidth: refWidth); + } + // The string tags used to identify the type of cap comes from a different + // package, which could get a new value at + // any time, so provide a fallback that ensures this won't break when used + // with a version that contains new values. + return PlatformCap(type: PlatformCapType.buttCap); +} + /// Converts a PatternItem to Pigeon's PlatformPatternItem for PlatformPolyline /// pattern member. @visibleForTesting diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart index 958e0bfdc996..1014782821c7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v22.3.0), do not edit directly. +// Autogenerated from Pigeon (v22.4.0), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers @@ -50,6 +50,16 @@ enum PlatformJointType { round, } +/// Enumeration of possible types of PlatformCap, corresponding to the +/// subclasses of Cap in the Google Maps Android SDK. +/// See https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/Cap. +enum PlatformCapType { + buttCap, + roundCap, + squareCap, + customCap, +} + /// Enumeration of possible types for PatternItem. enum PlatformPatternItemType { dot, @@ -669,10 +679,11 @@ class PlatformPolyline { List points; - /// The start and end cap data, as JSON. These should be set only from Cap.toJson, and the native code must interpret it according to the internal implementation details of that method. - Object startCap; + /// The cap at the start and end vertex of a polyline. + /// See https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/Cap. + PlatformCap startCap; - Object endCap; + PlatformCap endCap; bool visible; @@ -707,8 +718,8 @@ class PlatformPolyline { jointType: result[4]! as PlatformJointType, patterns: (result[5] as List?)!.cast(), points: (result[6] as List?)!.cast(), - startCap: result[7]!, - endCap: result[8]!, + startCap: result[7]! as PlatformCap, + endCap: result[8]! as PlatformCap, visible: result[9]! as bool, width: result[10]! as int, zIndex: result[11]! as int, @@ -716,6 +727,40 @@ class PlatformPolyline { } } +/// Pigeon equivalent of Cap from the platform interface. +/// https://github.com/flutter/packages/blob/main/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart +class PlatformCap { + PlatformCap({ + required this.type, + this.bitmapDescriptor, + this.refWidth, + }); + + PlatformCapType type; + + /// The JSON data returned by BitmapDescriptor.toJson. + Object? bitmapDescriptor; + + double? refWidth; + + Object encode() { + return [ + type, + bitmapDescriptor, + refWidth, + ]; + } + + static PlatformCap decode(Object result) { + result as List; + return PlatformCap( + type: result[0]! as PlatformCapType, + bitmapDescriptor: result[1], + refWidth: result[2] as double?, + ); + } +} + /// Pigeon equivalent of the PatternItem class. class PlatformPatternItem { PlatformPatternItem({ @@ -1264,101 +1309,107 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is PlatformJointType) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is PlatformPatternItemType) { + } else if (value is PlatformCapType) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is PlatformCameraPosition) { + } else if (value is PlatformPatternItemType) { buffer.putUint8(133); + writeValue(buffer, value.index); + } else if (value is PlatformCameraPosition) { + buffer.putUint8(134); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdate) { - buffer.putUint8(134); + buffer.putUint8(135); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdateNewCameraPosition) { - buffer.putUint8(135); + buffer.putUint8(136); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdateNewLatLng) { - buffer.putUint8(136); + buffer.putUint8(137); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdateNewLatLngBounds) { - buffer.putUint8(137); + buffer.putUint8(138); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdateNewLatLngZoom) { - buffer.putUint8(138); + buffer.putUint8(139); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdateScrollBy) { - buffer.putUint8(139); + buffer.putUint8(140); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdateZoomBy) { - buffer.putUint8(140); + buffer.putUint8(141); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdateZoom) { - buffer.putUint8(141); + buffer.putUint8(142); writeValue(buffer, value.encode()); } else if (value is PlatformCameraUpdateZoomTo) { - buffer.putUint8(142); + buffer.putUint8(143); writeValue(buffer, value.encode()); } else if (value is PlatformCircle) { - buffer.putUint8(143); + buffer.putUint8(144); writeValue(buffer, value.encode()); } else if (value is PlatformHeatmap) { - buffer.putUint8(144); + buffer.putUint8(145); writeValue(buffer, value.encode()); } else if (value is PlatformClusterManager) { - buffer.putUint8(145); + buffer.putUint8(146); writeValue(buffer, value.encode()); } else if (value is PlatformOffset) { - buffer.putUint8(146); + buffer.putUint8(147); writeValue(buffer, value.encode()); } else if (value is PlatformInfoWindow) { - buffer.putUint8(147); + buffer.putUint8(148); writeValue(buffer, value.encode()); } else if (value is PlatformMarker) { - buffer.putUint8(148); + buffer.putUint8(149); writeValue(buffer, value.encode()); } else if (value is PlatformPolygon) { - buffer.putUint8(149); + buffer.putUint8(150); writeValue(buffer, value.encode()); } else if (value is PlatformPolyline) { - buffer.putUint8(150); + buffer.putUint8(151); + writeValue(buffer, value.encode()); + } else if (value is PlatformCap) { + buffer.putUint8(152); writeValue(buffer, value.encode()); } else if (value is PlatformPatternItem) { - buffer.putUint8(151); + buffer.putUint8(153); writeValue(buffer, value.encode()); } else if (value is PlatformTile) { - buffer.putUint8(152); + buffer.putUint8(154); writeValue(buffer, value.encode()); } else if (value is PlatformTileOverlay) { - buffer.putUint8(153); + buffer.putUint8(155); writeValue(buffer, value.encode()); } else if (value is PlatformEdgeInsets) { - buffer.putUint8(154); + buffer.putUint8(156); writeValue(buffer, value.encode()); } else if (value is PlatformLatLng) { - buffer.putUint8(155); + buffer.putUint8(157); writeValue(buffer, value.encode()); } else if (value is PlatformLatLngBounds) { - buffer.putUint8(156); + buffer.putUint8(158); writeValue(buffer, value.encode()); } else if (value is PlatformCluster) { - buffer.putUint8(157); + buffer.putUint8(159); writeValue(buffer, value.encode()); } else if (value is PlatformCameraTargetBounds) { - buffer.putUint8(158); + buffer.putUint8(160); writeValue(buffer, value.encode()); } else if (value is PlatformMapViewCreationParams) { - buffer.putUint8(159); + buffer.putUint8(161); writeValue(buffer, value.encode()); } else if (value is PlatformMapConfiguration) { - buffer.putUint8(160); + buffer.putUint8(162); writeValue(buffer, value.encode()); } else if (value is PlatformPoint) { - buffer.putUint8(161); + buffer.putUint8(163); writeValue(buffer, value.encode()); } else if (value is PlatformTileLayer) { - buffer.putUint8(162); + buffer.putUint8(164); writeValue(buffer, value.encode()); } else if (value is PlatformZoomRange) { - buffer.putUint8(163); + buffer.putUint8(165); writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); @@ -1379,68 +1430,73 @@ class _PigeonCodec extends StandardMessageCodec { return value == null ? null : PlatformJointType.values[value]; case 132: final int? value = readValue(buffer) as int?; - return value == null ? null : PlatformPatternItemType.values[value]; + return value == null ? null : PlatformCapType.values[value]; case 133: - return PlatformCameraPosition.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null ? null : PlatformPatternItemType.values[value]; case 134: - return PlatformCameraUpdate.decode(readValue(buffer)!); + return PlatformCameraPosition.decode(readValue(buffer)!); case 135: - return PlatformCameraUpdateNewCameraPosition.decode(readValue(buffer)!); + return PlatformCameraUpdate.decode(readValue(buffer)!); case 136: - return PlatformCameraUpdateNewLatLng.decode(readValue(buffer)!); + return PlatformCameraUpdateNewCameraPosition.decode(readValue(buffer)!); case 137: - return PlatformCameraUpdateNewLatLngBounds.decode(readValue(buffer)!); + return PlatformCameraUpdateNewLatLng.decode(readValue(buffer)!); case 138: - return PlatformCameraUpdateNewLatLngZoom.decode(readValue(buffer)!); + return PlatformCameraUpdateNewLatLngBounds.decode(readValue(buffer)!); case 139: - return PlatformCameraUpdateScrollBy.decode(readValue(buffer)!); + return PlatformCameraUpdateNewLatLngZoom.decode(readValue(buffer)!); case 140: - return PlatformCameraUpdateZoomBy.decode(readValue(buffer)!); + return PlatformCameraUpdateScrollBy.decode(readValue(buffer)!); case 141: - return PlatformCameraUpdateZoom.decode(readValue(buffer)!); + return PlatformCameraUpdateZoomBy.decode(readValue(buffer)!); case 142: - return PlatformCameraUpdateZoomTo.decode(readValue(buffer)!); + return PlatformCameraUpdateZoom.decode(readValue(buffer)!); case 143: - return PlatformCircle.decode(readValue(buffer)!); + return PlatformCameraUpdateZoomTo.decode(readValue(buffer)!); case 144: - return PlatformHeatmap.decode(readValue(buffer)!); + return PlatformCircle.decode(readValue(buffer)!); case 145: - return PlatformClusterManager.decode(readValue(buffer)!); + return PlatformHeatmap.decode(readValue(buffer)!); case 146: - return PlatformOffset.decode(readValue(buffer)!); + return PlatformClusterManager.decode(readValue(buffer)!); case 147: - return PlatformInfoWindow.decode(readValue(buffer)!); + return PlatformOffset.decode(readValue(buffer)!); case 148: - return PlatformMarker.decode(readValue(buffer)!); + return PlatformInfoWindow.decode(readValue(buffer)!); case 149: - return PlatformPolygon.decode(readValue(buffer)!); + return PlatformMarker.decode(readValue(buffer)!); case 150: - return PlatformPolyline.decode(readValue(buffer)!); + return PlatformPolygon.decode(readValue(buffer)!); case 151: - return PlatformPatternItem.decode(readValue(buffer)!); + return PlatformPolyline.decode(readValue(buffer)!); case 152: - return PlatformTile.decode(readValue(buffer)!); + return PlatformCap.decode(readValue(buffer)!); case 153: - return PlatformTileOverlay.decode(readValue(buffer)!); + return PlatformPatternItem.decode(readValue(buffer)!); case 154: - return PlatformEdgeInsets.decode(readValue(buffer)!); + return PlatformTile.decode(readValue(buffer)!); case 155: - return PlatformLatLng.decode(readValue(buffer)!); + return PlatformTileOverlay.decode(readValue(buffer)!); case 156: - return PlatformLatLngBounds.decode(readValue(buffer)!); + return PlatformEdgeInsets.decode(readValue(buffer)!); case 157: - return PlatformCluster.decode(readValue(buffer)!); + return PlatformLatLng.decode(readValue(buffer)!); case 158: - return PlatformCameraTargetBounds.decode(readValue(buffer)!); + return PlatformLatLngBounds.decode(readValue(buffer)!); case 159: - return PlatformMapViewCreationParams.decode(readValue(buffer)!); + return PlatformCluster.decode(readValue(buffer)!); case 160: - return PlatformMapConfiguration.decode(readValue(buffer)!); + return PlatformCameraTargetBounds.decode(readValue(buffer)!); case 161: - return PlatformPoint.decode(readValue(buffer)!); + return PlatformMapViewCreationParams.decode(readValue(buffer)!); case 162: - return PlatformTileLayer.decode(readValue(buffer)!); + return PlatformMapConfiguration.decode(readValue(buffer)!); case 163: + return PlatformPoint.decode(readValue(buffer)!); + case 164: + return PlatformTileLayer.decode(readValue(buffer)!); + case 165: return PlatformZoomRange.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart index 8ed6ebb061e1..100a79531417 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart @@ -267,15 +267,40 @@ class PlatformPolyline { final List patterns; final List points; - /// The start and end cap data, as JSON. These should be set only from Cap.toJson, and the native code must interpret it according to the internal implementation details of that method. - // TODO(schectman): Convert below two fields to structured data. - final Object startCap; - final Object endCap; + /// The cap at the start and end vertex of a polyline. + /// See https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/Cap. + final PlatformCap startCap; + final PlatformCap endCap; + final bool visible; final int width; final int zIndex; } +/// Enumeration of possible types of PlatformCap, corresponding to the +/// subclasses of Cap in the Google Maps Android SDK. +/// See https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/Cap. +enum PlatformCapType { + buttCap, + roundCap, + squareCap, + customCap, +} + +/// Pigeon equivalent of Cap from the platform interface. +/// https://github.com/flutter/packages/blob/main/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart +class PlatformCap { + PlatformCap({required this.type, this.bitmapDescriptor, this.refWidth}); + + final PlatformCapType type; + + /// The JSON data returned by BitmapDescriptor.toJson. + // TODO(schectman): Convert to structured data. + // https://github.com/flutter/flutter/issues/155122 + final Object? bitmapDescriptor; + final double? refWidth; +} + /// Enumeration of possible types for PatternItem. enum PlatformPatternItemType { dot, 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 f44ad69f18de..1d0f5774fe38 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.14.8 +version: 2.14.9 environment: sdk: ^3.5.0 diff --git a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart index bd2ceb82dabe..512dea6fcf46 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart @@ -533,8 +533,14 @@ void main() { const Polyline object1 = Polyline(polylineId: PolylineId('1')); const Polyline object2old = Polyline(polylineId: PolylineId('2')); - final Polyline object2new = object2old.copyWith(widthParam: 42); - const Polyline object3 = Polyline(polylineId: PolylineId('3')); + final Polyline object2new = object2old.copyWith( + widthParam: 42, startCapParam: Cap.squareCap, endCapParam: Cap.buttCap); + final Cap customCap = + Cap.customCapFromBitmap(BitmapDescriptor.defaultMarker, refWidth: 15); + final Polyline object3 = Polyline( + polylineId: const PolylineId('3'), + startCap: customCap, + endCap: Cap.roundCap); await maps.updatePolylines( PolylineUpdates.from( {object1, object2old}, {object2new, object3}), @@ -572,6 +578,10 @@ void main() { expect(pattern?.encode(), platformPatternItemFromPatternItem(expected.patterns[i]).encode()); } + expect(actual.startCap.encode(), + platformCapFromCap(expected.startCap).encode()); + expect( + actual.endCap.encode(), platformCapFromCap(expected.endCap).encode()); } // Object one should be removed.