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 fa6f77a4219..1b2a6366ab7 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,8 @@ +## 2.14.10 + +* Adds 'PlatformBitmap' type. +* Updates type unsafe implementations. + ## 2.14.9 * Adds `PlatformCap` for `PlatformPolyline.startCap` and `endCap`. 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 b8617c8fa56..5701825f12d 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 @@ -61,94 +61,82 @@ class Convert { public static final String HEATMAP_GRADIENT_COLOR_MAP_SIZE_KEY = "colorMapSize"; private static BitmapDescriptor toBitmapDescriptor( - Object o, AssetManager assetManager, float density) { - return toBitmapDescriptor(o, assetManager, density, new BitmapDescriptorFactoryWrapper()); + Messages.PlatformBitmap platformBitmap, AssetManager assetManager, float density) { + return toBitmapDescriptor( + platformBitmap, assetManager, density, new BitmapDescriptorFactoryWrapper()); } private static BitmapDescriptor toBitmapDescriptor( - Object o, AssetManager assetManager, float density, BitmapDescriptorFactoryWrapper wrapper) { - final List data = toList(o); - final String descriptorType = toString(data.get(0)); - switch (descriptorType) { - case "defaultMarker": - if (data.size() == 1) { - return BitmapDescriptorFactory.defaultMarker(); - } else { - final float hue = toFloat(data.get(1)); - return BitmapDescriptorFactory.defaultMarker(hue); - } - case "fromAsset": - final String assetPath = toString(data.get(1)); - if (data.size() == 2) { - return BitmapDescriptorFactory.fromAsset( - FlutterInjector.instance().flutterLoader().getLookupKeyForAsset(assetPath)); - } else { - final String assetPackage = toString(data.get(2)); - return BitmapDescriptorFactory.fromAsset( - FlutterInjector.instance() - .flutterLoader() - .getLookupKeyForAsset(assetPath, assetPackage)); - } - case "fromAssetImage": - final String assetImagePath = toString(data.get(1)); - if (data.size() == 3) { - return BitmapDescriptorFactory.fromAsset( - FlutterInjector.instance().flutterLoader().getLookupKeyForAsset(assetImagePath)); - } else { - throw new IllegalArgumentException( - "'fromAssetImage' Expected exactly 3 arguments, got: " + data.size()); - } - case "fromBytes": - return getBitmapFromBytesLegacy(data); - case "asset": - if (!(data.get(1) instanceof Map)) { - throw new IllegalArgumentException("'asset' expected a map as the second parameter"); - } - final Map assetData = toMap(data.get(1)); - return getBitmapFromAsset( - assetData, assetManager, density, wrapper, new FlutterInjectorWrapper()); - case "bytes": - if (!(data.get(1) instanceof Map)) { - throw new IllegalArgumentException("'bytes' expected a map as the second parameter"); - } - final Map byteData = toMap(data.get(1)); - return getBitmapFromBytes(byteData, density, wrapper); - default: - throw new IllegalArgumentException("Cannot interpret " + o + " as BitmapDescriptor"); + Messages.PlatformBitmap platformBitmap, + AssetManager assetManager, + float density, + BitmapDescriptorFactoryWrapper wrapper) { + Object bitmap = platformBitmap.getBitmap(); + if (bitmap instanceof Messages.PlatformBitmapDefaultMarker) { + Messages.PlatformBitmapDefaultMarker typedBitmap = + (Messages.PlatformBitmapDefaultMarker) bitmap; + if (typedBitmap.getHue() == null) { + return BitmapDescriptorFactory.defaultMarker(); + } else { + final float hue = typedBitmap.getHue().floatValue(); + return BitmapDescriptorFactory.defaultMarker(hue); + } } + if (bitmap instanceof Messages.PlatformBitmapAsset) { + Messages.PlatformBitmapAsset typedBitmap = (Messages.PlatformBitmapAsset) bitmap; + final String assetPath = typedBitmap.getName(); + final String assetPackage = typedBitmap.getPkg(); + if (assetPackage == null) { + return BitmapDescriptorFactory.fromAsset( + FlutterInjector.instance().flutterLoader().getLookupKeyForAsset(assetPath)); + } else { + return BitmapDescriptorFactory.fromAsset( + FlutterInjector.instance() + .flutterLoader() + .getLookupKeyForAsset(assetPath, assetPackage)); + } + } + if (bitmap instanceof Messages.PlatformBitmapAssetImage) { + Messages.PlatformBitmapAssetImage typedBitmap = (Messages.PlatformBitmapAssetImage) bitmap; + final String assetImagePath = typedBitmap.getName(); + return BitmapDescriptorFactory.fromAsset( + FlutterInjector.instance().flutterLoader().getLookupKeyForAsset(assetImagePath)); + } + if (bitmap instanceof Messages.PlatformBitmapBytes) { + Messages.PlatformBitmapBytes typedBitmap = (Messages.PlatformBitmapBytes) bitmap; + return getBitmapFromBytesLegacy(typedBitmap); + } + if (bitmap instanceof Messages.PlatformBitmapAssetMap) { + Messages.PlatformBitmapAssetMap typedBitmap = (Messages.PlatformBitmapAssetMap) bitmap; + return getBitmapFromAsset( + typedBitmap, assetManager, density, wrapper, new FlutterInjectorWrapper()); + } + if (bitmap instanceof Messages.PlatformBitmapBytesMap) { + Messages.PlatformBitmapBytesMap typedBitmap = (Messages.PlatformBitmapBytesMap) bitmap; + return getBitmapFromBytes(typedBitmap, density, wrapper); + } + throw new IllegalArgumentException("PlatformBitmap did not contain a supported subtype."); } // Used for deprecated fromBytes bitmap descriptor. // Can be removed after support for "fromBytes" bitmap descriptor type is // removed. - private static BitmapDescriptor getBitmapFromBytesLegacy(List data) { - if (data.size() == 2) { - try { - Bitmap bitmap = toBitmap(data.get(1)); - return BitmapDescriptorFactory.fromBitmap(bitmap); - } catch (Exception e) { - throw new IllegalArgumentException("Unable to interpret bytes as a valid image.", e); - } - } else { - throw new IllegalArgumentException( - "fromBytes should have exactly one argument, interpretTileOverlayOptions the bytes. Got: " - + data.size()); + private static BitmapDescriptor getBitmapFromBytesLegacy( + Messages.PlatformBitmapBytes bitmapBytes) { + try { + Bitmap bitmap = toBitmap(bitmapBytes.getByteData()); + return BitmapDescriptorFactory.fromBitmap(bitmap); + } catch (Exception e) { + throw new IllegalArgumentException("Unable to interpret bytes as a valid image.", e); } } /** * Creates a BitmapDescriptor object from bytes data. * - *

