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
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ tasks.register<Delete>("clean") {
delete(layout.buildDirectory)
}

tasks.register<Exec>("installAndLaunch") {
description = "Installs and launches the demo app."
group = "install"
dependsOn(":demo:installDebug")
commandLine("adb", "shell", "am", "start", "-n", "com.google.maps.android.utils.demo/.MainActivity")
}

allprojects {
group = "com.google.maps.android"
// {x-release-please-start-version}
Expand Down
11 changes: 11 additions & 0 deletions demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins {
id("com.android.application")
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
id("kotlin-android")
alias(libs.plugins.compose.compiler)
}

android {
Expand Down Expand Up @@ -48,6 +49,7 @@ android {

buildFeatures {
viewBinding = true
compose = true
}

kotlin {
Expand Down Expand Up @@ -76,6 +78,15 @@ dependencies {

testImplementation(libs.junit)
testImplementation(libs.truth)

implementation(platform(libs.compose.bom))
implementation(libs.activity.compose)
implementation(libs.ui)
implementation(libs.ui.graphics)
implementation(libs.ui.tooling.preview)
implementation(libs.material3)
implementation(libs.material.icons.core)
debugImplementation(libs.ui.tooling)
// [END_EXCLUDE]
}
// [END maps_android_utils_install_snippet]
Expand Down
3 changes: 3 additions & 0 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
<activity
android:name=".ClusterAlgorithmsDemoActivity"
android:exported="true" />
<activity
android:name=".TransitLayerDemoActivity"
android:exported="true" />

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected void startDemo(boolean isRestore) {
try {
readItems();
} catch (JSONException e) {
Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.error_reading_markers), Toast.LENGTH_LONG).show();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class ClusterAlgorithmsDemoActivity : BaseDemoActivity() {
private fun setupSpinner() {
val spinner: Spinner = findViewById(R.id.algorithm_spinner)
val adapter = ArrayAdapter.createFromResource(
this, R.array.clustering_algorithms, android.R.layout.simple_spinner_item
this, R.array.clustering_algorithms, R.layout.text_view_spinner_item
)
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
adapter.setDropDownViewResource(R.layout.text_view_spinner_dropdown_item)
spinner.adapter = adapter
spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ private LatLng getMidpoint() {
public boolean onClusterClick(Cluster<Person> cluster) {
// Show a toast with some info when the cluster is clicked.
String firstName = cluster.getItems().iterator().next().name;
Toast.makeText(this, cluster.getSize() + " (including " + firstName + ")", Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.cluster_info_fmt, cluster.getSize(), firstName), Toast.LENGTH_SHORT)
.show();

// Zoom in the cluster. Need to create LatLngBounds and including all the cluster items
// inside of bounds, then animate to center of the bounds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public class CustomAdvancedMarkerClusteringDemoActivity extends BaseDemoActivity
public void onMapsSdkInitialized(@NonNull MapsInitializer.Renderer renderer) {
switch (renderer) {
case LATEST:
Log.d("MapsDemo", "The latest version of the renderer is used.");
Log.d("MapsDemo", getString(R.string.renderer_latest));
break;
case LEGACY:
Log.d("MapsDemo", "The legacy version of the renderer is used.");
Log.d("MapsDemo", getString(R.string.renderer_legacy));
break;
default:
break;
Expand Down Expand Up @@ -100,7 +100,7 @@ private PinConfig.Builder getPinConfig(Person person) {
@SuppressLint("SetTextI18n")
private View addTextAsMarker(int size) {
TextView textView = new TextView(getApplicationContext());
textView.setText("I am a cluster of size " + size);
textView.setText(getString(R.string.cluster_text_fmt, size));
textView.setBackgroundColor(Color.BLACK);
textView.setTextColor(Color.YELLOW);
return textView;
Expand Down Expand Up @@ -130,7 +130,8 @@ protected boolean shouldRenderAsCluster(@NonNull Cluster<Person> cluster) {
public boolean onClusterClick(Cluster<Person> cluster) {
// Show a toast with some info when the cluster is clicked.
String firstName = cluster.getItems().iterator().next().name;
Toast.makeText(this, cluster.getSize() + " (including " + firstName + ")", Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.cluster_info_fmt, cluster.getSize(), firstName), Toast.LENGTH_SHORT)
.show();

// Zoom in the cluster. Need to create LatLngBounds and including all the cluster items
// inside of bounds, then animate to center of the bounds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,28 @@ protected void startDemo(boolean isRestore) {
mMarkerB = getMap().addMarker(new MarkerOptions().position(new LatLng(-33.8291, 151.248)).draggable(true));
mPolyline = getMap().addPolyline(new PolylineOptions().geodesic(true));

Toast.makeText(this, "Drag the markers!", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.drag_the_markers), Toast.LENGTH_LONG).show();
showDistance();
}

@SuppressLint("SetTextI18n")
private void showDistance() {
double distance = SphericalUtil.computeDistanceBetween(mMarkerA.getPosition(), mMarkerB.getPosition());
mTextView.setText("The markers are " + formatNumber(distance) + " apart.");
mTextView.setText(getString(R.string.distance_format, formatNumber(distance)));
}

private void updatePolyline() {
mPolyline.setPoints(Arrays.asList(mMarkerA.getPosition(), mMarkerB.getPosition()));
}

private String formatNumber(double distance) {
String unit = "m";
String unit = getString(R.string.unit_m);
if (distance < 1) {
distance *= 1000;
unit = "mm";
unit = getString(R.string.unit_mm);
} else if (distance > 1000) {
distance /= 1000;
unit = "km";
unit = getString(R.string.unit_km);
}

return String.format("%4.3f%s", distance, unit);
Expand Down

This file was deleted.

Loading
Loading