Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions map-sample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ apply plugin: 'org.jetbrains.kotlin.android'
ext {
androidxLifecycleVersion = "2.6.2"
glideVersion = "4.13.2"
navSdkVersion = "6.3.0"
navSdkVersion = "7.0.0"
}

android {
namespace 'com.example.mapdemo'
compileSdkVersion 34
compileSdk 36

buildFeatures {
buildConfig true
}

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

// And dependencies.
api "androidx.appcompat:appcompat:1.6.1"
api "androidx.appcompat:appcompat:1.7.1"
api "androidx.cardview:cardview:1.0.0"
api "androidx.constraintlayout:constraintlayout:2.1.4"
api "androidx.customview:customview:1.1.0"
Expand All @@ -110,7 +110,10 @@ dependencies {
api "com.google.android.datatransport:transport-api:3.0.0"
api "com.google.android.datatransport:transport-backend-cct:3.1.4"
api "com.google.android.datatransport:transport-runtime:3.1.4"
api "com.google.auto.value:auto-value-annotations:1.6.2"
annotationProcessor "com.google.auto.value:auto-value:1.6.2"
api 'com.google.errorprone:error_prone_annotations:2.11.0'
api 'com.google.guava:guava:31.0.1-android'
api "joda-time:joda-time:2.10.14"
api "com.google.android.material:material:1.12.0"
api 'org.jetbrains.kotlin:kotlin-reflect:2.1.10'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
import android.widget.CompoundButton;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
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.MarkerOptions;
import com.google.android.libraries.navigation.SupportNavigationFragment;
import com.google.common.collect.ImmutableList;

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

private void setupNavFragment() {
setContentView(R.layout.background_color_customization_demo_nav_flavor);
setMarginForEdgeToEdgeSupport();
SupportNavigationFragment navFragment =
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
navFragment.getMapAsync(this);
}

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

map.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
}

private void setMarginForEdgeToEdgeSupport() {
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
// V+ devices.
// No margins are set for pre-Android V devices.
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
ImmutableList.of(
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
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.MarkerOptions;
import com.google.android.libraries.navigation.SupportNavigationFragment;
import com.google.common.collect.ImmutableList;

/** This shows how to create a simple activity with a map and a marker on the map. */
public class BasicMapDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
Expand All @@ -36,11 +38,13 @@ protected void onCreate(Bundle savedInstanceState) {
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
/* defaultValue= */ false)) {
setContentView(R.layout.basic_demo_nav_flavor);
setMarginForEdgeToEdgeSupport();
SupportNavigationFragment navFragment =
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
navFragment.getMapAsync(this);
} else {
setContentView(R.layout.basic_demo_maps_flavor);
setMarginForEdgeToEdgeSupport();
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
Expand All @@ -56,4 +60,13 @@ public void onMapReady(GoogleMap map) {
map.setOnMapLoadedCallback(
() -> map.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker")));
}

private void setMarginForEdgeToEdgeSupport() {
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
// V+ devices.
// No margins are set for pre-Android V devices.
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
ImmutableList.of(
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnCameraMoveStartedListener;
Expand All @@ -31,6 +32,7 @@
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.libraries.navigation.SupportNavigationFragment;
import com.google.common.collect.ImmutableList;

/** This shows how the Developer can clamp the camera. */
public class CameraClampingDemoActivity extends AppCompatActivity
Expand Down Expand Up @@ -73,12 +75,14 @@ protected void onCreate(Bundle savedInstanceState) {
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
/* defaultValue= */ false)) {
setContentView(R.layout.camera_clamping_demo_nav_flavor);
setMarginForEdgeToEdgeSupport();
performAdditionalSetup();
SupportNavigationFragment navFragment =
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
navFragment.getMapAsync(this);
} else {
setContentView(R.layout.camera_clamping_demo_maps_flavor);
setMarginForEdgeToEdgeSupport();
performAdditionalSetup();
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
Expand Down Expand Up @@ -189,4 +193,13 @@ public void onMinMaxZoomClampReset(View view) {
map.resetMinMaxZoomPreference();
toast("Min/Max zoom preferences reset.");
}

private void setMarginForEdgeToEdgeSupport() {
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
// V+ devices.
// No margins are set for pre-Android V devices.
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
ImmutableList.of(
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.widget.SeekBar;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
Expand All @@ -38,6 +39,7 @@
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.libraries.navigation.SupportNavigationFragment;
import com.google.common.collect.ImmutableList;

/** This shows how to change the camera position for the map. */
public class CameraDemoActivity extends AppCompatActivity
Expand Down Expand Up @@ -85,12 +87,14 @@ protected void onCreate(Bundle savedInstanceState) {
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
/* defaultValue= */ false)) {
setContentView(R.layout.camera_demo_nav_flavor);
setMarginForEdgeToEdgeSupport();
performAdditionalSetup();
SupportNavigationFragment navFragment =
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
navFragment.getMapAsync(this);
} else {
setContentView(R.layout.camera_demo_maps_flavor);
setMarginForEdgeToEdgeSupport();
performAdditionalSetup();
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
Expand Down Expand Up @@ -366,4 +370,13 @@ private void addCameraTargetToPath() {
LatLng target = map.getCameraPosition().target;
currPolylineOptions.add(target);
}

private void setMarginForEdgeToEdgeSupport() {
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
// V+ devices.
// No margins are set for pre-Android V devices.
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
ImmutableList.of(
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.widget.SeekBar.OnSeekBarChangeListener;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnCircleClickListener;
Expand All @@ -46,6 +47,7 @@
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.libraries.navigation.SupportNavigationFragment;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -180,12 +182,14 @@ protected void onCreate(Bundle savedInstanceState) {
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
/* defaultValue= */ false)) {
setContentView(R.layout.circle_demo_nav_flavor);
setMarginForEdgeToEdgeSupport();
performAdditionalSetup();
SupportNavigationFragment navFragment =
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
navFragment.getMapAsync(this);
} else {
setContentView(R.layout.circle_demo_maps_flavor);
setMarginForEdgeToEdgeSupport();
performAdditionalSetup();
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
Expand Down Expand Up @@ -333,4 +337,13 @@ private static List<PatternItem> generateRandomStrokePattern() {
return null;
}
}

private void setMarginForEdgeToEdgeSupport() {
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
// V+ devices.
// No margins are set for pre-Android V devices.
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
ImmutableList.of(
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import com.example.mapdemo.EdgeToEdgeUtil.EdgeToEdgeMarginConfig;
import com.example.mapdemo.OnMapAndViewReadyListener.OnGlobalLayoutAndMapReadyListener;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.libraries.navigation.SupportNavigationFragment;
import com.google.common.collect.ImmutableList;

/**
* A demo to show the effects of rapidly changing the center of a circle by simulating the day/night
Expand Down Expand Up @@ -54,11 +56,13 @@ protected void onCreate(Bundle savedInstanceState) {
ActivityIntents.EXTRA_SHOULD_USE_NAVIGATION_FLAVOR_FOR_DEMO,
/* defaultValue= */ false)) {
setContentView(R.layout.day_night_circle_demo_nav_flavor);
setMarginForEdgeToEdgeSupport();
SupportNavigationFragment navFragment =
(SupportNavigationFragment) getSupportFragmentManager().findFragmentById(R.id.map);
new OnMapAndViewReadyListener(navFragment, this);
} else {
setContentView(R.layout.day_night_circle_demo_maps_flavor);
setMarginForEdgeToEdgeSupport();
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
Expand Down Expand Up @@ -97,4 +101,13 @@ public void run() {
};
animationRunner.run();
}

private void setMarginForEdgeToEdgeSupport() {
// Margins are only set if the edge-to-edge mode is enabled, it's enabled by default for Android
// V+ devices.
// No margins are set for pre-Android V devices.
EdgeToEdgeUtil.setMarginForEdgeToEdgeSupport(
ImmutableList.of(
EdgeToEdgeMarginConfig.builder().setView(findViewById(R.id.layout_container)).build()));
}
}
Loading