This method requires the `byteData` map to contain specific keys: 'byteData' for image - * bytes, 'bitmapScaling' for scaling mode, and 'imagePixelRatio' for scale ratio. It may - * optionally include 'width' and/or 'height' for explicit image dimensions. - * - * @param byteData a map containing the byte data and scaling instructions. Expected keys are: - * 'byteData': the actual bytes of the image, 'bitmapScaling': the scaling mode, either 'auto' - * or 'none', 'imagePixelRatio': used with 'auto' bitmapScaling if width or height are not - * provided, 'width' (optional): the desired width, which affects scaling if 'height' is not - * provided, 'height' (optional): the desired height, which affects scaling if 'width' is not - * provided + * @param bytesMap a [PlatformBitmapBytesMap] containing the byte data from which to construct a + * [BitmapDescriptor] and a bitmap scaling mode. The optional `width` affects scaling when + * `height` is `null`, and the optional `height` affects scaling when `width` is `null. * @param density the density of the display, used to calculate pixel dimensions. * @param bitmapDescriptorFactory is an instance of the BitmapDescriptorFactoryWrapper. * @return BitmapDescriptor object from bytes data. @@ -157,34 +145,16 @@ private static BitmapDescriptor getBitmapFromBytesLegacy(List data) { */ @VisibleForTesting public static BitmapDescriptor getBitmapFromBytes( - Map byteData, float density, BitmapDescriptorFactoryWrapper bitmapDescriptorFactory) { - - final String byteDataKey = "byteData"; - final String bitmapScalingKey = "bitmapScaling"; - final String imagePixelRatioKey = "imagePixelRatio"; - - if (!byteData.containsKey(byteDataKey)) { - throw new IllegalArgumentException("'bytes' requires '" + byteDataKey + "' key."); - } - if (!byteData.containsKey(bitmapScalingKey)) { - throw new IllegalArgumentException("'bytes' requires '" + bitmapScalingKey + "' key."); - } - if (!byteData.containsKey(imagePixelRatioKey)) { - throw new IllegalArgumentException("'bytes' requires '" + imagePixelRatioKey + "' key."); - } - + Messages.PlatformBitmapBytesMap bytesMap, + float density, + BitmapDescriptorFactoryWrapper bitmapDescriptorFactory) { try { - Bitmap bitmap = toBitmap(byteData.get(byteDataKey)); - String scalingMode = toString(byteData.get(bitmapScalingKey)); + Bitmap bitmap = toBitmap(bytesMap.getByteData()); + Messages.PlatformMapBitmapScaling scalingMode = bytesMap.getBitmapScaling(); switch (scalingMode) { - case "auto": - final String widthKey = "width"; - final String heightKey = "height"; - - final Double width = - byteData.containsKey(widthKey) ? toDouble(byteData.get(widthKey)) : null; - final Double height = - byteData.containsKey(heightKey) ? toDouble(byteData.get(heightKey)) : null; + case AUTO: + final Double width = bytesMap.getWidth(); + final Double height = bytesMap.getHeight(); if (width != null || height != null) { int targetWidth = width != null ? toInt(width * density) : bitmap.getWidth(); @@ -203,10 +173,10 @@ public static BitmapDescriptor getBitmapFromBytes( toScaledBitmap(bitmap, targetWidth, targetHeight)); } else { // Scale image using given scale ratio - final float scale = density / toFloat(byteData.get(imagePixelRatioKey)); + final float scale = density / bytesMap.getImagePixelRatio().floatValue(); return bitmapDescriptorFactory.fromBitmap(toScaledBitmap(bitmap, scale)); } - case "none": + case NONE: break; } return bitmapDescriptorFactory.fromBitmap(bitmap); @@ -219,15 +189,13 @@ public static BitmapDescriptor getBitmapFromBytes( * Creates a BitmapDescriptor object from asset, using given details and density. * *

This method processes an asset specified by name and applies scaling based on the provided - * parameters. The `assetDetails` map must contain the keys 'assetName', 'bitmapScaling', and - * 'imagePixelRatio', and may optionally include 'width' and/or 'height' to explicitly set the - * dimensions of the output image. + * parameters. The `assetMap` object provides the asset name, bitmap scaling mode, and image pixel + * ratio, and may optionally include 'width' and/or 'height' to explicitly set the dimensions of + * the output image. * - * @param assetDetails a map containing the asset details and scaling instructions, with keys - * 'assetName': the name of the asset file, 'bitmapScaling': the scaling mode, either 'auto' - * or 'none', 'imagePixelRatio': used with 'auto' scaling to compute the scale ratio, 'width' - * (optional): the desired width, which affects scaling if 'height' is not provided, 'height' - * (optional): the desired height, which affects scaling if 'width' is not provided + * @param assetMap a [PlatformBitmapAssetMap] containing the asset name from which to construct a + * [BitmapDescriptor] and a bitmap scaling mode. The optional `width` affects scaling when + * `height` is `null`, and the optional `height` affects scaling when `width` is `null. * @param assetManager assetManager An instance of Android's AssetManager, which provides access * to any raw asset files stored in the application's assets directory. * @param density density the density of the display, used to calculate pixel dimensions. @@ -239,39 +207,19 @@ public static BitmapDescriptor getBitmapFromBytes( */ @VisibleForTesting public static BitmapDescriptor getBitmapFromAsset( - Map assetDetails, + Messages.PlatformBitmapAssetMap assetMap, AssetManager assetManager, float density, BitmapDescriptorFactoryWrapper bitmapDescriptorFactory, FlutterInjectorWrapper flutterInjector) { - - final String assetNameKey = "assetName"; - final String bitmapScalingKey = "bitmapScaling"; - final String imagePixelRatioKey = "imagePixelRatio"; - - if (!assetDetails.containsKey(assetNameKey)) { - throw new IllegalArgumentException("'asset' requires '" + assetNameKey + "' key."); - } - if (!assetDetails.containsKey(bitmapScalingKey)) { - throw new IllegalArgumentException("'asset' requires '" + bitmapScalingKey + "' key."); - } - if (!assetDetails.containsKey(imagePixelRatioKey)) { - throw new IllegalArgumentException("'asset' requires '" + imagePixelRatioKey + "' key."); - } - - final String assetName = toString(assetDetails.get(assetNameKey)); + final String assetName = assetMap.getAssetName(); final String assetKey = flutterInjector.getLookupKeyForAsset(assetName); - String scalingMode = toString(assetDetails.get(bitmapScalingKey)); + Messages.PlatformMapBitmapScaling scalingMode = assetMap.getBitmapScaling(); switch (scalingMode) { - case "auto": - final String widthKey = "width"; - final String heightKey = "height"; - - final Double width = - assetDetails.containsKey(widthKey) ? toDouble(assetDetails.get(widthKey)) : null; - final Double height = - assetDetails.containsKey(heightKey) ? toDouble(assetDetails.get(heightKey)) : null; + case AUTO: + final Double width = assetMap.getWidth(); + final Double height = assetMap.getHeight(); InputStream inputStream = null; try { inputStream = assetManager.open(assetKey); @@ -294,7 +242,7 @@ public static BitmapDescriptor getBitmapFromAsset( toScaledBitmap(bitmap, targetWidth, targetHeight)); } else { // Scale image using given scale. - final float scale = density / toFloat(assetDetails.get(imagePixelRatioKey)); + final float scale = density / assetMap.getImagePixelRatio().floatValue(); return bitmapDescriptorFactory.fromBitmap(toScaledBitmap(bitmap, scale)); } } catch (Exception e) { @@ -308,7 +256,7 @@ public static BitmapDescriptor getBitmapFromAsset( } } } - case "none": + case NONE: break; } @@ -500,11 +448,11 @@ static Point pointFromPigeon(Messages.PlatformPoint point) { } @Nullable - static Point pointFromPigeon(@Nullable Messages.PlatformOffset point, float density) { + static Point pointFromPigeon(@Nullable Messages.PlatformDoublePair point, float density) { if (point == null) { return null; } - return new Point((int) (point.getDx() * density), (int) (point.getDy() * density)); + return new Point((int) (point.getX() * density), (int) (point.getY() * density)); } static Messages.PlatformPoint pointToPigeon(Point point) { @@ -519,8 +467,7 @@ private static List toList(Object o) { return (Map) o; } - private static Bitmap toBitmap(Object o) { - byte[] bmpData = (byte[]) o; + private static Bitmap toBitmap(byte[] bmpData) { Bitmap bitmap = BitmapFactory.decodeByteArray(bmpData, 0, bmpData.length); if (bitmap == null) { throw new IllegalArgumentException("Unable to decode bytes as a valid bitmap."); @@ -548,10 +495,6 @@ private static Bitmap toScaledBitmap(Bitmap bitmap, int width, int height) { return bitmap; } - private static String toString(Object o) { - return (String) o; - } - static void interpretMapConfiguration( @NonNull Messages.PlatformMapConfiguration config, @NonNull GoogleMapOptionsSink sink) { final Messages.PlatformCameraTargetBounds cameraTargetBounds = config.getCameraTargetBounds(); @@ -647,8 +590,7 @@ static void interpretMarkerOptions( float density, BitmapDescriptorFactoryWrapper wrapper) { sink.setAlpha(marker.getAlpha().floatValue()); - sink.setAnchor( - marker.getAnchor().getDx().floatValue(), marker.getAnchor().getDy().floatValue()); + sink.setAnchor(marker.getAnchor().getX().floatValue(), marker.getAnchor().getY().floatValue()); sink.setConsumeTapEvents(marker.getConsumeTapEvents()); sink.setDraggable(marker.getDraggable()); sink.setFlat(marker.getFlat()); @@ -666,9 +608,9 @@ private static void interpretInfoWindowOptions( if (title != null) { sink.setInfoWindowText(title, infoWindow.getSnippet()); } - Messages.PlatformOffset infoWindowAnchor = infoWindow.getAnchor(); + Messages.PlatformDoublePair infoWindowAnchor = infoWindow.getAnchor(); sink.setInfoWindowAnchor( - infoWindowAnchor.getDx().floatValue(), infoWindowAnchor.getDy().floatValue()); + infoWindowAnchor.getX().floatValue(), infoWindowAnchor.getY().floatValue()); } static String interpretPolygonOptions(Messages.PlatformPolygon polygon, PolygonOptionsSink sink) { @@ -891,7 +833,7 @@ private static Cap capFromPigeon( toBitmapDescriptor(cap.getBitmapDescriptor(), assetManager, density), cap.getRefWidth().floatValue()); } - throw new IllegalArgumentException("Unrecognized Cap type: " + cap.getType()); + throw new IllegalArgumentException("Unrecognized PlatformCap 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 1227826382c..d2e29fab127 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 @@ -144,6 +144,18 @@ public enum PlatformPatternItemType { } } + /** Pigeon equivalent of [MapBitmapScaling]. */ + public enum PlatformMapBitmapScaling { + AUTO(0), + NONE(1); + + final int index; + + PlatformMapBitmapScaling(final int index) { + this.index = index; + } + } + /** * Pigeon representatation of a CameraPosition. * @@ -827,13 +839,13 @@ public void setAmount(@NonNull Double setterArg) { this.amount = setterArg; } - private @Nullable PlatformOffset focus; + private @Nullable PlatformDoublePair focus; - public @Nullable PlatformOffset getFocus() { + public @Nullable PlatformDoublePair getFocus() { return focus; } - public void setFocus(@Nullable PlatformOffset setterArg) { + public void setFocus(@Nullable PlatformDoublePair setterArg) { this.focus = setterArg; } @@ -867,10 +879,10 @@ public static final class Builder { return this; } - private @Nullable PlatformOffset focus; + private @Nullable PlatformDoublePair focus; @CanIgnoreReturnValue - public @NonNull Builder setFocus(@Nullable PlatformOffset setterArg) { + public @NonNull Builder setFocus(@Nullable PlatformDoublePair setterArg) { this.focus = setterArg; return this; } @@ -896,7 +908,7 @@ ArrayList toList() { Object amount = pigeonVar_list.get(0); pigeonResult.setAmount((Double) amount); Object focus = pigeonVar_list.get(1); - pigeonResult.setFocus((PlatformOffset) focus); + pigeonResult.setFocus((PlatformDoublePair) focus); return pigeonResult; } } @@ -1478,39 +1490,39 @@ ArrayList toList() { } /** - * Pigeon equivalent of the Offset class. + * Pair of double values, such as for an offset or size. * *

Generated class from Pigeon that represents data sent in messages. */ - public static final class PlatformOffset { - private @NonNull Double dx; + public static final class PlatformDoublePair { + private @NonNull Double x; - public @NonNull Double getDx() { - return dx; + public @NonNull Double getX() { + return x; } - public void setDx(@NonNull Double setterArg) { + public void setX(@NonNull Double setterArg) { if (setterArg == null) { - throw new IllegalStateException("Nonnull field \"dx\" is null."); + throw new IllegalStateException("Nonnull field \"x\" is null."); } - this.dx = setterArg; + this.x = setterArg; } - private @NonNull Double dy; + private @NonNull Double y; - public @NonNull Double getDy() { - return dy; + public @NonNull Double getY() { + return y; } - public void setDy(@NonNull Double setterArg) { + public void setY(@NonNull Double setterArg) { if (setterArg == null) { - throw new IllegalStateException("Nonnull field \"dy\" is null."); + throw new IllegalStateException("Nonnull field \"y\" is null."); } - this.dy = setterArg; + this.y = setterArg; } /** Constructor is non-public to enforce null safety; use Builder. */ - PlatformOffset() {} + PlatformDoublePair() {} @Override public boolean equals(Object o) { @@ -1520,37 +1532,37 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - PlatformOffset that = (PlatformOffset) o; - return dx.equals(that.dx) && dy.equals(that.dy); + PlatformDoublePair that = (PlatformDoublePair) o; + return x.equals(that.x) && y.equals(that.y); } @Override public int hashCode() { - return Objects.hash(dx, dy); + return Objects.hash(x, y); } public static final class Builder { - private @Nullable Double dx; + private @Nullable Double x; @CanIgnoreReturnValue - public @NonNull Builder setDx(@NonNull Double setterArg) { - this.dx = setterArg; + public @NonNull Builder setX(@NonNull Double setterArg) { + this.x = setterArg; return this; } - private @Nullable Double dy; + private @Nullable Double y; @CanIgnoreReturnValue - public @NonNull Builder setDy(@NonNull Double setterArg) { - this.dy = setterArg; + public @NonNull Builder setY(@NonNull Double setterArg) { + this.y = setterArg; return this; } - public @NonNull PlatformOffset build() { - PlatformOffset pigeonReturn = new PlatformOffset(); - pigeonReturn.setDx(dx); - pigeonReturn.setDy(dy); + public @NonNull PlatformDoublePair build() { + PlatformDoublePair pigeonReturn = new PlatformDoublePair(); + pigeonReturn.setX(x); + pigeonReturn.setY(y); return pigeonReturn; } } @@ -1558,17 +1570,17 @@ public static final class Builder { @NonNull ArrayList toList() { ArrayList toListResult = new ArrayList<>(2); - toListResult.add(dx); - toListResult.add(dy); + toListResult.add(x); + toListResult.add(y); return toListResult; } - static @NonNull PlatformOffset fromList(@NonNull ArrayList pigeonVar_list) { - PlatformOffset pigeonResult = new PlatformOffset(); - Object dx = pigeonVar_list.get(0); - pigeonResult.setDx((Double) dx); - Object dy = pigeonVar_list.get(1); - pigeonResult.setDy((Double) dy); + static @NonNull PlatformDoublePair fromList(@NonNull ArrayList pigeonVar_list) { + PlatformDoublePair pigeonResult = new PlatformDoublePair(); + Object x = pigeonVar_list.get(0); + pigeonResult.setX((Double) x); + Object y = pigeonVar_list.get(1); + pigeonResult.setY((Double) y); return pigeonResult; } } @@ -1599,13 +1611,13 @@ public void setSnippet(@Nullable String setterArg) { this.snippet = setterArg; } - private @NonNull PlatformOffset anchor; + private @NonNull PlatformDoublePair anchor; - public @NonNull PlatformOffset getAnchor() { + public @NonNull PlatformDoublePair getAnchor() { return anchor; } - public void setAnchor(@NonNull PlatformOffset setterArg) { + public void setAnchor(@NonNull PlatformDoublePair setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"anchor\" is null."); } @@ -1652,10 +1664,10 @@ public static final class Builder { return this; } - private @Nullable PlatformOffset anchor; + private @Nullable PlatformDoublePair anchor; @CanIgnoreReturnValue - public @NonNull Builder setAnchor(@NonNull PlatformOffset setterArg) { + public @NonNull Builder setAnchor(@NonNull PlatformDoublePair setterArg) { this.anchor = setterArg; return this; } @@ -1685,7 +1697,7 @@ ArrayList toList() { Object snippet = pigeonVar_list.get(1); pigeonResult.setSnippet((String) snippet); Object anchor = pigeonVar_list.get(2); - pigeonResult.setAnchor((PlatformOffset) anchor); + pigeonResult.setAnchor((PlatformDoublePair) anchor); return pigeonResult; } } @@ -1709,13 +1721,13 @@ public void setAlpha(@NonNull Double setterArg) { this.alpha = setterArg; } - private @NonNull PlatformOffset anchor; + private @NonNull PlatformDoublePair anchor; - public @NonNull PlatformOffset getAnchor() { + public @NonNull PlatformDoublePair getAnchor() { return anchor; } - public void setAnchor(@NonNull PlatformOffset setterArg) { + public void setAnchor(@NonNull PlatformDoublePair setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"anchor\" is null."); } @@ -1761,14 +1773,13 @@ public void setFlat(@NonNull Boolean setterArg) { this.flat = setterArg; } - /** The icon as JSON data. */ - private @NonNull Object icon; + private @NonNull PlatformBitmap icon; - public @NonNull Object getIcon() { + public @NonNull PlatformBitmap getIcon() { return icon; } - public void setIcon(@NonNull Object setterArg) { + public void setIcon(@NonNull PlatformBitmap setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"icon\" is null."); } @@ -1918,10 +1929,10 @@ public static final class Builder { return this; } - private @Nullable PlatformOffset anchor; + private @Nullable PlatformDoublePair anchor; @CanIgnoreReturnValue - public @NonNull Builder setAnchor(@NonNull PlatformOffset setterArg) { + public @NonNull Builder setAnchor(@NonNull PlatformDoublePair setterArg) { this.anchor = setterArg; return this; } @@ -1950,10 +1961,10 @@ public static final class Builder { return this; } - private @Nullable Object icon; + private @Nullable PlatformBitmap icon; @CanIgnoreReturnValue - public @NonNull Builder setIcon(@NonNull Object setterArg) { + public @NonNull Builder setIcon(@NonNull PlatformBitmap setterArg) { this.icon = setterArg; return this; } @@ -2057,7 +2068,7 @@ ArrayList toList() { Object alpha = pigeonVar_list.get(0); pigeonResult.setAlpha((Double) alpha); Object anchor = pigeonVar_list.get(1); - pigeonResult.setAnchor((PlatformOffset) anchor); + pigeonResult.setAnchor((PlatformDoublePair) anchor); Object consumeTapEvents = pigeonVar_list.get(2); pigeonResult.setConsumeTapEvents((Boolean) consumeTapEvents); Object draggable = pigeonVar_list.get(3); @@ -2065,7 +2076,7 @@ ArrayList toList() { Object flat = pigeonVar_list.get(4); pigeonResult.setFlat((Boolean) flat); Object icon = pigeonVar_list.get(5); - pigeonResult.setIcon(icon); + pigeonResult.setIcon((PlatformBitmap) icon); Object infoWindow = pigeonVar_list.get(6); pigeonResult.setInfoWindow((PlatformInfoWindow) infoWindow); Object position = pigeonVar_list.get(7); @@ -2794,14 +2805,13 @@ public void setType(@NonNull PlatformCapType setterArg) { this.type = setterArg; } - /** The JSON data returned by BitmapDescriptor.toJson. */ - private @Nullable Object bitmapDescriptor; + private @Nullable PlatformBitmap bitmapDescriptor; - public @Nullable Object getBitmapDescriptor() { + public @Nullable PlatformBitmap getBitmapDescriptor() { return bitmapDescriptor; } - public void setBitmapDescriptor(@Nullable Object setterArg) { + public void setBitmapDescriptor(@Nullable PlatformBitmap setterArg) { this.bitmapDescriptor = setterArg; } @@ -2847,10 +2857,10 @@ public static final class Builder { return this; } - private @Nullable Object bitmapDescriptor; + private @Nullable PlatformBitmap bitmapDescriptor; @CanIgnoreReturnValue - public @NonNull Builder setBitmapDescriptor(@Nullable Object setterArg) { + public @NonNull Builder setBitmapDescriptor(@Nullable PlatformBitmap setterArg) { this.bitmapDescriptor = setterArg; return this; } @@ -2886,7 +2896,7 @@ ArrayList toList() { Object type = pigeonVar_list.get(0); pigeonResult.setType((PlatformCapType) type); Object bitmapDescriptor = pigeonVar_list.get(1); - pigeonResult.setBitmapDescriptor(bitmapDescriptor); + pigeonResult.setBitmapDescriptor((PlatformBitmap) bitmapDescriptor); Object refWidth = pigeonVar_list.get(2); pigeonResult.setRefWidth((Double) refWidth); return pigeonResult; @@ -5012,225 +5022,1068 @@ ArrayList toList() { } } - private static class PigeonCodec extends StandardMessageCodec { - public static final PigeonCodec INSTANCE = new PigeonCodec(); + /** + * Pigeon equivalent of [BitmapDescriptor]. As there are multiple disjoint types of + * [BitmapDescriptor], [PlatformBitmap] contains a single field which may hold the pigeon + * equivalent type of any of them. + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static final class PlatformBitmap { + /** + * One of [PlatformBitmapAssetMap], [PlatformBitmapAsset], [PlatformBitmapAssetImage], + * [PlatformBitmapBytesMap], [PlatformBitmapBytes], or [PlatformBitmapDefaultMarker]. As Pigeon + * does not currently support data class inheritance, this approach allows for the different + * bitmap implementations to be valid argument and return types of the API methods. See + * https://github.com/flutter/flutter/issues/117819. + */ + private @NonNull Object bitmap; - private PigeonCodec() {} + public @NonNull Object getBitmap() { + return bitmap; + } + + public void setBitmap(@NonNull Object setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"bitmap\" is null."); + } + this.bitmap = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + PlatformBitmap() {} @Override - protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { - switch (type) { - case (byte) 129: - { - Object value = readValue(buffer); - return value == null ? null : PlatformMapType.values()[((Long) value).intValue()]; - } - case (byte) 130: - { - Object value = readValue(buffer); - return value == null ? null : PlatformRendererType.values()[((Long) value).intValue()]; - } - case (byte) 131: - { - Object value = readValue(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) 134: - 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) 137: - return PlatformCameraUpdateNewLatLng.fromList((ArrayList) readValue(buffer)); - case (byte) 138: - return PlatformCameraUpdateNewLatLngBounds.fromList( - (ArrayList) readValue(buffer)); - case (byte) 139: - return PlatformCameraUpdateNewLatLngZoom.fromList((ArrayList) readValue(buffer)); - case (byte) 140: - return PlatformCameraUpdateScrollBy.fromList((ArrayList) readValue(buffer)); - case (byte) 141: - return PlatformCameraUpdateZoomBy.fromList((ArrayList) readValue(buffer)); - case (byte) 142: - return PlatformCameraUpdateZoom.fromList((ArrayList) readValue(buffer)); - case (byte) 143: - return PlatformCameraUpdateZoomTo.fromList((ArrayList) readValue(buffer)); - case (byte) 144: - return PlatformCircle.fromList((ArrayList) readValue(buffer)); - case (byte) 145: - return PlatformHeatmap.fromList((ArrayList) readValue(buffer)); - case (byte) 146: - return PlatformClusterManager.fromList((ArrayList) readValue(buffer)); - case (byte) 147: - return PlatformOffset.fromList((ArrayList) readValue(buffer)); - case (byte) 148: - return PlatformInfoWindow.fromList((ArrayList) readValue(buffer)); - case (byte) 149: - return PlatformMarker.fromList((ArrayList) readValue(buffer)); - case (byte) 150: - return PlatformPolygon.fromList((ArrayList) readValue(buffer)); - case (byte) 151: - return PlatformPolyline.fromList((ArrayList) readValue(buffer)); - case (byte) 152: - return PlatformCap.fromList((ArrayList) readValue(buffer)); - case (byte) 153: - return PlatformPatternItem.fromList((ArrayList) readValue(buffer)); - case (byte) 154: - return PlatformTile.fromList((ArrayList) readValue(buffer)); - case (byte) 155: - return PlatformTileOverlay.fromList((ArrayList) readValue(buffer)); - case (byte) 156: - return PlatformEdgeInsets.fromList((ArrayList) readValue(buffer)); - case (byte) 157: - return PlatformLatLng.fromList((ArrayList) readValue(buffer)); - case (byte) 158: - return PlatformLatLngBounds.fromList((ArrayList) readValue(buffer)); - case (byte) 159: - return PlatformCluster.fromList((ArrayList) readValue(buffer)); - case (byte) 160: - return PlatformCameraTargetBounds.fromList((ArrayList) readValue(buffer)); - case (byte) 161: - return PlatformMapViewCreationParams.fromList((ArrayList) readValue(buffer)); - case (byte) 162: - 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); + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; } + PlatformBitmap that = (PlatformBitmap) o; + return bitmap.equals(that.bitmap); } @Override - protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { - if (value instanceof PlatformMapType) { - stream.write(129); - writeValue(stream, value == null ? null : ((PlatformMapType) value).index); - } else if (value instanceof PlatformRendererType) { - stream.write(130); - writeValue(stream, value == null ? null : ((PlatformRendererType) value).index); - } else if (value instanceof PlatformJointType) { - stream.write(131); - writeValue(stream, value == null ? null : ((PlatformJointType) value).index); - } 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(134); - writeValue(stream, ((PlatformCameraPosition) value).toList()); - } else if (value instanceof PlatformCameraUpdate) { - stream.write(135); - writeValue(stream, ((PlatformCameraUpdate) value).toList()); - } else if (value instanceof PlatformCameraUpdateNewCameraPosition) { - stream.write(136); - writeValue(stream, ((PlatformCameraUpdateNewCameraPosition) value).toList()); - } else if (value instanceof PlatformCameraUpdateNewLatLng) { - stream.write(137); - writeValue(stream, ((PlatformCameraUpdateNewLatLng) value).toList()); - } else if (value instanceof PlatformCameraUpdateNewLatLngBounds) { - stream.write(138); - writeValue(stream, ((PlatformCameraUpdateNewLatLngBounds) value).toList()); - } else if (value instanceof PlatformCameraUpdateNewLatLngZoom) { - stream.write(139); - writeValue(stream, ((PlatformCameraUpdateNewLatLngZoom) value).toList()); - } else if (value instanceof PlatformCameraUpdateScrollBy) { - stream.write(140); - writeValue(stream, ((PlatformCameraUpdateScrollBy) value).toList()); - } else if (value instanceof PlatformCameraUpdateZoomBy) { - stream.write(141); - writeValue(stream, ((PlatformCameraUpdateZoomBy) value).toList()); - } else if (value instanceof PlatformCameraUpdateZoom) { - stream.write(142); - writeValue(stream, ((PlatformCameraUpdateZoom) value).toList()); - } else if (value instanceof PlatformCameraUpdateZoomTo) { - stream.write(143); - writeValue(stream, ((PlatformCameraUpdateZoomTo) value).toList()); - } else if (value instanceof PlatformCircle) { - stream.write(144); - writeValue(stream, ((PlatformCircle) value).toList()); - } else if (value instanceof PlatformHeatmap) { - stream.write(145); - writeValue(stream, ((PlatformHeatmap) value).toList()); - } else if (value instanceof PlatformClusterManager) { - stream.write(146); - writeValue(stream, ((PlatformClusterManager) value).toList()); - } else if (value instanceof PlatformOffset) { - stream.write(147); - writeValue(stream, ((PlatformOffset) value).toList()); - } else if (value instanceof PlatformInfoWindow) { - stream.write(148); - writeValue(stream, ((PlatformInfoWindow) value).toList()); - } else if (value instanceof PlatformMarker) { - stream.write(149); - writeValue(stream, ((PlatformMarker) value).toList()); - } else if (value instanceof PlatformPolygon) { - stream.write(150); - writeValue(stream, ((PlatformPolygon) value).toList()); - } else if (value instanceof PlatformPolyline) { - 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(153); - writeValue(stream, ((PlatformPatternItem) value).toList()); - } else if (value instanceof PlatformTile) { - stream.write(154); - writeValue(stream, ((PlatformTile) value).toList()); - } else if (value instanceof PlatformTileOverlay) { - stream.write(155); - writeValue(stream, ((PlatformTileOverlay) value).toList()); - } else if (value instanceof PlatformEdgeInsets) { - stream.write(156); - writeValue(stream, ((PlatformEdgeInsets) value).toList()); - } else if (value instanceof PlatformLatLng) { - stream.write(157); - writeValue(stream, ((PlatformLatLng) value).toList()); - } else if (value instanceof PlatformLatLngBounds) { + public int hashCode() { + return Objects.hash(bitmap); + } + + public static final class Builder { + + private @Nullable Object bitmap; + + @CanIgnoreReturnValue + public @NonNull Builder setBitmap(@NonNull Object setterArg) { + this.bitmap = setterArg; + return this; + } + + public @NonNull PlatformBitmap build() { + PlatformBitmap pigeonReturn = new PlatformBitmap(); + pigeonReturn.setBitmap(bitmap); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(1); + toListResult.add(bitmap); + return toListResult; + } + + static @NonNull PlatformBitmap fromList(@NonNull ArrayList pigeonVar_list) { + PlatformBitmap pigeonResult = new PlatformBitmap(); + Object bitmap = pigeonVar_list.get(0); + pigeonResult.setBitmap(bitmap); + return pigeonResult; + } + } + + /** + * Pigeon equivalent of [DefaultMarker]. See + * https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#defaultMarker(float) + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static final class PlatformBitmapDefaultMarker { + private @Nullable Double hue; + + public @Nullable Double getHue() { + return hue; + } + + public void setHue(@Nullable Double setterArg) { + this.hue = setterArg; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlatformBitmapDefaultMarker that = (PlatformBitmapDefaultMarker) o; + return Objects.equals(hue, that.hue); + } + + @Override + public int hashCode() { + return Objects.hash(hue); + } + + public static final class Builder { + + private @Nullable Double hue; + + @CanIgnoreReturnValue + public @NonNull Builder setHue(@Nullable Double setterArg) { + this.hue = setterArg; + return this; + } + + public @NonNull PlatformBitmapDefaultMarker build() { + PlatformBitmapDefaultMarker pigeonReturn = new PlatformBitmapDefaultMarker(); + pigeonReturn.setHue(hue); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(1); + toListResult.add(hue); + return toListResult; + } + + static @NonNull PlatformBitmapDefaultMarker fromList( + @NonNull ArrayList pigeonVar_list) { + PlatformBitmapDefaultMarker pigeonResult = new PlatformBitmapDefaultMarker(); + Object hue = pigeonVar_list.get(0); + pigeonResult.setHue((Double) hue); + return pigeonResult; + } + } + + /** + * Pigeon equivalent of [BytesBitmap]. See + * https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#fromBitmap(android.graphics.Bitmap) + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static final class PlatformBitmapBytes { + private @NonNull byte[] byteData; + + public @NonNull byte[] getByteData() { + return byteData; + } + + public void setByteData(@NonNull byte[] setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"byteData\" is null."); + } + this.byteData = setterArg; + } + + private @Nullable PlatformDoublePair size; + + public @Nullable PlatformDoublePair getSize() { + return size; + } + + public void setSize(@Nullable PlatformDoublePair setterArg) { + this.size = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + PlatformBitmapBytes() {} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlatformBitmapBytes that = (PlatformBitmapBytes) o; + return Arrays.equals(byteData, that.byteData) && Objects.equals(size, that.size); + } + + @Override + public int hashCode() { + int pigeonVar_result = Objects.hash(size); + pigeonVar_result = 31 * pigeonVar_result + Arrays.hashCode(byteData); + return pigeonVar_result; + } + + public static final class Builder { + + private @Nullable byte[] byteData; + + @CanIgnoreReturnValue + public @NonNull Builder setByteData(@NonNull byte[] setterArg) { + this.byteData = setterArg; + return this; + } + + private @Nullable PlatformDoublePair size; + + @CanIgnoreReturnValue + public @NonNull Builder setSize(@Nullable PlatformDoublePair setterArg) { + this.size = setterArg; + return this; + } + + public @NonNull PlatformBitmapBytes build() { + PlatformBitmapBytes pigeonReturn = new PlatformBitmapBytes(); + pigeonReturn.setByteData(byteData); + pigeonReturn.setSize(size); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(2); + toListResult.add(byteData); + toListResult.add(size); + return toListResult; + } + + static @NonNull PlatformBitmapBytes fromList(@NonNull ArrayList pigeonVar_list) { + PlatformBitmapBytes pigeonResult = new PlatformBitmapBytes(); + Object byteData = pigeonVar_list.get(0); + pigeonResult.setByteData((byte[]) byteData); + Object size = pigeonVar_list.get(1); + pigeonResult.setSize((PlatformDoublePair) size); + return pigeonResult; + } + } + + /** + * Pigeon equivalent of [AssetBitmap]. See + * https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static final class PlatformBitmapAsset { + private @NonNull String name; + + public @NonNull String getName() { + return name; + } + + public void setName(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"name\" is null."); + } + this.name = setterArg; + } + + private @Nullable String pkg; + + public @Nullable String getPkg() { + return pkg; + } + + public void setPkg(@Nullable String setterArg) { + this.pkg = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + PlatformBitmapAsset() {} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlatformBitmapAsset that = (PlatformBitmapAsset) o; + return name.equals(that.name) && Objects.equals(pkg, that.pkg); + } + + @Override + public int hashCode() { + return Objects.hash(name, pkg); + } + + public static final class Builder { + + private @Nullable String name; + + @CanIgnoreReturnValue + public @NonNull Builder setName(@NonNull String setterArg) { + this.name = setterArg; + return this; + } + + private @Nullable String pkg; + + @CanIgnoreReturnValue + public @NonNull Builder setPkg(@Nullable String setterArg) { + this.pkg = setterArg; + return this; + } + + public @NonNull PlatformBitmapAsset build() { + PlatformBitmapAsset pigeonReturn = new PlatformBitmapAsset(); + pigeonReturn.setName(name); + pigeonReturn.setPkg(pkg); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(2); + toListResult.add(name); + toListResult.add(pkg); + return toListResult; + } + + static @NonNull PlatformBitmapAsset fromList(@NonNull ArrayList pigeonVar_list) { + PlatformBitmapAsset pigeonResult = new PlatformBitmapAsset(); + Object name = pigeonVar_list.get(0); + pigeonResult.setName((String) name); + Object pkg = pigeonVar_list.get(1); + pigeonResult.setPkg((String) pkg); + return pigeonResult; + } + } + + /** + * Pigeon equivalent of [AssetImageBitmap]. See + * https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static final class PlatformBitmapAssetImage { + private @NonNull String name; + + public @NonNull String getName() { + return name; + } + + public void setName(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"name\" is null."); + } + this.name = setterArg; + } + + private @NonNull Double scale; + + public @NonNull Double getScale() { + return scale; + } + + public void setScale(@NonNull Double setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"scale\" is null."); + } + this.scale = setterArg; + } + + private @Nullable PlatformDoublePair size; + + public @Nullable PlatformDoublePair getSize() { + return size; + } + + public void setSize(@Nullable PlatformDoublePair setterArg) { + this.size = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + PlatformBitmapAssetImage() {} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlatformBitmapAssetImage that = (PlatformBitmapAssetImage) o; + return name.equals(that.name) && scale.equals(that.scale) && Objects.equals(size, that.size); + } + + @Override + public int hashCode() { + return Objects.hash(name, scale, size); + } + + public static final class Builder { + + private @Nullable String name; + + @CanIgnoreReturnValue + public @NonNull Builder setName(@NonNull String setterArg) { + this.name = setterArg; + return this; + } + + private @Nullable Double scale; + + @CanIgnoreReturnValue + public @NonNull Builder setScale(@NonNull Double setterArg) { + this.scale = setterArg; + return this; + } + + private @Nullable PlatformDoublePair size; + + @CanIgnoreReturnValue + public @NonNull Builder setSize(@Nullable PlatformDoublePair setterArg) { + this.size = setterArg; + return this; + } + + public @NonNull PlatformBitmapAssetImage build() { + PlatformBitmapAssetImage pigeonReturn = new PlatformBitmapAssetImage(); + pigeonReturn.setName(name); + pigeonReturn.setScale(scale); + pigeonReturn.setSize(size); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(3); + toListResult.add(name); + toListResult.add(scale); + toListResult.add(size); + return toListResult; + } + + static @NonNull PlatformBitmapAssetImage fromList(@NonNull ArrayList pigeonVar_list) { + PlatformBitmapAssetImage pigeonResult = new PlatformBitmapAssetImage(); + Object name = pigeonVar_list.get(0); + pigeonResult.setName((String) name); + Object scale = pigeonVar_list.get(1); + pigeonResult.setScale((Double) scale); + Object size = pigeonVar_list.get(2); + pigeonResult.setSize((PlatformDoublePair) size); + return pigeonResult; + } + } + + /** + * Pigeon equivalent of [AssetMapBitmap]. See + * https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static final class PlatformBitmapAssetMap { + private @NonNull String assetName; + + public @NonNull String getAssetName() { + return assetName; + } + + public void setAssetName(@NonNull String setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"assetName\" is null."); + } + this.assetName = setterArg; + } + + private @NonNull PlatformMapBitmapScaling bitmapScaling; + + public @NonNull PlatformMapBitmapScaling getBitmapScaling() { + return bitmapScaling; + } + + public void setBitmapScaling(@NonNull PlatformMapBitmapScaling setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"bitmapScaling\" is null."); + } + this.bitmapScaling = setterArg; + } + + private @NonNull Double imagePixelRatio; + + public @NonNull Double getImagePixelRatio() { + return imagePixelRatio; + } + + public void setImagePixelRatio(@NonNull Double setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"imagePixelRatio\" is null."); + } + this.imagePixelRatio = setterArg; + } + + private @Nullable Double width; + + public @Nullable Double getWidth() { + return width; + } + + public void setWidth(@Nullable Double setterArg) { + this.width = setterArg; + } + + private @Nullable Double height; + + public @Nullable Double getHeight() { + return height; + } + + public void setHeight(@Nullable Double setterArg) { + this.height = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + PlatformBitmapAssetMap() {} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlatformBitmapAssetMap that = (PlatformBitmapAssetMap) o; + return assetName.equals(that.assetName) + && bitmapScaling.equals(that.bitmapScaling) + && imagePixelRatio.equals(that.imagePixelRatio) + && Objects.equals(width, that.width) + && Objects.equals(height, that.height); + } + + @Override + public int hashCode() { + return Objects.hash(assetName, bitmapScaling, imagePixelRatio, width, height); + } + + public static final class Builder { + + private @Nullable String assetName; + + @CanIgnoreReturnValue + public @NonNull Builder setAssetName(@NonNull String setterArg) { + this.assetName = setterArg; + return this; + } + + private @Nullable PlatformMapBitmapScaling bitmapScaling; + + @CanIgnoreReturnValue + public @NonNull Builder setBitmapScaling(@NonNull PlatformMapBitmapScaling setterArg) { + this.bitmapScaling = setterArg; + return this; + } + + private @Nullable Double imagePixelRatio; + + @CanIgnoreReturnValue + public @NonNull Builder setImagePixelRatio(@NonNull Double setterArg) { + this.imagePixelRatio = setterArg; + return this; + } + + private @Nullable Double width; + + @CanIgnoreReturnValue + public @NonNull Builder setWidth(@Nullable Double setterArg) { + this.width = setterArg; + return this; + } + + private @Nullable Double height; + + @CanIgnoreReturnValue + public @NonNull Builder setHeight(@Nullable Double setterArg) { + this.height = setterArg; + return this; + } + + public @NonNull PlatformBitmapAssetMap build() { + PlatformBitmapAssetMap pigeonReturn = new PlatformBitmapAssetMap(); + pigeonReturn.setAssetName(assetName); + pigeonReturn.setBitmapScaling(bitmapScaling); + pigeonReturn.setImagePixelRatio(imagePixelRatio); + pigeonReturn.setWidth(width); + pigeonReturn.setHeight(height); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(5); + toListResult.add(assetName); + toListResult.add(bitmapScaling); + toListResult.add(imagePixelRatio); + toListResult.add(width); + toListResult.add(height); + return toListResult; + } + + static @NonNull PlatformBitmapAssetMap fromList(@NonNull ArrayList pigeonVar_list) { + PlatformBitmapAssetMap pigeonResult = new PlatformBitmapAssetMap(); + Object assetName = pigeonVar_list.get(0); + pigeonResult.setAssetName((String) assetName); + Object bitmapScaling = pigeonVar_list.get(1); + pigeonResult.setBitmapScaling((PlatformMapBitmapScaling) bitmapScaling); + Object imagePixelRatio = pigeonVar_list.get(2); + pigeonResult.setImagePixelRatio((Double) imagePixelRatio); + Object width = pigeonVar_list.get(3); + pigeonResult.setWidth((Double) width); + Object height = pigeonVar_list.get(4); + pigeonResult.setHeight((Double) height); + return pigeonResult; + } + } + + /** + * Pigeon equivalent of [BytesMapBitmap]. See + * https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-frombitmap-bitmap-image + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static final class PlatformBitmapBytesMap { + private @NonNull byte[] byteData; + + public @NonNull byte[] getByteData() { + return byteData; + } + + public void setByteData(@NonNull byte[] setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"byteData\" is null."); + } + this.byteData = setterArg; + } + + private @NonNull PlatformMapBitmapScaling bitmapScaling; + + public @NonNull PlatformMapBitmapScaling getBitmapScaling() { + return bitmapScaling; + } + + public void setBitmapScaling(@NonNull PlatformMapBitmapScaling setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"bitmapScaling\" is null."); + } + this.bitmapScaling = setterArg; + } + + private @NonNull Double imagePixelRatio; + + public @NonNull Double getImagePixelRatio() { + return imagePixelRatio; + } + + public void setImagePixelRatio(@NonNull Double setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"imagePixelRatio\" is null."); + } + this.imagePixelRatio = setterArg; + } + + private @Nullable Double width; + + public @Nullable Double getWidth() { + return width; + } + + public void setWidth(@Nullable Double setterArg) { + this.width = setterArg; + } + + private @Nullable Double height; + + public @Nullable Double getHeight() { + return height; + } + + public void setHeight(@Nullable Double setterArg) { + this.height = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + PlatformBitmapBytesMap() {} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlatformBitmapBytesMap that = (PlatformBitmapBytesMap) o; + return Arrays.equals(byteData, that.byteData) + && bitmapScaling.equals(that.bitmapScaling) + && imagePixelRatio.equals(that.imagePixelRatio) + && Objects.equals(width, that.width) + && Objects.equals(height, that.height); + } + + @Override + public int hashCode() { + int pigeonVar_result = Objects.hash(bitmapScaling, imagePixelRatio, width, height); + pigeonVar_result = 31 * pigeonVar_result + Arrays.hashCode(byteData); + return pigeonVar_result; + } + + public static final class Builder { + + private @Nullable byte[] byteData; + + @CanIgnoreReturnValue + public @NonNull Builder setByteData(@NonNull byte[] setterArg) { + this.byteData = setterArg; + return this; + } + + private @Nullable PlatformMapBitmapScaling bitmapScaling; + + @CanIgnoreReturnValue + public @NonNull Builder setBitmapScaling(@NonNull PlatformMapBitmapScaling setterArg) { + this.bitmapScaling = setterArg; + return this; + } + + private @Nullable Double imagePixelRatio; + + @CanIgnoreReturnValue + public @NonNull Builder setImagePixelRatio(@NonNull Double setterArg) { + this.imagePixelRatio = setterArg; + return this; + } + + private @Nullable Double width; + + @CanIgnoreReturnValue + public @NonNull Builder setWidth(@Nullable Double setterArg) { + this.width = setterArg; + return this; + } + + private @Nullable Double height; + + @CanIgnoreReturnValue + public @NonNull Builder setHeight(@Nullable Double setterArg) { + this.height = setterArg; + return this; + } + + public @NonNull PlatformBitmapBytesMap build() { + PlatformBitmapBytesMap pigeonReturn = new PlatformBitmapBytesMap(); + pigeonReturn.setByteData(byteData); + pigeonReturn.setBitmapScaling(bitmapScaling); + pigeonReturn.setImagePixelRatio(imagePixelRatio); + pigeonReturn.setWidth(width); + pigeonReturn.setHeight(height); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(5); + toListResult.add(byteData); + toListResult.add(bitmapScaling); + toListResult.add(imagePixelRatio); + toListResult.add(width); + toListResult.add(height); + return toListResult; + } + + static @NonNull PlatformBitmapBytesMap fromList(@NonNull ArrayList pigeonVar_list) { + PlatformBitmapBytesMap pigeonResult = new PlatformBitmapBytesMap(); + Object byteData = pigeonVar_list.get(0); + pigeonResult.setByteData((byte[]) byteData); + Object bitmapScaling = pigeonVar_list.get(1); + pigeonResult.setBitmapScaling((PlatformMapBitmapScaling) bitmapScaling); + Object imagePixelRatio = pigeonVar_list.get(2); + pigeonResult.setImagePixelRatio((Double) imagePixelRatio); + Object width = pigeonVar_list.get(3); + pigeonResult.setWidth((Double) width); + Object height = pigeonVar_list.get(4); + pigeonResult.setHeight((Double) height); + return pigeonResult; + } + } + + private static class PigeonCodec extends StandardMessageCodec { + public static final PigeonCodec INSTANCE = new PigeonCodec(); + + private PigeonCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 129: + { + Object value = readValue(buffer); + return value == null ? null : PlatformMapType.values()[((Long) value).intValue()]; + } + case (byte) 130: + { + Object value = readValue(buffer); + return value == null ? null : PlatformRendererType.values()[((Long) value).intValue()]; + } + case (byte) 131: + { + Object value = readValue(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) 134: + { + Object value = readValue(buffer); + return value == null + ? null + : PlatformMapBitmapScaling.values()[((Long) value).intValue()]; + } + case (byte) 135: + return PlatformCameraPosition.fromList((ArrayList) readValue(buffer)); + case (byte) 136: + return PlatformCameraUpdate.fromList((ArrayList) readValue(buffer)); + case (byte) 137: + return PlatformCameraUpdateNewCameraPosition.fromList( + (ArrayList) readValue(buffer)); + case (byte) 138: + return PlatformCameraUpdateNewLatLng.fromList((ArrayList) readValue(buffer)); + case (byte) 139: + return PlatformCameraUpdateNewLatLngBounds.fromList( + (ArrayList) readValue(buffer)); + case (byte) 140: + return PlatformCameraUpdateNewLatLngZoom.fromList((ArrayList) readValue(buffer)); + case (byte) 141: + return PlatformCameraUpdateScrollBy.fromList((ArrayList) readValue(buffer)); + case (byte) 142: + return PlatformCameraUpdateZoomBy.fromList((ArrayList) readValue(buffer)); + case (byte) 143: + return PlatformCameraUpdateZoom.fromList((ArrayList) readValue(buffer)); + case (byte) 144: + return PlatformCameraUpdateZoomTo.fromList((ArrayList) readValue(buffer)); + case (byte) 145: + return PlatformCircle.fromList((ArrayList) readValue(buffer)); + case (byte) 146: + return PlatformHeatmap.fromList((ArrayList) readValue(buffer)); + case (byte) 147: + return PlatformClusterManager.fromList((ArrayList) readValue(buffer)); + case (byte) 148: + return PlatformDoublePair.fromList((ArrayList) readValue(buffer)); + case (byte) 149: + return PlatformInfoWindow.fromList((ArrayList) readValue(buffer)); + case (byte) 150: + return PlatformMarker.fromList((ArrayList) readValue(buffer)); + case (byte) 151: + return PlatformPolygon.fromList((ArrayList) readValue(buffer)); + case (byte) 152: + return PlatformPolyline.fromList((ArrayList) readValue(buffer)); + case (byte) 153: + return PlatformCap.fromList((ArrayList) readValue(buffer)); + case (byte) 154: + return PlatformPatternItem.fromList((ArrayList) readValue(buffer)); + case (byte) 155: + return PlatformTile.fromList((ArrayList) readValue(buffer)); + case (byte) 156: + return PlatformTileOverlay.fromList((ArrayList) readValue(buffer)); + case (byte) 157: + return PlatformEdgeInsets.fromList((ArrayList) readValue(buffer)); + case (byte) 158: + return PlatformLatLng.fromList((ArrayList) readValue(buffer)); + case (byte) 159: + return PlatformLatLngBounds.fromList((ArrayList) readValue(buffer)); + case (byte) 160: + return PlatformCluster.fromList((ArrayList) readValue(buffer)); + case (byte) 161: + return PlatformCameraTargetBounds.fromList((ArrayList) readValue(buffer)); + case (byte) 162: + return PlatformMapViewCreationParams.fromList((ArrayList) readValue(buffer)); + case (byte) 163: + return PlatformMapConfiguration.fromList((ArrayList) readValue(buffer)); + case (byte) 164: + return PlatformPoint.fromList((ArrayList) readValue(buffer)); + case (byte) 165: + return PlatformTileLayer.fromList((ArrayList) readValue(buffer)); + case (byte) 166: + return PlatformZoomRange.fromList((ArrayList) readValue(buffer)); + case (byte) 167: + return PlatformBitmap.fromList((ArrayList) readValue(buffer)); + case (byte) 168: + return PlatformBitmapDefaultMarker.fromList((ArrayList) readValue(buffer)); + case (byte) 169: + return PlatformBitmapBytes.fromList((ArrayList) readValue(buffer)); + case (byte) 170: + return PlatformBitmapAsset.fromList((ArrayList) readValue(buffer)); + case (byte) 171: + return PlatformBitmapAssetImage.fromList((ArrayList) readValue(buffer)); + case (byte) 172: + return PlatformBitmapAssetMap.fromList((ArrayList) readValue(buffer)); + case (byte) 173: + return PlatformBitmapBytesMap.fromList((ArrayList) readValue(buffer)); + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof PlatformMapType) { + stream.write(129); + writeValue(stream, value == null ? null : ((PlatformMapType) value).index); + } else if (value instanceof PlatformRendererType) { + stream.write(130); + writeValue(stream, value == null ? null : ((PlatformRendererType) value).index); + } else if (value instanceof PlatformJointType) { + stream.write(131); + writeValue(stream, value == null ? null : ((PlatformJointType) value).index); + } 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 PlatformMapBitmapScaling) { + stream.write(134); + writeValue(stream, value == null ? null : ((PlatformMapBitmapScaling) value).index); + } else if (value instanceof PlatformCameraPosition) { + stream.write(135); + writeValue(stream, ((PlatformCameraPosition) value).toList()); + } else if (value instanceof PlatformCameraUpdate) { + stream.write(136); + writeValue(stream, ((PlatformCameraUpdate) value).toList()); + } else if (value instanceof PlatformCameraUpdateNewCameraPosition) { + stream.write(137); + writeValue(stream, ((PlatformCameraUpdateNewCameraPosition) value).toList()); + } else if (value instanceof PlatformCameraUpdateNewLatLng) { + stream.write(138); + writeValue(stream, ((PlatformCameraUpdateNewLatLng) value).toList()); + } else if (value instanceof PlatformCameraUpdateNewLatLngBounds) { + stream.write(139); + writeValue(stream, ((PlatformCameraUpdateNewLatLngBounds) value).toList()); + } else if (value instanceof PlatformCameraUpdateNewLatLngZoom) { + stream.write(140); + writeValue(stream, ((PlatformCameraUpdateNewLatLngZoom) value).toList()); + } else if (value instanceof PlatformCameraUpdateScrollBy) { + stream.write(141); + writeValue(stream, ((PlatformCameraUpdateScrollBy) value).toList()); + } else if (value instanceof PlatformCameraUpdateZoomBy) { + stream.write(142); + writeValue(stream, ((PlatformCameraUpdateZoomBy) value).toList()); + } else if (value instanceof PlatformCameraUpdateZoom) { + stream.write(143); + writeValue(stream, ((PlatformCameraUpdateZoom) value).toList()); + } else if (value instanceof PlatformCameraUpdateZoomTo) { + stream.write(144); + writeValue(stream, ((PlatformCameraUpdateZoomTo) value).toList()); + } else if (value instanceof PlatformCircle) { + stream.write(145); + writeValue(stream, ((PlatformCircle) value).toList()); + } else if (value instanceof PlatformHeatmap) { + stream.write(146); + writeValue(stream, ((PlatformHeatmap) value).toList()); + } else if (value instanceof PlatformClusterManager) { + stream.write(147); + writeValue(stream, ((PlatformClusterManager) value).toList()); + } else if (value instanceof PlatformDoublePair) { + stream.write(148); + writeValue(stream, ((PlatformDoublePair) value).toList()); + } else if (value instanceof PlatformInfoWindow) { + stream.write(149); + writeValue(stream, ((PlatformInfoWindow) value).toList()); + } else if (value instanceof PlatformMarker) { + stream.write(150); + writeValue(stream, ((PlatformMarker) value).toList()); + } else if (value instanceof PlatformPolygon) { + stream.write(151); + writeValue(stream, ((PlatformPolygon) value).toList()); + } else if (value instanceof PlatformPolyline) { + stream.write(152); + writeValue(stream, ((PlatformPolyline) value).toList()); + } else if (value instanceof PlatformCap) { + stream.write(153); + writeValue(stream, ((PlatformCap) value).toList()); + } else if (value instanceof PlatformPatternItem) { + stream.write(154); + writeValue(stream, ((PlatformPatternItem) value).toList()); + } else if (value instanceof PlatformTile) { + stream.write(155); + writeValue(stream, ((PlatformTile) value).toList()); + } else if (value instanceof PlatformTileOverlay) { + stream.write(156); + writeValue(stream, ((PlatformTileOverlay) value).toList()); + } else if (value instanceof PlatformEdgeInsets) { + stream.write(157); + writeValue(stream, ((PlatformEdgeInsets) value).toList()); + } else if (value instanceof PlatformLatLng) { stream.write(158); + writeValue(stream, ((PlatformLatLng) value).toList()); + } else if (value instanceof PlatformLatLngBounds) { + stream.write(159); writeValue(stream, ((PlatformLatLngBounds) value).toList()); } else if (value instanceof PlatformCluster) { - stream.write(159); + stream.write(160); writeValue(stream, ((PlatformCluster) value).toList()); } else if (value instanceof PlatformCameraTargetBounds) { - stream.write(160); + stream.write(161); writeValue(stream, ((PlatformCameraTargetBounds) value).toList()); } else if (value instanceof PlatformMapViewCreationParams) { - stream.write(161); + stream.write(162); writeValue(stream, ((PlatformMapViewCreationParams) value).toList()); } else if (value instanceof PlatformMapConfiguration) { - stream.write(162); + stream.write(163); writeValue(stream, ((PlatformMapConfiguration) value).toList()); } else if (value instanceof PlatformPoint) { - stream.write(163); + stream.write(164); writeValue(stream, ((PlatformPoint) value).toList()); } else if (value instanceof PlatformTileLayer) { - stream.write(164); + stream.write(165); writeValue(stream, ((PlatformTileLayer) value).toList()); } else if (value instanceof PlatformZoomRange) { - stream.write(165); + stream.write(166); writeValue(stream, ((PlatformZoomRange) value).toList()); + } else if (value instanceof PlatformBitmap) { + stream.write(167); + writeValue(stream, ((PlatformBitmap) value).toList()); + } else if (value instanceof PlatformBitmapDefaultMarker) { + stream.write(168); + writeValue(stream, ((PlatformBitmapDefaultMarker) value).toList()); + } else if (value instanceof PlatformBitmapBytes) { + stream.write(169); + writeValue(stream, ((PlatformBitmapBytes) value).toList()); + } else if (value instanceof PlatformBitmapAsset) { + stream.write(170); + writeValue(stream, ((PlatformBitmapAsset) value).toList()); + } else if (value instanceof PlatformBitmapAssetImage) { + stream.write(171); + writeValue(stream, ((PlatformBitmapAssetImage) value).toList()); + } else if (value instanceof PlatformBitmapAssetMap) { + stream.write(172); + writeValue(stream, ((PlatformBitmapAssetMap) value).toList()); + } else if (value instanceof PlatformBitmapBytesMap) { + stream.write(173); + writeValue(stream, ((PlatformBitmapBytesMap) value).toList()); } else { super.writeValue(stream, value); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ClusterManagersControllerTest.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ClusterManagersControllerTest.java index dd41a3fbd02..d35b7a8022f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ClusterManagersControllerTest.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ClusterManagersControllerTest.java @@ -28,12 +28,9 @@ import io.flutter.plugins.googlemaps.Messages.MapsCallbackApi; import java.io.ByteArrayOutputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; import org.junit.After; import org.junit.Before; @@ -185,16 +182,21 @@ private Messages.PlatformMarker createPlatformMarker( ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); fakeBitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); - Map byteData = new HashMap<>(); - byteData.put("byteData", byteArray); - byteData.put("bitmapScaling", "none"); - byteData.put("imagePixelRatio", ""); - Messages.PlatformOffset anchor = - new Messages.PlatformOffset.Builder().setDx(0.0).setDy(0.0).build(); + Messages.PlatformBitmap icon = + new Messages.PlatformBitmap.Builder() + .setBitmap( + new Messages.PlatformBitmapBytesMap.Builder() + .setByteData(byteArray) + .setImagePixelRatio(1.0) + .setBitmapScaling(Messages.PlatformMapBitmapScaling.NONE) + .build()) + .build(); + Messages.PlatformDoublePair anchor = + new Messages.PlatformDoublePair.Builder().setX(0.0).setY(0.0).build(); return new Messages.PlatformMarker.Builder() .setMarkerId(markerId) .setConsumeTapEvents(false) - .setIcon(Arrays.asList("bytes", byteData)) + .setIcon(icon) .setAlpha(1.0) .setDraggable(false) .setFlat(false) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ConvertTest.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ConvertTest.java index a7331b89f79..0e41c977c7e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ConvertTest.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/ConvertTest.java @@ -44,7 +44,6 @@ import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.After; @@ -140,26 +139,24 @@ public void ConvertClusterToPigeonReturnsCorrectData() { public void GetBitmapFromAssetAuto() throws Exception { String fakeAssetName = "fake_asset_name"; String fakeAssetKey = "fake_asset_key"; - Map assetDetails = new HashMap<>(); - assetDetails.put("assetName", fakeAssetName); - assetDetails.put("bitmapScaling", "auto"); - assetDetails.put("width", 15.0f); - assetDetails.put("height", 15.0f); - assetDetails.put("imagePixelRatio", 2.0f); when(flutterInjectorWrapper.getLookupKeyForAsset(fakeAssetName)).thenReturn(fakeAssetKey); when(assetManager.open(fakeAssetKey)).thenReturn(buildImageInputStream()); when(bitmapDescriptorFactoryWrapper.fromBitmap(any())).thenReturn(mockBitmapDescriptor); + Messages.PlatformBitmapAssetMap bitmap = + new Messages.PlatformBitmapAssetMap.Builder() + .setBitmapScaling(Messages.PlatformMapBitmapScaling.AUTO) + .setWidth(15.0) + .setHeight(15.0) + .setImagePixelRatio(2.0) + .setAssetName(fakeAssetName) + .build(); BitmapDescriptor result = Convert.getBitmapFromAsset( - assetDetails, - assetManager, - 1.0f, - bitmapDescriptorFactoryWrapper, - flutterInjectorWrapper); + bitmap, assetManager, 1.0f, bitmapDescriptorFactoryWrapper, flutterInjectorWrapper); Assert.assertEquals(mockBitmapDescriptor, result); } @@ -169,25 +166,22 @@ public void GetBitmapFromAssetAutoAndWidth() throws Exception { String fakeAssetName = "fake_asset_name"; String fakeAssetKey = "fake_asset_key"; - Map assetDetails = new HashMap<>(); - assetDetails.put("assetName", fakeAssetName); - assetDetails.put("bitmapScaling", "auto"); - assetDetails.put("width", 15.0f); - assetDetails.put("imagePixelRatio", 2.0f); - when(flutterInjectorWrapper.getLookupKeyForAsset(fakeAssetName)).thenReturn(fakeAssetKey); when(assetManager.open(fakeAssetKey)).thenReturn(buildImageInputStream()); when(bitmapDescriptorFactoryWrapper.fromBitmap(any())).thenReturn(mockBitmapDescriptor); + Messages.PlatformBitmapAssetMap bitmap = + new Messages.PlatformBitmapAssetMap.Builder() + .setAssetName(fakeAssetName) + .setWidth(15.0) + .setImagePixelRatio(2.0) + .setBitmapScaling(Messages.PlatformMapBitmapScaling.AUTO) + .build(); BitmapDescriptor result = Convert.getBitmapFromAsset( - assetDetails, - assetManager, - 1.0f, - bitmapDescriptorFactoryWrapper, - flutterInjectorWrapper); + bitmap, assetManager, 1.0f, bitmapDescriptorFactoryWrapper, flutterInjectorWrapper); Assert.assertEquals(mockBitmapDescriptor, result); } @@ -197,25 +191,22 @@ public void GetBitmapFromAssetAutoAndHeight() throws Exception { String fakeAssetName = "fake_asset_name"; String fakeAssetKey = "fake_asset_key"; - Map assetDetails = new HashMap<>(); - assetDetails.put("assetName", fakeAssetName); - assetDetails.put("bitmapScaling", "auto"); - assetDetails.put("height", 15.0f); - assetDetails.put("imagePixelRatio", 2.0f); - when(flutterInjectorWrapper.getLookupKeyForAsset(fakeAssetName)).thenReturn(fakeAssetKey); when(assetManager.open(fakeAssetKey)).thenReturn(buildImageInputStream()); when(bitmapDescriptorFactoryWrapper.fromBitmap(any())).thenReturn(mockBitmapDescriptor); + Messages.PlatformBitmapAssetMap bitmap = + new Messages.PlatformBitmapAssetMap.Builder() + .setBitmapScaling(Messages.PlatformMapBitmapScaling.AUTO) + .setHeight(15.0) + .setImagePixelRatio(2.0) + .setAssetName(fakeAssetName) + .build(); BitmapDescriptor result = Convert.getBitmapFromAsset( - assetDetails, - assetManager, - 1.0f, - bitmapDescriptorFactoryWrapper, - flutterInjectorWrapper); + bitmap, assetManager, 1.0f, bitmapDescriptorFactoryWrapper, flutterInjectorWrapper); Assert.assertEquals(mockBitmapDescriptor, result); } @@ -225,11 +216,6 @@ public void GetBitmapFromAssetNoScaling() throws Exception { String fakeAssetName = "fake_asset_name"; String fakeAssetKey = "fake_asset_key"; - Map assetDetails = new HashMap<>(); - assetDetails.put("assetName", fakeAssetName); - assetDetails.put("bitmapScaling", "noScaling"); - assetDetails.put("imagePixelRatio", 2.0f); - when(flutterInjectorWrapper.getLookupKeyForAsset(fakeAssetName)).thenReturn(fakeAssetKey); when(assetManager.open(fakeAssetKey)).thenReturn(buildImageInputStream()); @@ -237,14 +223,16 @@ public void GetBitmapFromAssetNoScaling() throws Exception { when(bitmapDescriptorFactoryWrapper.fromAsset(any())).thenReturn(mockBitmapDescriptor); verify(bitmapDescriptorFactoryWrapper, never()).fromBitmap(any()); + Messages.PlatformBitmapAssetMap bitmap = + new Messages.PlatformBitmapAssetMap.Builder() + .setBitmapScaling(Messages.PlatformMapBitmapScaling.NONE) + .setImagePixelRatio(2.0) + .setAssetName(fakeAssetName) + .build(); BitmapDescriptor result = Convert.getBitmapFromAsset( - assetDetails, - assetManager, - 1.0f, - bitmapDescriptorFactoryWrapper, - flutterInjectorWrapper); + bitmap, assetManager, 1.0f, bitmapDescriptorFactoryWrapper, flutterInjectorWrapper); Assert.assertEquals(mockBitmapDescriptor, result); } @@ -253,15 +241,17 @@ public void GetBitmapFromAssetNoScaling() throws Exception { public void GetBitmapFromBytesAuto() { byte[] bmpData = Base64.decode(base64Image, Base64.DEFAULT); - Map assetDetails = new HashMap<>(); - assetDetails.put("byteData", bmpData); - assetDetails.put("bitmapScaling", "auto"); - assetDetails.put("imagePixelRatio", 2.0f); - when(bitmapDescriptorFactoryWrapper.fromBitmap(any())).thenReturn(mockBitmapDescriptor); + Messages.PlatformBitmapBytesMap bitmap = + new Messages.PlatformBitmapBytesMap.Builder() + .setBitmapScaling(Messages.PlatformMapBitmapScaling.AUTO) + .setImagePixelRatio(2.0) + .setByteData(bmpData) + .build(); + BitmapDescriptor result = - Convert.getBitmapFromBytes(assetDetails, 1f, bitmapDescriptorFactoryWrapper); + Convert.getBitmapFromBytes(bitmap, 1f, bitmapDescriptorFactoryWrapper); Assert.assertEquals(mockBitmapDescriptor, result); } @@ -270,16 +260,17 @@ public void GetBitmapFromBytesAuto() { public void GetBitmapFromBytesAutoAndWidth() { byte[] bmpData = Base64.decode(base64Image, Base64.DEFAULT); - Map assetDetails = new HashMap<>(); - assetDetails.put("byteData", bmpData); - assetDetails.put("bitmapScaling", "auto"); - assetDetails.put("imagePixelRatio", 2.0f); - assetDetails.put("width", 15.0f); - when(bitmapDescriptorFactoryWrapper.fromBitmap(any())).thenReturn(mockBitmapDescriptor); + Messages.PlatformBitmapBytesMap bitmap = + new Messages.PlatformBitmapBytesMap.Builder() + .setBitmapScaling(Messages.PlatformMapBitmapScaling.AUTO) + .setImagePixelRatio(2.0) + .setByteData(bmpData) + .setWidth(15.0) + .build(); BitmapDescriptor result = - Convert.getBitmapFromBytes(assetDetails, 1f, bitmapDescriptorFactoryWrapper); + Convert.getBitmapFromBytes(bitmap, 1f, bitmapDescriptorFactoryWrapper); Assert.assertEquals(mockBitmapDescriptor, result); } @@ -288,16 +279,17 @@ public void GetBitmapFromBytesAutoAndWidth() { public void GetBitmapFromBytesAutoAndHeight() { byte[] bmpData = Base64.decode(base64Image, Base64.DEFAULT); - Map assetDetails = new HashMap<>(); - assetDetails.put("byteData", bmpData); - assetDetails.put("bitmapScaling", "auto"); - assetDetails.put("imagePixelRatio", 2.0f); - assetDetails.put("height", 15.0f); - when(bitmapDescriptorFactoryWrapper.fromBitmap(any())).thenReturn(mockBitmapDescriptor); + Messages.PlatformBitmapBytesMap bitmap = + new Messages.PlatformBitmapBytesMap.Builder() + .setBitmapScaling(Messages.PlatformMapBitmapScaling.AUTO) + .setImagePixelRatio(2.0) + .setByteData(bmpData) + .setHeight(15.0) + .build(); BitmapDescriptor result = - Convert.getBitmapFromBytes(assetDetails, 1f, bitmapDescriptorFactoryWrapper); + Convert.getBitmapFromBytes(bitmap, 1f, bitmapDescriptorFactoryWrapper); Assert.assertEquals(mockBitmapDescriptor, result); } @@ -306,15 +298,16 @@ public void GetBitmapFromBytesAutoAndHeight() { public void GetBitmapFromBytesNoScaling() { byte[] bmpData = Base64.decode(base64Image, Base64.DEFAULT); - Map assetDetails = new HashMap<>(); - assetDetails.put("byteData", bmpData); - assetDetails.put("bitmapScaling", "noScaling"); - assetDetails.put("imagePixelRatio", 2.0f); - when(bitmapDescriptorFactoryWrapper.fromBitmap(any())).thenReturn(mockBitmapDescriptor); + Messages.PlatformBitmapBytesMap bitmap = + new Messages.PlatformBitmapBytesMap.Builder() + .setBitmapScaling(Messages.PlatformMapBitmapScaling.NONE) + .setImagePixelRatio(2.0) + .setByteData(bmpData) + .build(); BitmapDescriptor result = - Convert.getBitmapFromBytes(assetDetails, 1f, bitmapDescriptorFactoryWrapper); + Convert.getBitmapFromBytes(bitmap, 1f, bitmapDescriptorFactoryWrapper); Assert.assertEquals(mockBitmapDescriptor, result); } @@ -324,15 +317,16 @@ public void GetBitmapFromBytesThrowsErrorIfInvalidImageData() { String invalidBase64Image = "not valid image data"; byte[] bmpData = Base64.decode(invalidBase64Image, Base64.DEFAULT); - Map assetDetails = new HashMap<>(); - assetDetails.put("byteData", bmpData); - assetDetails.put("bitmapScaling", "noScaling"); - assetDetails.put("imagePixelRatio", 2.0f); - verify(bitmapDescriptorFactoryWrapper, never()).fromBitmap(any()); + Messages.PlatformBitmapBytesMap bitmap = + new Messages.PlatformBitmapBytesMap.Builder() + .setBitmapScaling(Messages.PlatformMapBitmapScaling.NONE) + .setImagePixelRatio(2.0) + .setByteData(bmpData) + .build(); try { - Convert.getBitmapFromBytes(assetDetails, 1f, bitmapDescriptorFactoryWrapper); + Convert.getBitmapFromBytes(bitmap, 1f, bitmapDescriptorFactoryWrapper); } catch (IllegalArgumentException e) { Assert.assertEquals(e.getMessage(), "Unable to interpret bytes as a valid image."); throw e; // rethrow the exception diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/MarkersControllerTest.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/MarkersControllerTest.java index 9df0b8d523d..6df43c1a7f2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/MarkersControllerTest.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/MarkersControllerTest.java @@ -25,11 +25,8 @@ import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugins.googlemaps.Messages.MapsCallbackApi; import java.io.ByteArrayOutputStream; -import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -62,18 +59,23 @@ private static Messages.PlatformMarker.Builder defaultMarkerBuilder() { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); fakeBitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); - Map byteData = new HashMap<>(); - byteData.put("byteData", byteArray); - byteData.put("bitmapScaling", "none"); - byteData.put("imagePixelRatio", ""); - Messages.PlatformOffset anchor = - new Messages.PlatformOffset.Builder().setDx(0.5).setDy(0.0).build(); + Messages.PlatformBitmap icon = + new Messages.PlatformBitmap.Builder() + .setBitmap( + new Messages.PlatformBitmapBytesMap.Builder() + .setByteData(byteArray) + .setImagePixelRatio(1.0) + .setBitmapScaling(Messages.PlatformMapBitmapScaling.NONE) + .build()) + .build(); + Messages.PlatformDoublePair anchor = + new Messages.PlatformDoublePair.Builder().setX(0.5).setY(0.0).build(); Messages.PlatformInfoWindow infoWindow = new Messages.PlatformInfoWindow.Builder().setAnchor(anchor).build(); return new Messages.PlatformMarker.Builder() .setPosition( new Messages.PlatformLatLng.Builder().setLatitude(0.0).setLongitude(0.0).build()) - .setAnchor(new Messages.PlatformOffset.Builder().setDx(0.0).setDy(0.0).build()) + .setAnchor(new Messages.PlatformDoublePair.Builder().setX(0.0).setY(0.0).build()) .setFlat(false) .setDraggable(false) .setVisible(true) @@ -81,7 +83,7 @@ private static Messages.PlatformMarker.Builder defaultMarkerBuilder() { .setRotation(0.0) .setZIndex(0.0) .setConsumeTapEvents(false) - .setIcon(Arrays.asList("bytes", byteData)) + .setIcon(icon) .setInfoWindow(infoWindow); } 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 c3e86cb1014..32a751825d7 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 @@ -681,8 +681,12 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { latitude: latLng.latitude, longitude: latLng.longitude); } - static PlatformOffset _platformOffsetFromOffset(Offset offset) { - return PlatformOffset(dx: offset.dx, dy: offset.dy); + static PlatformDoublePair _platformPairFromOffset(Offset offset) { + return PlatformDoublePair(x: offset.dx, y: offset.dy); + } + + static PlatformDoublePair _platformPairFromSize(Size size) { + return PlatformDoublePair(x: size.width, y: size.height); } static ScreenCoordinate _screenCoordinateFromPlatformPoint( @@ -724,17 +728,17 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { return PlatformInfoWindow( title: window.title, snippet: window.snippet, - anchor: _platformOffsetFromOffset(window.anchor)); + anchor: _platformPairFromOffset(window.anchor)); } static PlatformMarker _platformMarkerFromMarker(Marker marker) { return PlatformMarker( alpha: marker.alpha, - anchor: _platformOffsetFromOffset(marker.anchor), + anchor: _platformPairFromOffset(marker.anchor), consumeTapEvents: marker.consumeTapEvents, draggable: marker.draggable, flat: marker.flat, - icon: marker.icon.toJson(), + icon: platformBitmapFromBitmapDescriptor(marker.icon), infoWindow: _platformInfoWindowFromInfoWindow(marker.infoWindow), position: _platformLatLngFromLatLng(marker.position), rotation: marker.rotation, @@ -836,7 +840,7 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { amount: update.amount, focus: update.focus == null ? null - : _platformOffsetFromOffset(update.focus!))); + : _platformPairFromOffset(update.focus!))); case CameraUpdateType.zoomIn: update as CameraUpdateZoomIn; return PlatformCameraUpdate( @@ -852,6 +856,96 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { PlatformCameraUpdateScrollBy(dx: update.dx, dy: update.dy)); } } + + /// Convert [MapBitmapScaling] from platform interface to [PlatformMapBitmapScaling] Pigeon. + @visibleForTesting + static PlatformMapBitmapScaling platformMapBitmapScalingFromScaling( + MapBitmapScaling scaling) { + switch (scaling) { + case MapBitmapScaling.auto: + return PlatformMapBitmapScaling.auto; + case MapBitmapScaling.none: + return PlatformMapBitmapScaling.none; + } + + // The enum 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. This is deliberately outside + // the switch rather than a `default` so that the linter will flag the + // switch as needing an update. + // ignore: dead_code + return PlatformMapBitmapScaling.auto; + } + + /// Convert [BitmapDescriptor] from platform interface to [PlatformBitmap] pigeon. + @visibleForTesting + static PlatformBitmap platformBitmapFromBitmapDescriptor( + BitmapDescriptor bitmap) { + switch (bitmap) { + case final DefaultMarker marker: + return PlatformBitmap( + bitmap: PlatformBitmapDefaultMarker(hue: marker.hue?.toDouble())); + case final BytesBitmap bytes: + return PlatformBitmap( + bitmap: PlatformBitmapBytes( + byteData: bytes.byteData, + size: (bytes.size == null) + ? null + : _platformPairFromSize(bytes.size!))); + case final AssetBitmap asset: + return PlatformBitmap( + bitmap: PlatformBitmapAsset(name: asset.name, pkg: asset.package)); + case final AssetImageBitmap asset: + return PlatformBitmap( + bitmap: PlatformBitmapAssetImage( + name: asset.name, + scale: asset.scale, + size: (asset.size == null) + ? null + : _platformPairFromSize(asset.size!))); + case final AssetMapBitmap asset: + return PlatformBitmap( + bitmap: PlatformBitmapAssetMap( + assetName: asset.assetName, + bitmapScaling: + platformMapBitmapScalingFromScaling(asset.bitmapScaling), + imagePixelRatio: asset.imagePixelRatio, + width: asset.width, + height: asset.height)); + case final BytesMapBitmap bytes: + return PlatformBitmap( + bitmap: PlatformBitmapBytesMap( + byteData: bytes.byteData, + bitmapScaling: + platformMapBitmapScalingFromScaling(bytes.bitmapScaling), + imagePixelRatio: bytes.imagePixelRatio, + width: bytes.width, + height: bytes.height)); + default: + throw ArgumentError( + 'Unrecognized type of bitmap ${bitmap.runtimeType}', 'bitmap'); + } + } + + /// Convert [Cap] from platform interface to [PlatformCap] pigeon. + @visibleForTesting + static PlatformCap platformCapFromCap(Cap cap) { + switch (cap.type) { + case CapType.butt: + return PlatformCap(type: PlatformCapType.buttCap); + case CapType.square: + return PlatformCap(type: PlatformCapType.squareCap); + case CapType.round: + return PlatformCap(type: PlatformCapType.roundCap); + case CapType.custom: + cap as CustomCap; + return PlatformCap( + type: PlatformCapType.customCap, + bitmapDescriptor: + platformBitmapFromBitmapDescriptor(cap.bitmapDescriptor), + refWidth: cap.refWidth); + } + } } /// Callback handler for map events from the platform host. @@ -1219,63 +1313,30 @@ 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 PlatformPatternItem platformPatternItemFromPatternItem(PatternItem item) { - final List json = item.toJson() as List; - final String tag = json[0] as String; - PlatformPatternItemType type; - double? length; - - /// These string values identify the type of pattern. They are defined and - /// used in the PatternItem class's factory methods in - /// lib/src/types/pattern_item.dart, in the - /// google_maps_flutter_platform_interface package. - // TODO(schectman): Convert PatternItem to structured data. - // https://github.com/flutter/flutter/issues/155121 - switch (tag) { - case 'dot': - type = PlatformPatternItemType.dot; - case 'dash': - type = PlatformPatternItemType.dash; - length = json[1] as double; - case 'gap': - type = PlatformPatternItemType.gap; - length = json[1] as double; - default: - throw ArgumentError('Invalid tag "$tag for PatternItem type.', 'item'); - } - return PlatformPatternItem(type: type, length: length); + switch (item.type) { + case PatternItemType.dot: + return PlatformPatternItem(type: PlatformPatternItemType.dot); + case PatternItemType.dash: + final double length = (item as VariableLengthPatternItem).length; + return PlatformPatternItem( + type: PlatformPatternItemType.dash, length: length); + case PatternItemType.gap: + final double length = (item as VariableLengthPatternItem).length; + return PlatformPatternItem( + type: PlatformPatternItemType.gap, length: length); + } + + // The enum 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. This is deliberately outside + // the switch rather than a `default` so that the linter will flag the + // switch as needing an update. + // ignore: dead_code + return PlatformPatternItem(type: PlatformPatternItemType.dot); } /// Update specification for a set of [TileOverlay]s. 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 1014782821c..51bf2abd56f 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 @@ -67,6 +67,12 @@ enum PlatformPatternItemType { gap, } +/// Pigeon equivalent of [MapBitmapScaling]. +enum PlatformMapBitmapScaling { + auto, + none, +} + /// Pigeon representatation of a CameraPosition. class PlatformCameraPosition { PlatformCameraPosition({ @@ -266,7 +272,7 @@ class PlatformCameraUpdateZoomBy { double amount; - PlatformOffset? focus; + PlatformDoublePair? focus; Object encode() { return [ @@ -279,7 +285,7 @@ class PlatformCameraUpdateZoomBy { result as List; return PlatformCameraUpdateZoomBy( amount: result[0]! as double, - focus: result[1] as PlatformOffset?, + focus: result[1] as PlatformDoublePair?, ); } } @@ -437,29 +443,29 @@ class PlatformClusterManager { } } -/// Pigeon equivalent of the Offset class. -class PlatformOffset { - PlatformOffset({ - required this.dx, - required this.dy, +/// Pair of double values, such as for an offset or size. +class PlatformDoublePair { + PlatformDoublePair({ + required this.x, + required this.y, }); - double dx; + double x; - double dy; + double y; Object encode() { return [ - dx, - dy, + x, + y, ]; } - static PlatformOffset decode(Object result) { + static PlatformDoublePair decode(Object result) { result as List; - return PlatformOffset( - dx: result[0]! as double, - dy: result[1]! as double, + return PlatformDoublePair( + x: result[0]! as double, + y: result[1]! as double, ); } } @@ -476,7 +482,7 @@ class PlatformInfoWindow { String? snippet; - PlatformOffset anchor; + PlatformDoublePair anchor; Object encode() { return [ @@ -491,7 +497,7 @@ class PlatformInfoWindow { return PlatformInfoWindow( title: result[0] as String?, snippet: result[1] as String?, - anchor: result[2]! as PlatformOffset, + anchor: result[2]! as PlatformDoublePair, ); } } @@ -504,7 +510,7 @@ class PlatformMarker { this.consumeTapEvents = false, this.draggable = false, this.flat = false, - this.icon = const ['defaultMarker'], + required this.icon, required this.infoWindow, required this.position, this.rotation = 0.0, @@ -516,7 +522,7 @@ class PlatformMarker { double alpha; - PlatformOffset anchor; + PlatformDoublePair anchor; bool consumeTapEvents; @@ -524,8 +530,7 @@ class PlatformMarker { bool flat; - /// The icon as JSON data. - Object icon; + PlatformBitmap icon; PlatformInfoWindow infoWindow; @@ -563,11 +568,11 @@ class PlatformMarker { result as List; return PlatformMarker( alpha: result[0]! as double, - anchor: result[1]! as PlatformOffset, + anchor: result[1]! as PlatformDoublePair, consumeTapEvents: result[2]! as bool, draggable: result[3]! as bool, flat: result[4]! as bool, - icon: result[5]!, + icon: result[5]! as PlatformBitmap, infoWindow: result[6]! as PlatformInfoWindow, position: result[7]! as PlatformLatLng, rotation: result[8]! as double, @@ -738,8 +743,7 @@ class PlatformCap { PlatformCapType type; - /// The JSON data returned by BitmapDescriptor.toJson. - Object? bitmapDescriptor; + PlatformBitmap? bitmapDescriptor; double? refWidth; @@ -755,7 +759,7 @@ class PlatformCap { result as List; return PlatformCap( type: result[0]! as PlatformCapType, - bitmapDescriptor: result[1], + bitmapDescriptor: result[1] as PlatformBitmap?, refWidth: result[2] as double?, ); } @@ -1293,6 +1297,235 @@ class PlatformZoomRange { } } +/// Pigeon equivalent of [BitmapDescriptor]. As there are multiple disjoint +/// types of [BitmapDescriptor], [PlatformBitmap] contains a single field which +/// may hold the pigeon equivalent type of any of them. +class PlatformBitmap { + PlatformBitmap({ + required this.bitmap, + }); + + /// One of [PlatformBitmapAssetMap], [PlatformBitmapAsset], + /// [PlatformBitmapAssetImage], [PlatformBitmapBytesMap], + /// [PlatformBitmapBytes], or [PlatformBitmapDefaultMarker]. + /// As Pigeon does not currently support data class inheritance, this + /// approach allows for the different bitmap implementations to be valid + /// argument and return types of the API methods. See + /// https://github.com/flutter/flutter/issues/117819. + Object bitmap; + + Object encode() { + return [ + bitmap, + ]; + } + + static PlatformBitmap decode(Object result) { + result as List; + return PlatformBitmap( + bitmap: result[0]!, + ); + } +} + +/// Pigeon equivalent of [DefaultMarker]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#defaultMarker(float) +class PlatformBitmapDefaultMarker { + PlatformBitmapDefaultMarker({ + this.hue, + }); + + double? hue; + + Object encode() { + return [ + hue, + ]; + } + + static PlatformBitmapDefaultMarker decode(Object result) { + result as List; + return PlatformBitmapDefaultMarker( + hue: result[0] as double?, + ); + } +} + +/// Pigeon equivalent of [BytesBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#fromBitmap(android.graphics.Bitmap) +class PlatformBitmapBytes { + PlatformBitmapBytes({ + required this.byteData, + this.size, + }); + + Uint8List byteData; + + PlatformDoublePair? size; + + Object encode() { + return [ + byteData, + size, + ]; + } + + static PlatformBitmapBytes decode(Object result) { + result as List; + return PlatformBitmapBytes( + byteData: result[0]! as Uint8List, + size: result[1] as PlatformDoublePair?, + ); + } +} + +/// Pigeon equivalent of [AssetBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +class PlatformBitmapAsset { + PlatformBitmapAsset({ + required this.name, + this.pkg, + }); + + String name; + + String? pkg; + + Object encode() { + return [ + name, + pkg, + ]; + } + + static PlatformBitmapAsset decode(Object result) { + result as List; + return PlatformBitmapAsset( + name: result[0]! as String, + pkg: result[1] as String?, + ); + } +} + +/// Pigeon equivalent of [AssetImageBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +class PlatformBitmapAssetImage { + PlatformBitmapAssetImage({ + required this.name, + required this.scale, + this.size, + }); + + String name; + + double scale; + + PlatformDoublePair? size; + + Object encode() { + return [ + name, + scale, + size, + ]; + } + + static PlatformBitmapAssetImage decode(Object result) { + result as List; + return PlatformBitmapAssetImage( + name: result[0]! as String, + scale: result[1]! as double, + size: result[2] as PlatformDoublePair?, + ); + } +} + +/// Pigeon equivalent of [AssetMapBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +class PlatformBitmapAssetMap { + PlatformBitmapAssetMap({ + required this.assetName, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height, + }); + + String assetName; + + PlatformMapBitmapScaling bitmapScaling; + + double imagePixelRatio; + + double? width; + + double? height; + + Object encode() { + return [ + assetName, + bitmapScaling, + imagePixelRatio, + width, + height, + ]; + } + + static PlatformBitmapAssetMap decode(Object result) { + result as List; + return PlatformBitmapAssetMap( + assetName: result[0]! as String, + bitmapScaling: result[1]! as PlatformMapBitmapScaling, + imagePixelRatio: result[2]! as double, + width: result[3] as double?, + height: result[4] as double?, + ); + } +} + +/// Pigeon equivalent of [BytesMapBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-frombitmap-bitmap-image +class PlatformBitmapBytesMap { + PlatformBitmapBytesMap({ + required this.byteData, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height, + }); + + Uint8List byteData; + + PlatformMapBitmapScaling bitmapScaling; + + double imagePixelRatio; + + double? width; + + double? height; + + Object encode() { + return [ + byteData, + bitmapScaling, + imagePixelRatio, + width, + height, + ]; + } + + static PlatformBitmapBytesMap decode(Object result) { + result as List; + return PlatformBitmapBytesMap( + byteData: result[0]! as Uint8List, + bitmapScaling: result[1]! as PlatformMapBitmapScaling, + imagePixelRatio: result[2]! as double, + width: result[3] as double?, + height: result[4] as double?, + ); + } +} + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -1315,102 +1548,126 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is PlatformPatternItemType) { buffer.putUint8(133); writeValue(buffer, value.index); - } else if (value is PlatformCameraPosition) { + } else if (value is PlatformMapBitmapScaling) { buffer.putUint8(134); - writeValue(buffer, value.encode()); - } else if (value is PlatformCameraUpdate) { + writeValue(buffer, value.index); + } else if (value is PlatformCameraPosition) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraUpdateNewCameraPosition) { + } else if (value is PlatformCameraUpdate) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraUpdateNewLatLng) { + } else if (value is PlatformCameraUpdateNewCameraPosition) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraUpdateNewLatLngBounds) { + } else if (value is PlatformCameraUpdateNewLatLng) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraUpdateNewLatLngZoom) { + } else if (value is PlatformCameraUpdateNewLatLngBounds) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraUpdateScrollBy) { + } else if (value is PlatformCameraUpdateNewLatLngZoom) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraUpdateZoomBy) { + } else if (value is PlatformCameraUpdateScrollBy) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraUpdateZoom) { + } else if (value is PlatformCameraUpdateZoomBy) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraUpdateZoomTo) { + } else if (value is PlatformCameraUpdateZoom) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is PlatformCircle) { + } else if (value is PlatformCameraUpdateZoomTo) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is PlatformHeatmap) { + } else if (value is PlatformCircle) { buffer.putUint8(145); writeValue(buffer, value.encode()); - } else if (value is PlatformClusterManager) { + } else if (value is PlatformHeatmap) { buffer.putUint8(146); writeValue(buffer, value.encode()); - } else if (value is PlatformOffset) { + } else if (value is PlatformClusterManager) { buffer.putUint8(147); writeValue(buffer, value.encode()); - } else if (value is PlatformInfoWindow) { + } else if (value is PlatformDoublePair) { buffer.putUint8(148); writeValue(buffer, value.encode()); - } else if (value is PlatformMarker) { + } else if (value is PlatformInfoWindow) { buffer.putUint8(149); writeValue(buffer, value.encode()); - } else if (value is PlatformPolygon) { + } else if (value is PlatformMarker) { buffer.putUint8(150); writeValue(buffer, value.encode()); - } else if (value is PlatformPolyline) { + } else if (value is PlatformPolygon) { buffer.putUint8(151); writeValue(buffer, value.encode()); - } else if (value is PlatformCap) { + } else if (value is PlatformPolyline) { buffer.putUint8(152); writeValue(buffer, value.encode()); - } else if (value is PlatformPatternItem) { + } else if (value is PlatformCap) { buffer.putUint8(153); writeValue(buffer, value.encode()); - } else if (value is PlatformTile) { + } else if (value is PlatformPatternItem) { buffer.putUint8(154); writeValue(buffer, value.encode()); - } else if (value is PlatformTileOverlay) { + } else if (value is PlatformTile) { buffer.putUint8(155); writeValue(buffer, value.encode()); - } else if (value is PlatformEdgeInsets) { + } else if (value is PlatformTileOverlay) { buffer.putUint8(156); writeValue(buffer, value.encode()); - } else if (value is PlatformLatLng) { + } else if (value is PlatformEdgeInsets) { buffer.putUint8(157); writeValue(buffer, value.encode()); - } else if (value is PlatformLatLngBounds) { + } else if (value is PlatformLatLng) { buffer.putUint8(158); writeValue(buffer, value.encode()); - } else if (value is PlatformCluster) { + } else if (value is PlatformLatLngBounds) { buffer.putUint8(159); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraTargetBounds) { + } else if (value is PlatformCluster) { buffer.putUint8(160); writeValue(buffer, value.encode()); - } else if (value is PlatformMapViewCreationParams) { + } else if (value is PlatformCameraTargetBounds) { buffer.putUint8(161); writeValue(buffer, value.encode()); - } else if (value is PlatformMapConfiguration) { + } else if (value is PlatformMapViewCreationParams) { buffer.putUint8(162); writeValue(buffer, value.encode()); - } else if (value is PlatformPoint) { + } else if (value is PlatformMapConfiguration) { buffer.putUint8(163); writeValue(buffer, value.encode()); - } else if (value is PlatformTileLayer) { + } else if (value is PlatformPoint) { buffer.putUint8(164); writeValue(buffer, value.encode()); - } else if (value is PlatformZoomRange) { + } else if (value is PlatformTileLayer) { buffer.putUint8(165); writeValue(buffer, value.encode()); + } else if (value is PlatformZoomRange) { + buffer.putUint8(166); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmap) { + buffer.putUint8(167); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapDefaultMarker) { + buffer.putUint8(168); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapBytes) { + buffer.putUint8(169); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapAsset) { + buffer.putUint8(170); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapAssetImage) { + buffer.putUint8(171); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapAssetMap) { + buffer.putUint8(172); + writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapBytesMap) { + buffer.putUint8(173); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -1435,69 +1692,86 @@ class _PigeonCodec extends StandardMessageCodec { final int? value = readValue(buffer) as int?; return value == null ? null : PlatformPatternItemType.values[value]; case 134: - return PlatformCameraPosition.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null ? null : PlatformMapBitmapScaling.values[value]; case 135: - return PlatformCameraUpdate.decode(readValue(buffer)!); + return PlatformCameraPosition.decode(readValue(buffer)!); case 136: - return PlatformCameraUpdateNewCameraPosition.decode(readValue(buffer)!); + return PlatformCameraUpdate.decode(readValue(buffer)!); case 137: - return PlatformCameraUpdateNewLatLng.decode(readValue(buffer)!); + return PlatformCameraUpdateNewCameraPosition.decode(readValue(buffer)!); case 138: - return PlatformCameraUpdateNewLatLngBounds.decode(readValue(buffer)!); + return PlatformCameraUpdateNewLatLng.decode(readValue(buffer)!); case 139: - return PlatformCameraUpdateNewLatLngZoom.decode(readValue(buffer)!); + return PlatformCameraUpdateNewLatLngBounds.decode(readValue(buffer)!); case 140: - return PlatformCameraUpdateScrollBy.decode(readValue(buffer)!); + return PlatformCameraUpdateNewLatLngZoom.decode(readValue(buffer)!); case 141: - return PlatformCameraUpdateZoomBy.decode(readValue(buffer)!); + return PlatformCameraUpdateScrollBy.decode(readValue(buffer)!); case 142: - return PlatformCameraUpdateZoom.decode(readValue(buffer)!); + return PlatformCameraUpdateZoomBy.decode(readValue(buffer)!); case 143: - return PlatformCameraUpdateZoomTo.decode(readValue(buffer)!); + return PlatformCameraUpdateZoom.decode(readValue(buffer)!); case 144: - return PlatformCircle.decode(readValue(buffer)!); + return PlatformCameraUpdateZoomTo.decode(readValue(buffer)!); case 145: - return PlatformHeatmap.decode(readValue(buffer)!); + return PlatformCircle.decode(readValue(buffer)!); case 146: - return PlatformClusterManager.decode(readValue(buffer)!); + return PlatformHeatmap.decode(readValue(buffer)!); case 147: - return PlatformOffset.decode(readValue(buffer)!); + return PlatformClusterManager.decode(readValue(buffer)!); case 148: - return PlatformInfoWindow.decode(readValue(buffer)!); + return PlatformDoublePair.decode(readValue(buffer)!); case 149: - return PlatformMarker.decode(readValue(buffer)!); + return PlatformInfoWindow.decode(readValue(buffer)!); case 150: - return PlatformPolygon.decode(readValue(buffer)!); + return PlatformMarker.decode(readValue(buffer)!); case 151: - return PlatformPolyline.decode(readValue(buffer)!); + return PlatformPolygon.decode(readValue(buffer)!); case 152: - return PlatformCap.decode(readValue(buffer)!); + return PlatformPolyline.decode(readValue(buffer)!); case 153: - return PlatformPatternItem.decode(readValue(buffer)!); + return PlatformCap.decode(readValue(buffer)!); case 154: - return PlatformTile.decode(readValue(buffer)!); + return PlatformPatternItem.decode(readValue(buffer)!); case 155: - return PlatformTileOverlay.decode(readValue(buffer)!); + return PlatformTile.decode(readValue(buffer)!); case 156: - return PlatformEdgeInsets.decode(readValue(buffer)!); + return PlatformTileOverlay.decode(readValue(buffer)!); case 157: - return PlatformLatLng.decode(readValue(buffer)!); + return PlatformEdgeInsets.decode(readValue(buffer)!); case 158: - return PlatformLatLngBounds.decode(readValue(buffer)!); + return PlatformLatLng.decode(readValue(buffer)!); case 159: - return PlatformCluster.decode(readValue(buffer)!); + return PlatformLatLngBounds.decode(readValue(buffer)!); case 160: - return PlatformCameraTargetBounds.decode(readValue(buffer)!); + return PlatformCluster.decode(readValue(buffer)!); case 161: - return PlatformMapViewCreationParams.decode(readValue(buffer)!); + return PlatformCameraTargetBounds.decode(readValue(buffer)!); case 162: - return PlatformMapConfiguration.decode(readValue(buffer)!); + return PlatformMapViewCreationParams.decode(readValue(buffer)!); case 163: - return PlatformPoint.decode(readValue(buffer)!); + return PlatformMapConfiguration.decode(readValue(buffer)!); case 164: - return PlatformTileLayer.decode(readValue(buffer)!); + return PlatformPoint.decode(readValue(buffer)!); case 165: + return PlatformTileLayer.decode(readValue(buffer)!); + case 166: return PlatformZoomRange.decode(readValue(buffer)!); + case 167: + return PlatformBitmap.decode(readValue(buffer)!); + case 168: + return PlatformBitmapDefaultMarker.decode(readValue(buffer)!); + case 169: + return PlatformBitmapBytes.decode(readValue(buffer)!); + case 170: + return PlatformBitmapAsset.decode(readValue(buffer)!); + case 171: + return PlatformBitmapAssetImage.decode(readValue(buffer)!); + case 172: + return PlatformBitmapAssetMap.decode(readValue(buffer)!); + case 173: + return PlatformBitmapBytesMap.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 100a7953141..4982a9390ea 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 @@ -88,7 +88,7 @@ class PlatformCameraUpdateScrollBy { class PlatformCameraUpdateZoomBy { PlatformCameraUpdateZoomBy(this.amount, [this.focus]); final double amount; - final PlatformOffset? focus; + final PlatformDoublePair? focus; } /// Pigeon equivalent of ZoomIn/ZoomOut @@ -147,12 +147,12 @@ class PlatformClusterManager { final String identifier; } -/// Pigeon equivalent of the Offset class. -class PlatformOffset { - PlatformOffset(this.dx, this.dy); +/// Pair of double values, such as for an offset or size. +class PlatformDoublePair { + PlatformDoublePair(this.x, this.y); - final double dx; - final double dy; + final double x; + final double y; } /// Pigeon equivalent of the InfoWindow class. @@ -165,19 +165,19 @@ class PlatformInfoWindow { final String? title; final String? snippet; - final PlatformOffset anchor; + final PlatformDoublePair anchor; } /// Pigeon equivalent of the Marker class. class PlatformMarker { PlatformMarker({ required this.markerId, + required this.icon, this.alpha = 1.0, required this.anchor, this.consumeTapEvents = false, this.draggable = false, this.flat = false, - this.icon = const ['defaultMarker'], required this.infoWindow, required this.position, this.rotation = 0.0, @@ -187,14 +187,12 @@ class PlatformMarker { }); final double alpha; - final PlatformOffset anchor; + final PlatformDoublePair anchor; final bool consumeTapEvents; final bool draggable; final bool flat; - /// The icon as JSON data. - // TODO(schectman): replace this with structured data. - final Object icon; + final PlatformBitmap icon; final PlatformInfoWindow infoWindow; final PlatformLatLng position; final double rotation; @@ -294,10 +292,7 @@ class PlatformCap { 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 PlatformBitmap? bitmapDescriptor; final double? refWidth; } @@ -509,6 +504,96 @@ class PlatformZoomRange { final double? max; } +/// Pigeon equivalent of [BitmapDescriptor]. As there are multiple disjoint +/// types of [BitmapDescriptor], [PlatformBitmap] contains a single field which +/// may hold the pigeon equivalent type of any of them. +class PlatformBitmap { + PlatformBitmap({required this.bitmap}); + + /// One of [PlatformBitmapAssetMap], [PlatformBitmapAsset], + /// [PlatformBitmapAssetImage], [PlatformBitmapBytesMap], + /// [PlatformBitmapBytes], or [PlatformBitmapDefaultMarker]. + /// As Pigeon does not currently support data class inheritance, this + /// approach allows for the different bitmap implementations to be valid + /// argument and return types of the API methods. See + /// https://github.com/flutter/flutter/issues/117819. + final Object bitmap; +} + +/// Pigeon equivalent of [DefaultMarker]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#defaultMarker(float) +class PlatformBitmapDefaultMarker { + PlatformBitmapDefaultMarker({this.hue}); + + final double? hue; +} + +/// Pigeon equivalent of [BytesBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#fromBitmap(android.graphics.Bitmap) +class PlatformBitmapBytes { + PlatformBitmapBytes({required this.byteData, this.size}); + + final Uint8List byteData; + final PlatformDoublePair? size; +} + +/// Pigeon equivalent of [AssetBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +class PlatformBitmapAsset { + PlatformBitmapAsset({required this.name, this.pkg}); + + final String name; + final String? pkg; +} + +/// Pigeon equivalent of [AssetImageBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +class PlatformBitmapAssetImage { + PlatformBitmapAssetImage( + {required this.name, required this.scale, this.size}); + final String name; + final double scale; + final PlatformDoublePair? size; +} + +/// Pigeon equivalent of [MapBitmapScaling]. +enum PlatformMapBitmapScaling { + auto, + none, +} + +/// Pigeon equivalent of [AssetMapBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname +class PlatformBitmapAssetMap { + PlatformBitmapAssetMap( + {required this.assetName, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height}); + final String assetName; + final PlatformMapBitmapScaling bitmapScaling; + final double imagePixelRatio; + final double? width; + final double? height; +} + +/// Pigeon equivalent of [BytesMapBitmap]. See +/// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-frombitmap-bitmap-image +class PlatformBitmapBytesMap { + PlatformBitmapBytesMap( + {required this.byteData, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height}); + final Uint8List byteData; + final PlatformMapBitmapScaling bitmapScaling; + final double imagePixelRatio; + final double? width; + final double? height; +} + /// Interface for non-test interactions with the native SDK. /// /// For test-only state queries, see [MapsInspectorApi]. 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 1d0f5774fe3..a9a1ec62d36 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.9 +version: 2.14.10 environment: sdk: ^3.5.0 @@ -21,7 +21,7 @@ dependencies: flutter: sdk: flutter flutter_plugin_android_lifecycle: ^2.0.1 - google_maps_flutter_platform_interface: ^2.9.2 + google_maps_flutter_platform_interface: ^2.9.5 stream_transform: ^2.0.0 dev_dependencies: 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 512dea6fcf4..2b3bd06edc0 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 @@ -408,20 +408,25 @@ void main() { expect(toChange.length, 1); final List? encoded = toChange.first?.encode() as List?; expect(encoded?[0], object2new.alpha); - final PlatformOffset? offset = encoded?[1] as PlatformOffset?; - expect(offset?.dx, object2new.anchor.dx); - expect(offset?.dy, object2new.anchor.dy); - expect(encoded?.getRange(2, 6).toList(), [ + final PlatformDoublePair? offset = encoded?[1] as PlatformDoublePair?; + expect(offset?.x, object2new.anchor.dx); + expect(offset?.y, object2new.anchor.dy); + expect(encoded?.getRange(2, 5).toList(), [ object2new.consumeTapEvents, object2new.draggable, object2new.flat, - object2new.icon.toJson(), ]); + expect( + (encoded?[5] as PlatformBitmap?)?.bitmap.runtimeType, + GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( + object2new.icon) + .bitmap + .runtimeType); final PlatformInfoWindow? window = encoded?[6] as PlatformInfoWindow?; expect(window?.title, object2new.infoWindow.title); expect(window?.snippet, object2new.infoWindow.snippet); - expect(window?.anchor.dx, object2new.infoWindow.anchor.dx); - expect(window?.anchor.dy, object2new.infoWindow.anchor.dy); + expect(window?.anchor.x, object2new.infoWindow.anchor.dx); + expect(window?.anchor.y, object2new.infoWindow.anchor.dy); final PlatformLatLng? latLng = encoded?[7] as PlatformLatLng?; expect(latLng?.latitude, object2new.position.latitude); expect(latLng?.longitude, object2new.position.longitude); @@ -438,20 +443,25 @@ void main() { expect(toAdd.length, 1); final List? encoded = toAdd.first?.encode() as List?; expect(encoded?[0], object3.alpha); - final PlatformOffset? offset = encoded?[1] as PlatformOffset?; - expect(offset?.dx, object3.anchor.dx); - expect(offset?.dy, object3.anchor.dy); - expect(encoded?.getRange(2, 6).toList(), [ + final PlatformDoublePair? offset = encoded?[1] as PlatformDoublePair?; + expect(offset?.x, object3.anchor.dx); + expect(offset?.y, object3.anchor.dy); + expect(encoded?.getRange(2, 5).toList(), [ object3.consumeTapEvents, object3.draggable, object3.flat, - object3.icon.toJson(), ]); + expect( + (encoded?[5] as PlatformBitmap?)?.bitmap.runtimeType, + GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( + object3.icon) + .bitmap + .runtimeType); final PlatformInfoWindow? window = encoded?[6] as PlatformInfoWindow?; expect(window?.title, object3.infoWindow.title); expect(window?.snippet, object3.infoWindow.snippet); - expect(window?.anchor.dx, object3.infoWindow.anchor.dx); - expect(window?.anchor.dy, object3.infoWindow.anchor.dy); + expect(window?.anchor.x, object3.infoWindow.anchor.dx); + expect(window?.anchor.y, object3.infoWindow.anchor.dy); final PlatformLatLng? latLng = encoded?[7] as PlatformLatLng?; expect(latLng?.latitude, object3.position.latitude); expect(latLng?.longitude, object3.position.longitude); @@ -578,10 +588,18 @@ 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()); + final PlatformCap expectedStartCap = + GoogleMapsFlutterAndroid.platformCapFromCap(expected.startCap); + final PlatformCap expectedEndCap = + GoogleMapsFlutterAndroid.platformCapFromCap(expected.endCap); + expect(actual.startCap.type, expectedStartCap.type); + expect(actual.startCap.refWidth, expectedStartCap.refWidth); + expect(actual.startCap.bitmapDescriptor?.bitmap.runtimeType, + expectedStartCap.bitmapDescriptor?.bitmap.runtimeType); + expect(actual.endCap.type, expectedEndCap.type); + expect(actual.endCap.refWidth, expectedEndCap.refWidth); + expect(actual.endCap.bitmapDescriptor?.bitmap.runtimeType, + expectedEndCap.bitmapDescriptor?.bitmap.runtimeType); } // Object one should be removed. @@ -898,8 +916,8 @@ void main() { final PlatformCameraUpdateZoomBy typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateZoomBy; update as CameraUpdateZoomBy; - expect(typedUpdate.focus?.dx, update.focus?.dx); - expect(typedUpdate.focus?.dy, update.focus?.dy); + expect(typedUpdate.focus?.x, update.focus?.dx); + expect(typedUpdate.focus?.y, update.focus?.dy); expect(typedUpdate.amount, update.amount); }); @@ -952,6 +970,75 @@ void main() { expect(typedUpdate.out, true); }); + test('MapBitmapScaling to PlatformMapBitmapScaling', () { + expect( + GoogleMapsFlutterAndroid.platformMapBitmapScalingFromScaling( + MapBitmapScaling.auto), + PlatformMapBitmapScaling.auto); + expect( + GoogleMapsFlutterAndroid.platformMapBitmapScalingFromScaling( + MapBitmapScaling.none), + PlatformMapBitmapScaling.none); + }); + + test('DefaultMarker bitmap to PlatformBitmap', () { + final BitmapDescriptor bitmap = BitmapDescriptor.defaultMarkerWithHue(10.0); + final PlatformBitmap platformBitmap = + GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(bitmap); + expect(platformBitmap.bitmap, isA()); + final PlatformBitmapDefaultMarker typedBitmap = + platformBitmap.bitmap as PlatformBitmapDefaultMarker; + expect(typedBitmap.hue, 10.0); + }); + + test('BytesMapBitmap bitmap to PlatformBitmap', () { + final Uint8List data = Uint8List.fromList([1, 2, 3, 4]); + final BytesMapBitmap bitmap = BitmapDescriptor.bytes(data, + imagePixelRatio: 2.0, width: 100.0, height: 200.0); + final PlatformBitmap platformBitmap = + GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(bitmap); + expect(platformBitmap.bitmap, isA()); + final PlatformBitmapBytesMap typedBitmap = + platformBitmap.bitmap as PlatformBitmapBytesMap; + expect(typedBitmap.byteData, data); + expect(typedBitmap.bitmapScaling, PlatformMapBitmapScaling.auto); + expect(typedBitmap.imagePixelRatio, 2.0); + expect(typedBitmap.width, 100.0); + expect(typedBitmap.height, 200.0); + }); + + test('AssetMapBitmap bitmap to PlatformBitmap', () { + const String assetName = 'fake_asset_name'; + final AssetMapBitmap bitmap = AssetMapBitmap(assetName, + imagePixelRatio: 2.0, width: 100.0, height: 200.0); + final PlatformBitmap platformBitmap = + GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(bitmap); + expect(platformBitmap.bitmap, isA()); + final PlatformBitmapAssetMap typedBitmap = + platformBitmap.bitmap as PlatformBitmapAssetMap; + expect(typedBitmap.assetName, assetName); + expect(typedBitmap.bitmapScaling, PlatformMapBitmapScaling.auto); + expect(typedBitmap.imagePixelRatio, 2.0); + expect(typedBitmap.width, 100.0); + expect(typedBitmap.height, 200.0); + }); + + test('Cap to PlatformCap', () { + expect(GoogleMapsFlutterAndroid.platformCapFromCap(Cap.buttCap).encode(), + PlatformCap(type: PlatformCapType.buttCap).encode()); + expect(GoogleMapsFlutterAndroid.platformCapFromCap(Cap.roundCap).encode(), + PlatformCap(type: PlatformCapType.roundCap).encode()); + expect(GoogleMapsFlutterAndroid.platformCapFromCap(Cap.squareCap).encode(), + PlatformCap(type: PlatformCapType.squareCap).encode()); + + const BitmapDescriptor bitmap = BitmapDescriptor.defaultMarker; + const CustomCap customCap = CustomCap(bitmap, refWidth: 15.0); + final PlatformCap platformCap = + GoogleMapsFlutterAndroid.platformCapFromCap(customCap); + expect(platformCap.type, PlatformCapType.customCap); + expect(customCap.refWidth, 15.0); + }); + testWidgets('Use PlatformViewLink when using surface view', (WidgetTester tester) async { final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid();