Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion ApiDemos/java/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ dependencies {
implementation(libs.appcompat)
implementation(libs.recyclerview)
implementation(libs.volley)
implementation(platform(libs.kotlinBom))
implementation(libs.playServicesMaps)
implementation(libs.material)

// Tests
testImplementation(libs.junit)
Expand Down
1 change: 1 addition & 0 deletions ApiDemos/java/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ limitations under the License.
android:label="@string/data_driven_boundaries_label" />
<activity
android:name=".DataDrivenDatasetStylingActivity"
android:theme="@style/MaterialAppTheme"
android:exported="true"
android:label="@string/data_driven_styling_label" />
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class ApiDemoApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "onCreate called");
checkApiKey();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@
package com.example.mapdemo;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowInsets;
import android.widget.Button;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.ColorUtils;
import androidx.core.view.WindowCompat;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
Expand Down Expand Up @@ -100,6 +106,7 @@ private DataSet findDataSetByLabel(String label) {
private static FeatureLayer datasetLayer = null;
private GoogleMap map;
private String lastGlobalId = null;
private ViewGroup mapContainer;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -115,6 +122,39 @@ protected void onCreate(Bundle savedInstanceState) {
for (int buttonId : buttonIds) {
findViewById(buttonId).setOnClickListener(view -> switchDataSet(((Button) view).getText().toString()));
}

mapContainer = findViewById(R.id.map_container);

handleCutout();
}

private void handleCutout() {
Window window = getWindow(); // Assuming this method is within an Activity or Fragment

WindowCompat.setDecorFitsSystemWindows(window, false);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsets onApplyWindowInsets(@NonNull View view, @NonNull WindowInsets windowInsets) {
android.graphics.Insets insets = windowInsets.getInsets(WindowInsets.Type.systemBars());
int topInset = insets.top;
mapContainer.setPadding(0, topInset, 0, 0);
return windowInsets;
}
});
} else {
window.getDecorView().setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsets onApplyWindowInsets(@NonNull View view, @NonNull WindowInsets windowInsets) {
int topInset = windowInsets.getSystemWindowInsetTop();
mapContainer.setPadding(0, topInset, 0, 0);
return windowInsets;
}
});
}
}

/**
Expand Down Expand Up @@ -270,8 +310,8 @@ private void styleBoulderDatasetLayer() {
// Create the style factory function.
FeatureLayer.StyleFactory styleFactory = feature -> {
// Set default colors to yellow and point radius to 8.
int fillColor = Color.GREEN;
int strokeColor = Color.YELLOW;
int fillColor;
int strokeColor;
float pointRadius = 8F;
float strokeWidth = 3F;

Expand Down
59 changes: 42 additions & 17 deletions ApiDemos/java/app/src/main/res/layout/data_driven_styling_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,71 @@
limitations under the License.
-->

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Map Fragment -->

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/top_bar"
android:layout_width="0dp"
android:layout_height="?attr/actionBarSize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/data_driven_styling_label"
app:titleTextColor="?attr/colorOnPrimary"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
/>

<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_height="0dp"
map:backgroundColor="#fff0b2dd"
map:mapId="@string/map_id"
class="com.google.android.gms.maps.SupportMapFragment" />
class="com.google.android.gms.maps.SupportMapFragment"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_bar" />

<!-- Buttons to center the map -->
<LinearLayout
android:id="@+id/button_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:padding="16dp">
android:padding="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/top_bar">

<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/button_boulder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Boulder" />
android:layout_margin="4dp"
android:padding="8dp"
android:text="@string/boulder" />

<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/button_ny"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New York" />
android:layout_margin="4dp"
android:padding="8dp"
android:text="@string/new_york" />

<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/button_kyoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kyoto" />
</LinearLayout>
android:layout_margin="4dp"
android:padding="8dp"
android:text="@string/kyoto" />

</LinearLayout>

</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
5 changes: 5 additions & 0 deletions ApiDemos/java/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,9 @@
<!-- Data Driven Boundaries Demo -->
<string name="data_driven_boundaries_label">Data Driven Boundaries Demo</string>
<string name="data_driven_boundaries_description">Demonstrates how to use Data Driven styling for boundaries.</string>

<!-- Data Driven Dataset Styling -->
<string name="kyoto">Kyoto</string>
<string name="new_york">New York</string>
<string name="boulder">Boulder</string>
</resources>
5 changes: 5 additions & 0 deletions ApiDemos/java/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>


<style name="MaterialAppTheme" parent="Theme.Material3.DynamicColors.DayNight.NoActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
23 changes: 11 additions & 12 deletions ApiDemos/java/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
[versions]
androidxJunit = "1.2.1"
appcompat = "1.7.0"
espresso = "3.6.1"
junit = "4.13.2"
material = "1.12.0"
playServicesMaps = "19.0.0"
recyclerview = "1.4.0"
volley = "1.2.1"
kotlinBom = "2.0.21"
playServicesMaps = "19.0.0"
junit = "4.13.2"
androidxJunit = "1.2.1"
espresso = "3.6.1"


[libraries]
androidxJunit = { group = "androidx.test.ext", name = "junit", version.ref = "androidxJunit" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" }
volley = { group = "com.android.volley", name = "volley", version.ref = "volley" }
kotlinBom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version.ref = "kotlinBom" }
playServicesMaps = { group = "com.google.android.gms", name = "play-services-maps", version.ref = "playServicesMaps" }
espressoCore = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidxJunit = { group = "androidx.test.ext", name = "junit", version.ref = "androidxJunit" }
espressoCore = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
playServicesMaps = { group = "com.google.android.gms", name = "play-services-maps", version.ref = "playServicesMaps" }
recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" }
volley = { group = "com.android.volley", name = "volley", version.ref = "volley" }
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:title="@string/app_name"
app:title="@string/data_driven_styling_label"
app:titleTextColor="?attr/colorOnPrimary"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
/>
Expand Down
Loading