From 4ee2170919da1646212483fbe643a2b471dba096 Mon Sep 17 00:00:00 2001 From: Chris Arriola Date: Wed, 27 Oct 2021 13:21:21 -0500 Subject: [PATCH] fix: Fix v18.0.0 build errors (#740) * fix: Fix build errors from v18.0.0 Change-Id: Id4a2b5edf71832ffe71e2296de979b9a48b7786a * Update CI to only build GMS on non-snippet code. Change-Id: I1cbc08546758ec1ae40851777efdbe2ac2e941a4 * Remove redundant snippet end tag. Change-Id: I8101762c705a31af6c63deec91152246e19b9622 * Fix nullability errors. Change-Id: I3e535c0389586bf69a6780c5ce46c813e2b3241f --- .github/workflows/build.yml | 6 +- .../CloudBasedMapStylingDemoActivity.java | 73 +++++++++++++++++++ .../res/layout/cloud_styling_basic_demo.xml | 65 +++++++++++++++++ .../kotlindemos/BasicMapDemoActivity.kt | 7 +- .../example/kotlindemos/CameraDemoActivity.kt | 8 +- .../example/kotlindemos/CircleDemoActivity.kt | 12 +-- .../example/kotlindemos/EventsDemoActivity.kt | 4 +- .../kotlindemos/GroundOverlayDemoActivity.kt | 4 +- .../example/kotlindemos/IndoorDemoActivity.kt | 4 +- .../example/kotlindemos/LayersDemoActivity.kt | 6 +- .../kotlindemos/LiteListDemoActivity.kt | 4 +- .../kotlindemos/LocationSourceDemoActivity.kt | 2 + .../com/example/kotlindemos/MainActivity.kt | 4 +- ...arkerCloseInfoWindowOnRetapDemoActivity.kt | 2 +- .../example/kotlindemos/MarkerDemoActivity.kt | 10 +-- .../kotlindemos/MyLocationDemoActivity.kt | 4 +- .../kotlindemos/OnMapAndViewReadyListener.kt | 2 +- .../kotlindemos/PolygonDemoActivity.kt | 2 +- .../example/kotlindemos/TagsDemoActivity.kt | 4 +- .../kotlindemos/TileOverlayDemoActivity.kt | 2 +- .../kotlindemos/UiSettingsDemoActivity.kt | 2 +- .../polyline/PolylineDemoActivity.kt | 6 +- .../kotlin/MapRendererOptInApplication.kt | 4 +- .../com/google/maps/example/kotlin/Markers.kt | 12 +-- .../maps/example/kotlin/TileOverlays.kt | 5 +- .../com/google/maps/utils/kotlin/Heatmaps.kt | 6 +- 26 files changed, 195 insertions(+), 65 deletions(-) create mode 100644 ApiDemos/java/app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java create mode 100644 ApiDemos/java/app/src/v3/res/layout/cloud_styling_basic_demo.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 676e0131..b37f805f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: - name: Build and check run: | cd ApiDemos - for dir in ./*/ ; do ( cd "$dir" && ./gradlew assemble lint ); done + for dir in ./*/ ; do ( cd "$dir" && ./gradlew buildGmsDebugPreBundle ); done build-WearOS: runs-on: ubuntu-latest @@ -65,7 +65,7 @@ jobs: java-version: '11' - name: Build and check - run: cd WearOS && ./gradlew assembleDebug lintDebug + run: cd WearOS && ./gradlew build build-Snippets: runs-on: ubuntu-latest @@ -110,7 +110,7 @@ jobs: cd "$dir" for tutorial in ./*/ do - cd "$tutorial" && ./gradlew assembleDebug lintDebug + cd "$tutorial" && ./gradlew buildDebug cd .. done cd .. diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java b/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java new file mode 100644 index 00000000..bd4b7f91 --- /dev/null +++ b/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java @@ -0,0 +1,73 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.example.mapdemo; + +import android.os.Bundle; +import androidx.appcompat.app.AppCompatActivity; +import com.google.android.libraries.maps.GoogleMap; +import com.google.android.libraries.maps.OnMapReadyCallback; +import com.google.android.libraries.maps.SupportMapFragment; + +/** + * This shows how to use Cloud-based Map Styling in a simple Activity. For more information on how + * to style a map using this method, see: + * https://developers.google.com/maps/documentation/android-sdk/cloud-based-map-styling + **/ +public class CloudBasedMapStylingDemoActivity extends AppCompatActivity implements + OnMapReadyCallback { + + private static final String MAP_TYPE_KEY = "map_type"; + private GoogleMap map; + private int currentMapType = GoogleMap.MAP_TYPE_NORMAL; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (savedInstanceState != null) { + currentMapType = savedInstanceState.getInt(MAP_TYPE_KEY); + } + + // The underlying style the map will use has been set in the layout + // `cloud_styling_basic_demo` under the SupportMapFragment's `map:mapId` attribute. + setContentView(R.layout.cloud_styling_basic_demo); + SupportMapFragment mapFragment = + (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); + mapFragment.getMapAsync(this); + + setUpButtonListeners(); + } + + @Override + public void onMapReady(GoogleMap map) { + this.map = map; + map.setMapType(currentMapType); + } + + private void setUpButtonListeners() { + findViewById(R.id.styling_normal_mode).setOnClickListener( + v -> setMapType(GoogleMap.MAP_TYPE_NORMAL)); + findViewById(R.id.styling_satellite_mode).setOnClickListener( + v -> setMapType(GoogleMap.MAP_TYPE_SATELLITE)); + findViewById(R.id.styling_hybrid_mode).setOnClickListener( + v -> setMapType(GoogleMap.MAP_TYPE_HYBRID)); + findViewById(R.id.styling_terrain_mode).setOnClickListener( + v -> setMapType(GoogleMap.MAP_TYPE_TERRAIN)); + } + + private void setMapType(int mapType) { + currentMapType = mapType; + map.setMapType(mapType); + } +} \ No newline at end of file diff --git a/ApiDemos/java/app/src/v3/res/layout/cloud_styling_basic_demo.xml b/ApiDemos/java/app/src/v3/res/layout/cloud_styling_basic_demo.xml new file mode 100644 index 00000000..d9da142a --- /dev/null +++ b/ApiDemos/java/app/src/v3/res/layout/cloud_styling_basic_demo.xml @@ -0,0 +1,65 @@ + + + + + + + + +