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
3 changes: 2 additions & 1 deletion demo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024 Google Inc.
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -65,6 +65,7 @@ dependencies {
implementation(libs.kotlinx.coroutines.android)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.material)
implementation(libs.core.ktx)

testImplementation(libs.junit)
testImplementation(libs.truth)
Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?><!--
Copyright 2024 Google LLC
Copyright 2025 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013 Google Inc.
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@
import static com.google.maps.android.utils.demo.ApiKeyValidatorKt.hasMapsApiKey;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.NonNull;
Expand All @@ -30,6 +31,11 @@

import java.util.Objects;

import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;

public abstract class BaseDemoActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private boolean mIsRestore;
Expand All @@ -49,6 +55,30 @@ public void onCreate(Bundle savedInstanceState) {

mIsRestore = savedInstanceState != null;
setContentView(getLayoutId());
// This tells the system that the app will handle drawing behind the system bars.
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);

// This is the root view of my layout.
// Make sure to replace R.id.root_layout with the actual ID of your root view.
final View rootView = findViewById(android.R.id.content);

// Add a listener to handle window insets.
ViewCompat.setOnApplyWindowInsetsListener(rootView, (view, windowInsets) -> {
final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());

// Apply the insets as padding to the view.
// This will push the content down from behind the status bar and up from
// behind the navigation bar.
view.setPadding(
insets.left,
insets.top,
insets.right,
insets.bottom
);

// Return CONSUMED to signal that we've handled the insets.
return WindowInsetsCompat.CONSUMED;
});
setUpMap();
}

Expand All @@ -73,4 +103,4 @@ private void setUpMap() {
protected GoogleMap getMap() {
return mMap;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google Inc.
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,11 @@

import androidx.appcompat.app.AppCompatActivity;

import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private ViewGroup mListView;

Expand All @@ -34,6 +39,31 @@ protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.main);

// This tells the system that the app will handle drawing behind the system bars.
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);

// This is the root view of my layout.
// Make sure to replace R.id.root_layout with the actual ID of your root view.
final View rootView = findViewById(android.R.id.content);

// Add a listener to handle window insets.
ViewCompat.setOnApplyWindowInsetsListener(rootView, (view, windowInsets) -> {
final Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());

// Apply the insets as padding to the view.
// This will push the content down from behind the status bar and up from
// behind the navigation bar.
view.setPadding(
insets.left,
insets.top,
insets.right,
insets.bottom
);

// Return CONSUMED to signal that we've handled the insets.
return WindowInsetsCompat.CONSUMED;
});

mListView = findViewById(R.id.list);

addDemo("Advanced Markers Clustering Example", CustomAdvancedMarkerClusteringDemoActivity.class);
Expand Down
26 changes: 13 additions & 13 deletions demo/src/main/res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright 2020 Google Inc.
~
~ 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.
Copyright 2025 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.
-->

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
Expand Down
40 changes: 40 additions & 0 deletions demo/src/main/res/values-v27/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--
Copyright 2025 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.
-->

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Other theme attributes -->

<!-- Make status and navigation bars transparent -->
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>

<!--
Required for edge-to-edge display. This allows the app to draw behind
the system bars.
-->
<item name="android:windowDrawsSystemBarBackgrounds">true</item>

<!--
On API 27+, this allows the app to render in the display cutout area.
'shortEdges' is a good default.
-->
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>

</resources>
44 changes: 26 additions & 18 deletions demo/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
<!--
~ Copyright 2020 Google Inc.
~
~ 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.
Copyright 2025 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.
-->

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Other theme attributes -->

<!-- Make status and navigation bars transparent -->
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>

<!--
Required for edge-to-edge display. This allows the app to draw behind
the system bars.
-->
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class HeatmapTileProvider private constructor(builder: Builder) : TileProvider {
* @return A new HeatmapTileProvider.
*/
fun build(): HeatmapTileProvider {
check(this.weightedData?.isNotEmpty() == true) { "No input data: you must use either .data or .weightedData before building." }
require(this.weightedData?.isNotEmpty() == true) { "No input data: you must use either .data or .weightedData before building." }
return HeatmapTileProvider(this)
}
}
Expand Down Expand Up @@ -423,4 +423,4 @@ class HeatmapTileProvider private constructor(builder: Builder) : TileProvider {
return buckets.values.maxOrNull() ?: 0.0
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class HeatmapTileProviderTest {
try {
HeatmapTileProvider.Builder().build()
fail("Should have thrown IllegalStateException")
} catch (e: IllegalStateException) {
} catch (_: IllegalArgumentException) {
// success
}
}
Expand All @@ -56,7 +56,7 @@ class HeatmapTileProviderTest {
try {
HeatmapTileProvider.Builder().data(emptyList())
fail("Should have thrown IllegalArgumentException")
} catch (e: IllegalArgumentException) {
} catch (_: IllegalArgumentException) {
// success
}
}
Expand All @@ -74,13 +74,13 @@ class HeatmapTileProviderTest {
try {
HeatmapTileProvider.Builder().data(data).radius(0)
fail("Should have thrown IllegalArgumentException")
} catch (e: IllegalArgumentException) {
} catch (_: IllegalArgumentException) {
// success
}
try {
HeatmapTileProvider.Builder().data(data).radius(100)
fail("Should have thrown IllegalArgumentException")
} catch (e: IllegalArgumentException) {
} catch (_: IllegalArgumentException) {
// success
}
}
Expand All @@ -98,13 +98,13 @@ class HeatmapTileProviderTest {
try {
HeatmapTileProvider.Builder().data(data).opacity(-1.0)
fail("Should have thrown IllegalArgumentException")
} catch (e: IllegalArgumentException) {
} catch (_: IllegalArgumentException) {
// success
}
try {
HeatmapTileProvider.Builder().data(data).opacity(2.0)
fail("Should have thrown IllegalArgumentException")
} catch (e: IllegalArgumentException) {
} catch (_: IllegalArgumentException) {
// success
}
}
Expand Down