Skip to content

Commit 9af1149

Browse files
committed
Bump map-sample to NavSDK 7.0.
1 parent e0beaea commit 9af1149

File tree

114 files changed

+939
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+939
-73
lines changed

map-sample/app/build.gradle

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ apply plugin: 'org.jetbrains.kotlin.android'
2121
ext {
2222
androidxLifecycleVersion = "2.6.2"
2323
glideVersion = "4.13.2"
24-
navSdkVersion = "6.3.0"
24+
navSdkVersion = "7.0.0"
2525
}
2626

2727
android {
2828
namespace 'com.example.mapdemo'
29-
compileSdkVersion 34
29+
compileSdk 36
3030

3131
buildFeatures {
3232
buildConfig true
3333
}
3434

3535
defaultConfig {
3636
applicationId "com.example.mapdemo"
37-
// Navigation SDK supports a minimum of SDK 23.
38-
minSdkVersion 23
37+
// Navigation SDK supports a minimum of SDK 24.
38+
minSdkVersion 24
3939
// This example targets SDK 30 so that there's no need to explicitly include permissions
4040
// flows in the app.
41-
targetSdkVersion 34
41+
targetSdkVersion 36
4242
versionCode 1
4343
versionName "1.0"
4444
// Set this to the languages you actually use, otherwise you'll include resource strings
@@ -93,7 +93,7 @@ dependencies {
9393
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
9494

9595
// And dependencies.
96-
api "androidx.appcompat:appcompat:1.6.1"
96+
api "androidx.appcompat:appcompat:1.7.1"
9797
api "androidx.cardview:cardview:1.0.0"
9898
api "androidx.constraintlayout:constraintlayout:2.1.4"
9999
api "androidx.customview:customview:1.1.0"
@@ -110,7 +110,10 @@ dependencies {
110110
api "com.google.android.datatransport:transport-api:3.0.0"
111111
api "com.google.android.datatransport:transport-backend-cct:3.1.4"
112112
api "com.google.android.datatransport:transport-runtime:3.1.4"
113+
api "com.google.auto.value:auto-value-annotations:1.6.2"
114+
annotationProcessor "com.google.auto.value:auto-value:1.6.2"
113115
api 'com.google.errorprone:error_prone_annotations:2.11.0'
116+
api 'com.google.guava:guava:31.0.1-android'
114117
api "joda-time:joda-time:2.10.14"
115118
api "com.google.android.material:material:1.12.0"
116119
api 'org.jetbrains.kotlin:kotlin-reflect:2.1.10'

map-sample/app/src/main/java/com/example/mapdemo/BackgroundColorCustomizationDemoActivity.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2024 Google LLC
2+
* Copyright (C) 2012 The Android Open Source Project
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -21,15 +21,17 @@
2121
import android.widget.CompoundButton;
2222
import androidx.annotation.Nullable;
2323
import androidx.appcompat.app.AppCompatActivity;
24+
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
2425
import com.google.android.gms.maps.GoogleMap;
2526
import com.google.android.gms.maps.OnMapReadyCallback;
2627
import com.google.android.gms.maps.SupportMapFragment;
2728
import com.google.android.gms.maps.model.LatLng;
2829
import com.google.android.gms.maps.model.MarkerOptions;
2930
import com.google.android.libraries.navigation.SupportNavigationFragment;
31+
import com.google.common.collect.ImmutableList;
3032

3133
/**
32-
* This shows how to create a simple activity with a custom background color appiled to the map, and
34+
* This shows how to create a simple activity with a custom background color applied to the map, and
3335
* add a marker on the map.
3436
*/
3537
public class BackgroundColorCustomizationDemoActivity extends AppCompatActivity
@@ -50,13 +52,15 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
5052

5153
private void setupNavFragment() {
5254
setContentView(R.layout.background_color_customization_demo_nav_flavor);
55+
setMarginForEdgeToEdgeSupport();
5356
SupportNavigationFragment navFragment =
5457
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
5558
navFragment.getMapAsync(this);
5659
}
5760

5861
private void setupMapFragment() {
5962
setContentView(R.layout.background_color_customization_demo_maps_flavor);
63+
setMarginForEdgeToEdgeSupport();
6064
SupportMapFragment mapFragment =
6165
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
6266
mapFragment.getMapAsync(this);
@@ -82,4 +86,13 @@ public void onCheckedChanged(CompoundButton view, boolean isChecked) {
8286

8387
map.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
8488
}
89+
90+
private void setMarginForEdgeToEdgeSupport() {
91+
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
92+
// V+ devices.
93+
// No margins are set for pre-Android V devices.
94+
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
95+
ImmutableList.of(
96+
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
97+
}
8598
}

map-sample/app/src/main/java/com/example/mapdemo/BasicMapDemoActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
import android.os.Bundle;
2020
import androidx.appcompat.app.AppCompatActivity;
21+
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
2122
import com.google.android.gms.maps.GoogleMap;
2223
import com.google.android.gms.maps.OnMapReadyCallback;
2324
import com.google.android.gms.maps.SupportMapFragment;
2425
import com.google.android.gms.maps.model.LatLng;
2526
import com.google.android.gms.maps.model.MarkerOptions;
2627
import com.google.android.libraries.navigation.SupportNavigationFragment;
28+
import com.google.common.collect.ImmutableList;
2729

2830
/** This shows how to create a simple activity with a map and a marker on the map. */
2931
public class BasicMapDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
@@ -36,11 +38,13 @@ protected void onCreate(Bundle savedInstanceState) {
3638
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
3739
/* defaultValue= */ false)) {
3840
setContentView(R.layout.basic_demo_nav_flavor);
41+
setMarginForEdgeToEdgeSupport();
3942
SupportNavigationFragment navFragment =
4043
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
4144
navFragment.getMapAsync(this);
4245
} else {
4346
setContentView(R.layout.basic_demo_maps_flavor);
47+
setMarginForEdgeToEdgeSupport();
4448
SupportMapFragment mapFragment =
4549
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
4650
mapFragment.getMapAsync(this);
@@ -56,4 +60,13 @@ public void onMapReady(GoogleMap map) {
5660
map.setOnMapLoadedCallback(
5761
() -> map.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker")));
5862
}
63+
64+
private void setMarginForEdgeToEdgeSupport() {
65+
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
66+
// V+ devices.
67+
// No margins are set for pre-Android V devices.
68+
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
69+
ImmutableList.of(
70+
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
71+
}
5972
}

map-sample/app/src/main/java/com/example/mapdemo/CameraClampingDemoActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import android.widget.TextView;
2323
import android.widget.Toast;
2424
import androidx.appcompat.app.AppCompatActivity;
25+
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
2526
import com.google.android.gms.maps.CameraUpdateFactory;
2627
import com.google.android.gms.maps.GoogleMap;
2728
import com.google.android.gms.maps.GoogleMap.OnCameraMoveStartedListener;
@@ -31,6 +32,7 @@
3132
import com.google.android.gms.maps.model.LatLng;
3233
import com.google.android.gms.maps.model.LatLngBounds;
3334
import com.google.android.libraries.navigation.SupportNavigationFragment;
35+
import com.google.common.collect.ImmutableList;
3436

3537
/** This shows how the Developer can clamp the camera. */
3638
public class CameraClampingDemoActivity extends AppCompatActivity
@@ -73,12 +75,14 @@ protected void onCreate(Bundle savedInstanceState) {
7375
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
7476
/* defaultValue= */ false)) {
7577
setContentView(R.layout.camera_clamping_demo_nav_flavor);
78+
setMarginForEdgeToEdgeSupport();
7679
performAdditionalSetup();
7780
SupportNavigationFragment navFragment =
7881
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
7982
navFragment.getMapAsync(this);
8083
} else {
8184
setContentView(R.layout.camera_clamping_demo_maps_flavor);
85+
setMarginForEdgeToEdgeSupport();
8286
performAdditionalSetup();
8387
SupportMapFragment mapFragment =
8488
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
@@ -189,4 +193,13 @@ public void onMinMaxZoomClampReset(View view) {
189193
map.resetMinMaxZoomPreference();
190194
toast("Min/Max zoom preferences reset.");
191195
}
196+
197+
private void setMarginForEdgeToEdgeSupport() {
198+
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
199+
// V+ devices.
200+
// No margins are set for pre-Android V devices.
201+
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
202+
ImmutableList.of(
203+
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
204+
}
192205
}

map-sample/app/src/main/java/com/example/mapdemo/CameraDemoActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.widget.SeekBar;
2525
import android.widget.Toast;
2626
import androidx.appcompat.app.AppCompatActivity;
27+
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
2728
import com.google.android.gms.maps.CameraUpdate;
2829
import com.google.android.gms.maps.CameraUpdateFactory;
2930
import com.google.android.gms.maps.GoogleMap;
@@ -38,6 +39,7 @@
3839
import com.google.android.gms.maps.model.LatLng;
3940
import com.google.android.gms.maps.model.PolylineOptions;
4041
import com.google.android.libraries.navigation.SupportNavigationFragment;
42+
import com.google.common.collect.ImmutableList;
4143

4244
/** This shows how to change the camera position for the map. */
4345
public class CameraDemoActivity extends AppCompatActivity
@@ -85,12 +87,14 @@ protected void onCreate(Bundle savedInstanceState) {
8587
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
8688
/* defaultValue= */ false)) {
8789
setContentView(R.layout.camera_demo_nav_flavor);
90+
setMarginForEdgeToEdgeSupport();
8891
performAdditionalSetup();
8992
SupportNavigationFragment navFragment =
9093
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
9194
navFragment.getMapAsync(this);
9295
} else {
9396
setContentView(R.layout.camera_demo_maps_flavor);
97+
setMarginForEdgeToEdgeSupport();
9498
performAdditionalSetup();
9599
SupportMapFragment mapFragment =
96100
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
@@ -366,4 +370,13 @@ private void addCameraTargetToPath() {
366370
LatLng target = map.getCameraPosition().target;
367371
currPolylineOptions.add(target);
368372
}
373+
374+
private void setMarginForEdgeToEdgeSupport() {
375+
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
376+
// V+ devices.
377+
// No margins are set for pre-Android V devices.
378+
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
379+
ImmutableList.of(
380+
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
381+
}
369382
}

map-sample/app/src/main/java/com/example/mapdemo/CircleDemoActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.widget.SeekBar.OnSeekBarChangeListener;
2727
import androidx.appcompat.app.AppCompatActivity;
2828
import androidx.fragment.app.Fragment;
29+
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
2930
import com.google.android.gms.maps.CameraUpdateFactory;
3031
import com.google.android.gms.maps.GoogleMap;
3132
import com.google.android.gms.maps.GoogleMap.OnCircleClickListener;
@@ -46,6 +47,7 @@
4647
import com.google.android.gms.maps.model.Polyline;
4748
import com.google.android.gms.maps.model.PolylineOptions;
4849
import com.google.android.libraries.navigation.SupportNavigationFragment;
50+
import com.google.common.collect.ImmutableList;
4951
import java.util.ArrayList;
5052
import java.util.Arrays;
5153
import java.util.List;
@@ -180,12 +182,14 @@ protected void onCreate(Bundle savedInstanceState) {
180182
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
181183
/* defaultValue= */ false)) {
182184
setContentView(R.layout.circle_demo_nav_flavor);
185+
setMarginForEdgeToEdgeSupport();
183186
performAdditionalSetup();
184187
SupportNavigationFragment navFragment =
185188
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
186189
navFragment.getMapAsync(this);
187190
} else {
188191
setContentView(R.layout.circle_demo_maps_flavor);
192+
setMarginForEdgeToEdgeSupport();
189193
performAdditionalSetup();
190194
SupportMapFragment mapFragment =
191195
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
@@ -333,4 +337,13 @@ private static List<PatternItem> generateRandomStrokePattern() {
333337
return null;
334338
}
335339
}
340+
341+
private void setMarginForEdgeToEdgeSupport() {
342+
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
343+
// V+ devices.
344+
// No margins are set for pre-Android V devices.
345+
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
346+
ImmutableList.of(
347+
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
348+
}
336349
}

map-sample/app/src/main/java/com/example/mapdemo/DayNightCircleDemoActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
import android.os.Bundle;
2020
import android.os.Handler;
2121
import androidx.appcompat.app.AppCompatActivity;
22+
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
2223
import com.example.mapdemo.OnMapAndViewReadyListener.OnGlobalLayoutAndMapReadyListener;
2324
import com.google.android.gms.maps.GoogleMap;
2425
import com.google.android.gms.maps.SupportMapFragment;
2526
import com.google.android.gms.maps.model.Circle;
2627
import com.google.android.gms.maps.model.CircleOptions;
2728
import com.google.android.gms.maps.model.LatLng;
2829
import com.google.android.libraries.navigation.SupportNavigationFragment;
30+
import com.google.common.collect.ImmutableList;
2931

3032
/**
3133
* A demo to show the effects of rapidly changing the center of a circle by simulating the day/night
@@ -54,11 +56,13 @@ protected void onCreate(Bundle savedInstanceState) {
5456
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
5557
/* defaultValue= */ false)) {
5658
setContentView(R.layout.day_night_circle_demo_nav_flavor);
59+
setMarginForEdgeToEdgeSupport();
5760
SupportNavigationFragment navFragment =
5861
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
5962
new OnMapAndViewReadyListener(navFragment, this);
6063
} else {
6164
setContentView(R.layout.day_night_circle_demo_maps_flavor);
65+
setMarginForEdgeToEdgeSupport();
6266
SupportMapFragment mapFragment =
6367
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
6468
new OnMapAndViewReadyListener(mapFragment, this);
@@ -97,4 +101,13 @@ public void run() {
97101
};
98102
animationRunner.run();
99103
}
104+
105+
private void setMarginForEdgeToEdgeSupport() {
106+
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
107+
// V+ devices.
108+
// No margins are set for pre-Android V devices.
109+
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
110+
ImmutableList.of(
111+
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
112+
}
100113
}

0 commit comments

Comments
 (0)