From d38dfe384637d2c8c162241142dc938e94a9e754 Mon Sep 17 00:00:00 2001 From: Dale Hawkins <107309+dkhawk@users.noreply.github.com> Date: Tue, 18 Aug 2026 15:45:09 -0600 Subject: [PATCH] chore(styling,demos): clean up StyledMapDemo strings and copyright headers - Clean up StyledMapDemoActivity raw string formatting and resource templates - Add common string array resources in arrays.xml - Update 2026 copyright headers and clean lint warnings across remaining map demo activities --- .../main/res/layout/ground_overlay_demo.xml | 4 +- .../street_view_panorama_events_demo.xml | 4 +- .../street_view_panorama_options_demo.xml | 4 +- .../src/main/res/layout/tile_overlay_demo.xml | 4 +- .../src/main/res/layout/ui_settings_demo.xml | 4 +- .../common-ui/src/main/res/values/arrays.xml | 22 ++ .../common-ui/src/main/res/values/strings.xml | 34 +- ApiDemos/project/java-app/build.gradle.kts | 3 +- .../StreetViewPanoramaEventsDemoActivity.java | 10 +- ApiDemos/project/kotlin-app/build.gradle.kts | 4 +- ...ackgroundColorCustomizationDemoActivity.kt | 4 +- ...orCustomizationProgrammaticDemoActivity.kt | 4 +- .../CloudBasedMapStylingDemoActivity.kt | 4 +- .../DataDrivenBoundariesActivity.kt | 4 +- .../kotlindemos/MapColorSchemeActivity.kt | 4 +- .../kotlindemos/MapInPagerDemoActivity.kt | 5 +- ...arkerCloseInfoWindowOnRetapDemoActivity.kt | 4 +- .../kotlindemos/MultiMapDemoActivity.kt | 4 +- .../kotlindemos/MyLocationDemoActivity.kt | 4 +- .../kotlindemos/PolygonDemoActivity.kt | 4 +- .../kotlindemos/PolylineDemoActivity.kt | 6 +- .../kotlindemos/ProgrammaticDemoActivity.kt | 10 +- .../kotlindemos/RetainMapDemoActivity.kt | 8 +- .../StreetViewPanoramaBasicDemoActivity.kt | 4 +- .../StreetViewPanoramaEventsDemoActivity.kt | 12 +- ...treetViewPanoramaNavigationDemoActivity.kt | 4 +- .../StreetViewPanoramaViewDemoActivity.kt | 4 +- .../kotlindemos/StyledMapDemoActivity.kt | 296 +++++++++--------- .../example/kotlindemos/TagsDemoActivity.kt | 4 +- 29 files changed, 265 insertions(+), 217 deletions(-) create mode 100644 ApiDemos/project/common-ui/src/main/res/values/arrays.xml diff --git a/ApiDemos/project/common-ui/src/main/res/layout/ground_overlay_demo.xml b/ApiDemos/project/common-ui/src/main/res/layout/ground_overlay_demo.xml index d568ef797..14aa1027e 100644 --- a/ApiDemos/project/common-ui/src/main/res/layout/ground_overlay_demo.xml +++ b/ApiDemos/project/common-ui/src/main/res/layout/ground_overlay_demo.xml @@ -1,5 +1,5 @@ + + + 2.0 + 21.0 + + diff --git a/ApiDemos/project/common-ui/src/main/res/values/strings.xml b/ApiDemos/project/common-ui/src/main/res/values/strings.xml index 8fd4ff0ab..641941e8b 100755 --- a/ApiDemos/project/common-ui/src/main/res/values/strings.xml +++ b/ApiDemos/project/common-ui/src/main/res/values/strings.xml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - + Maps SDK for Android Demos (Java) Maps SDK for Android Demos (Java) Maps SDK for Android Demos (Kotlin) @@ -32,12 +32,18 @@ Demonstrates how to use Camera Clamping. Camera Clamping Demo - Clamp to Adelaide - Clamp to Pacific - Reset LatLng Bounds + Adelaide + Pacific + Reset + Bounds: None + Bounds: Adelaide + Bounds: Pacific + Position: (%1$.6f, %2$.6f)\nzoom=%3$.1f, tilt=%4$.1f\u00b0, bearing=%5$.1f\u00b0 MinZoom++ - MaxZoom-- - Reset Zoom Bounds + MaxZoom-- + Reset Zoom + Zoom Limits: %1$.1f – %2$.1f + Zoom Limits: 2.0 – 21.0 Clear Clickable @@ -51,6 +57,9 @@ Custom Duration Events Demonstrates event handling. + Tapped: (%1$s, %2$s) + Long pressed: (%1$s, %2$s) + Position: (%1$s, %2$s)\nzoom=%3$s, tilt=%4$s\u00b0, bearing=%5$s\u00b0 Fade In Tiles Fill Alpha Fill Hue @@ -121,6 +130,9 @@ Demonstrates how to take a snapshot of the map. Area for the map snapshot. Take snapshot + Live Map + Captured Snapshot + Tap \"Take snapshot\" to capture the map \u25A0 Stroke Alpha Stroke Hue @@ -199,10 +211,19 @@ Position Demonstrates how to show a Street View panorama and map. Street View Panorama and Map + Long-press & drag Pegman on the map to jump Street View. Tap arrows in Street View to walk. + Moved Pegman to your location + Finding your current location\u2026 + Location unavailable. Please check device location settings. + Location permission is required to find your location. Please grant it in app settings. Standard Street View Panorama using a Fragment. Street View Panorama Standard Street View Panorama with event handling. Street View Panorama events + Times panorama changed=%1$d + Times camera changed=%1$d + Times clicked=%1$d : %2$s + Times long clicked=%1$d : %2$s Street View Panorama with programmatic navigation. Street View Panorama navigation Street View Panorama with toggles for options. @@ -217,6 +238,7 @@ Advanced Markers Showcases the usage of Advanced Markers. + Hello! DEMO_MAP_ID diff --git a/ApiDemos/project/java-app/build.gradle.kts b/ApiDemos/project/java-app/build.gradle.kts index 73e208bf6..ca0b55a79 100644 --- a/ApiDemos/project/java-app/build.gradle.kts +++ b/ApiDemos/project/java-app/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2025 Google LLC + * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,6 +68,7 @@ dependencies { implementation(libs.recyclerview) implementation(libs.volley) implementation(libs.play.services.maps) + implementation(libs.play.services.location) implementation(libs.material) implementation(libs.activity) implementation(project(":ApiDemos:common-ui")) diff --git a/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java index ad03fb251..212217e07 100755 --- a/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java +++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -98,13 +98,13 @@ protected void onCreate(final Bundle savedInstanceState) { @Override public void onStreetViewPanoramaChange(StreetViewPanoramaLocation location) { if (location != null) { - panoChangeTimesTextView.setText("Times panorama changed=" + ++panoChangeTimes); + panoChangeTimesTextView.setText(getString(com.example.common_ui.R.string.pano_change_times, ++panoChangeTimes)); } } @Override public void onStreetViewPanoramaCameraChange(StreetViewPanoramaCamera camera) { - panoCameraChangeTextView.setText("Times camera changed=" + ++panoCameraChangeTimes); + panoCameraChangeTextView.setText(getString(com.example.common_ui.R.string.pano_camera_change_times, ++panoCameraChangeTimes)); } @Override @@ -113,7 +113,7 @@ public void onStreetViewPanoramaClick(StreetViewPanoramaOrientation orientation) if (point != null) { panoClickTimes++; panoClickTextView.setText( - "Times clicked=" + panoClickTimes + " : " + point); + getString(com.example.common_ui.R.string.pano_click_times, panoClickTimes, point)); streetViewPanorama.animateTo( new StreetViewPanoramaCamera.Builder() .orientation(orientation) @@ -128,7 +128,7 @@ public void onStreetViewPanoramaLongClick(StreetViewPanoramaOrientation orientat if (point != null) { panoLongClickTimes++; panoLongClickTextView.setText( - "Times long clicked=" + panoLongClickTimes + " : " + point); + getString(com.example.common_ui.R.string.pano_long_click_times, panoLongClickTimes, point)); } } } diff --git a/ApiDemos/project/kotlin-app/build.gradle.kts b/ApiDemos/project/kotlin-app/build.gradle.kts index 810fa6e18..868ca5bf6 100644 --- a/ApiDemos/project/kotlin-app/build.gradle.kts +++ b/ApiDemos/project/kotlin-app/build.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget /* - * Copyright 2025 Google LLC + * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ android { buildTypes { getByName("release") { isMinifyEnabled = true + isShrinkResources = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" @@ -84,6 +85,7 @@ dependencies { implementation(libs.lifecycle.runtime.ktx) implementation(libs.maps.ktx) implementation(libs.maps.utils.ktx) + implementation(libs.play.services.location) implementation(libs.activity) diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt index 417051e6e..1e8e59297 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ class BackgroundColorCustomizationDemoActivity : SamplesBaseActivity(), OnMapRea setContentView(R.layout.background_color_customization_demo) val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment? mapFragment?.getMapAsync(this) - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } /** diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt index 11d39d4da..a7fff2c83 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ class BackgroundColorCustomizationProgrammaticDemoActivity : SamplesBaseActivity } else { mapFragment.getMapAsync(this) } - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } override fun onMapReady(map: GoogleMap) { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt index 3622e4cd3..8dc6e5983 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt @@ -6,7 +6,7 @@ * corresponding file under the `app/src/gms` directory. */ /* - * Copyright 2020 Google LLC + * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ class CloudBasedMapStylingDemoActivity : SamplesBaseActivity(), OnMapReadyCallba val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment? mapFragment!!.getMapAsync(this) setUpButtonListeners() - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } override fun onMapReady(map: GoogleMap) { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenBoundariesActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenBoundariesActivity.kt index 26d0c7d82..c80f5ab51 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenBoundariesActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenBoundariesActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -107,7 +107,7 @@ class DataDrivenBoundariesActivity : SamplesBaseActivity(), OnMapReadyCallback, setupBoundarySelectorButton() // Setup the new selector button // --- Insets --- - applyInsets(findViewById(R.id.map_container)) // Apply insets if needed + applyInsets(findViewById(R.id.map_container)) // Apply insets if needed } private fun setupBoundarySelectorButton() { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MapColorSchemeActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MapColorSchemeActivity.kt index a2866b03e..460f4cbbf 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MapColorSchemeActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MapColorSchemeActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright 2025 Google LLC + * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ class MapColorSchemeActivity : buttonLight = findViewById(R.id.map_color_light_mode) buttonDark = findViewById(R.id.map_color_dark_mode) buttonFollowSystem = findViewById(R.id.map_color_follow_system_mode) - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } override fun onMapReady(googleMap: GoogleMap) { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MapInPagerDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MapInPagerDemoActivity.kt index eff3890bf..edeb7f36e 100755 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MapInPagerDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MapInPagerDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ class MapInPagerDemoActivity : SamplesBaseActivity() { // This is required to avoid a black flash when the map is loaded. The flash is due // to the use of a SurfaceView as the underlying view of the map. pager.requestTransparentRegion(pager) - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } /** A simple fragment that displays a TextView. */ @@ -55,6 +55,7 @@ class MapInPagerDemoActivity : SamplesBaseActivity() { } /** A simple FragmentPagerAdapter that returns two TextFragment and a SupportMapFragment. */ + @Suppress("DEPRECATION") class MyAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MarkerCloseInfoWindowOnRetapDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MarkerCloseInfoWindowOnRetapDemoActivity.kt index c9397e4e0..c37dab971 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MarkerCloseInfoWindowOnRetapDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MarkerCloseInfoWindowOnRetapDemoActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018 Google LLC + * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -70,7 +70,7 @@ class MarkerCloseInfoWindowOnRetapDemoActivity : val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment OnMapAndViewReadyListener(mapFragment, this) - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } override fun onMapReady(googleMap: GoogleMap?) { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MultiMapDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MultiMapDemoActivity.kt index 1ca406943..6beb36268 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MultiMapDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MultiMapDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -25,6 +25,6 @@ class MultiMapDemoActivity : SamplesBaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.multimap_demo) - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } } \ No newline at end of file diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MyLocationDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MyLocationDemoActivity.kt index e86d74bff..65ce1558a 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MyLocationDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/MyLocationDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ class MyLocationDemoActivity : SamplesBaseActivity(), val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment? mapFragment?.getMapAsync(this) - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } override fun onMapReady(googleMap: GoogleMap) { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/PolygonDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/PolygonDemoActivity.kt index fea47f8b7..71a236a39 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/PolygonDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/PolygonDemoActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018 Google LLC + * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -131,7 +131,7 @@ class PolygonDemoActivity : val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment mapFragment.getMapAsync(this) - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } // [START_EXCLUDE silent] diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/PolylineDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/PolylineDemoActivity.kt index a871551ea..e0c8f7b03 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/PolylineDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/PolylineDemoActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018 Google LLC + * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -155,7 +155,7 @@ class PolylineDemoActivity : val mapFragment = supportFragmentManager.findFragmentById(com.example.common_ui.R.id.map) as SupportMapFragment mapFragment.getMapAsync(this) - applyInsets(findViewById(com.example.common_ui.R.id.map_container)) + applyInsets(findViewById(com.example.common_ui.R.id.map_container)) } // [START_EXCLUDE silent] @@ -165,8 +165,6 @@ class PolylineDemoActivity : // [END_EXCLUDE] override fun onMapReady(googleMap: GoogleMap) { - googleMap - with(googleMap) { // Override the default content description on the view, for accessibility mode. setContentDescription(getString(com.example.common_ui.R.string.polyline_demo_description)) diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/ProgrammaticDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/ProgrammaticDemoActivity.kt index b54d13098..fdb4f236a 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/ProgrammaticDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/ProgrammaticDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2025 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ // limitations under the License. package com.example.kotlindemos -import android.R import android.os.Bundle import android.view.View import androidx.lifecycle.lifecycleScope @@ -21,6 +20,7 @@ import com.google.android.gms.maps.SupportMapFragment import com.google.android.gms.maps.model.LatLng import com.google.maps.android.ktx.addMarker import com.google.maps.android.ktx.awaitMap +import kotlinx.coroutines.launch /** * Demonstrates how to instantiate a SupportMapFragment programmatically and add a marker to it. @@ -36,18 +36,18 @@ class ProgrammaticDemoActivity : SamplesBaseActivity() { ?: SupportMapFragment.newInstance().also { // Then we add it using a FragmentTransaction. val fragmentTransaction = supportFragmentManager.beginTransaction() - fragmentTransaction.add(R.id.content, it, MAP_FRAGMENT_TAG) + fragmentTransaction.add(android.R.id.content, it, MAP_FRAGMENT_TAG) fragmentTransaction.commit() } - lifecycleScope.launchWhenCreated { + lifecycleScope.launch { val map = mapFragment.awaitMap() map.addMarker { position(LatLng(0.0, 0.0)) title("Marker") } } - applyInsets(findViewById(com.example.common_ui.R.id.map_container)) + applyInsets(findViewById(com.example.common_ui.R.id.map_container)) } companion object { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/RetainMapDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/RetainMapDemoActivity.kt index 36c22497f..f837e601c 100755 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/RetainMapDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/RetainMapDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.google.android.gms.maps.SupportMapFragment import com.google.android.gms.maps.model.LatLng import com.google.maps.android.ktx.addMarker import com.google.maps.android.ktx.awaitMap +import kotlinx.coroutines.launch /** * This shows how to retain a map across activity restarts (e.g., from screen rotations), which can @@ -34,15 +35,16 @@ class RetainMapDemoActivity : SamplesBaseActivity() { supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment if (savedInstanceState == null) { // First incarnation of this activity. + @Suppress("DEPRECATION") mapFragment.retainInstance = true } - lifecycleScope.launchWhenCreated { + lifecycleScope.launch { val map = mapFragment.awaitMap() map.addMarker { position(LatLng(0.0, 0.0)) title("Marker") } } - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } } \ No newline at end of file diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaBasicDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaBasicDemoActivity.kt index 40ea537b1..bc1c68d5a 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaBasicDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaBasicDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ class StreetViewPanoramaBasicDemoActivity : SamplesBaseActivity() { // loaded which is when the savedInstanceState is null). savedInstanceState ?: panorama.setPosition(SYDNEY) } - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } companion object { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaEventsDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaEventsDemoActivity.kt index 1930d9fa7..37bdf0f3d 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaEventsDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaEventsDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -74,22 +74,22 @@ class StreetViewPanoramaEventsDemoActivity : SamplesBaseActivity(), // loaded which is when the savedInstanceState is null). savedInstanceState ?: streetViewPanorama.setPosition(SYDNEY) } - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } override fun onStreetViewPanoramaChange(location: StreetViewPanoramaLocation) { - panoChangeTimesTextView.text = "Times panorama changed=" + ++panoChangeTimes + panoChangeTimesTextView.text = getString(R.string.pano_change_times, ++panoChangeTimes) } override fun onStreetViewPanoramaCameraChange(camera: StreetViewPanoramaCamera) { - panoCameraChangeTextView.text = "Times camera changed=" + ++panoCameraChangeTimes + panoCameraChangeTextView.text = getString(R.string.pano_camera_change_times, ++panoCameraChangeTimes) } override fun onStreetViewPanoramaClick(orientation: StreetViewPanoramaOrientation) { val point = streetViewPanorama.orientationToPoint(orientation) point?.let { panoClickTimes++ - panoClickTextView.text = "Times clicked=$panoClickTimes : $point" + panoClickTextView.text = getString(R.string.pano_click_times, panoClickTimes, it) streetViewPanorama.animateTo( StreetViewPanoramaCamera.Builder() .orientation(orientation) @@ -103,7 +103,7 @@ class StreetViewPanoramaEventsDemoActivity : SamplesBaseActivity(), val point = streetViewPanorama.orientationToPoint(orientation) if (point != null) { panoLongClickTimes++ - panoLongClickTextView.text = "Times long clicked=$panoLongClickTimes : $point" + panoLongClickTextView.text = getString(R.string.pano_long_click_times, panoLongClickTimes, point) } } diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaNavigationDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaNavigationDemoActivity.kt index e06169426..a08b1b111 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaNavigationDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaNavigationDemoActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018 Google LLC + * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -190,7 +190,7 @@ class StreetViewPanoramaNavigationDemoActivity : SamplesBaseActivity() { private fun onMovePosition() { val location = streetViewPanorama.location val camera = streetViewPanorama.panoramaCamera - location.links?.let { + if (location.links.isNotEmpty()) { val link = location.links.findClosestLinkToBearing(camera.bearing) streetViewPanorama.setPosition(link.panoId) } diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaViewDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaViewDemoActivity.kt index 296844220..b427adad5 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaViewDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StreetViewPanoramaViewDemoActivity.kt @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2026 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ class StreetViewPanoramaViewDemoActivity : SamplesBaseActivity() { // StreetViewPanoramaView requires that the Bundle you pass contain _ONLY_ // StreetViewPanoramaView SDK objects or sub-Bundles. streetViewPanoramaView.onCreate(savedInstanceState?.getBundle(STREETVIEW_BUNDLE_KEY)) - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } override fun onResume() { diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StyledMapDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StyledMapDemoActivity.kt index 7df53b8fc..7c638b8e3 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StyledMapDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/StyledMapDemoActivity.kt @@ -1,148 +1,148 @@ -/* - * Copyright 2023 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.kotlindemos - -import android.content.DialogInterface -import android.os.Bundle -import android.util.Log -import android.view.Menu -import android.view.MenuItem -import android.view.View -import android.widget.Toast -import androidx.appcompat.app.AlertDialog - -import com.google.android.gms.maps.CameraUpdateFactory -import com.google.android.gms.maps.GoogleMap -import com.google.android.gms.maps.OnMapReadyCallback -import com.google.android.gms.maps.SupportMapFragment -import com.google.android.gms.maps.model.LatLng -import com.google.android.gms.maps.model.MapStyleOptions -import java.util.ArrayList - -class StyledMapDemoActivity : SamplesBaseActivity(), OnMapReadyCallback { - - private var mMap: GoogleMap? = null - private var mSelectedStyleId = com.example.common_ui.R.string.style_label_default - - companion object { - private const val TAG = "StyledMapDemoActivity" - private const val SELECTED_STYLE = "selected_style" - private val SYDNEY = LatLng(-33.8688, 151.2093) - } - - private val mStyleIds = intArrayOf( - com.example.common_ui.R.string.style_label_retro, - com.example.common_ui.R.string.style_label_night, - com.example.common_ui.R.string.style_label_grayscale, - com.example.common_ui.R.string.style_label_no_pois_no_transit, - com.example.common_ui.R.string.style_label_default - ) - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - if (savedInstanceState != null) { - mSelectedStyleId = savedInstanceState.getInt(SELECTED_STYLE) - } - setContentView(com.example.common_ui.R.layout.styled_map_demo) - - val mapFragment = - supportFragmentManager.findFragmentById(com.example.common_ui.R.id.map) as SupportMapFragment - mapFragment.getMapAsync(this) - applyInsets(findViewById(com.example.common_ui.R.id.map_container)) - } - - override fun onSaveInstanceState(outState: Bundle) { - outState.putInt(SELECTED_STYLE, mSelectedStyleId) - super.onSaveInstanceState(outState) - } - - override fun onMapReady(map: GoogleMap) { - mMap = map - mMap?.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 14f)) - setSelectedStyle() - } - - override fun onCreateOptionsMenu(menu: Menu): Boolean { - menuInflater.inflate(R.menu.styled_map, menu) - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - if (item.itemId == com.example.common_ui.R.id.menu_style_choose) { - showStylesDialog() - } - return true - } - - private fun showStylesDialog() { - val styleNames = ArrayList() - for (style in mStyleIds) { - styleNames.add(getString(style)) - } - - val builder = AlertDialog.Builder(this) - builder.setTitle(getString(com.example.common_ui.R.string.style_choose)) - builder.setItems(styleNames.toTypedArray(), - DialogInterface.OnClickListener { _, which -> - mSelectedStyleId = mStyleIds[which] - val msg = getString(com.example.common_ui.R.string.style_set_to, getString(mSelectedStyleId)) - Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show() - Log.d(TAG, msg) - setSelectedStyle() - }) - builder.show() - } - - private fun setSelectedStyle() { - val style: MapStyleOptions? - val id = mSelectedStyleId - style = when (id) { - com.example.common_ui.R.string.style_label_retro -> - MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_retro) - com.example.common_ui.R.string.style_label_night -> - MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_night) - com.example.common_ui.R.string.style_label_grayscale -> - MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_grayscale) - com.example.common_ui.R.string.style_label_no_pois_no_transit -> - MapStyleOptions( - "[" + - " {" + - " \"featureType\":\"poi.business\"," + - " \"elementType\":\"all\"," + - " \"stylers\":[" + - " {" + - " \"visibility\":\"off\"" + - " }" + - " ]" + - " }," + - " {" + - " \"featureType\":\"transit\"," + - " \"elementType\":\"all\"," + - " \"stylers\":[" + - " {" + - " \"visibility\":\"off\"" + - " }" + - " ]" + - " }" + - "]" - ) - com.example.common_ui.R.string.style_label_default -> null - else -> return - } - mMap?.setMapStyle(style) - } -} +/* + * Copyright 2026 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.kotlindemos + +import android.content.DialogInterface +import android.os.Bundle +import android.util.Log +import android.view.Menu +import android.view.MenuItem +import android.view.View +import android.widget.Toast +import androidx.appcompat.app.AlertDialog + +import com.google.android.gms.maps.CameraUpdateFactory +import com.google.android.gms.maps.GoogleMap +import com.google.android.gms.maps.OnMapReadyCallback +import com.google.android.gms.maps.SupportMapFragment +import com.google.android.gms.maps.model.LatLng +import com.google.android.gms.maps.model.MapStyleOptions +import java.util.ArrayList + +class StyledMapDemoActivity : SamplesBaseActivity(), OnMapReadyCallback { + + private var mMap: GoogleMap? = null + private var mSelectedStyleId = com.example.common_ui.R.string.style_label_default + + companion object { + private const val TAG = "StyledMapDemoActivity" + private const val SELECTED_STYLE = "selected_style" + private val SYDNEY = LatLng(-33.8688, 151.2093) + } + + private val mStyleIds = intArrayOf( + com.example.common_ui.R.string.style_label_retro, + com.example.common_ui.R.string.style_label_night, + com.example.common_ui.R.string.style_label_grayscale, + com.example.common_ui.R.string.style_label_no_pois_no_transit, + com.example.common_ui.R.string.style_label_default + ) + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + if (savedInstanceState != null) { + mSelectedStyleId = savedInstanceState.getInt(SELECTED_STYLE) + } + setContentView(com.example.common_ui.R.layout.styled_map_demo) + + val mapFragment = + supportFragmentManager.findFragmentById(com.example.common_ui.R.id.map) as SupportMapFragment + mapFragment.getMapAsync(this) + applyInsets(findViewById(com.example.common_ui.R.id.map_container)) + } + + override fun onSaveInstanceState(outState: Bundle) { + outState.putInt(SELECTED_STYLE, mSelectedStyleId) + super.onSaveInstanceState(outState) + } + + override fun onMapReady(map: GoogleMap) { + mMap = map + mMap?.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 14f)) + setSelectedStyle() + } + + override fun onCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.styled_map, menu) + return true + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + if (item.itemId == com.example.common_ui.R.id.menu_style_choose) { + showStylesDialog() + } + return true + } + + private fun showStylesDialog() { + val styleNames = ArrayList() + for (style in mStyleIds) { + styleNames.add(getString(style)) + } + + val builder = AlertDialog.Builder(this) + builder.setTitle(getString(com.example.common_ui.R.string.style_choose)) + builder.setItems(styleNames.toTypedArray(), + DialogInterface.OnClickListener { _, which -> + mSelectedStyleId = mStyleIds[which] + val msg = getString(com.example.common_ui.R.string.style_set_to, getString(mSelectedStyleId)) + Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show() + Log.d(TAG, msg) + setSelectedStyle() + }) + builder.show() + } + + private fun setSelectedStyle() { + val style: MapStyleOptions? + val id = mSelectedStyleId + style = when (id) { + com.example.common_ui.R.string.style_label_retro -> + MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_retro) + com.example.common_ui.R.string.style_label_night -> + MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_night) + com.example.common_ui.R.string.style_label_grayscale -> + MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_grayscale) + com.example.common_ui.R.string.style_label_no_pois_no_transit -> + MapStyleOptions( + "[" + + " {" + + " \"featureType\":\"poi.business\"," + + " \"elementType\":\"all\"," + + " \"stylers\":[" + + " {" + + " \"visibility\":\"off\"" + + " }" + + " ]" + + " }," + + " {" + + " \"featureType\":\"transit\"," + + " \"elementType\":\"all\"," + + " \"stylers\":[" + + " {" + + " \"visibility\":\"off\"" + + " }" + + " ]" + + " }" + + "]" + ) + com.example.common_ui.R.string.style_label_default -> null + else -> return + } + mMap?.setMapStyle(style) + } +} diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/TagsDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/TagsDemoActivity.kt index d282bc03f..88bb4c194 100644 --- a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/TagsDemoActivity.kt +++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/TagsDemoActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018 Google LLC + * Copyright 2026 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,7 +88,7 @@ class TagsDemoActivity : SamplesBaseActivity(), val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment OnMapAndViewReadyListener(mapFragment, this) - applyInsets(findViewById(R.id.map_container)) + applyInsets(findViewById(R.id.map_container)) } override fun onMapReady(googleMap: GoogleMap?) {