+
+
+
+
+
+
+
+
+ android:theme="@style/MaterialAppTheme">
-
+
+
+
+
+
+
+
+
+ android:name=".DataDrivenBoundariesActivity"
+ android:theme="@style/MaterialAppTheme"
+ android:exported="true"
+ android:label="@string/data_driven_boundaries_label" />
+
+
-
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/AdvancedMarkersDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/AdvancedMarkersDemoActivity.java
similarity index 91%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/AdvancedMarkersDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/AdvancedMarkersDemoActivity.java
index fdab92600..32e835072 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/AdvancedMarkersDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/AdvancedMarkersDemoActivity.java
@@ -16,9 +16,14 @@
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
+import android.view.View;
import android.widget.TextView;
+import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.graphics.Insets;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.WindowInsetsCompat;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
@@ -36,7 +41,7 @@
* possibilities.
*/
// [START maps_android_sample_marker_advanced]
-public class AdvancedMarkersDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class AdvancedMarkersDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
private static final LatLng SINGAPORE = new LatLng(1.3521, 103.8198);
private static final LatLng KUALA_LUMPUR = new LatLng(3.1390, 101.6869);
@@ -52,14 +57,17 @@ public class AdvancedMarkersDemoActivity extends AppCompatActivity implements On
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.advanced_markers_demo);
+ setContentView(com.example.common_ui.R.layout.advanced_markers_demo);
- SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
if (mapFragment != null) {
mapFragment.getMapAsync(this);
}
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
+
+
@Override
public void onMapReady(GoogleMap map) {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(SINGAPORE, ZOOM_LEVEL));
diff --git a/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/ApiDemoApplication.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/ApiDemoApplication.java
new file mode 100644
index 000000000..8410b5080
--- /dev/null
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/ApiDemoApplication.java
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+package com.example.mapdemo;
+
+import android.app.Application;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.Toast;
+
+//noinspection UnusedImport
+import com.example.common_ui.R; // <-- Keep this import
+
+import androidx.annotation.Nullable;
+
+import java.util.Objects;
+
+/**
+ * {@code ApiDemoApplication} is a custom Application class for the API demo.
+ *
+ * This class is responsible for application-wide initialization and setup,
+ * such as checking for the presence and validity of the API key during the
+ * application's startup.
+ *
+ * It extends the {@link Application} class and overrides the {@link #onCreate()}
+ * method to perform these initialization tasks.
+ */
+public class ApiDemoApplication extends Application {
+ private static final String TAG = "ApiDemoApplication";
+ private boolean mapIdSet = false;
+ private String mapId = null;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ checkApiKey();
+ }
+
+ /**
+ * Checks if the API key for Google Maps is properly configured in the application's metadata.
+ *
+ * This method retrieves the API key from the application's metadata, specifically looking for
+ * a string value associated with the key "com.google.android.geo.API_KEY".
+ * The key must be present, not blank, and not set to the placeholder value "DEFAULT_API_KEY".
+ *
+ * If any of these checks fail, a Toast message is displayed indicating that the API key is missing or
+ * incorrectly configured, and a RuntimeException is thrown.
+ *
+ */
+ private void checkApiKey() {
+ try {
+ ApplicationInfo appInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
+ Bundle bundle = Objects.requireNonNull(appInfo.metaData);
+
+ String apiKey = bundle.getString("com.google.android.geo.API_KEY"); // Key name is important!
+
+ if (apiKey == null || apiKey.isBlank() || apiKey.equals("DEFAULT_API_KEY")) {
+ Toast.makeText(this, "API Key was not set in secrets.properties", Toast.LENGTH_LONG).show();
+ throw new RuntimeException("API Key was not set in secrets.properties");
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Package name not found.", e);
+ throw new RuntimeException("Error getting package info.", e);
+ } catch (NullPointerException e) {
+ Log.e(TAG, "Error accessing meta-data.", e); // Handle the case where meta-data is completely missing.
+ throw new RuntimeException("Error accessing meta-data in manifest", e);
+ }
+ }
+
+ /**
+ * Retrieves the map ID from the BuildConfig or string resource.
+ *
+ * @return The valid map ID or null if no valid map ID is found.
+ */
+ @Nullable
+ public String getMapId() {
+ if (!mapIdSet) {
+ if (!BuildConfig.MAP_ID.equals("MAP_ID")) {
+ mapId = BuildConfig.MAP_ID;
+ } else if (!getString(R.string.map_id).equals("DEMO_MAP_ID")) {
+ mapId = getString(R.string.map_id);
+ } else {
+ Log.w(TAG, "Map ID is not set. See README for instructions.");
+ Toast.makeText(this, "Map ID is not set. Some features may not work. See README for instructions.", Toast.LENGTH_LONG).show();
+ }
+ mapIdSet = true;
+ }
+ return mapId;
+ }
+}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/BackgroundColorCustomizationDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/BackgroundColorCustomizationDemoActivity.java
similarity index 80%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/BackgroundColorCustomizationDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/BackgroundColorCustomizationDemoActivity.java
index f8d0707d8..89afbc469 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/BackgroundColorCustomizationDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/BackgroundColorCustomizationDemoActivity.java
@@ -16,6 +16,8 @@
import android.os.Bundle;
import android.widget.CheckBox;
+
+import androidx.activity.EdgeToEdge;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.gms.common.internal.Preconditions;
@@ -24,24 +26,27 @@
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.material.switchmaterial.SwitchMaterial;
/**
* This shows how to create a simple activity with a custom background color appiled to the map, and
* add a marker on the map.
+ *
*/
-public class BackgroundColorCustomizationDemoActivity extends AppCompatActivity
+public class BackgroundColorCustomizationDemoActivity extends SamplesBaseActivity
implements OnMapReadyCallback {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.background_color_customization_demo);
+ setContentView(com.example.common_ui.R.layout.background_color_customization_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
Preconditions.checkNotNull(mapFragment)
.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
/**
@@ -52,7 +57,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
public void onMapReady(GoogleMap map) {
map.setMapType(GoogleMap.MAP_TYPE_NONE);
- CheckBox mapTypeToggleCheckbox = (CheckBox) findViewById(R.id.map_type_toggle);
+ SwitchMaterial mapTypeToggleCheckbox = findViewById(com.example.common_ui.R.id.map_type_toggle);
mapTypeToggleCheckbox.setOnCheckedChangeListener(
(view, isChecked) -> map.setMapType(isChecked ? GoogleMap.MAP_TYPE_NORMAL : GoogleMap.MAP_TYPE_NONE));
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/BackgroundColorCustomizationProgrammaticDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/BackgroundColorCustomizationProgrammaticDemoActivity.java
similarity index 87%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/BackgroundColorCustomizationProgrammaticDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/BackgroundColorCustomizationProgrammaticDemoActivity.java
index 2aeb8b8c1..6515b07f3 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/BackgroundColorCustomizationProgrammaticDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/BackgroundColorCustomizationProgrammaticDemoActivity.java
@@ -17,6 +17,8 @@
import android.graphics.Color;
import android.os.Bundle;
import android.widget.CheckBox;
+
+import androidx.activity.EdgeToEdge;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;
@@ -31,7 +33,7 @@
* This shows how to to instantiate a SupportMapFragment programmatically with a custom background
* color applied to the map, and add a marker on the map.
*/
-public class BackgroundColorCustomizationProgrammaticDemoActivity extends AppCompatActivity
+public class BackgroundColorCustomizationProgrammaticDemoActivity extends SamplesBaseActivity
implements OnMapReadyCallback {
private static final String MAP_FRAGMENT_TAG = "map";
@@ -41,7 +43,7 @@ public class BackgroundColorCustomizationProgrammaticDemoActivity extends AppCom
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.background_color_customization_programmatic_demo);
+ setContentView(com.example.common_ui.R.layout.background_color_customization_programmatic_demo);
// It isn't possible to set a fragment's id programmatically so we set a tag instead and
// search for it using that.
@@ -57,17 +59,18 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
// Then we add the fragment using a FragmentTransaction.
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
- fragmentTransaction.replace(R.id.map, mapFragment, MAP_FRAGMENT_TAG);
+ fragmentTransaction.replace(com.example.common_ui.R.id.map, mapFragment, MAP_FRAGMENT_TAG);
fragmentTransaction.commit();
}
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
public void onMapReady(GoogleMap map) {
map.setMapType(GoogleMap.MAP_TYPE_NONE);
- CheckBox mapTypeToggleCheckbox = (CheckBox) findViewById(R.id.map_type_toggle);
+ CheckBox mapTypeToggleCheckbox = findViewById(com.example.common_ui.R.id.map_type_toggle);
mapTypeToggleCheckbox.setOnCheckedChangeListener(
(view, isChecked) -> map.setMapType(isChecked ? GoogleMap.MAP_TYPE_NORMAL : GoogleMap.MAP_TYPE_NONE));
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/BasicMapDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/BasicMapDemoActivity.java
similarity index 85%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/BasicMapDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/BasicMapDemoActivity.java
index 807d3b9f3..fec64ca23 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/BasicMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/BasicMapDemoActivity.java
@@ -28,16 +28,17 @@
* This shows how to create a simple activity with a map and a marker on the map.
*/
// [START maps_android_sample_basic_map]
-public class BasicMapDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class BasicMapDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.basic_demo);
+ setContentView(com.example.common_ui.R.layout.basic_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
/**
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/CameraClampingDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CameraClampingDemoActivity.java
similarity index 92%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/CameraClampingDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CameraClampingDemoActivity.java
index f04f81913..a9adb65ea 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/CameraClampingDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CameraClampingDemoActivity.java
@@ -34,7 +34,7 @@
/**
* This shows how to constrain the camera to specific boundaries and zoom levels.
*/
-public class CameraClampingDemoActivity extends AppCompatActivity
+public class CameraClampingDemoActivity extends SamplesBaseActivity
implements OnMapReadyCallback, OnCameraIdleListener {
private static final String TAG = CameraClampingDemoActivity.class.getSimpleName();
@@ -71,16 +71,17 @@ public class CameraClampingDemoActivity extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.camera_clamping_demo);
+ setContentView(com.example.common_ui.R.layout.camera_clamping_demo);
mMap = null;
resetMinMaxZoom();
- mCameraTextView = (TextView) findViewById(R.id.camera_text);
+ mCameraTextView = findViewById(com.example.common_ui.R.id.camera_text);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -105,7 +106,7 @@ public void onCameraIdle() {
*/
private boolean checkReady() {
if (mMap == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/CameraDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CameraDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/CameraDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CameraDemoActivity.java
index 4442b06b2..62b66668e 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/CameraDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CameraDemoActivity.java
@@ -43,7 +43,7 @@
* This shows how to change the camera position for the map.
*/
// [START maps_camera_events]
-public class CameraDemoActivity extends AppCompatActivity implements
+public class CameraDemoActivity extends SamplesBaseActivity implements
OnCameraMoveStartedListener,
OnCameraMoveListener,
OnCameraMoveCanceledListener,
@@ -85,18 +85,19 @@ public class CameraDemoActivity extends AppCompatActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.camera_demo);
+ setContentView(com.example.common_ui.R.layout.camera_demo);
// [START_EXCLUDE silent]
- animateToggle = findViewById(R.id.animate);
- customDurationToggle = findViewById(R.id.duration_toggle);
- customDurationBar = findViewById(R.id.duration_bar);
+ animateToggle = findViewById(com.example.common_ui.R.id.animate);
+ customDurationToggle = findViewById(com.example.common_ui.R.id.duration_toggle);
+ customDurationBar = findViewById(com.example.common_ui.R.id.duration_bar);
updateEnabledState();
// [END_EXCLUDE]
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
// [START_EXCLUDE silent]
@@ -126,13 +127,14 @@ public void onMapReady(GoogleMap googleMap) {
}
// [START_EXCLUDE silent]
+
/**
* When the map is not ready the CameraUpdateFactory cannot be used. This should be called on
* all entry points that call methods on the Google Maps API.
*/
private boolean checkReady() {
if (map == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/CircleDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CircleDemoActivity.java
similarity index 88%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/CircleDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CircleDemoActivity.java
index 5b08db466..6767c6143 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/CircleDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CircleDemoActivity.java
@@ -55,7 +55,7 @@
/**
* This shows how to draw circles on a map.
*/
-public class CircleDemoActivity extends AppCompatActivity
+public class CircleDemoActivity extends SamplesBaseActivity
implements OnSeekBarChangeListener, OnMarkerDragListener, OnMapLongClickListener,
OnItemSelectedListener, OnMapReadyCallback {
@@ -78,7 +78,7 @@ public class CircleDemoActivity extends AppCompatActivity
private GoogleMap map;
- private List circles = new ArrayList<>(1);
+ private final List circles = new ArrayList<>(1);
private int fillColorArgb;
private int strokeColorArgb;
@@ -95,10 +95,10 @@ public class CircleDemoActivity extends AppCompatActivity
// string resource IDs as identifiers.
private static final int[] PATTERN_TYPE_NAME_RESOURCE_IDS = {
- R.string.pattern_solid, // Default
- R.string.pattern_dashed,
- R.string.pattern_dotted,
- R.string.pattern_mixed,
+ com.example.common_ui.R.string.pattern_solid, // Default
+ com.example.common_ui.R.string.pattern_dashed,
+ com.example.common_ui.R.string.pattern_dotted,
+ com.example.common_ui.R.string.pattern_mixed,
};
private class DraggableCircle {
@@ -173,38 +173,39 @@ private static double toRadiusMeters(LatLng center, LatLng radius) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.circle_demo);
+ setContentView(com.example.common_ui.R.layout.circle_demo);
- fillHueBar = findViewById(R.id.fillHueSeekBar);
+ fillHueBar = findViewById(com.example.common_ui.R.id.fillHueSeekBar);
fillHueBar.setMax(MAX_HUE_DEGREES);
fillHueBar.setProgress(MAX_HUE_DEGREES / 2);
- fillAlphaBar = findViewById(R.id.fillAlphaSeekBar);
+ fillAlphaBar = findViewById(com.example.common_ui.R.id.fillAlphaSeekBar);
fillAlphaBar.setMax(MAX_ALPHA);
fillAlphaBar.setProgress(MAX_ALPHA / 2);
- strokeWidthBar = findViewById(R.id.strokeWidthSeekBar);
+ strokeWidthBar = findViewById(com.example.common_ui.R.id.strokeWidthSeekBar);
strokeWidthBar.setMax(MAX_WIDTH_PX);
strokeWidthBar.setProgress(MAX_WIDTH_PX / 3);
- strokeHueBar = findViewById(R.id.strokeHueSeekBar);
+ strokeHueBar = findViewById(com.example.common_ui.R.id.strokeHueSeekBar);
strokeHueBar.setMax(MAX_HUE_DEGREES);
strokeHueBar.setProgress(0);
- strokeAlphaBar = findViewById(R.id.strokeAlphaSeekBar);
+ strokeAlphaBar = findViewById(com.example.common_ui.R.id.strokeAlphaSeekBar);
strokeAlphaBar.setMax(MAX_ALPHA);
strokeAlphaBar.setProgress(MAX_ALPHA);
- strokePatternSpinner = findViewById(R.id.strokePatternSpinner);
+ strokePatternSpinner = findViewById(com.example.common_ui.R.id.strokePatternSpinner);
strokePatternSpinner.setAdapter(new ArrayAdapter<>(
this, android.R.layout.simple_spinner_item,
getResourceStrings(PATTERN_TYPE_NAME_RESOURCE_IDS)));
- clickabilityCheckbox = findViewById(R.id.toggleClickability);
+ clickabilityCheckbox = findViewById(com.example.common_ui.R.id.toggleClickability);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
private String[] getResourceStrings(int[] resourceIds) {
@@ -218,7 +219,7 @@ private String[] getResourceStrings(int[] resourceIds) {
@Override
public void onMapReady(GoogleMap googleMap) {
// Override the default content description on the view, for accessibility mode.
- googleMap.setContentDescription(getString(R.string.map_circle_description));
+ googleMap.setContentDescription(getString(com.example.common_ui.R.string.map_circle_description));
map = googleMap;
map.setOnMarkerDragListener(this);
@@ -261,13 +262,13 @@ public void onCircleClick(Circle circle) {
private List getSelectedPattern(int pos) {
int id = PATTERN_TYPE_NAME_RESOURCE_IDS[pos];
- if (id == R.string.pattern_solid) {
+ if (id == com.example.common_ui.R.string.pattern_solid) {
return null;
- } else if (id == R.string.pattern_dotted) {
+ } else if (id == com.example.common_ui.R.string.pattern_dotted) {
return PATTERN_DOTTED;
- } else if (id == R.string.pattern_dashed) {
+ } else if (id == com.example.common_ui.R.string.pattern_dashed) {
return PATTERN_DASHED;
- } else if (id == R.string.pattern_mixed) {
+ } else if (id == com.example.common_ui.R.string.pattern_mixed) {
return PATTERN_MIXED;
} else {
return null;
@@ -276,7 +277,7 @@ private List getSelectedPattern(int pos) {
@Override
public void onItemSelected(AdapterView> parent, View view, int pos, long id) {
- if (parent.getId() == R.id.strokePatternSpinner) {
+ if (parent.getId() == com.example.common_ui.R.id.strokePatternSpinner) {
for (DraggableCircle draggableCircle : circles) {
draggableCircle.setStrokePattern(getSelectedPattern(pos));
}
@@ -345,7 +346,7 @@ private void onMarkerMoved(Marker marker) {
@Override
public void onMapLongClick(LatLng point) {
// We know the center, let's place the outline at a point 3/4 along the view.
- View view = getSupportFragmentManager().findFragmentById(R.id.map).getView();
+ View view = getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map).getView();
LatLng radiusLatLng = map.getProjection().fromScreenLocation(new Point(
view.getHeight() * 3 / 4, view.getWidth() * 3 / 4));
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
similarity index 77%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
index f4b0510b5..93f21802f 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
@@ -25,7 +25,7 @@
* to style a map using this method, see:
* https://developers.google.com/maps/documentation/android-sdk/cloud-based-map-styling
**/
-public class CloudBasedMapStylingDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class CloudBasedMapStylingDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
private static final String MAP_TYPE_KEY = "map_type";
private GoogleMap map;
@@ -40,12 +40,13 @@ protected void onCreate(Bundle savedInstanceState) {
// The underlying style the map will use has been set in the layout
// `cloud_styling_basic_demo` under the SupportMapFragment's `map:mapId` attribute.
- setContentView(R.layout.cloud_styling_basic_demo);
+ setContentView(com.example.common_ui.R.layout.cloud_styling_basic_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
setUpButtonListeners();
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -55,13 +56,13 @@ public void onMapReady(GoogleMap map) {
}
private void setUpButtonListeners() {
- findViewById(R.id.styling_normal_mode).setOnClickListener(
+ findViewById(com.example.common_ui.R.id.styling_normal_mode).setOnClickListener(
v -> setMapType(GoogleMap.MAP_TYPE_NORMAL));
- findViewById(R.id.styling_satellite_mode).setOnClickListener(
+ findViewById(com.example.common_ui.R.id.styling_satellite_mode).setOnClickListener(
v -> setMapType(GoogleMap.MAP_TYPE_SATELLITE));
- findViewById(R.id.styling_hybrid_mode).setOnClickListener(
+ findViewById(com.example.common_ui.R.id.styling_hybrid_mode).setOnClickListener(
v -> setMapType(GoogleMap.MAP_TYPE_HYBRID));
- findViewById(R.id.styling_terrain_mode).setOnClickListener(
+ findViewById(com.example.common_ui.R.id.styling_terrain_mode).setOnClickListener(
v -> setMapType(GoogleMap.MAP_TYPE_TERRAIN));
}
diff --git a/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DataDrivenBoundariesActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DataDrivenBoundariesActivity.java
new file mode 100644
index 000000000..84cad55ff
--- /dev/null
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DataDrivenBoundariesActivity.java
@@ -0,0 +1,377 @@
+// 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.
+package com.example.mapdemo;
+
+import static java.lang.Math.round;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.Toast;
+
+import androidx.activity.EdgeToEdge;
+import androidx.annotation.NonNull;
+import androidx.appcompat.widget.PopupMenu;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+
+//noinspection UnusedImport
+import com.example.common_ui.R; // <-- Keep this import
+
+import com.google.android.gms.maps.CameraUpdateFactory;
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.GoogleMapOptions;
+import com.google.android.gms.maps.OnMapReadyCallback;
+import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.Feature;
+import com.google.android.gms.maps.model.FeatureClickEvent;
+import com.google.android.gms.maps.model.FeatureLayer;
+import com.google.android.gms.maps.model.FeatureLayerOptions;
+import com.google.android.gms.maps.model.FeatureStyle;
+import com.google.android.gms.maps.model.FeatureType;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.MapCapabilities;
+import com.google.android.gms.maps.model.PlaceFeature;
+import com.google.android.material.button.MaterialButton;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * This sample showcases how to use the Data-driven styling for boundaries. For more information
+ * on how the Data-driven styling for boundaries work, check out the following link:
+ * https://developers.google.com/maps/documentation/android-sdk/dds-boundaries/overview
+ */
+// [START maps_android_data_driven_styling_boundaries]
+public class DataDrivenBoundariesActivity extends SamplesBaseActivity implements OnMapReadyCallback,
+ FeatureLayer.OnFeatureClickListener, PopupMenu.OnMenuItemClickListener {
+ private static final String TAG = DataDrivenBoundariesActivity.class.getName();
+
+ private static final LatLng HANA_HAWAII = new LatLng(20.7522, -155.9877); // Hana, Hawaii
+ private static final LatLng CENTER_US = new LatLng(39.8283, -98.5795); // Approximate geographical center of the contiguous US
+
+ private GoogleMap map;
+
+ private FeatureLayer localityLayer = null;
+ private FeatureLayer areaLevel1Layer = null;
+ private FeatureLayer countryLayer = null;
+
+ private final FeatureLayer.StyleFactory localityStyleFactory = getLocalityStyleFactory();
+ private final FeatureLayer.StyleFactory countryStyleFactory = getCountryStyleFactory();
+ private final FeatureLayer.StyleFactory areaLevel1StyleFactory = getAreaLevel1StyleFactory();
+
+ // Which layers are currently enabled
+ private boolean localityEnabled = true;
+ private boolean adminAreaEnabled = false;
+ private boolean countryEnabled = false;
+
+ private final Set selectedPlaceIds = new HashSet<>();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ EdgeToEdge.enable(this);
+ setContentView(R.layout.data_driven_boundaries_demo);
+
+ // [START_EXCLUDE silent]
+ // 1. Get the Application instance and cast it
+ ApiDemoApplication app = (ApiDemoApplication) getApplication();
+
+ // 2. Call the getMapId() method
+ String mapId = app.getMapId();
+
+ if (mapId == null) {
+ finish();
+ return;
+ }
+ // [END_EXCLUDE]
+
+ // --- Programmatically Create and Add Map Fragment ---
+ // 1. Create GoogleMapOptions
+ GoogleMapOptions mapOptions = new GoogleMapOptions();
+
+ // 2. Set the mapId from the secrets.properties file
+ mapOptions.mapId(mapId);
+ // 3. Create SupportMapFragment instance with options
+ SupportMapFragment mapFragment = SupportMapFragment.newInstance(mapOptions);
+
+ // 4. Add the fragment to your FrameLayout container using FragmentManager
+ FragmentManager fragmentManager = getSupportFragmentManager();
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+ fragmentTransaction.replace(R.id.map_fragment_container, mapFragment); // Use the container ID from XML
+ fragmentTransaction.commit();
+ // --- End Programmatic Creation ---
+
+ mapFragment.getMapAsync(this);
+
+ findViewById(R.id.button_hawaii).setOnClickListener(view -> centerMapOnLocation(HANA_HAWAII, 11f));
+ findViewById(R.id.button_us).setOnClickListener(view -> centerMapOnLocation(CENTER_US, 1f));
+
+ applyInsets(findViewById(R.id.map_container));
+
+ setupBoundarySelectorButton();
+
+ // [START_EXCLUDE silent]
+ applyInsets(findViewById(R.id.map_container));
+ // [END_EXCLUDE]
+ }
+
+ private void setupBoundarySelectorButton() {
+ MaterialButton stylingTypeButton = findViewById(R.id.button_feature_type);
+ stylingTypeButton.setOnClickListener(v -> {
+ PopupMenu popupMenu = new PopupMenu(this, v);
+ MenuInflater inflater = popupMenu.getMenuInflater();
+ inflater.inflate(R.menu.boundary_types_menu, popupMenu.getMenu());
+
+ popupMenu.setOnMenuItemClickListener(this);
+
+ popupMenu.getMenu().findItem(R.id.boundary_type_locality).setChecked(localityEnabled);
+ popupMenu.getMenu().findItem(R.id.boundary_type_administrative_area_level_1).setChecked(adminAreaEnabled);
+ popupMenu.getMenu().findItem(R.id.boundary_type_country).setChecked(countryEnabled);
+ popupMenu.show();
+ });
+ }
+ // [END_EXCLUDE]
+
+ private void centerMapOnLocation(LatLng location, float zoomLevel) {
+ map.moveCamera(CameraUpdateFactory.newLatLngZoom(location, zoomLevel));
+ }
+
+ @Override
+ public void onMapReady(@NonNull GoogleMap googleMap) {
+ this.map = googleMap;
+ MapCapabilities capabilities = map.getMapCapabilities();
+ Log.d(TAG, "Data-driven Styling is available: " + capabilities.isDataDrivenStylingAvailable());
+
+ if (!capabilities.isDataDrivenStylingAvailable()) {
+ Toast.makeText(
+ this,
+ "Data-driven Styling is not available. See README.md for instructions.",
+ Toast.LENGTH_LONG
+ ).show();
+ }
+
+ // Gets the LOCALITY feature layer.
+ localityLayer = googleMap.getFeatureLayer(
+ new FeatureLayerOptions.Builder()
+ .featureType(FeatureType.LOCALITY)
+ .build()
+ );
+
+ // Gets the ADMINISTRATIVE_AREA_LEVEL_1 feature layer.
+ areaLevel1Layer = googleMap.getFeatureLayer(
+ new FeatureLayerOptions.Builder()
+ .featureType(FeatureType.ADMINISTRATIVE_AREA_LEVEL_1)
+ .build()
+ );
+
+ // Gets the COUNTRY feature layer.
+ countryLayer = googleMap.getFeatureLayer(
+ new FeatureLayerOptions.Builder()
+ .featureType(FeatureType.COUNTRY)
+ .build()
+ );
+ countryLayer.addOnFeatureClickListener(this);
+
+ centerMapOnLocation(HANA_HAWAII, 11f);
+
+ // Apply the current set of styles.
+ updateStyles();
+ }
+
+ /**
+ * Updates the styles of the locality, area level 1, and country layers based on the current
+ * state of the `localityEnabled`, `adminAreaEnabled`, and `countryEnabled` flags.
+ *
+ * For each layer, if the corresponding flag is true, the layer's features will be styled using
+ * the layer specific style factory function.
+ */
+ private void updateStyles() {
+ if (localityLayer != null && areaLevel1Layer != null && countryLayer != null) {
+ localityLayer.setFeatureStyle(localityEnabled ? localityStyleFactory : null);
+ areaLevel1Layer.setFeatureStyle(adminAreaEnabled ? areaLevel1StyleFactory : null);
+ if (countryEnabled) {
+ countryLayer.setFeatureStyle(countryStyleFactory);
+ } else {
+ countryLayer.setFeatureStyle(null);
+ }
+ }
+ }
+
+ /**
+ * Creates a StyleFactory for a FeatureLayer that styles Hana, HI on its Place ID.
+ *
+ * This method defines a style factory that checks if a given feature is a {@link PlaceFeature}.
+ * and if that feature matches "ChIJ0zQtYiWsVHkRk8lRoB1RNPo" (Hana, HI) applies a specific style.
+ * Otherwise, it returns null, indicating no specific styling is applied.
+ *
+ * @return A {@link FeatureLayer.StyleFactory} instance that can be used to style features in a FeatureLayer.
+ * The factory returns a {@link FeatureStyle} for Hana, HI, and null for other features.
+ */
+ private static FeatureLayer.StyleFactory getLocalityStyleFactory() {
+ int purple = 0x810FCB;
+ // Define a style with purple fill at 50% opacity and
+ // solid purple border.
+ int fillColor = setAlphaValueOnColor(purple, 0.5f);
+ int strokeColor = setAlphaValueOnColor(purple, 1f);
+
+ return feature -> {
+ // Check if the feature is an instance of PlaceFeature,
+ // which contains a place ID.
+ if (feature instanceof PlaceFeature placeFeature) {
+
+ // Determine if the place ID is for Hana, HI.
+ if ("ChIJ0zQtYiWsVHkRk8lRoB1RNPo".equals(placeFeature.getPlaceId())) {
+ // Use FeatureStyle.Builder to configure the FeatureStyle object
+ // returned by the style factory function.
+ return new FeatureStyle.Builder()
+ .fillColor(fillColor)
+ .strokeColor(strokeColor)
+ .build();
+ }
+ }
+ return null;
+ };
+ }
+
+ /**
+ * Creates a StyleFactory for area level 1 features (e.g., states, provinces).
+ *
+ * This factory provides a semi-transparent fill color for each area level 1 feature.
+ *
+ * @return A StyleFactory that can be used to style area level 1 features on a map.
+ */
+ private static FeatureLayer.StyleFactory getAreaLevel1StyleFactory() {
+ int alpha = (int) (255 * 0.25);
+
+ return feature -> {
+ if (feature instanceof PlaceFeature placeFeature) {
+
+ // Return a hueColor in the range [-299,299]. If the value is
+ // negative, add 300 to make the value positive.
+ int hueColor = placeFeature.getPlaceId().hashCode() % 300;
+ if (hueColor < 0) {
+ hueColor += 300;
+ }
+ return new FeatureStyle.Builder()
+ // Set the fill color for the state based on the hashed hue color.
+ .fillColor(Color.HSVToColor(alpha, new float[]{hueColor, 1f, 1f}))
+ .build();
+ }
+ return null;
+ };
+ }
+
+ /**
+ * Creates a StyleFactory for styling country features on a FeatureLayer highlighting selected
+ * countries. Selection is determined via the selectedPlaceIds set.
+ *
+ * *Note:* If the set of selected countries changes, this function must be called to update the
+ * styling.
+ *
+ * @return A FeatureLayer.StyleFactory that can be used to style country features.
+ */
+ private FeatureLayer.StyleFactory getCountryStyleFactory() {
+ int defaultFillColor = setAlphaValueOnColor(Color.BLACK, 0.1f);
+ int selectedFillColor = setAlphaValueOnColor(Color.RED, 0.33f);
+ return feature -> {
+ if (feature instanceof PlaceFeature) {
+ int fillColor = selectedPlaceIds.contains(((PlaceFeature) feature).getPlaceId()) ? selectedFillColor : defaultFillColor;
+ FeatureStyle.Builder build = new FeatureStyle.Builder();
+ return build.fillColor(fillColor).strokeColor(Color.BLACK).build();
+ }
+ return null;
+ };
+ }
+
+ /**
+ * Called when a feature is clicked on the map. It is only applied to the country layer.
+ *
+ * Each time a country is clicked, its place ID is added to the selectedPlaceIds set or removed
+ * if it was already present. Each time the set is
+ *
+ */
+ @Override
+ public void onFeatureClick(@NonNull FeatureClickEvent event) {
+ // Get the list of features affected by the click using
+ // getPlaceIds() defined below.
+ List newSelectedPlaceIds = getPlaceIds(event.getFeatures());
+
+ for (String placeId : newSelectedPlaceIds) {
+ if (selectedPlaceIds.contains(placeId)) {
+ selectedPlaceIds.remove(placeId);
+ } else {
+ selectedPlaceIds.add(placeId);
+ }
+ }
+
+ // Reset the feature styling
+ countryLayer.setFeatureStyle(countryStyleFactory);
+ }
+
+ // Gets a List of place IDs from the FeatureClickEvent object.
+ private List getPlaceIds(List features) {
+ List placeIds = new ArrayList<>();
+ for (Feature feature : features) {
+ if (feature instanceof PlaceFeature) {
+ placeIds.add(((PlaceFeature) feature).getPlaceId());
+ }
+ }
+ return placeIds;
+ }
+
+ private static int setAlphaValueOnColor(int color, float alpha) {
+ return (color & 0x00ffffff) | (round(alpha * 255) << 24);
+ }
+
+ /**
+ * Handles the click events for menu items in the boundary type selection menu.
+ * This method is called when a user selects a boundary type (locality, administrative area, or country) from the menu.
+ * It toggles the checked state of the selected menu item and updates the corresponding boolean flags (localityEnabled, adminAreaEnabled, countryEnabled).
+ * Finally, it calls the {@link #updateStyles()} method to reflect the changes in the map's display.
+ *
+ * @param item The MenuItem that was clicked.
+ * @return True if the event was handled, false otherwise. In this case it always return true if one of the correct items was selected.
+ */ // [START_EXCLUDE silent]
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ Log.d(TAG, "onMenuItemClick: " + item.getItemId());
+ int id = item.getItemId();
+ boolean result = false;
+
+ if (id == R.id.boundary_type_locality) {
+ item.setChecked(!item.isChecked());
+ localityEnabled = item.isChecked();
+ result = true;
+ } else if (id == R.id.boundary_type_administrative_area_level_1) {
+ item.setChecked(!item.isChecked());
+ adminAreaEnabled = item.isChecked();
+ result = true;
+ } else if (id == R.id.boundary_type_country) {
+ item.setChecked(!item.isChecked());
+ countryEnabled = item.isChecked();
+ result = true;
+ }
+
+ updateStyles();
+
+ return result;
+ }
+ // [END_EXCLUDE]
+}
+// [END maps_android_data_driven_styling_boundaries]
\ No newline at end of file
diff --git a/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DataDrivenDatasetStylingActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DataDrivenDatasetStylingActivity.java
new file mode 100644
index 000000000..9173181a4
--- /dev/null
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DataDrivenDatasetStylingActivity.java
@@ -0,0 +1,408 @@
+// 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.
+package com.example.mapdemo;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.Button;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.core.graphics.ColorUtils;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
+
+//noinspection UnusedImport
+import com.example.common_ui.R; // <-- Keep this import
+
+import com.google.android.gms.maps.CameraUpdateFactory;
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.GoogleMapOptions;
+import com.google.android.gms.maps.OnMapReadyCallback;
+import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.DatasetFeature;
+import com.google.android.gms.maps.model.Feature;
+import com.google.android.gms.maps.model.FeatureClickEvent;
+import com.google.android.gms.maps.model.FeatureLayer;
+import com.google.android.gms.maps.model.FeatureLayerOptions;
+import com.google.android.gms.maps.model.FeatureStyle;
+import com.google.android.gms.maps.model.FeatureType;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.MapCapabilities;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * This sample showcases how to use the Data-driven styling for datasets. For more information
+ * on how the Data-driven styling for boundaries work, check out the following link:
+ * https://developers.google.com/maps/documentation/android-sdk/dds-datasets/overview
+ *
+ * This is meant to work with the datasets in the res/raw directory.
+ */
+// [START maps_android_data_driven_styling_datasets]
+public class DataDrivenDatasetStylingActivity extends SamplesBaseActivity implements OnMapReadyCallback, FeatureLayer.OnFeatureClickListener {
+ private record DataSet(
+ String label,
+ String datasetId,
+ LatLng location,
+ float zoomLevel,
+ DataDrivenDatasetStylingActivity.DataSet.StylingCallback callback) {
+ public interface StylingCallback {
+ void styleDatasetLayer();
+ }
+ }
+
+ /**
+ * An array of DataSet objects representing different geographic locations and their associated data.
+ * Each DataSet contains:
+ * - A human-readable name (e.g., "Boulder", "New York").
+ * - A unique Dataset ID, which should correspond to a dataset id in the Datasets console tab.
+ * - The central latitude and longitude coordinates (LatLng) of the location.
+ * - A styling function (method reference) that defines how to style the data from that dataset on a map.
+ *
+ * This array is used to configure which datasets are available for display and how they should be presented.
+ * Each element of the array should be a new DataSet object.
+ * Modify the constructor arguments of each DataSet to define your specific data and styles.
+ * The styling function will receive a `Layer` to which it can add elements.
+ *
+ * Example:
+ * - `new DataSet("Boulder", "Boulder-DataSet-Id", new LatLng(40.0150, -105.2705), this::styleBoulderDatasetLayer)`
+ * This creates a DataSet for Boulder, identified by "Boulder-DataSet-Id", centered on the given coordinates,
+ * and styled using the `styleBoulderDatasetLayer` method.
+ *
+ * Note: We have use the secrets plugin to allow us to configure the Dataset IDs in our secrets.properties file.
+ */
+ private final DataSet[] dataSets = new DataSet[] {
+ new DataSet("Boulder", BuildConfig.BOULDER_DATASET_ID, new LatLng(40.0150, -105.2705), 11f, this::styleBoulderDatasetLayer),
+ new DataSet("New York", BuildConfig.NEW_YORK_DATASET_ID, new LatLng(40.786244, -73.962684), 14f, this::styleNYCDatasetLayer),
+ new DataSet("Kyoto", BuildConfig.KYOTO_DATASET_ID, new LatLng(35.005081, 135.764385), 13.5f, this::styleKyotoDatasetsLayer),
+ };
+
+ private DataSet findDataSetByLabel(String label) {
+ for (DataSet dataSet : dataSets) {
+ if (dataSet.label().equalsIgnoreCase(label)) { // Case-insensitive comparison
+ return dataSet;
+ }
+ }
+ return null; // Return null if no match is found
+ }
+
+ private static final String TAG = DataDrivenDatasetStylingActivity.class.getName();
+ private static FeatureLayer datasetLayer = null;
+ private GoogleMap map;
+ private String lastGlobalId = null;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.data_driven_styling_demo);
+
+ // [START_EXCLUDE silent]
+ // 1. Get the Application instance and cast it
+ ApiDemoApplication app = (ApiDemoApplication) getApplication();
+
+ // 2. Call the getMapId() method
+ String mapId = app.getMapId();
+
+ if (mapId == null) {
+ finish();
+ return;
+ }
+ // [END_EXCLUDE]
+
+ // --- Programmatically Create and Add Map Fragment ---
+ // 1. Create GoogleMapOptions
+ GoogleMapOptions mapOptions = new GoogleMapOptions();
+
+ // 2. Set the mapId from the secrets.properties file
+ mapOptions.mapId(BuildConfig.MAP_ID); // Use the mapId retrieved earlier
+
+ // 3. Create SupportMapFragment instance with options
+ SupportMapFragment mapFragment = SupportMapFragment.newInstance(mapOptions);
+ mapFragment.getMapAsync(this);
+
+ // 4. Add the fragment to your FrameLayout container using FragmentManager
+ FragmentManager fragmentManager = getSupportFragmentManager();
+ FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
+ fragmentTransaction.replace(R.id.map_fragment_container, mapFragment); // Use the container ID from XML
+ fragmentTransaction.commit();
+ // --- End Programmatic Creation ---
+
+
+ int[] buttonIds = {R.id.button_boulder, R.id.button_ny, R.id.button_kyoto};
+ for (int buttonId : buttonIds) {
+ findViewById(buttonId).setOnClickListener(view -> switchDataSet(((Button) view).getText().toString()));
+ }
+
+ applyInsets(findViewById(R.id.map_container));
+ }
+
+ /**
+ * Switches the currently displayed dataset to the one specified by the provided label.
+ *
+ * This method attempts to find a DataSet object associated with the given label.
+ * If a matching DataSet is found, it updates the map's feature layer to display the
+ * data from that dataset. It also applies styling to the new dataset layer and centers
+ * the map on the dataset's specified location.
+ *
+ * If no matching DataSet is found, a toast message is displayed indicating the failure.
+ *
+ * @param label The label of the dataset to switch to. This label should correspond to a
+ * dataset that has been previously added or loaded.
+ */
+ private void switchDataSet(String label) {
+ DataSet dataSet = findDataSetByLabel(label);
+ if (dataSet == null) {
+ Toast.makeText(this, "Failed to find dataset" + label, Toast.LENGTH_SHORT).show();
+ } else {
+ datasetLayer = map.getFeatureLayer(
+ new FeatureLayerOptions.Builder()
+ .featureType(FeatureType.DATASET)
+ .datasetId(dataSet.datasetId())
+ .build()
+ );
+ dataSet.callback.styleDatasetLayer();
+ centerMapOnLocation(dataSet.location(), dataSet.zoomLevel());
+ }
+ }
+
+ @Override
+ public void onMapReady(@NonNull GoogleMap googleMap) {
+ this.map = googleMap;
+
+ MapCapabilities capabilities = map.getMapCapabilities();
+ Log.d(TAG, "Data-driven Styling is available: " + capabilities.isDataDrivenStylingAvailable());
+ if (!capabilities.isDataDrivenStylingAvailable()) {
+ Toast.makeText(
+ this,
+ "Data-driven Styling is not available. See README.md for instructions.",
+ Toast.LENGTH_LONG
+ ).show();
+ }
+
+ // Switch to the default dataset which must happen before adding the feature click listener
+ switchDataSet("Boulder");
+
+ datasetLayer.addOnFeatureClickListener(this);
+ }
+
+ private void styleNYCDatasetLayer() {
+ FeatureLayer.StyleFactory styleFactory = feature -> {
+ int fillColor = Color.GREEN;
+ int strokeColor = Color.YELLOW;
+ float pointRadius = 12F;
+
+ if (feature instanceof DatasetFeature) {
+ Map furColors = ((DatasetFeature) feature).getDatasetAttributes();
+ String furColor = furColors.get("Color");
+
+ if (furColor != null) {
+ switch (furColor) {
+ case "Black+":
+ fillColor = Color.BLACK;
+ strokeColor = Color.BLACK;
+ break;
+ case "Cinnamon+":
+ fillColor = 0xFF8B0000; // dark red color
+ strokeColor = 0xFF8B0000;
+ break;
+ case "Cinnamon+Gray":
+ fillColor = 0xFF8B0000; // dark red color
+ strokeColor = 0xFF8B0000;
+ pointRadius = 10F;
+ break;
+ case "Cinnamon+White":
+ fillColor = 0xFF8B0000; // dark red color
+ strokeColor = Color.WHITE;
+ pointRadius = 10F;
+ break;
+ case "Gray+":
+ fillColor = Color.GRAY;
+ break;
+ case "Gray+Cinnamon":
+ fillColor = Color.GRAY;
+ strokeColor = 0xFF8B0000; // dark red color
+ pointRadius = 10F;
+ break;
+ case "Gray+Cinnamon, White":
+ fillColor = Color.LTGRAY;
+ strokeColor = 0xFF8B0000; // dark red color
+ pointRadius = 10F;
+ break;
+ case "Gray+White":
+ fillColor = Color.GRAY;
+ strokeColor = Color.WHITE;
+ pointRadius = 10F;
+ break;
+ }
+ }
+
+ return new FeatureStyle.Builder()
+ .fillColor(fillColor)
+ .strokeColor(strokeColor)
+ .pointRadius(pointRadius)
+ .build();
+ }
+ return null;
+ };
+
+ if (datasetLayer != null) {
+ datasetLayer.setFeatureStyle(styleFactory);
+ }
+ }
+
+ private void styleKyotoDatasetsLayer() {
+ // Create the style factory function.
+ FeatureLayer.StyleFactory styleFactory = feature -> {
+ // Check if the feature is an instance of DatasetFeature.
+ if (feature instanceof DatasetFeature datasetFeature) {
+ // Determine the value of the typecategory attribute.
+ Map typeCategories = datasetFeature.getDatasetAttributes();
+ String typeCategory = typeCategories.get("type");
+
+ // Set default colors to green.
+ int fillColor;
+ int strokeColor;
+
+ if ("temple".equals(typeCategory)) {
+ // Color temples areas blue.
+ fillColor = Color.BLUE;
+ strokeColor = Color.BLUE;
+ } else {
+ // Color all other areas green.
+ fillColor = Color.GREEN;
+ strokeColor = Color.GREEN;
+ }
+
+ return new FeatureStyle.Builder()
+ .fillColor(fillColor)
+ .strokeColor(strokeColor)
+ .strokeWidth(2F)
+ .build();
+ }
+ return null;
+ };
+
+ // Apply the style factory function to the feature layer.
+ if (datasetLayer != null) {
+ datasetLayer.setFeatureStyle(styleFactory);
+ }
+ }
+
+ private void styleBoulderDatasetLayer() {
+ final int EASY = Color.GREEN;
+ final int MODERATE = Color.BLUE;
+ final int DIFFICULT = Color.RED;
+
+ // Create the style factory function.
+ FeatureLayer.StyleFactory styleFactory = feature -> {
+ // Set default colors to yellow and point radius to 8.
+ int fillColor;
+ int strokeColor;
+ float pointRadius = 8F;
+ float strokeWidth = 3F;
+
+ // Check if the feature is an instance of DatasetFeature.
+ if (feature instanceof DatasetFeature datasetFeature) {
+ Map attributes = datasetFeature.getDatasetAttributes();
+ String difficulty = attributes.get("OSMPTrailsOSMPDIFFICULTY");
+ String name = attributes.get("OSMPTrailsOSMPTRAILNAME");
+ String dogsAllowed = attributes.get("OSMPTrailsOSMPDOGREGGEN");
+
+ if ("Easy".equals(difficulty)) {
+ fillColor = EASY;
+ } else if ("Moderate".equals(difficulty)) {
+ fillColor = MODERATE;
+ } else if ("Difficult".equals(difficulty)) {
+ fillColor = DIFFICULT;
+ } else {
+ Log.w(TAG, name + " -> Unknown difficulty: " + difficulty);
+ fillColor = Color.MAGENTA;
+ }
+
+ if ("No Dogs".equals(dogsAllowed)) {
+ fillColor = ColorUtils.setAlphaComponent(fillColor, 66);
+ strokeWidth = 5f;
+ } else if ("LVS".equals(dogsAllowed)) {
+ // No change needed
+ } else if ("LR".equals(dogsAllowed) || "RV".equals(dogsAllowed)) {
+ fillColor = ColorUtils.setAlphaComponent(fillColor, 75);
+ } else {
+ Log.w(TAG, name + " -> Unknown dogs reg: " + dogsAllowed);
+ }
+
+ strokeColor = fillColor;
+
+ return new FeatureStyle.Builder()
+ .fillColor(fillColor)
+ .strokeColor(strokeColor)
+ .pointRadius(pointRadius)
+ .strokeWidth(strokeWidth)
+ .build();
+ }
+ return null;
+ };
+
+ // Apply the style factory function to the feature layer.
+ if (datasetLayer != null) {
+ datasetLayer.setFeatureStyle(styleFactory);
+ }
+ }
+
+
+ private void centerMapOnLocation(LatLng location, float zoomLevel) {
+ map.moveCamera(CameraUpdateFactory.newLatLngZoom(location, zoomLevel));
+ }
+
+ @Override
+ public void onFeatureClick(FeatureClickEvent event) {
+ List clickFeatures = event.getFeatures();
+ lastGlobalId = null;
+ if (clickFeatures.get(0) instanceof DatasetFeature) {
+ lastGlobalId = ((DatasetFeature) clickFeatures.get(0)).getDatasetAttributes().get("globalid");
+ styleDatasetsLayerClickEvent();
+ }
+ }
+
+ private void styleDatasetsLayerClickEvent() {
+ FeatureLayer.StyleFactory styleFactory = feature -> {
+ if (feature instanceof DatasetFeature) {
+ Map globalIDs = ((DatasetFeature) feature).getDatasetAttributes();
+ String globalID = globalIDs.get("globalid");
+ int fillColor = Color.GREEN;
+ int strokeColor = Color.GREEN;
+
+ if (globalID != null && globalID.equals(lastGlobalId)) {
+ fillColor = Color.BLUE;
+ strokeColor = Color.BLUE;
+ }
+
+ return new FeatureStyle.Builder()
+ .fillColor(fillColor)
+ .strokeColor(strokeColor)
+ .build();
+ }
+ return null;
+ };
+
+ if (datasetLayer != null) {
+ datasetLayer.setFeatureStyle(styleFactory);
+ }
+ }
+}
+// [END maps_android_data_driven_styling_datasets]
+
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/DemoDetails.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DemoDetails.java
similarity index 87%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/DemoDetails.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DemoDetails.java
index d804ea0ff..5dc2aabe0 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/DemoDetails.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DemoDetails.java
@@ -35,10 +35,10 @@ public class DemoDetails {
/**
* The demo activity's class.
*/
- public final Class extends AppCompatActivity> activityClass;
+ public final Class extends SamplesBaseActivity> activityClass;
public DemoDetails(
- int titleId, int descriptionId, Class extends AppCompatActivity> activityClass) {
+ int titleId, int descriptionId, Class extends SamplesBaseActivity> activityClass) {
this.titleId = titleId;
this.descriptionId = descriptionId;
this.activityClass = activityClass;
diff --git a/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DemoDetailsList.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DemoDetailsList.java
new file mode 100755
index 000000000..cd8301ca5
--- /dev/null
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/DemoDetailsList.java
@@ -0,0 +1,162 @@
+// 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.
+
+
+package com.example.mapdemo;
+
+/**
+ * A list of all the demos we have available.
+ */
+public final class DemoDetailsList {
+
+ /**
+ * This class should not be instantiated.
+ */
+ private DemoDetailsList() {
+ }
+
+ public static final DemoDetails[] DEMOS = {
+ new DemoDetails(com.example.common_ui.R.string.advanced_markers_demo_label,
+ com.example.common_ui.R.string.advanced_markers_demo_details,
+ AdvancedMarkersDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.basic_map_demo_label,
+ com.example.common_ui.R.string.basic_map_demo_description,
+ BasicMapDemoActivity.class),
+ new DemoDetails(
+ com.example.common_ui.R.string.background_color_customization_demo_label,
+ com.example.common_ui.R.string.background_color_customization_demo_description,
+ BackgroundColorCustomizationDemoActivity.class),
+ new DemoDetails(
+ com.example.common_ui.R.string.background_color_customization_programmatic_demo_label,
+ com.example.common_ui.R.string.background_color_customization_programmatic_demo_description,
+ BackgroundColorCustomizationProgrammaticDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.camera_demo_label,
+ com.example.common_ui.R.string.camera_demo_description,
+ CameraDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.camera_clamping_demo_label,
+ com.example.common_ui.R.string.camera_clamping_demo_description,
+ CameraClampingDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.cloud_styling_label,
+ com.example.common_ui.R.string.cloud_styling_description,
+ CloudBasedMapStylingDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.circle_demo_label,
+ com.example.common_ui.R.string.circle_demo_description,
+ CircleDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.data_driven_styling_label,
+ com.example.common_ui.R.string.data_driven_styling_description,
+ DataDrivenDatasetStylingActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.data_driven_boundaries_label,
+ com.example.common_ui.R.string.data_driven_boundaries_description,
+ DataDrivenBoundariesActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.events_demo_label,
+ com.example.common_ui.R.string.events_demo_description,
+ EventsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.ground_overlay_demo_label,
+ com.example.common_ui.R.string.ground_overlay_demo_description,
+ GroundOverlayDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.indoor_demo_label,
+ com.example.common_ui.R.string.indoor_demo_description,
+ IndoorDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.layers_demo_label,
+ com.example.common_ui.R.string.layers_demo_description,
+ LayersDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.lite_demo_label,
+ com.example.common_ui.R.string.lite_demo_description,
+ LiteDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.lite_list_demo_label,
+ com.example.common_ui.R.string.lite_list_demo_description,
+ LiteListDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.location_source_demo_label,
+ com.example.common_ui.R.string.location_source_demo_description,
+ LocationSourceDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.map_in_pager_demo_label,
+ com.example.common_ui.R.string.map_in_pager_demo_description,
+ MapInPagerDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.map_color_scheme_demo_label,
+ com.example.common_ui.R.string.map_color_scheme_demo_description,
+ MapColorSchemeActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.marker_demo_label,
+ com.example.common_ui.R.string.marker_demo_description,
+ MarkerDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.marker_close_info_window_on_retap_demo_label,
+ com.example.common_ui.R.string.marker_close_info_window_on_retap_demo_description,
+ MarkerCloseInfoWindowOnRetapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.multi_map_demo_label,
+ com.example.common_ui.R.string.multi_map_demo_description,
+ MultiMapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.my_location_demo_label,
+ com.example.common_ui.R.string.my_location_demo_description,
+ MyLocationDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.options_demo_label,
+ com.example.common_ui.R.string.options_demo_description,
+ OptionsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.polygon_demo_label,
+ com.example.common_ui.R.string.polygon_demo_description,
+ PolygonDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.polyline_demo_label,
+ com.example.common_ui.R.string.polyline_demo_description,
+ PolylineDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.programmatic_demo_label,
+ com.example.common_ui.R.string.programmatic_demo_description,
+ ProgrammaticDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.raw_map_view_demo_label,
+ com.example.common_ui.R.string.raw_map_view_demo_description,
+ RawMapViewDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.retain_map_demo_label,
+ com.example.common_ui.R.string.retain_map_demo_description,
+ RetainMapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.save_state_demo_label,
+ com.example.common_ui.R.string.save_state_demo_description,
+ SaveStateDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.snapshot_demo_label,
+ com.example.common_ui.R.string.snapshot_demo_description,
+ SnapshotDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.split_street_view_panorama_and_map_demo_label,
+ com.example.common_ui.R.string.split_street_view_panorama_and_map_demo_description,
+ SplitStreetViewPanoramaAndMapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_basic_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_basic_demo_description,
+ StreetViewPanoramaBasicDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_events_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_events_demo_description,
+ StreetViewPanoramaEventsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_navigation_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_navigation_demo_description,
+ StreetViewPanoramaNavigationDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_options_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_options_demo_description,
+ StreetViewPanoramaOptionsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_view_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_view_demo_description,
+ StreetViewPanoramaViewDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.styled_map_demo_label,
+ com.example.common_ui.R.string.styled_map_demo_description,
+ StyledMapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.tags_demo_label,
+ com.example.common_ui.R.string.tags_demo_description,
+ TagsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.tile_coordinate_demo_label,
+ com.example.common_ui.R.string.tile_coordinate_demo_description,
+ TileCoordinateDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.tile_overlay_demo_label,
+ com.example.common_ui.R.string.tile_overlay_demo_description,
+ TileOverlayDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.ui_settings_demo_label,
+ com.example.common_ui.R.string.ui_settings_demo_description,
+ UiSettingsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.visible_region_demo_label,
+ com.example.common_ui.R.string.visible_region_demo_description,
+ VisibleRegionDemoActivity.class),
+ };
+}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/EventsDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/EventsDemoActivity.java
similarity index 85%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/EventsDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/EventsDemoActivity.java
index c484e34de..6699be4ee 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/EventsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/EventsDemoActivity.java
@@ -32,7 +32,7 @@
* This shows how to listen to some {@link GoogleMap} events.
*/
// [START maps_android_sample_events]
-public class EventsDemoActivity extends AppCompatActivity
+public class EventsDemoActivity extends SamplesBaseActivity
implements OnMapClickListener, OnMapLongClickListener, OnCameraIdleListener,
OnMapReadyCallback {
@@ -43,14 +43,15 @@ public class EventsDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.events_demo);
+ setContentView(com.example.common_ui.R.layout.events_demo);
- tapTextView = findViewById(R.id.tap_text);
- cameraTextView = findViewById(R.id.camera_text);
+ tapTextView = findViewById(com.example.common_ui.R.id.tap_text);
+ cameraTextView = findViewById(com.example.common_ui.R.id.camera_text);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/FeatureView.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/FeatureView.java
similarity index 85%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/FeatureView.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/FeatureView.java
index d24e82e8e..fd5935296 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/FeatureView.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/FeatureView.java
@@ -33,7 +33,7 @@ public FeatureView(Context context) {
LayoutInflater layoutInflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- layoutInflater.inflate(R.layout.feature, this);
+ layoutInflater.inflate(com.example.common_ui.R.layout.feature, this);
}
/**
@@ -42,7 +42,7 @@ public FeatureView(Context context) {
* @param titleId the resource id of the title of the demo
*/
public synchronized void setTitleId(int titleId) {
- ((TextView) (findViewById(R.id.title))).setText(titleId);
+ ((TextView) (findViewById(com.example.common_ui.R.id.title))).setText(titleId);
}
/**
@@ -51,7 +51,7 @@ public synchronized void setTitleId(int titleId) {
* @param descriptionId the resource id of the description of the demo
*/
public synchronized void setDescriptionId(int descriptionId) {
- ((TextView) (findViewById(R.id.description))).setText(descriptionId);
+ ((TextView) (findViewById(com.example.common_ui.R.id.description))).setText(descriptionId);
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/GroundOverlayDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/GroundOverlayDemoActivity.java
similarity index 87%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/GroundOverlayDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/GroundOverlayDemoActivity.java
index 99f8c86cf..d99ee0e3f 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/GroundOverlayDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/GroundOverlayDemoActivity.java
@@ -39,7 +39,7 @@
/**
* This shows how to add a ground overlay to a map.
*/
-public class GroundOverlayDemoActivity extends AppCompatActivity
+public class GroundOverlayDemoActivity extends SamplesBaseActivity
implements OnSeekBarChangeListener, OnMapReadyCallback,
GoogleMap.OnGroundOverlayClickListener {
@@ -63,15 +63,16 @@ public class GroundOverlayDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.ground_overlay_demo);
+ setContentView(com.example.common_ui.R.layout.ground_overlay_demo);
- transparencyBar = findViewById(R.id.transparencySeekBar);
+ transparencyBar = findViewById(com.example.common_ui.R.id.transparencySeekBar);
transparencyBar.setMax(TRANSPARENCY_MAX);
transparencyBar.setProgress(0);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -82,8 +83,8 @@ public void onMapReady(GoogleMap map) {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(NEWARK, 11));
images.clear();
- images.add(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922));
- images.add(BitmapDescriptorFactory.fromResource(R.drawable.newark_prudential_sunny));
+ images.add(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.newark_nj_1922));
+ images.add(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.newark_prudential_sunny));
// Add a small, rotated overlay that is clickable by default
// (set by the initial state of the checkbox.)
@@ -91,7 +92,7 @@ public void onMapReady(GoogleMap map) {
.image(images.get(1)).anchor(0, 1)
.position(NEAR_NEWARK, 4300f, 3025f)
.bearing(30)
- .clickable(((CheckBox) findViewById(R.id.toggleClickability)).isChecked()));
+ .clickable(((CheckBox) findViewById(com.example.common_ui.R.id.toggleClickability)).isChecked()));
// Add a large overlay at Newark on top of the smaller overlay.
groundOverlay = map.addGroundOverlay(new GroundOverlayOptions()
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/IndoorDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/IndoorDemoActivity.java
similarity index 92%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/IndoorDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/IndoorDemoActivity.java
index 62b078abe..9640b843d 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/IndoorDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/IndoorDemoActivity.java
@@ -34,7 +34,7 @@
/**
* A demo activity showing how to use indoor.
*/
-public class IndoorDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class IndoorDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
private GoogleMap map;
@@ -43,11 +43,12 @@ public class IndoorDemoActivity extends AppCompatActivity implements OnMapReadyC
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.indoor_demo);
+ setContentView(com.example.common_ui.R.layout.indoor_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -128,7 +129,7 @@ public void onHigherLevel(View view) {
}
private void setText(String message) {
- TextView text = findViewById(R.id.top_text);
+ TextView text = findViewById(com.example.common_ui.R.id.top_text);
text.setText(message);
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/LayersDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LayersDemoActivity.java
similarity index 84%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/LayersDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LayersDemoActivity.java
index 60c7b3f7a..821e93362 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/LayersDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LayersDemoActivity.java
@@ -46,7 +46,7 @@
/**
* Demonstrates the different base layers of a map.
*/
-public class LayersDemoActivity extends AppCompatActivity
+public class LayersDemoActivity extends SamplesBaseActivity
implements OnItemSelectedListener, OnMapReadyCallback,
ActivityCompat.OnRequestPermissionsResultCallback {
@@ -73,23 +73,24 @@ public class LayersDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.layers_demo);
+ setContentView(com.example.common_ui.R.layout.layers_demo);
- mSpinner = findViewById(R.id.layers_spinner);
+ mSpinner = findViewById(com.example.common_ui.R.id.layers_spinner);
ArrayAdapter adapter = ArrayAdapter.createFromResource(
- this, R.array.layers_array, android.R.layout.simple_spinner_item);
+ this, com.example.common_ui.R.array.layers_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(adapter);
mSpinner.setOnItemSelectedListener(this);
- mTrafficCheckbox = findViewById(R.id.traffic);
- mMyLocationCheckbox = findViewById(R.id.my_location);
- mBuildingsCheckbox = findViewById(R.id.buildings);
- mIndoorCheckbox = findViewById(R.id.indoor);
+ mTrafficCheckbox = findViewById(com.example.common_ui.R.id.traffic);
+ mMyLocationCheckbox = findViewById(com.example.common_ui.R.id.my_location);
+ mBuildingsCheckbox = findViewById(com.example.common_ui.R.id.buildings);
+ mIndoorCheckbox = findViewById(com.example.common_ui.R.id.indoor);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -104,7 +105,7 @@ public void onMapReady(GoogleMap map) {
private boolean checkReady() {
if (mMap == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
@@ -224,17 +225,17 @@ private void updateMapType() {
}
String layerName = ((String) mSpinner.getSelectedItem());
- if (layerName.equals(getString(R.string.normal))) {
+ if (layerName.equals(getString(com.example.common_ui.R.string.normal))) {
mMap.setMapType(MAP_TYPE_NORMAL);
- } else if (layerName.equals(getString(R.string.hybrid))) {
+ } else if (layerName.equals(getString(com.example.common_ui.R.string.hybrid))) {
mMap.setMapType(MAP_TYPE_HYBRID);
- } else if (layerName.equals(getString(R.string.satellite))) {
+ } else if (layerName.equals(getString(com.example.common_ui.R.string.satellite))) {
mMap.setMapType(MAP_TYPE_SATELLITE);
- } else if (layerName.equals(getString(R.string.terrain))) {
+ } else if (layerName.equals(getString(com.example.common_ui.R.string.terrain))) {
mMap.setMapType(MAP_TYPE_TERRAIN);
- } else if (layerName.equals(getString(R.string.none_map))) {
+ } else if (layerName.equals(getString(com.example.common_ui.R.string.none_map))) {
mMap.setMapType(MAP_TYPE_NONE);
} else {
Log.i("LDA", "Error setting layer with name " + layerName);
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/LiteDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LiteDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/LiteDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LiteDemoActivity.java
index ec914142f..2f1806db5 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/LiteDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LiteDemoActivity.java
@@ -37,7 +37,7 @@
* launch the Google Maps Mobile application, {@link com.google.android.gms.maps.CameraUpdate}s
* and {@link com.google.android.gms.maps.model.Polygon}s.
*/
-public class LiteDemoActivity extends AppCompatActivity implements
+public class LiteDemoActivity extends SamplesBaseActivity implements
OnMapAndViewReadyListener.OnGlobalLayoutAndMapReadyListener {
private static final LatLng BRISBANE = new LatLng(-27.47093, 153.0235);
@@ -67,12 +67,13 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the layout
- setContentView(R.layout.lite_demo);
+ setContentView(com.example.common_ui.R.layout.lite_demo);
// Get the map and register for the ready callback
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
/**
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/LiteListDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LiteListDemoActivity.java
similarity index 91%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/LiteListDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LiteListDemoActivity.java
index 28cfd3c3c..e2638c915 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/LiteListDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LiteListDemoActivity.java
@@ -40,7 +40,7 @@
* Note the use of the view holder pattern with the
* {@link com.google.android.gms.maps.OnMapReadyCallback}.
*/
-public class LiteListDemoActivity extends AppCompatActivity {
+public class LiteListDemoActivity extends SamplesBaseActivity {
private RecyclerView mRecyclerView;
@@ -50,32 +50,33 @@ public class LiteListDemoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.lite_list_demo);
+ setContentView(com.example.common_ui.R.layout.lite_list_demo);
mGridLayoutManager = new GridLayoutManager(this, 2);
mLinearLayoutManager = new LinearLayoutManager(this);
// Set up the RecyclerView
- mRecyclerView = findViewById(R.id.recycler_view);
+ mRecyclerView = findViewById(com.example.common_ui.R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
mRecyclerView.setAdapter(new MapAdapter(LIST_LOCATIONS));
mRecyclerView.setRecyclerListener(mRecycleListener);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
/** Create a menu to switch between Linear and Grid LayoutManager. */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.lite_list_menu, menu);
+ getMenuInflater().inflate(com.example.common_ui.R.menu.lite_list_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
- if (id == R.id.layout_linear) {
+ if (id == com.example.common_ui.R.id.layout_linear) {
mRecyclerView.setLayoutManager(mLinearLayoutManager);
- } else if (id == R.id.layout_grid) {
+ } else if (id == com.example.common_ui.R.id.layout_grid) {
mRecyclerView.setLayoutManager(mGridLayoutManager);
}
return true;
@@ -89,7 +90,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
*/
private class MapAdapter extends RecyclerView.Adapter {
- private NamedLocation[] namedLocations;
+ private final NamedLocation[] namedLocations;
private MapAdapter(NamedLocation[] locations) {
super();
@@ -99,7 +100,7 @@ private MapAdapter(NamedLocation[] locations) {
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext())
- .inflate(R.layout.lite_list_demo_row, parent, false));
+ .inflate(com.example.common_ui.R.layout.lite_list_demo_row, parent, false));
}
/**
@@ -138,8 +139,8 @@ class ViewHolder extends RecyclerView.ViewHolder implements OnMapReadyCallback {
private ViewHolder(View itemView) {
super(itemView);
layout = itemView;
- mapView = layout.findViewById(R.id.lite_listrow_map);
- title = layout.findViewById(R.id.lite_listrow_text);
+ mapView = layout.findViewById(com.example.common_ui.R.id.lite_listrow_map);
+ title = layout.findViewById(com.example.common_ui.R.id.lite_listrow_text);
if (mapView != null) {
// Initialise the MapView
mapView.onCreate(null);
@@ -193,7 +194,7 @@ private void bindView(int pos) {
* Sets the map type to {@link com.google.android.gms.maps.GoogleMap#MAP_TYPE_NONE} and clears
* the map.
*/
- private RecyclerView.RecyclerListener mRecycleListener = new RecyclerView.RecyclerListener() {
+ private final RecyclerView.RecyclerListener mRecycleListener = new RecyclerView.RecyclerListener() {
@Override
public void onViewRecycled(RecyclerView.ViewHolder holder) {
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/LocationSourceDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LocationSourceDemoActivity.java
similarity index 93%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/LocationSourceDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LocationSourceDemoActivity.java
index 6986f9476..d3e3fd53b 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/LocationSourceDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/LocationSourceDemoActivity.java
@@ -34,7 +34,7 @@
/**
* This shows how to use a custom location source.
*/
-public class LocationSourceDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class LocationSourceDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
/**
* A {@link LocationSource} which reports a new location whenever a user long presses the map
@@ -88,13 +88,14 @@ public void onResume() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.basic_demo);
+ setContentView(com.example.common_ui.R.layout.basic_demo);
mLocationSource = new LongPressLocationSource();
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MainActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MainActivity.java
similarity index 84%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/MainActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MainActivity.java
index 7d55fbf58..43f950d2a 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MainActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MainActivity.java
@@ -26,6 +26,7 @@
import android.widget.ListAdapter;
import android.widget.ListView;
+import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
/**
@@ -33,7 +34,7 @@
*
* The main layout lists the demonstrated features, with buttons to launch them.
*/
-public final class MainActivity extends AppCompatActivity {
+public final class MainActivity extends SamplesBaseActivity {
private static final String TAG = MainActivity.class.getSimpleName();
@@ -42,11 +43,12 @@ private static class CustomArrayAdapter extends ArrayAdapter {
/** @param demos An array containing the details of the demos to be displayed. */
public CustomArrayAdapter(Context context, DemoDetails[] demos) {
- super(context, R.layout.feature, R.id.title, demos);
+ super(context, com.example.common_ui.R.layout.feature, com.example.common_ui.R.id.title, demos);
}
+ @NonNull
@Override
- public View getView(int position, View convertView, ViewGroup parent) {
+ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
FeatureView featureView;
if (convertView instanceof FeatureView) {
featureView = (FeatureView) convertView;
@@ -71,11 +73,11 @@ public View getView(int position, View convertView, ViewGroup parent) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
+ setContentView(com.example.common_ui.R.layout.main);
ListAdapter adapter = new CustomArrayAdapter(this, DemoDetailsList.DEMOS);
- ListView demoListView = (ListView) findViewById(R.id.list);
+ ListView demoListView = findViewById(com.example.common_ui.R.id.list);
if (demoListView != null) {
demoListView.setAdapter(adapter);
demoListView.setOnItemClickListener(
@@ -84,5 +86,6 @@ protected void onCreate(Bundle savedInstanceState) {
startActivity(new Intent(view.getContext(), demo.activityClass));
});
}
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
}
diff --git a/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MapColorSchemeActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MapColorSchemeActivity.java
new file mode 100755
index 000000000..414995f2c
--- /dev/null
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MapColorSchemeActivity.java
@@ -0,0 +1,61 @@
+/*
+ * 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
+ *
+ * https://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.
+ */
+
+package com.example.mapdemo;
+
+import android.os.Bundle;
+import android.widget.Button;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+
+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.MapColorScheme;
+
+public class MapColorSchemeActivity extends SamplesBaseActivity implements OnMapReadyCallback {
+
+ private Button buttonLight;
+ private Button buttonDark;
+ private Button buttonFollowSystem;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(com.example.common_ui.R.layout.map_color_scheme_demo);
+ SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
+ if (mapFragment != null) {
+ mapFragment.getMapAsync(this);
+ }
+ buttonLight = findViewById(com.example.common_ui.R.id.map_color_light_mode);
+ buttonDark = findViewById(com.example.common_ui.R.id.map_color_dark_mode);
+ buttonFollowSystem = findViewById(com.example.common_ui.R.id.map_color_follow_system_mode);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
+ }
+
+ @Override
+ public void onMapReady(@NonNull GoogleMap googleMap) {
+
+ googleMap.setMapColorScheme(MapColorScheme.DARK);
+
+ buttonLight.setOnClickListener(view -> googleMap.setMapColorScheme(MapColorScheme.LIGHT));
+
+ buttonDark.setOnClickListener(view -> googleMap.setMapColorScheme(MapColorScheme.DARK));
+
+ buttonFollowSystem.setOnClickListener(view -> googleMap.setMapColorScheme(MapColorScheme.FOLLOW_SYSTEM));
+ }
+}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MapInPagerDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MapInPagerDemoActivity.java
similarity index 87%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/MapInPagerDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MapInPagerDemoActivity.java
index db3365cee..d772eda89 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MapInPagerDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MapInPagerDemoActivity.java
@@ -31,21 +31,23 @@
* This shows how to add a map to a ViewPager. Note the use of
* {@link ViewGroup#requestTransparentRegion(View)} to reduce jankiness.
*/
-public class MapInPagerDemoActivity extends AppCompatActivity {
+public class MapInPagerDemoActivity extends SamplesBaseActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.map_in_pager_demo);
+ setContentView(com.example.common_ui.R.layout.map_in_pager_demo);
MyAdapter adapter = new MyAdapter(getSupportFragmentManager());
- ViewPager pager = findViewById(R.id.pager);
+ ViewPager pager = findViewById(com.example.common_ui.R.id.pager);
pager.setAdapter(adapter);
// This is required to avoid a black flash when the map is loaded. The flash is due
// to the use of a SurfaceView as the underlying view of the map.
pager.requestTransparentRegion(pager);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
/** A simple fragment that displays a TextView. */
@@ -53,7 +55,7 @@ public static class TextFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- return inflater.inflate(R.layout.text_fragment, container, false);
+ return inflater.inflate(com.example.common_ui.R.layout.text_fragment, container, false);
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
similarity index 94%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
index 7177f39b7..f069eaa1c 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
@@ -32,7 +32,7 @@
/**
* This shows how to close the info window when the currently selected marker is re-tapped.
*/
-public class MarkerCloseInfoWindowOnRetapDemoActivity extends AppCompatActivity implements
+public class MarkerCloseInfoWindowOnRetapDemoActivity extends SamplesBaseActivity implements
OnMarkerClickListener,
OnMapClickListener,
OnMapAndViewReadyListener.OnGlobalLayoutAndMapReadyListener {
@@ -53,11 +53,13 @@ public class MarkerCloseInfoWindowOnRetapDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.marker_close_info_window_on_retap_demo);
+ setContentView(com.example.common_ui.R.layout.marker_close_info_window_on_retap_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MarkerDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MarkerDemoActivity.java
similarity index 97%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/MarkerDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MarkerDemoActivity.java
index 2d0e5a55a..03437e394 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MarkerDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MarkerDemoActivity.java
@@ -38,9 +38,10 @@
import android.os.Handler;
import android.os.SystemClock;
+import com.example.common_ui.R;
+
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
-import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import android.text.SpannableString;
@@ -65,7 +66,7 @@
* This shows how to place markers on a map.
*/
// [START maps_android_sample_marker]
-public class MarkerDemoActivity extends AppCompatActivity implements
+public class MarkerDemoActivity extends SamplesBaseActivity implements
OnMarkerClickListener,
OnInfoWindowClickListener,
OnMarkerDragListener,
@@ -150,7 +151,7 @@ private void render(Marker marker, View view) {
((ImageView) view.findViewById(R.id.badge)).setImageResource(badge);
String title = marker.getTitle();
- TextView titleUi = ((TextView) view.findViewById(R.id.title));
+ TextView titleUi = view.findViewById(R.id.title);
if (title != null) {
// Spannable string allows us to edit the formatting of the text.
SpannableString titleText = new SpannableString(title);
@@ -161,7 +162,7 @@ private void render(Marker marker, View view) {
}
String snippet = marker.getSnippet();
- TextView snippetUi = ((TextView) view.findViewById(R.id.snippet));
+ TextView snippetUi = view.findViewById(R.id.snippet);
if (snippet != null && snippet.length() > 12) {
SpannableString snippetText = new SpannableString(snippet);
snippetText.setSpan(new ForegroundColorSpan(Color.MAGENTA), 0, 10, 0);
@@ -214,15 +215,15 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.marker_demo);
- mTopText = (TextView) findViewById(R.id.top_text);
+ mTopText = findViewById(R.id.top_text);
- mRotationBar = (SeekBar) findViewById(R.id.rotationSeekBar);
+ mRotationBar = findViewById(R.id.rotationSeekBar);
mRotationBar.setMax(360);
mRotationBar.setOnSeekBarChangeListener(this);
- mFlatBox = (CheckBox) findViewById(R.id.flat);
+ mFlatBox = findViewById(R.id.flat);
- mOptions = (RadioGroup) findViewById(R.id.custom_info_window_options);
+ mOptions = findViewById(R.id.custom_info_window_options);
mOptions.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
@@ -236,6 +237,8 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
+
+ applyInsets(findViewById(R.id.map_container));
}
@Override
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MultiMapDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MultiMapDemoActivity.java
similarity index 81%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/MultiMapDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MultiMapDemoActivity.java
index 6382f7702..f0403251f 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MultiMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MultiMapDemoActivity.java
@@ -16,16 +16,18 @@
package com.example.mapdemo;
import android.os.Bundle;
+
import androidx.appcompat.app.AppCompatActivity;
/**
* This shows how to create a simple activity with multiple maps on screen.
*/
-public class MultiMapDemoActivity extends AppCompatActivity {
+public class MultiMapDemoActivity extends SamplesBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.multimap_demo);
+ setContentView(com.example.common_ui.R.layout.multimap_demo);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MyLocationDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MyLocationDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/MyLocationDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MyLocationDemoActivity.java
index 500c6b5f7..7f9008f8a 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MyLocationDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/MyLocationDemoActivity.java
@@ -42,7 +42,7 @@
* permission is not granted, the Activity is finished with an error message.
*/
// [START maps_android_sample_my_location]
-public class MyLocationDemoActivity extends AppCompatActivity
+public class MyLocationDemoActivity extends SamplesBaseActivity
implements
OnMyLocationButtonClickListener,
OnMyLocationClickListener,
@@ -67,11 +67,12 @@ public class MyLocationDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.my_location_demo);
+ setContentView(com.example.common_ui.R.layout.my_location_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/OnMapAndViewReadyListener.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/OnMapAndViewReadyListener.java
similarity index 100%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/OnMapAndViewReadyListener.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/OnMapAndViewReadyListener.java
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/OptionsDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/OptionsDemoActivity.java
similarity index 80%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/OptionsDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/OptionsDemoActivity.java
index 8b88b1d0a..9ad50b638 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/OptionsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/OptionsDemoActivity.java
@@ -22,11 +22,12 @@
/**
* An activity that creates a map with some initial options.
*/
-public final class OptionsDemoActivity extends AppCompatActivity {
+public final class OptionsDemoActivity extends SamplesBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.options_demo);
+ setContentView(com.example.common_ui.R.layout.options_demo);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/PermissionUtils.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/PermissionUtils.java
similarity index 95%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/PermissionUtils.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/PermissionUtils.java
index 25c5d1aff..a7572f1ff 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/PermissionUtils.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/PermissionUtils.java
@@ -97,7 +97,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
finishActivity = getArguments().getBoolean(ARGUMENT_FINISH_ACTIVITY);
return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.location_permission_denied)
+ .setMessage(com.example.common_ui.R.string.location_permission_denied)
.setPositiveButton(android.R.string.ok, null)
.create();
}
@@ -106,7 +106,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
if (finishActivity) {
- Toast.makeText(getActivity(), R.string.permission_required_toast,
+ Toast.makeText(getActivity(), com.example.common_ui.R.string.permission_required_toast,
Toast.LENGTH_SHORT).show();
getActivity().finish();
}
@@ -155,7 +155,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
finishActivity = arguments.getBoolean(ARGUMENT_FINISH_ACTIVITY);
return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.permission_rationale_location)
+ .setMessage(com.example.common_ui.R.string.permission_rationale_location)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@@ -176,7 +176,7 @@ public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
if (finishActivity) {
Toast.makeText(getActivity(),
- R.string.permission_required_toast,
+ com.example.common_ui.R.string.permission_required_toast,
Toast.LENGTH_SHORT)
.show();
getActivity().finish();
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/PolygonDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/PolygonDemoActivity.java
similarity index 82%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/PolygonDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/PolygonDemoActivity.java
index 4be71e21a..95bda098a 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/PolygonDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/PolygonDemoActivity.java
@@ -48,7 +48,7 @@
* This shows how to draw polygons on a map.
*/
// [START maps_android_sample_polygons]
-public class PolygonDemoActivity extends AppCompatActivity
+public class PolygonDemoActivity extends SamplesBaseActivity
implements OnSeekBarChangeListener, OnItemSelectedListener, OnMapReadyCallback {
private static final LatLng CENTER = new LatLng(-20, 130);
@@ -79,57 +79,59 @@ public class PolygonDemoActivity extends AppCompatActivity
// string resource IDs as identifiers.
private static final int[] JOINT_TYPE_NAME_RESOURCE_IDS = {
- R.string.joint_type_default, // Default
- R.string.joint_type_bevel,
- R.string.joint_type_round,
+ com.example.common_ui.R.string.joint_type_default, // Default
+ com.example.common_ui.R.string.joint_type_bevel,
+ com.example.common_ui.R.string.joint_type_round,
};
private static final int[] PATTERN_TYPE_NAME_RESOURCE_IDS = {
- R.string.pattern_solid, // Default
- R.string.pattern_dashed,
- R.string.pattern_dotted,
- R.string.pattern_mixed,
+ com.example.common_ui.R.string.pattern_solid, // Default
+ com.example.common_ui.R.string.pattern_dashed,
+ com.example.common_ui.R.string.pattern_dotted,
+ com.example.common_ui.R.string.pattern_mixed,
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.polygon_demo);
+ setContentView(com.example.common_ui.R.layout.polygon_demo);
- fillHueBar = findViewById(R.id.fillHueSeekBar);
+ fillHueBar = findViewById(com.example.common_ui.R.id.fillHueSeekBar);
fillHueBar.setMax(MAX_HUE_DEGREES);
fillHueBar.setProgress(MAX_HUE_DEGREES / 2);
- fillAlphaBar = findViewById(R.id.fillAlphaSeekBar);
+ fillAlphaBar = findViewById(com.example.common_ui.R.id.fillAlphaSeekBar);
fillAlphaBar.setMax(MAX_ALPHA);
fillAlphaBar.setProgress(MAX_ALPHA / 2);
- strokeWidthBar = findViewById(R.id.strokeWidthSeekBar);
+ strokeWidthBar = findViewById(com.example.common_ui.R.id.strokeWidthSeekBar);
strokeWidthBar.setMax(MAX_WIDTH_PX);
strokeWidthBar.setProgress(MAX_WIDTH_PX / 3);
- strokeHueBar = findViewById(R.id.strokeHueSeekBar);
+ strokeHueBar = findViewById(com.example.common_ui.R.id.strokeHueSeekBar);
strokeHueBar.setMax(MAX_HUE_DEGREES);
strokeHueBar.setProgress(0);
- strokeAlphaBar = findViewById(R.id.strokeAlphaSeekBar);
+ strokeAlphaBar = findViewById(com.example.common_ui.R.id.strokeAlphaSeekBar);
strokeAlphaBar.setMax(MAX_ALPHA);
strokeAlphaBar.setProgress(MAX_ALPHA);
- strokeJointTypeSpinner = findViewById(R.id.strokeJointTypeSpinner);
+ strokeJointTypeSpinner = findViewById(com.example.common_ui.R.id.strokeJointTypeSpinner);
strokeJointTypeSpinner.setAdapter(new ArrayAdapter<>(
this, android.R.layout.simple_spinner_item,
getResourceStrings(JOINT_TYPE_NAME_RESOURCE_IDS)));
- strokePatternSpinner = findViewById(R.id.strokePatternSpinner);
+ strokePatternSpinner = findViewById(com.example.common_ui.R.id.strokePatternSpinner);
strokePatternSpinner.setAdapter(new ArrayAdapter<>(
this, android.R.layout.simple_spinner_item,
getResourceStrings(PATTERN_TYPE_NAME_RESOURCE_IDS)));
- clickabilityCheckbox = findViewById(R.id.toggleClickability);
+ clickabilityCheckbox = findViewById(com.example.common_ui.R.id.toggleClickability);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
// [START_EXCLUDE silent]
@@ -145,7 +147,7 @@ private String[] getResourceStrings(int[] resourceIds) {
@Override
public void onMapReady(GoogleMap map) {
// Override the default content description on the view, for accessibility mode.
- map.setContentDescription(getString(R.string.polygon_demo_description));
+ map.setContentDescription(getString(com.example.common_ui.R.string.polygon_demo_description));
int fillColorArgb = Color.HSVToColor(
fillAlphaBar.getProgress(), new float[]{fillHueBar.getProgress(), 1, 1});
@@ -202,11 +204,11 @@ private List createRectangle(LatLng center, double halfWidth, double hal
private int getSelectedJointType(int pos) {
int id = JOINT_TYPE_NAME_RESOURCE_IDS[pos];
- if (id == R.string.joint_type_bevel) {
+ if (id == com.example.common_ui.R.string.joint_type_bevel) {
return JointType.BEVEL;
- } else if (id == R.string.joint_type_round) {
+ } else if (id == com.example.common_ui.R.string.joint_type_round) {
return JointType.ROUND;
- } else if (id == R.string.joint_type_default) {
+ } else if (id == com.example.common_ui.R.string.joint_type_default) {
return JointType.DEFAULT;
}
return 0;
@@ -214,13 +216,13 @@ private int getSelectedJointType(int pos) {
private List getSelectedPattern(int pos) {
int id = PATTERN_TYPE_NAME_RESOURCE_IDS[pos];
- if (id == R.string.pattern_solid) {
+ if (id == com.example.common_ui.R.string.pattern_solid) {
return null;
- } else if (id == R.string.pattern_dotted) {
+ } else if (id == com.example.common_ui.R.string.pattern_dotted) {
return PATTERN_DOTTED;
- } else if (id == R.string.pattern_dashed) {
+ } else if (id == com.example.common_ui.R.string.pattern_dashed) {
return PATTERN_DASHED;
- } else if (id == R.string.pattern_mixed) {
+ } else if (id == com.example.common_ui.R.string.pattern_mixed) {
return PATTERN_MIXED;
} else {
return null;
@@ -230,9 +232,9 @@ private List getSelectedPattern(int pos) {
@Override
public void onItemSelected(AdapterView> parent, View view, int pos, long id) {
int parentId = parent.getId();
- if (parentId == R.id.strokeJointTypeSpinner) {
+ if (parentId == com.example.common_ui.R.id.strokeJointTypeSpinner) {
mutablePolygon.setStrokeJointType(getSelectedJointType(pos));
- } else if (parentId == R.id.strokePatternSpinner) {
+ } else if (parentId == com.example.common_ui.R.id.strokePatternSpinner) {
mutablePolygon.setStrokePattern(getSelectedPattern(pos));
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/PolylineDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/PolylineDemoActivity.java
similarity index 79%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/PolylineDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/PolylineDemoActivity.java
index 2aa5c1b4e..cda119abf 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/PolylineDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/PolylineDemoActivity.java
@@ -13,7 +13,7 @@
// limitations under the License.
-package com.example.mapdemo.polyline;
+package com.example.mapdemo;
import android.graphics.Color;
import android.os.Bundle;
@@ -55,7 +55,7 @@
* This shows how to draw polylines on a map.
*/
// [START maps_android_sample_polylines]
-public class PolylineDemoActivity extends AppCompatActivity
+public class PolylineDemoActivity extends SamplesBaseActivity
implements OnSeekBarChangeListener, OnItemSelectedListener, OnMapReadyCallback {
// City locations for mutable polyline.
@@ -99,67 +99,69 @@ public class PolylineDemoActivity extends AppCompatActivity
// string resource IDs as identifiers.
private static final int[] CAP_TYPE_NAME_RESOURCE_IDS = {
- R.string.cap_butt, // Default
- R.string.cap_round,
- R.string.cap_square,
- R.string.cap_image,
+ com.example.common_ui.R.string.cap_butt, // Default
+ com.example.common_ui.R.string.cap_round,
+ com.example.common_ui.R.string.cap_square,
+ com.example.common_ui.R.string.cap_image,
};
private static final int[] JOINT_TYPE_NAME_RESOURCE_IDS = {
- R.string.joint_type_default, // Default
- R.string.joint_type_bevel,
- R.string.joint_type_round,
+ com.example.common_ui.R.string.joint_type_default, // Default
+ com.example.common_ui.R.string.joint_type_bevel,
+ com.example.common_ui.R.string.joint_type_round,
};
private static final int[] PATTERN_TYPE_NAME_RESOURCE_IDS = {
- R.string.pattern_solid, // Default
- R.string.pattern_dashed,
- R.string.pattern_dotted,
- R.string.pattern_mixed,
+ com.example.common_ui.R.string.pattern_solid, // Default
+ com.example.common_ui.R.string.pattern_dashed,
+ com.example.common_ui.R.string.pattern_dotted,
+ com.example.common_ui.R.string.pattern_mixed,
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.polyline_demo);
+ setContentView(com.example.common_ui.R.layout.polyline_demo);
- hueBar = findViewById(R.id.hueSeekBar);
+ hueBar = findViewById(com.example.common_ui.R.id.hueSeekBar);
hueBar.setMax(MAX_HUE_DEGREES);
hueBar.setProgress(0);
- alphaBar = findViewById(R.id.alphaSeekBar);
+ alphaBar = findViewById(com.example.common_ui.R.id.alphaSeekBar);
alphaBar.setMax(MAX_ALPHA);
alphaBar.setProgress(MAX_ALPHA);
- widthBar = findViewById(R.id.widthSeekBar);
+ widthBar = findViewById(com.example.common_ui.R.id.widthSeekBar);
widthBar.setMax(MAX_WIDTH_PX);
widthBar.setProgress(MAX_WIDTH_PX / 2);
- startCapSpinner = findViewById(R.id.startCapSpinner);
+ startCapSpinner = findViewById(com.example.common_ui.R.id.startCapSpinner);
startCapSpinner.setAdapter(new ArrayAdapter<>(
this, android.R.layout.simple_spinner_item,
getResourceStrings(CAP_TYPE_NAME_RESOURCE_IDS)));
- endCapSpinner = findViewById(R.id.endCapSpinner);
+ endCapSpinner = findViewById(com.example.common_ui.R.id.endCapSpinner);
endCapSpinner.setAdapter(new ArrayAdapter<>(
this, android.R.layout.simple_spinner_item,
getResourceStrings(CAP_TYPE_NAME_RESOURCE_IDS)));
- jointTypeSpinner = findViewById(R.id.jointTypeSpinner);
+ jointTypeSpinner = findViewById(com.example.common_ui.R.id.jointTypeSpinner);
jointTypeSpinner.setAdapter(new ArrayAdapter<>(
this, android.R.layout.simple_spinner_item,
getResourceStrings(JOINT_TYPE_NAME_RESOURCE_IDS)));
- patternSpinner = findViewById(R.id.patternSpinner);
+ patternSpinner = findViewById(com.example.common_ui.R.id.patternSpinner);
patternSpinner.setAdapter(new ArrayAdapter<>(
this, android.R.layout.simple_spinner_item,
getResourceStrings(PATTERN_TYPE_NAME_RESOURCE_IDS)));
- clickabilityCheckbox = findViewById(R.id.toggleClickability);
+ clickabilityCheckbox = findViewById(com.example.common_ui.R.id.toggleClickability);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
// [START_EXCLUDE silent]
@@ -176,7 +178,7 @@ private String[] getResourceStrings(int[] resourceIds) {
public void onMapReady(GoogleMap map) {
// Override the default content description on the view, for accessibility mode.
- map.setContentDescription(getString(R.string.polyline_demo_description));
+ map.setContentDescription(getString(com.example.common_ui.R.string.polyline_demo_description));
// A geodesic polyline that goes around the world.
map.addPolyline(new PolylineOptions()
@@ -225,15 +227,15 @@ public void onPolylineClick(Polyline polyline) {
// [START_EXCLUDE silent]
private Cap getSelectedCap(int pos) {
int id = CAP_TYPE_NAME_RESOURCE_IDS[pos];
- if (id == R.string.cap_butt) {
+ if (id == com.example.common_ui.R.string.cap_butt) {
return new ButtCap();
- } else if (id == R.string.cap_square) {
+ } else if (id == com.example.common_ui.R.string.cap_square) {
return new SquareCap();
- } else if (id == R.string.cap_round) {
+ } else if (id == com.example.common_ui.R.string.cap_round) {
return new RoundCap();
- } else if (id == R.string.cap_image) {
+ } else if (id == com.example.common_ui.R.string.cap_image) {
return new CustomCap(
- BitmapDescriptorFactory.fromResource(R.drawable.chevron),
+ BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.chevron),
CUSTOM_CAP_IMAGE_REF_WIDTH_PX);
}
return null;
@@ -241,11 +243,11 @@ private Cap getSelectedCap(int pos) {
private int getSelectedJointType(int pos) {
int id = JOINT_TYPE_NAME_RESOURCE_IDS[pos];
- if (id == R.string.joint_type_bevel) {
+ if (id == com.example.common_ui.R.string.joint_type_bevel) {
return JointType.BEVEL;
- } else if (id == R.string.joint_type_round) {
+ } else if (id == com.example.common_ui.R.string.joint_type_round) {
return JointType.ROUND;
- } else if (id == R.string.joint_type_default) {
+ } else if (id == com.example.common_ui.R.string.joint_type_default) {
return JointType.DEFAULT;
}
return 0;
@@ -253,13 +255,13 @@ private int getSelectedJointType(int pos) {
private List getSelectedPattern(int pos) {
int id = PATTERN_TYPE_NAME_RESOURCE_IDS[pos];
- if (id == R.string.pattern_solid) {
+ if (id == com.example.common_ui.R.string.pattern_solid) {
return null;
- } else if (id == R.string.pattern_dotted) {
+ } else if (id == com.example.common_ui.R.string.pattern_dotted) {
return PATTERN_DOTTED;
- } else if (id == R.string.pattern_dashed) {
+ } else if (id == com.example.common_ui.R.string.pattern_dashed) {
return PATTERN_DASHED;
- } else if (id == R.string.pattern_mixed) {
+ } else if (id == com.example.common_ui.R.string.pattern_mixed) {
return PATTERN_MIXED;
} else {
return null;
@@ -269,13 +271,13 @@ private List getSelectedPattern(int pos) {
@Override
public void onItemSelected(AdapterView> parent, View view, int pos, long id) {
int parentId = parent.getId();
- if (parentId == R.id.startCapSpinner) {
+ if (parentId == com.example.common_ui.R.id.startCapSpinner) {
mutablePolyline.setStartCap(getSelectedCap(pos));
- } else if (parentId == R.id.endCapSpinner) {
+ } else if (parentId == com.example.common_ui.R.id.endCapSpinner) {
mutablePolyline.setEndCap(getSelectedCap(pos));
- } else if (parentId == R.id.jointTypeSpinner) {
+ } else if (parentId == com.example.common_ui.R.id.jointTypeSpinner) {
mutablePolyline.setJointType(getSelectedJointType(pos));
- } else if (parentId == R.id.patternSpinner) {
+ } else if (parentId == com.example.common_ui.R.id.patternSpinner) {
mutablePolyline.setPattern(getSelectedPattern(pos));
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/ProgrammaticDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/ProgrammaticDemoActivity.java
similarity index 92%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/ProgrammaticDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/ProgrammaticDemoActivity.java
index 558fdf6da..235215894 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/ProgrammaticDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/ProgrammaticDemoActivity.java
@@ -29,7 +29,7 @@
/**
* Demonstrates how to instantiate a SupportMapFragment programmatically and add a marker to it.
*/
-public class ProgrammaticDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class ProgrammaticDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
private static final String MAP_FRAGMENT_TAG = "map";
@@ -54,6 +54,8 @@ protected void onCreate(Bundle savedInstanceState) {
fragmentTransaction.commit();
}
mapFragment.getMapAsync(this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/RawMapViewDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/RawMapViewDemoActivity.java
similarity index 89%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/RawMapViewDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/RawMapViewDemoActivity.java
index d69a7f066..d2539a928 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/RawMapViewDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/RawMapViewDemoActivity.java
@@ -23,13 +23,16 @@
import android.os.Bundle;
-import androidx.appcompat.app.AppCompatActivity;
+import androidx.annotation.NonNull;
+
+//noinspection UnusedImport
+import com.example.common_ui.R; // <-- Keep this import
/**
* This shows how to create a simple activity with a raw MapView and add a marker to it. This
* requires forwarding all the important lifecycle methods onto MapView.
*/
-public class RawMapViewDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class RawMapViewDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
private MapView mMapView;
@@ -47,14 +50,16 @@ protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
- mMapView = (MapView) findViewById(R.id.map);
+ mMapView = findViewById(R.id.map);
mMapView.onCreate(mapViewBundle);
mMapView.getMapAsync(this);
+
+ applyInsets(mMapView);
}
@Override
- public void onSaveInstanceState(Bundle outState) {
+ public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
Bundle mapViewBundle = outState.getBundle(MAPVIEW_BUNDLE_KEY);
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/RetainMapDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/RetainMapDemoActivity.java
similarity index 85%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/RetainMapDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/RetainMapDemoActivity.java
index 026396e83..db776f876 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/RetainMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/RetainMapDemoActivity.java
@@ -29,15 +29,15 @@
* This shows how to retain a map across activity restarts (e.g., from screen rotations), which can
* be faster than relying on state serialization.
*/
-public class RetainMapDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class RetainMapDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.basic_demo);
+ setContentView(com.example.common_ui.R.layout.basic_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
if (savedInstanceState == null) {
// First incarnation of this activity.
@@ -45,6 +45,8 @@ protected void onCreate(Bundle savedInstanceState) {
}
mapFragment.getMapAsync(this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
diff --git a/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SamplesBaseActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SamplesBaseActivity.java
new file mode 100644
index 000000000..6a1518dcb
--- /dev/null
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SamplesBaseActivity.java
@@ -0,0 +1,50 @@
+// 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.
+
+package com.example.mapdemo;
+
+
+import android.os.Bundle;
+import android.view.View;
+
+import androidx.activity.EdgeToEdge;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.graphics.Insets;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.WindowInsetsCompat;
+
+public class SamplesBaseActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ EdgeToEdge.enable(this);
+ }
+
+ /**
+ * Applies insets to the container view to properly handle window insets.
+ *
+ * @param container the container view to apply insets to
+ */
+ protected static void applyInsets(View container) {
+ ViewCompat.setOnApplyWindowInsetsListener(container,
+ (view, insets) -> {
+ Insets innerPadding = insets.getInsets(WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
+ view.setPadding(innerPadding.left, innerPadding.top, innerPadding.right, innerPadding.bottom);
+ return insets;
+ }
+ );
+ }
+}
\ No newline at end of file
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/SaveStateDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SaveStateDemoActivity.java
similarity index 98%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/SaveStateDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SaveStateDemoActivity.java
index 2c32b5e57..af2c109f7 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/SaveStateDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SaveStateDemoActivity.java
@@ -38,7 +38,7 @@
* This activity shows how to save the state of a MapFragment when the activity is recreated, like
* after rotation of the device.
*/
-public class SaveStateDemoActivity extends AppCompatActivity {
+public class SaveStateDemoActivity extends SamplesBaseActivity {
/** Default marker position when the activity is first created. */
private static final LatLng DEFAULT_MARKER_POSITION = new LatLng(48.858179, 2.294576);
@@ -155,6 +155,7 @@ public void onCreate(Bundle savedInstanceState) {
}
getMapAsync(this);
+
}
@@ -215,6 +216,6 @@ public void onMarkerDragEnd(Marker marker) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.save_state_demo);
+ setContentView(com.example.common_ui.R.layout.save_state_demo);
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/SnapshotDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SnapshotDemoActivity.java
similarity index 82%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/SnapshotDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SnapshotDemoActivity.java
index 198a44b56..9bca4d771 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/SnapshotDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SnapshotDemoActivity.java
@@ -32,7 +32,7 @@
/**
* This shows how to take a snapshot of the map.
*/
-public class SnapshotDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class SnapshotDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
/**
* Note that this may be null if the Google Play services APK is not available.
@@ -44,12 +44,14 @@ public class SnapshotDemoActivity extends AppCompatActivity implements OnMapRead
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.snapshot_demo);
- mWaitForMapLoadCheckBox = (CheckBox) findViewById(R.id.wait_for_map_load);
+ setContentView(com.example.common_ui.R.layout.snapshot_demo);
+ mWaitForMapLoadCheckBox = findViewById(com.example.common_ui.R.id.wait_for_map_load);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -69,7 +71,7 @@ private void takeSnapshot() {
return;
}
- final ImageView snapshotHolder = (ImageView) findViewById(R.id.snapshot_holder);
+ final ImageView snapshotHolder = findViewById(com.example.common_ui.R.id.snapshot_holder);
final SnapshotReadyCallback callback = new SnapshotReadyCallback() {
@Override
@@ -95,7 +97,7 @@ public void onMapLoaded() {
* Called when the clear button is clicked.
*/
public void onClearScreenshot(View view) {
- ImageView snapshotHolder = (ImageView) findViewById(R.id.snapshot_holder);
+ ImageView snapshotHolder = findViewById(com.example.common_ui.R.id.snapshot_holder);
snapshotHolder.setImageDrawable(null);
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
similarity index 91%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
index 7118ee6a8..2ff30e18a 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
@@ -36,7 +36,7 @@
/**
* This shows how to create a simple activity with streetview and a map
*/
-public class SplitStreetViewPanoramaAndMapDemoActivity extends AppCompatActivity
+public class SplitStreetViewPanoramaAndMapDemoActivity extends SamplesBaseActivity
implements OnMarkerDragListener, OnStreetViewPanoramaChangeListener {
private static final String MARKER_POSITION_KEY = "MarkerPosition";
@@ -51,7 +51,7 @@ public class SplitStreetViewPanoramaAndMapDemoActivity extends AppCompatActivity
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.split_street_view_panorama_and_map_demo);
+ setContentView(com.example.common_ui.R.layout.split_street_view_panorama_and_map_demo);
final LatLng markerPosition;
if (savedInstanceState == null) {
@@ -62,7 +62,7 @@ protected void onCreate(final Bundle savedInstanceState) {
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
new OnStreetViewPanoramaReadyCallback() {
@Override
@@ -79,7 +79,7 @@ public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
});
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap map) {
@@ -87,10 +87,11 @@ public void onMapReady(GoogleMap map) {
// Creates a draggable marker. Long press to drag.
marker = map.addMarker(new MarkerOptions()
.position(markerPosition)
- .icon(BitmapDescriptorFactory.fromResource(R.drawable.pegman))
+ .icon(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.pegman))
.draggable(true));
}
});
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
similarity index 87%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
index 41d72fd3e..c529b637e 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
@@ -27,7 +27,7 @@
/**
* This shows how to create a simple activity with streetview
*/
-public class StreetViewPanoramaBasicDemoActivity extends AppCompatActivity {
+public class StreetViewPanoramaBasicDemoActivity extends SamplesBaseActivity {
// George St, Sydney
private static final LatLng SYDNEY = new LatLng(-33.87365, 151.20689);
@@ -35,11 +35,11 @@ public class StreetViewPanoramaBasicDemoActivity extends AppCompatActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.street_view_panorama_basic_demo);
+ setContentView(com.example.common_ui.R.layout.street_view_panorama_basic_demo);
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
new OnStreetViewPanoramaReadyCallback() {
@Override
@@ -51,5 +51,7 @@ public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
}
}
});
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
similarity index 88%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
index 17ffa6e03..ad03fb251 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
@@ -35,7 +35,7 @@
/**
* This shows how to listen to some {@link StreetViewPanorama} events.
*/
-public class StreetViewPanoramaEventsDemoActivity extends AppCompatActivity
+public class StreetViewPanoramaEventsDemoActivity extends SamplesBaseActivity
implements OnStreetViewPanoramaChangeListener, OnStreetViewPanoramaCameraChangeListener,
OnStreetViewPanoramaClickListener, OnStreetViewPanoramaLongClickListener {
@@ -63,16 +63,16 @@ public class StreetViewPanoramaEventsDemoActivity extends AppCompatActivity
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.street_view_panorama_events_demo);
+ setContentView(com.example.common_ui.R.layout.street_view_panorama_events_demo);
- panoChangeTimesTextView = findViewById(R.id.change_pano);
- panoCameraChangeTextView = findViewById(R.id.change_camera);
- panoClickTextView = findViewById(R.id.click_pano);
- panoLongClickTextView = findViewById(R.id.long_click_pano);
+ panoChangeTimesTextView = findViewById(com.example.common_ui.R.id.change_pano);
+ panoCameraChangeTextView = findViewById(com.example.common_ui.R.id.change_camera);
+ panoClickTextView = findViewById(com.example.common_ui.R.id.click_pano);
+ panoLongClickTextView = findViewById(com.example.common_ui.R.id.long_click_pano);
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
panorama -> {
streetViewPanorama = panorama;
@@ -91,6 +91,8 @@ protected void onCreate(final Bundle savedInstanceState) {
streetViewPanorama.setPosition(SYDNEY);
}
});
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -111,7 +113,7 @@ public void onStreetViewPanoramaClick(StreetViewPanoramaOrientation orientation)
if (point != null) {
panoClickTimes++;
panoClickTextView.setText(
- "Times clicked=" + panoClickTimes + " : " + point.toString());
+ "Times clicked=" + panoClickTimes + " : " + point);
streetViewPanorama.animateTo(
new StreetViewPanoramaCamera.Builder()
.orientation(orientation)
@@ -126,7 +128,7 @@ public void onStreetViewPanoramaLongClick(StreetViewPanoramaOrientation orientat
if (point != null) {
panoLongClickTimes++;
panoLongClickTextView.setText(
- "Times long clicked=" + panoLongClickTimes + " : " + point.toString());
+ "Times long clicked=" + panoLongClickTimes + " : " + point);
}
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
similarity index 94%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
index e0f8b847d..0b93213a1 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
@@ -36,7 +36,7 @@
* which can be adjusted dynamically
*/
-public class StreetViewPanoramaNavigationDemoActivity extends AppCompatActivity {
+public class StreetViewPanoramaNavigationDemoActivity extends SamplesBaseActivity {
// George St, Sydney
private static final LatLng SYDNEY = new LatLng(-33.87365, 151.20689);
@@ -64,11 +64,11 @@ public class StreetViewPanoramaNavigationDemoActivity extends AppCompatActivity
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.street_view_panorama_navigation_demo);
+ setContentView(com.example.common_ui.R.layout.street_view_panorama_navigation_demo);
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
new OnStreetViewPanoramaReadyCallback() {
@Override
@@ -81,7 +81,8 @@ public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
}
}
});
- mCustomDurationBar = (SeekBar) findViewById(R.id.duration_bar);
+ mCustomDurationBar = findViewById(com.example.common_ui.R.id.duration_bar);
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
/**
@@ -90,7 +91,7 @@ public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
*/
private boolean checkReady() {
if (mStreetViewPanorama == null) {
- Toast.makeText(this, R.string.panorama_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.panorama_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
similarity index 82%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
index e8916817e..435139685 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
@@ -30,12 +30,12 @@
/**
* This shows how to create an activity with static streetview (all options have been switched off)
*/
-public class StreetViewPanoramaOptionsDemoActivity extends AppCompatActivity {
+public class StreetViewPanoramaOptionsDemoActivity extends SamplesBaseActivity {
// Cole St, San Fran
private static final LatLng SAN_FRAN = new LatLng(37.765927, -122.449972);
- private static int RADIUS = 20;
+ private static final int RADIUS = 20;
private StreetViewPanorama streetViewPanorama;
@@ -52,17 +52,17 @@ public class StreetViewPanoramaOptionsDemoActivity extends AppCompatActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.street_view_panorama_options_demo);
+ setContentView(com.example.common_ui.R.layout.street_view_panorama_options_demo);
- streetNameCheckbox = findViewById(R.id.streetnames);
- navigationCheckbox = findViewById(R.id.navigation);
- zoomCheckbox = findViewById(R.id.zoom);
- panningCheckbox = findViewById(R.id.panning);
- outdoorCheckbox = findViewById(R.id.outdoor);
+ streetNameCheckbox = findViewById(com.example.common_ui.R.id.streetnames);
+ navigationCheckbox = findViewById(com.example.common_ui.R.id.navigation);
+ zoomCheckbox = findViewById(com.example.common_ui.R.id.zoom);
+ panningCheckbox = findViewById(com.example.common_ui.R.id.panning);
+ outdoorCheckbox = findViewById(com.example.common_ui.R.id.outdoor);
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
panorama -> {
streetViewPanorama = panorama;
@@ -77,6 +77,8 @@ protected void onCreate(final Bundle savedInstanceState) {
setPosition();
}
});
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
private void setPosition() {
@@ -89,7 +91,7 @@ private void setPosition() {
private boolean checkReady() {
if (streetViewPanorama == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java
index b242a8f94..28798ac0e 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java
@@ -28,7 +28,7 @@
/**
* This shows how to create a simple activity with streetview
*/
-public class StreetViewPanoramaViewDemoActivity extends AppCompatActivity {
+public class StreetViewPanoramaViewDemoActivity extends SamplesBaseActivity {
// George St, Sydney
private static final LatLng SYDNEY = new LatLng(-33.87365, 151.20689);
@@ -58,6 +58,8 @@ protected void onCreate(Bundle savedInstanceState) {
streetViewBundle = savedInstanceState.getBundle(STREETVIEW_BUNDLE_KEY);
}
streetViewPanoramaView.onCreate(streetViewBundle);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StyledMapDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StyledMapDemoActivity.java
similarity index 77%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/StyledMapDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StyledMapDemoActivity.java
index 933824778..0cc498ac0 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/StyledMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/StyledMapDemoActivity.java
@@ -38,7 +38,7 @@
/**
* This shows how to style a map with JSON.
*/
-public class StyledMapDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class StyledMapDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
private GoogleMap mMap = null;
@@ -48,16 +48,16 @@ public class StyledMapDemoActivity extends AppCompatActivity implements OnMapRea
// Stores the ID of the currently selected style, so that we can re-apply it when
// the activity restores state, for example when the device changes orientation.
- private int mSelectedStyleId = R.string.style_label_default;
+ private int mSelectedStyleId = com.example.common_ui.R.string.style_label_default;
// These are simply the string resource IDs for each of the style names. We use them
// as identifiers when choosing which style to apply.
- private int mStyleIds[] = {
- R.string.style_label_retro,
- R.string.style_label_night,
- R.string.style_label_grayscale,
- R.string.style_label_no_pois_no_transit,
- R.string.style_label_default,
+ private final int[] mStyleIds = {
+ com.example.common_ui.R.string.style_label_retro,
+ com.example.common_ui.R.string.style_label_night,
+ com.example.common_ui.R.string.style_label_grayscale,
+ com.example.common_ui.R.string.style_label_no_pois_no_transit,
+ com.example.common_ui.R.string.style_label_default,
};
private static final LatLng SYDNEY = new LatLng(-33.8688, 151.2093);
@@ -68,11 +68,13 @@ protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState != null) {
mSelectedStyleId = savedInstanceState.getInt(SELECTED_STYLE);
}
- setContentView(R.layout.styled_map_demo);
+ setContentView(com.example.common_ui.R.layout.styled_map_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -91,13 +93,13 @@ public void onMapReady(GoogleMap map) {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.styled_map, menu);
+ getMenuInflater().inflate(com.example.common_ui.R.menu.styled_map, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.menu_style_choose) {
+ if (item.getItemId() == com.example.common_ui.R.id.menu_style_choose) {
showStylesDialog();
}
return true;
@@ -118,13 +120,13 @@ private void showStylesDialog() {
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.style_choose));
+ builder.setTitle(getString(com.example.common_ui.R.string.style_choose));
builder.setItems(styleNames.toArray(new CharSequence[styleNames.size()]),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mSelectedStyleId = mStyleIds[which];
- String msg = getString(R.string.style_set_to, getString(mSelectedStyleId));
+ String msg = getString(com.example.common_ui.R.string.style_set_to, getString(mSelectedStyleId));
Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT).show();
Log.d(TAG, msg);
setSelectedStyle();
@@ -141,16 +143,16 @@ public void onClick(DialogInterface dialog, int which) {
private void setSelectedStyle() {
MapStyleOptions style;
int id = mSelectedStyleId;
- if (id == R.string.style_label_retro) {
+ if (id == com.example.common_ui.R.string.style_label_retro) {
// Sets the retro style via raw resource JSON.
- style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_retro);
- } else if (id == R.string.style_label_night) {
+ style = MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_retro);
+ } else if (id == com.example.common_ui.R.string.style_label_night) {
// Sets the night style via raw resource JSON.
- style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night);
- } else if (id == R.string.style_label_grayscale) {
+ style = MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_night);
+ } else if (id == com.example.common_ui.R.string.style_label_grayscale) {
// Sets the grayscale style via raw resource JSON.
- style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_grayscale);
- } else if (id == R.string.style_label_no_pois_no_transit) {
+ style = MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_grayscale);
+ } else if (id == com.example.common_ui.R.string.style_label_no_pois_no_transit) {
// Sets the no POIs or transit style via JSON string.
style = new MapStyleOptions("[" +
" {" +
@@ -172,7 +174,7 @@ private void setSelectedStyle() {
" ]" +
" }" +
"]");
- } else if (id == R.string.style_label_default) {
+ } else if (id == com.example.common_ui.R.string.style_label_default) {
// Removes previously set style, by setting it to null.
style = null;
} else {
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/TagsDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/TagsDemoActivity.java
similarity index 93%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/TagsDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/TagsDemoActivity.java
index ef4ebf5f5..96baa43f4 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/TagsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/TagsDemoActivity.java
@@ -47,7 +47,7 @@
/**
* This shows how to use setTag/getTag on API objects.
*/
-public class TagsDemoActivity extends AppCompatActivity implements
+public class TagsDemoActivity extends SamplesBaseActivity implements
OnCircleClickListener,
OnGroundOverlayClickListener,
OnMarkerClickListener,
@@ -94,13 +94,15 @@ public String toString() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.tags_demo);
+ setContentView(com.example.common_ui.R.layout.tags_demo);
- mTagText = (TextView) findViewById(R.id.tag_text);
+ mTagText = findViewById(com.example.common_ui.R.id.tag_text);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -131,7 +133,7 @@ public void onMapReady(GoogleMap map) {
// Override the default content description on the view, for accessibility mode.
// Ideally this string would be localised.
- map.setContentDescription(getString(R.string.tags_demo_map_description));
+ map.setContentDescription(getString(com.example.common_ui.R.string.tags_demo_map_description));
// Create bounds that include all locations of the map.
LatLngBounds bounds = new LatLngBounds.Builder()
@@ -157,7 +159,7 @@ private void addObjectsToMap() {
// A ground overlay at Sydney.
mSydneyGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions()
- .image(BitmapDescriptorFactory.fromResource(R.drawable.harbour_bridge))
+ .image(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.harbour_bridge))
.position(SYDNEY, 700000)
.clickable(true));
mSydneyGroundOverlay.setTag(new CustomTag("Sydney ground overlay"));
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/TileCoordinateDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/TileCoordinateDemoActivity.java
similarity index 75%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/TileCoordinateDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/TileCoordinateDemoActivity.java
index 72ed124b1..b2621fb7d 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/TileCoordinateDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/TileCoordinateDemoActivity.java
@@ -24,6 +24,7 @@
import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
@@ -35,16 +36,18 @@
/**
* This demonstrates tile overlay coordinates.
*/
-public class TileCoordinateDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class TileCoordinateDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.tile_coordinate_demo);
+ setContentView(com.example.common_ui.R.layout.tile_coordinate_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map));
}
@Override
@@ -59,24 +62,15 @@ private static class CoordTileProvider implements TileProvider {
private final float scaleFactor;
- private final Bitmap borderTile;
-
public CoordTileProvider(Context context) {
/* Scale factor based on density, with a 0.6 multiplier to increase tile generation
* speed */
scaleFactor = context.getResources().getDisplayMetrics().density * 0.6f;
- Paint borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
- borderPaint.setStyle(Paint.Style.STROKE);
- borderTile = Bitmap.createBitmap((int) (TILE_SIZE_DP * scaleFactor),
- (int) (TILE_SIZE_DP * scaleFactor), android.graphics.Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(borderTile);
- canvas.drawRect(0, 0, TILE_SIZE_DP * scaleFactor, TILE_SIZE_DP * scaleFactor,
- borderPaint);
}
@Override
public Tile getTile(int x, int y, int zoom) {
- Bitmap coordTile = drawTileCoords(x, y, zoom);
+ Bitmap coordTile = createTile(x, y, zoom);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
coordTile.compress(Bitmap.CompressFormat.PNG, 0, stream);
byte[] bitmapData = stream.toByteArray();
@@ -84,16 +78,23 @@ public Tile getTile(int x, int y, int zoom) {
(int) (TILE_SIZE_DP * scaleFactor), bitmapData);
}
- private Bitmap drawTileCoords(int x, int y, int zoom) {
- // Synchronize copying the bitmap to avoid a race condition in some devices.
- Bitmap copy = null;
- synchronized (borderTile) {
- copy = borderTile.copy(android.graphics.Bitmap.Config.ARGB_8888, true);
- }
- Canvas canvas = new Canvas(copy);
+ private Bitmap createTile(int x, int y, int zoom) {
+ Bitmap tile =
+ Bitmap.createBitmap(
+ (int) (TILE_SIZE_DP * scaleFactor),
+ (int) (TILE_SIZE_DP * scaleFactor),
+ Config.ARGB_8888);
+ Canvas canvas = new Canvas(tile);
+
+ // Draw the tile borders.
+ Paint borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ borderPaint.setStyle(Paint.Style.STROKE);
+ canvas.drawRect(0, 0, TILE_SIZE_DP * scaleFactor,
+ TILE_SIZE_DP * scaleFactor, borderPaint);
+
+ // Draw the tile position text.
String tileCoords = "(" + x + ", " + y + ")";
String zoomLevel = "zoom = " + zoom;
- /* Paint is not thread safe. */
Paint mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setTextAlign(Paint.Align.CENTER);
mTextPaint.setTextSize(18 * scaleFactor);
@@ -101,7 +102,8 @@ private Bitmap drawTileCoords(int x, int y, int zoom) {
TILE_SIZE_DP * scaleFactor / 2, mTextPaint);
canvas.drawText(zoomLevel, TILE_SIZE_DP * scaleFactor / 2,
TILE_SIZE_DP * scaleFactor * 2 / 3, mTextPaint);
- return copy;
+
+ return tile;
}
}
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/TileOverlayDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/TileOverlayDemoActivity.java
similarity index 90%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/TileOverlayDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/TileOverlayDemoActivity.java
index 695905675..bf7d7bf72 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/TileOverlayDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/TileOverlayDemoActivity.java
@@ -38,7 +38,7 @@
/**
* This demonstrates how to add a tile overlay to a map.
*/
-public class TileOverlayDemoActivity extends AppCompatActivity
+public class TileOverlayDemoActivity extends SamplesBaseActivity
implements OnSeekBarChangeListener, OnMapReadyCallback {
private static final int TRANSPARENCY_MAX = 100;
@@ -53,15 +53,17 @@ public class TileOverlayDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.tile_overlay_demo);
+ setContentView(com.example.common_ui.R.layout.tile_overlay_demo);
- transparencyBar = (SeekBar) findViewById(R.id.transparencySeekBar);
+ transparencyBar = findViewById(com.example.common_ui.R.id.transparencySeekBar);
transparencyBar.setMax(TRANSPARENCY_MAX);
transparencyBar.setProgress(0);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/UiSettingsDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/UiSettingsDemoActivity.java
similarity index 86%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/UiSettingsDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/UiSettingsDemoActivity.java
index efa445a12..52c31feb0 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/UiSettingsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/UiSettingsDemoActivity.java
@@ -36,7 +36,7 @@
/**
* This shows how UI settings can be toggled.
*/
-public class UiSettingsDemoActivity extends AppCompatActivity implements OnMapReadyCallback {
+public class UiSettingsDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@@ -59,14 +59,16 @@ public class UiSettingsDemoActivity extends AppCompatActivity implements OnMapRe
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.ui_settings_demo);
+ setContentView(com.example.common_ui.R.layout.ui_settings_demo);
- mMyLocationButtonCheckbox = (CheckBox) findViewById(R.id.mylocationbutton_toggle);
- mMyLocationLayerCheckbox = (CheckBox) findViewById(R.id.mylocationlayer_toggle);
+ mMyLocationButtonCheckbox = findViewById(com.example.common_ui.R.id.mylocationbutton_toggle);
+ mMyLocationLayerCheckbox = findViewById(com.example.common_ui.R.id.mylocationlayer_toggle);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
/**
@@ -84,13 +86,13 @@ public void onMapReady(GoogleMap map) {
mUiSettings = mMap.getUiSettings();
// Keep the UI Settings state in sync with the checkboxes.
- mUiSettings.setZoomControlsEnabled(isChecked(R.id.zoom_buttons_toggle));
- mUiSettings.setCompassEnabled(isChecked(R.id.compass_toggle));
- mUiSettings.setMyLocationButtonEnabled(isChecked(R.id.mylocationbutton_toggle));
- mUiSettings.setScrollGesturesEnabled(isChecked(R.id.scroll_toggle));
- mUiSettings.setZoomGesturesEnabled(isChecked(R.id.zoom_gestures_toggle));
- mUiSettings.setTiltGesturesEnabled(isChecked(R.id.tilt_toggle));
- mUiSettings.setRotateGesturesEnabled(isChecked(R.id.rotate_toggle));
+ mUiSettings.setZoomControlsEnabled(isChecked(com.example.common_ui.R.id.zoom_buttons_toggle));
+ mUiSettings.setCompassEnabled(isChecked(com.example.common_ui.R.id.compass_toggle));
+ mUiSettings.setMyLocationButtonEnabled(isChecked(com.example.common_ui.R.id.mylocationbutton_toggle));
+ mUiSettings.setScrollGesturesEnabled(isChecked(com.example.common_ui.R.id.scroll_toggle));
+ mUiSettings.setZoomGesturesEnabled(isChecked(com.example.common_ui.R.id.zoom_gestures_toggle));
+ mUiSettings.setTiltGesturesEnabled(isChecked(com.example.common_ui.R.id.tilt_toggle));
+ mUiSettings.setRotateGesturesEnabled(isChecked(com.example.common_ui.R.id.rotate_toggle));
if (ActivityCompat.checkSelfPermission(this, permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED
@@ -98,7 +100,7 @@ public void onMapReady(GoogleMap map) {
!= PackageManager.PERMISSION_GRANTED) {
return;
}
- mMap.setMyLocationEnabled(isChecked(R.id.mylocationlayer_toggle));
+ mMap.setMyLocationEnabled(isChecked(com.example.common_ui.R.id.mylocationlayer_toggle));
}
/**
@@ -107,7 +109,7 @@ public void onMapReady(GoogleMap map) {
*/
private boolean checkReady() {
if (mMap == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/VisibleRegionDemoActivity.java b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/VisibleRegionDemoActivity.java
similarity index 91%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/VisibleRegionDemoActivity.java
rename to ApiDemos/project/java-app/src/main/java/com/example/mapdemo/VisibleRegionDemoActivity.java
index 4b25d759b..4ba7e9c81 100755
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/VisibleRegionDemoActivity.java
+++ b/ApiDemos/project/java-app/src/main/java/com/example/mapdemo/VisibleRegionDemoActivity.java
@@ -37,7 +37,7 @@
* This shows how to use setPadding to allow overlays that obscure part of the map without
* obscuring the map UI or copyright notices.
*/
-public class VisibleRegionDemoActivity extends AppCompatActivity implements
+public class VisibleRegionDemoActivity extends SamplesBaseActivity implements
OnMapAndViewReadyListener.OnGlobalLayoutAndMapReadyListener {
/**
@@ -66,12 +66,14 @@ public class VisibleRegionDemoActivity extends AppCompatActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.visible_region_demo);
- mMessageView = (TextView) findViewById(R.id.message_text);
+ setContentView(com.example.common_ui.R.layout.visible_region_demo);
+ mMessageView = findViewById(com.example.common_ui.R.id.message_text);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
+
+ applyInsets(findViewById(com.example.common_ui.R.id.map_container));
}
@Override
@@ -98,7 +100,7 @@ public void onCameraIdle() {
*/
private boolean checkReady() {
if (mMap == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
@@ -136,7 +138,7 @@ public void setMorePadding(View view) {
if (!checkReady()) {
return;
}
- View mapView = (getSupportFragmentManager().findFragmentById(R.id.map)).getView();
+ View mapView = (getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map)).getView();
int left = 150;
int top = 0;
int right = mapView.getWidth() / 3;
diff --git a/ApiDemos/java/app/src/gms/AndroidManifest.xml b/ApiDemos/project/java-app/src/v3/AndroidManifest.xml
similarity index 92%
rename from ApiDemos/java/app/src/gms/AndroidManifest.xml
rename to ApiDemos/project/java-app/src/v3/AndroidManifest.xml
index 3eaef5e9b..e3bbb04f5 100644
--- a/ApiDemos/java/app/src/gms/AndroidManifest.xml
+++ b/ApiDemos/project/java-app/src/v3/AndroidManifest.xml
@@ -13,7 +13,8 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
+
-
-
-
-
+
@@ -83,6 +75,9 @@
+
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/BasicMapDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/BasicMapDemoActivity.java
similarity index 93%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/BasicMapDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/BasicMapDemoActivity.java
index 88d394411..02c7e6a7e 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/BasicMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/BasicMapDemoActivity.java
@@ -31,10 +31,10 @@ public class BasicMapDemoActivity extends AppCompatActivity implements OnMapRead
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.basic_demo);
+ setContentView(com.example.common_ui.R.layout.basic_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CameraClampingDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CameraClampingDemoActivity.java
similarity index 94%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/CameraClampingDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CameraClampingDemoActivity.java
index 5ff656f62..c4f99b1f5 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CameraClampingDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CameraClampingDemoActivity.java
@@ -69,15 +69,15 @@ public class CameraClampingDemoActivity extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.camera_clamping_demo);
+ setContentView(com.example.common_ui.R.layout.camera_clamping_demo);
mMap = null;
resetMinMaxZoom();
- mCameraTextView = (TextView) findViewById(R.id.camera_text);
+ mCameraTextView = (TextView) findViewById(com.example.common_ui.R.id.camera_text);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -103,7 +103,7 @@ public void onCameraIdle() {
*/
private boolean checkReady() {
if (mMap == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CameraDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CameraDemoActivity.java
similarity index 96%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/CameraDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CameraDemoActivity.java
index 4ef0b7edd..373d931dc 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CameraDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CameraDemoActivity.java
@@ -84,17 +84,17 @@ public class CameraDemoActivity extends AppCompatActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.camera_demo);
+ setContentView(com.example.common_ui.R.layout.camera_demo);
// [START_EXCLUDE silent]
- animateToggle = findViewById(R.id.animate);
- customDurationToggle = findViewById(R.id.duration_toggle);
- customDurationBar = findViewById(R.id.duration_bar);
+ animateToggle = findViewById(com.example.common_ui.R.id.animate);
+ customDurationToggle = findViewById(com.example.common_ui.R.id.duration_toggle);
+ customDurationBar = findViewById(com.example.common_ui.R.id.duration_bar);
updateEnabledState();
// [END_EXCLUDE]
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -131,7 +131,7 @@ public void onMapReady(GoogleMap googleMap) {
*/
private boolean checkReady() {
if (map == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CircleDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CircleDemoActivity.java
similarity index 89%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/CircleDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CircleDemoActivity.java
index 608879003..b3eacf7e5 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CircleDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CircleDemoActivity.java
@@ -95,10 +95,10 @@ public class CircleDemoActivity extends AppCompatActivity
// string resource IDs as identifiers.
private static final int[] PATTERN_TYPE_NAME_RESOURCE_IDS = {
- R.string.pattern_solid, // Default
- R.string.pattern_dashed,
- R.string.pattern_dotted,
- R.string.pattern_mixed,
+ com.example.common_ui.R.string.pattern_solid, // Default
+ com.example.common_ui.R.string.pattern_dashed,
+ com.example.common_ui.R.string.pattern_dotted,
+ com.example.common_ui.R.string.pattern_mixed,
};
private class DraggableCircle {
@@ -173,37 +173,37 @@ private static double toRadiusMeters(LatLng center, LatLng radius) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.circle_demo);
+ setContentView(com.example.common_ui.R.layout.circle_demo);
- fillHueBar = findViewById(R.id.fillHueSeekBar);
+ fillHueBar = findViewById(com.example.common_ui.R.id.fillHueSeekBar);
fillHueBar.setMax(MAX_HUE_DEGREES);
fillHueBar.setProgress(MAX_HUE_DEGREES / 2);
- fillAlphaBar = findViewById(R.id.fillAlphaSeekBar);
+ fillAlphaBar = findViewById(com.example.common_ui.R.id.fillAlphaSeekBar);
fillAlphaBar.setMax(MAX_ALPHA);
fillAlphaBar.setProgress(MAX_ALPHA / 2);
- strokeWidthBar = findViewById(R.id.strokeWidthSeekBar);
+ strokeWidthBar = findViewById(com.example.common_ui.R.id.strokeWidthSeekBar);
strokeWidthBar.setMax(MAX_WIDTH_PX);
strokeWidthBar.setProgress(MAX_WIDTH_PX / 3);
- strokeHueBar = findViewById(R.id.strokeHueSeekBar);
+ strokeHueBar = findViewById(com.example.common_ui.R.id.strokeHueSeekBar);
strokeHueBar.setMax(MAX_HUE_DEGREES);
strokeHueBar.setProgress(0);
- strokeAlphaBar = findViewById(R.id.strokeAlphaSeekBar);
+ strokeAlphaBar = findViewById(com.example.common_ui.R.id.strokeAlphaSeekBar);
strokeAlphaBar.setMax(MAX_ALPHA);
strokeAlphaBar.setProgress(MAX_ALPHA);
- strokePatternSpinner = findViewById(R.id.strokePatternSpinner);
+ strokePatternSpinner = findViewById(com.example.common_ui.R.id.strokePatternSpinner);
strokePatternSpinner.setAdapter(new ArrayAdapter<>(
- this, android.R.layout.simple_spinner_item,
+ this, android.com.example.common_ui.R.layout.simple_spinner_item,
getResourceStrings(PATTERN_TYPE_NAME_RESOURCE_IDS)));
- clickabilityCheckbox = findViewById(R.id.toggleClickability);
+ clickabilityCheckbox = findViewById(com.example.common_ui.R.id.toggleClickability);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -218,7 +218,7 @@ private String[] getResourceStrings(int[] resourceIds) {
@Override
public void onMapReady(GoogleMap googleMap) {
// Override the default content description on the view, for accessibility mode.
- googleMap.setContentDescription(getString(R.string.map_circle_description));
+ googleMap.setContentDescription(getString(com.example.common_ui.R.string.map_circle_description));
map = googleMap;
map.setOnMarkerDragListener(this);
@@ -261,13 +261,13 @@ public void onCircleClick(Circle circle) {
private List getSelectedPattern(int pos) {
switch (PATTERN_TYPE_NAME_RESOURCE_IDS[pos]) {
- case R.string.pattern_solid:
+ case com.example.common_ui.R.string.pattern_solid:
return null;
- case R.string.pattern_dotted:
+ case com.example.common_ui.R.string.pattern_dotted:
return PATTERN_DOTTED;
- case R.string.pattern_dashed:
+ case com.example.common_ui.R.string.pattern_dashed:
return PATTERN_DASHED;
- case R.string.pattern_mixed:
+ case com.example.common_ui.R.string.pattern_mixed:
return PATTERN_MIXED;
default:
return null;
@@ -276,7 +276,7 @@ private List getSelectedPattern(int pos) {
@Override
public void onItemSelected(AdapterView> parent, View view, int pos, long id) {
- if (parent.getId() == R.id.strokePatternSpinner) {
+ if (parent.getId() == com.example.common_ui.R.id.strokePatternSpinner) {
for (DraggableCircle draggableCircle : circles) {
draggableCircle.setStrokePattern(getSelectedPattern(pos));
}
@@ -345,7 +345,7 @@ private void onMarkerMoved(Marker marker) {
@Override
public void onMapLongClick(LatLng point) {
// We know the center, let's place the outline at a point 3/4 along the view.
- View view = getSupportFragmentManager().findFragmentById(R.id.map).getView();
+ View view = getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map).getView();
LatLng radiusLatLng = map.getProjection().fromScreenLocation(new Point(
view.getHeight() * 3 / 4, view.getWidth() * 3 / 4));
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
similarity index 83%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
index bd4b7f915..e7864f99f 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/CloudBasedMapStylingDemoActivity.java
@@ -41,9 +41,9 @@ protected void onCreate(Bundle savedInstanceState) {
// The underlying style the map will use has been set in the layout
// `cloud_styling_basic_demo` under the SupportMapFragment's `map:mapId` attribute.
- setContentView(R.layout.cloud_styling_basic_demo);
+ setContentView(com.example.common_ui.R.layout.cloud_styling_basic_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
setUpButtonListeners();
@@ -56,13 +56,13 @@ public void onMapReady(GoogleMap map) {
}
private void setUpButtonListeners() {
- findViewById(R.id.styling_normal_mode).setOnClickListener(
+ findViewById(com.example.common_ui.R.id.styling_normal_mode).setOnClickListener(
v -> setMapType(GoogleMap.MAP_TYPE_NORMAL));
- findViewById(R.id.styling_satellite_mode).setOnClickListener(
+ findViewById(com.example.common_ui.R.id.styling_satellite_mode).setOnClickListener(
v -> setMapType(GoogleMap.MAP_TYPE_SATELLITE));
- findViewById(R.id.styling_hybrid_mode).setOnClickListener(
+ findViewById(com.example.common_ui.R.id.styling_hybrid_mode).setOnClickListener(
v -> setMapType(GoogleMap.MAP_TYPE_HYBRID));
- findViewById(R.id.styling_terrain_mode).setOnClickListener(
+ findViewById(com.example.common_ui.R.id.styling_terrain_mode).setOnClickListener(
v -> setMapType(GoogleMap.MAP_TYPE_TERRAIN));
}
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/DemoDetails.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/DemoDetails.java
similarity index 100%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/DemoDetails.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/DemoDetails.java
diff --git a/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/DemoDetailsList.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/DemoDetailsList.java
new file mode 100755
index 000000000..b93847ca2
--- /dev/null
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/DemoDetailsList.java
@@ -0,0 +1,150 @@
+// 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.
+
+
+package com.example.mapdemo;
+
+import com.example.mapdemo.polyline.PolylineDemoActivity;
+
+/**
+ * A list of all the demos we have available.
+ */
+public final class DemoDetailsList {
+
+ /**
+ * This class should not be instantiated.
+ */
+ private DemoDetailsList() {
+ }
+
+ public static final DemoDetails[] DEMOS = {
+ new DemoDetails(com.example.common_ui.R.string.basic_map_demo_label,
+ com.example.common_ui.R.string.basic_map_demo_description,
+ BasicMapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.camera_demo_label,
+ com.example.common_ui.R.string.camera_demo_description,
+ CameraDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.camera_clamping_demo_label,
+ com.example.common_ui.R.string.camera_clamping_demo_description,
+ CameraClampingDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.circle_demo_label,
+ com.example.common_ui.R.string.circle_demo_description,
+ CircleDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.cloud_styling_label,
+ com.example.common_ui.R.string.cloud_styling_description,
+ CloudBasedMapStylingDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.events_demo_label,
+ com.example.common_ui.R.string.events_demo_description,
+ EventsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.ground_overlay_demo_label,
+ com.example.common_ui.R.string.ground_overlay_demo_description,
+ GroundOverlayDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.indoor_demo_label,
+ com.example.common_ui.R.string.indoor_demo_description,
+ IndoorDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.layers_demo_label,
+ com.example.common_ui.R.string.layers_demo_description,
+ LayersDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.lite_demo_label,
+ com.example.common_ui.R.string.lite_demo_description,
+ LiteDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.lite_list_demo_label,
+ com.example.common_ui.R.string.lite_list_demo_description,
+ LiteListDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.location_source_demo_label,
+ com.example.common_ui.R.string.location_source_demo_description,
+ LocationSourceDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.map_in_pager_demo_label,
+ com.example.common_ui.R.string.map_in_pager_demo_description,
+ MapInPagerDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.marker_demo_label,
+ com.example.common_ui.R.string.marker_demo_description,
+ MarkerDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.marker_collision_label,
+ com.example.common_ui.R.string.marker_collision_description,
+ MarkerCollisionDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.marker_close_info_window_on_retap_demo_label,
+ com.example.common_ui.R.string.marker_close_info_window_on_retap_demo_description,
+ MarkerCloseInfoWindowOnRetapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.polyline_demo_label,
+ com.example.common_ui.R.string.polyline_demo_description,
+ PolylineDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.multi_map_demo_label,
+ com.example.common_ui.R.string.multi_map_demo_description,
+ MultiMapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.my_location_demo_label,
+ com.example.common_ui.R.string.my_location_demo_description,
+ MyLocationDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.options_demo_label,
+ com.example.common_ui.R.string.options_demo_description,
+ OptionsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.polygon_demo_label,
+ com.example.common_ui.R.string.polygon_demo_description,
+ PolygonDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.polyline_demo_label,
+ com.example.common_ui.R.string.polyline_demo_description,
+ PolylineDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.programmatic_demo_label,
+ com.example.common_ui.R.string.programmatic_demo_description,
+ ProgrammaticDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.raw_map_view_demo_label,
+ com.example.common_ui.R.string.raw_map_view_demo_description,
+ RawMapViewDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.retain_map_demo_label,
+ com.example.common_ui.R.string.retain_map_demo_description,
+ RetainMapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.save_state_demo_label,
+ com.example.common_ui.R.string.save_state_demo_description,
+ SaveStateDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.snapshot_demo_label,
+ com.example.common_ui.R.string.snapshot_demo_description,
+ SnapshotDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.split_street_view_panorama_and_map_demo_label,
+ com.example.common_ui.R.string.split_street_view_panorama_and_map_demo_description,
+ SplitStreetViewPanoramaAndMapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_basic_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_basic_demo_description,
+ StreetViewPanoramaBasicDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_events_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_events_demo_description,
+ StreetViewPanoramaEventsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_navigation_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_navigation_demo_description,
+ StreetViewPanoramaNavigationDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_options_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_options_demo_description,
+ StreetViewPanoramaOptionsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.street_view_panorama_view_demo_label,
+ com.example.common_ui.R.string.street_view_panorama_view_demo_description,
+ StreetViewPanoramaViewDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.styled_map_demo_label,
+ com.example.common_ui.R.string.styled_map_demo_description,
+ StyledMapDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.tags_demo_label,
+ com.example.common_ui.R.string.tags_demo_description,
+ TagsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.tile_coordinate_demo_label,
+ com.example.common_ui.R.string.tile_coordinate_demo_description,
+ TileCoordinateDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.tile_overlay_demo_label,
+ com.example.common_ui.R.string.tile_overlay_demo_description,
+ TileOverlayDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.ui_settings_demo_label,
+ com.example.common_ui.R.string.ui_settings_demo_description,
+ UiSettingsDemoActivity.class),
+ new DemoDetails(com.example.common_ui.R.string.visible_region_demo_label,
+ com.example.common_ui.R.string.visible_region_demo_description,
+ VisibleRegionDemoActivity.class),
+ };
+}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/EventsDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/EventsDemoActivity.java
similarity index 89%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/EventsDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/EventsDemoActivity.java
index 41e79063a..25ec84b88 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/EventsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/EventsDemoActivity.java
@@ -42,13 +42,13 @@ public class EventsDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.events_demo);
+ setContentView(com.example.common_ui.R.layout.events_demo);
- tapTextView = findViewById(R.id.tap_text);
- cameraTextView = findViewById(R.id.camera_text);
+ tapTextView = findViewById(com.example.common_ui.R.id.tap_text);
+ cameraTextView = findViewById(com.example.common_ui.R.id.camera_text);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/FeatureView.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/FeatureView.java
similarity index 85%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/FeatureView.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/FeatureView.java
index b67d91dd5..a9250fe24 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/FeatureView.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/FeatureView.java
@@ -34,7 +34,7 @@ public FeatureView(Context context) {
LayoutInflater layoutInflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- layoutInflater.inflate(R.layout.feature, this);
+ layoutInflater.inflate(com.example.common_ui.R.layout.feature, this);
}
/**
@@ -43,7 +43,7 @@ public FeatureView(Context context) {
* @param titleId the resource id of the title of the demo
*/
public synchronized void setTitleId(int titleId) {
- ((TextView) (findViewById(R.id.title))).setText(titleId);
+ ((TextView) (findViewById(com.example.common_ui.R.id.title))).setText(titleId);
}
/**
@@ -52,7 +52,7 @@ public synchronized void setTitleId(int titleId) {
* @param descriptionId the resource id of the description of the demo
*/
public synchronized void setDescriptionId(int descriptionId) {
- ((TextView) (findViewById(R.id.description))).setText(descriptionId);
+ ((TextView) (findViewById(com.example.common_ui.R.id.description))).setText(descriptionId);
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/GroundOverlayDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/GroundOverlayDemoActivity.java
similarity index 90%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/GroundOverlayDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/GroundOverlayDemoActivity.java
index d5c2b61db..9939db7a0 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/GroundOverlayDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/GroundOverlayDemoActivity.java
@@ -63,14 +63,14 @@ public class GroundOverlayDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.ground_overlay_demo);
+ setContentView(com.example.common_ui.R.layout.ground_overlay_demo);
- transparencyBar = findViewById(R.id.transparencySeekBar);
+ transparencyBar = findViewById(com.example.common_ui.R.id.transparencySeekBar);
transparencyBar.setMax(TRANSPARENCY_MAX);
transparencyBar.setProgress(0);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -82,8 +82,8 @@ public void onMapReady(GoogleMap map) {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(NEWARK, 11));
images.clear();
- images.add(BitmapDescriptorFactory.fromResource(R.drawable.newark_nj_1922));
- images.add(BitmapDescriptorFactory.fromResource(R.drawable.newark_prudential_sunny));
+ images.add(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.newark_nj_1922));
+ images.add(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.newark_prudential_sunny));
// Add a small, rotated overlay that is clickable by default
// (set by the initial state of the checkbox.)
@@ -91,7 +91,7 @@ public void onMapReady(GoogleMap map) {
.image(images.get(1)).anchor(0, 1)
.position(NEAR_NEWARK, 4300f, 3025f)
.bearing(30)
- .clickable(((CheckBox) findViewById(R.id.toggleClickability)).isChecked()));
+ .clickable(((CheckBox) findViewById(com.example.common_ui.R.id.toggleClickability)).isChecked()));
// Add a large overlay at Newark on top of the smaller overlay.
groundOverlay = map.addGroundOverlay(new GroundOverlayOptions()
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/IndoorDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/IndoorDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/IndoorDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/IndoorDemoActivity.java
index 072362d51..73dea0b2a 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/IndoorDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/IndoorDemoActivity.java
@@ -42,10 +42,10 @@ public class IndoorDemoActivity extends AppCompatActivity implements OnMapReadyC
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.indoor_demo);
+ setContentView(com.example.common_ui.R.layout.indoor_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -127,7 +127,7 @@ public void onHigherLevel(View view) {
}
private void setText(String message) {
- TextView text = findViewById(R.id.top_text);
+ TextView text = findViewById(com.example.common_ui.R.id.top_text);
text.setText(message);
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/LayersDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LayersDemoActivity.java
similarity index 83%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/LayersDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LayersDemoActivity.java
index 842b4d0c3..21a8379b7 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/LayersDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LayersDemoActivity.java
@@ -71,22 +71,22 @@ public class LayersDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.layers_demo);
+ setContentView(com.example.common_ui.R.layout.layers_demo);
- mSpinner = (Spinner) findViewById(R.id.layers_spinner);
+ mSpinner = (Spinner) findViewById(com.example.common_ui.R.id.layers_spinner);
ArrayAdapter adapter = ArrayAdapter.createFromResource(
- this, R.array.layers_array, android.R.layout.simple_spinner_item);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ this, R.array.layers_array, android.com.example.common_ui.R.layout.simple_spinner_item);
+ adapter.setDropDownViewResource(android.com.example.common_ui.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(adapter);
mSpinner.setOnItemSelectedListener(this);
- mTrafficCheckbox = (CheckBox) findViewById(R.id.traffic);
- mMyLocationCheckbox = (CheckBox) findViewById(R.id.my_location);
- mBuildingsCheckbox = (CheckBox) findViewById(R.id.buildings);
- mIndoorCheckbox = (CheckBox) findViewById(R.id.indoor);
+ mTrafficCheckbox = (CheckBox) findViewById(com.example.common_ui.R.id.traffic);
+ mMyLocationCheckbox = (CheckBox) findViewById(com.example.common_ui.R.id.my_location);
+ mBuildingsCheckbox = (CheckBox) findViewById(com.example.common_ui.R.id.buildings);
+ mIndoorCheckbox = (CheckBox) findViewById(com.example.common_ui.R.id.indoor);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -102,7 +102,7 @@ public void onMapReady(GoogleMap map) {
private boolean checkReady() {
if (mMap == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
@@ -219,17 +219,17 @@ private void updateMapType() {
}
String layerName = ((String) mSpinner.getSelectedItem());
- if (layerName.equals(getString(R.string.normal))) {
+ if (layerName.equals(getString(com.example.common_ui.R.string.normal))) {
mMap.setMapType(MAP_TYPE_NORMAL);
- } else if (layerName.equals(getString(R.string.hybrid))) {
+ } else if (layerName.equals(getString(com.example.common_ui.R.string.hybrid))) {
mMap.setMapType(MAP_TYPE_HYBRID);
- } else if (layerName.equals(getString(R.string.satellite))) {
+ } else if (layerName.equals(getString(com.example.common_ui.R.string.satellite))) {
mMap.setMapType(MAP_TYPE_SATELLITE);
- } else if (layerName.equals(getString(R.string.terrain))) {
+ } else if (layerName.equals(getString(com.example.common_ui.R.string.terrain))) {
mMap.setMapType(MAP_TYPE_TERRAIN);
- } else if (layerName.equals(getString(R.string.none_map))) {
+ } else if (layerName.equals(getString(com.example.common_ui.R.string.none_map))) {
mMap.setMapType(MAP_TYPE_NONE);
} else {
Log.i("LDA", "Error setting layer with name " + layerName);
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/LiteDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LiteDemoActivity.java
similarity index 98%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/LiteDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LiteDemoActivity.java
index 99881796c..4a59466ba 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/LiteDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LiteDemoActivity.java
@@ -67,11 +67,11 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the layout
- setContentView(R.layout.lite_demo);
+ setContentView(com.example.common_ui.R.layout.lite_demo);
// Get the map and register for the ready callback
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/LiteListDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LiteListDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/LiteListDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LiteListDemoActivity.java
index 60b193ae8..15dfd4eb9 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/LiteListDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LiteListDemoActivity.java
@@ -50,13 +50,13 @@ public class LiteListDemoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.lite_list_demo);
+ setContentView(com.example.common_ui.R.layout.lite_list_demo);
mGridLayoutManager = new GridLayoutManager(this, 2);
mLinearLayoutManager = new LinearLayoutManager(this);
// Set up the RecyclerView
- mRecyclerView = findViewById(R.id.recycler_view);
+ mRecyclerView = findViewById(com.example.common_ui.R.id.recycler_view);
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
mRecyclerView.setAdapter(new MapAdapter(LIST_LOCATIONS));
@@ -73,10 +73,10 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.layout_linear:
+ case com.example.common_ui.R.id.layout_linear:
mRecyclerView.setLayoutManager(mLinearLayoutManager);
break;
- case R.id.layout_grid:
+ case com.example.common_ui.R.id.layout_grid:
mRecyclerView.setLayoutManager(mGridLayoutManager);
break;
}
@@ -101,7 +101,7 @@ private MapAdapter(NamedLocation[] locations) {
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext())
- .inflate(R.layout.lite_list_demo_row, parent, false));
+ .inflate(com.example.common_ui.R.layout.lite_list_demo_row, parent, false));
}
/**
@@ -140,8 +140,8 @@ class ViewHolder extends RecyclerView.ViewHolder implements OnMapReadyCallback {
private ViewHolder(View itemView) {
super(itemView);
layout = itemView;
- mapView = layout.findViewById(R.id.lite_listrow_map);
- title = layout.findViewById(R.id.lite_listrow_text);
+ mapView = layout.findViewById(com.example.common_ui.R.id.lite_listrow_map);
+ title = layout.findViewById(com.example.common_ui.R.id.lite_listrow_text);
if (mapView != null) {
// Initialise the MapView
mapView.onCreate(null);
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/LocationSourceDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LocationSourceDemoActivity.java
similarity index 97%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/LocationSourceDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LocationSourceDemoActivity.java
index 52b3a797f..d89155b95 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/LocationSourceDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/LocationSourceDemoActivity.java
@@ -86,12 +86,12 @@ public void onResume() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.basic_demo);
+ setContentView(com.example.common_ui.R.layout.basic_demo);
mLocationSource = new LongPressLocationSource();
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MainActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MainActivity.java
similarity index 87%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/MainActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MainActivity.java
index e308c30f2..bb9a06784 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MainActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MainActivity.java
@@ -47,7 +47,7 @@ private static class CustomArrayAdapter extends ArrayAdapter {
* @param demos An array containing the details of the demos to be displayed.
*/
public CustomArrayAdapter(Context context, DemoDetails[] demos) {
- super(context, R.layout.feature, R.id.title, demos);
+ super(context, com.example.common_ui.R.layout.feature, com.example.common_ui.R.id.title, demos);
}
@Override
@@ -76,17 +76,17 @@ public View getView(int position, View convertView, ViewGroup parent) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- ListView list = findViewById(R.id.list);
+ setContentView(com.example.common_ui.R.layout.main);
+ ListView list = findViewById(com.example.common_ui.R.id.list);
ListAdapter adapter = new CustomArrayAdapter(this, DemoDetailsList.DEMOS);
list.setAdapter(adapter);
list.setOnItemClickListener(this);
- list.setEmptyView(findViewById(R.id.empty));
+ list.setEmptyView(findViewById(com.example.common_ui.R.id.empty));
if (BuildConfig.MAPS_API_KEY.isEmpty()) {
- Toast.makeText(this, "Add your own API key in local.properties as MAPS_API_KEY=YOUR_API_KEY", Toast.LENGTH_LONG).show();
+ Toast.makeText(this, "Add your own API key in secrets.properties as MAPS_API_KEY=YOUR_API_KEY", Toast.LENGTH_LONG).show();
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MapInPagerDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MapInPagerDemoActivity.java
similarity index 91%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/MapInPagerDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MapInPagerDemoActivity.java
index ff436fc3a..5056d86bc 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MapInPagerDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MapInPagerDemoActivity.java
@@ -41,10 +41,10 @@ public class MapInPagerDemoActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.map_in_pager_demo);
+ setContentView(com.example.common_ui.R.layout.map_in_pager_demo);
mAdapter = new MyAdapter(getSupportFragmentManager());
- mPager = (ViewPager) findViewById(R.id.pager);
+ mPager = (ViewPager) findViewById(com.example.common_ui.R.id.pager);
mPager.setAdapter(mAdapter);
// This is required to avoid a black flash when the map is loaded. The flash is due
@@ -57,7 +57,7 @@ public static class TextFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- return inflater.inflate(R.layout.text_fragment, container, false);
+ return inflater.inflate(com.example.common_ui.R.layout.text_fragment, container, false);
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
similarity index 97%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
index fd2fac36f..2a7273559 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MarkerCloseInfoWindowOnRetapDemoActivity.java
@@ -52,10 +52,10 @@ public class MarkerCloseInfoWindowOnRetapDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.marker_close_info_window_on_retap_demo);
+ setContentView(com.example.common_ui.R.layout.marker_close_info_window_on_retap_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MarkerCollisionDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MarkerCollisionDemoActivity.java
similarity index 96%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/MarkerCollisionDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MarkerCollisionDemoActivity.java
index dbced934d..a4990abe6 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MarkerCollisionDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MarkerCollisionDemoActivity.java
@@ -37,10 +37,10 @@ public class MarkerCollisionDemoActivity extends AppCompatActivity implements On
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.marker_collision_demo);
+ setContentView(com.example.common_ui.R.layout.marker_collision_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MarkerDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MarkerDemoActivity.java
similarity index 89%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/MarkerDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MarkerDemoActivity.java
index fba07ed4e..79c5a1f64 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MarkerDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MarkerDemoActivity.java
@@ -97,13 +97,13 @@ class CustomInfoWindowAdapter implements InfoWindowAdapter {
private final View mContents;
CustomInfoWindowAdapter() {
- mWindow = getLayoutInflater().inflate(R.layout.custom_info_window, null);
- mContents = getLayoutInflater().inflate(R.layout.custom_info_contents, null);
+ mWindow = getLayoutInflater().inflate(com.example.common_ui.R.layout.custom_info_window, null);
+ mContents = getLayoutInflater().inflate(com.example.common_ui.R.layout.custom_info_contents, null);
}
@Override
public View getInfoWindow(Marker marker) {
- if (mOptions.getCheckedRadioButtonId() != R.id.custom_info_window) {
+ if (mOptions.getCheckedRadioButtonId() != com.example.common_ui.R.id.custom_info_window) {
// This means that getInfoContents will be called.
return null;
}
@@ -113,7 +113,7 @@ public View getInfoWindow(Marker marker) {
@Override
public View getInfoContents(Marker marker) {
- if (mOptions.getCheckedRadioButtonId() != R.id.custom_info_contents) {
+ if (mOptions.getCheckedRadioButtonId() != com.example.common_ui.R.id.custom_info_contents) {
// This means that the default info contents will be used.
return null;
}
@@ -125,31 +125,31 @@ private void render(Marker marker, View view) {
int badge;
// Use the equals() method on a Marker to check for equals. Do not use ==.
if (marker.equals(mBrisbane)) {
- badge = R.drawable.badge_qld;
+ badge = com.example.common_ui.R.drawable.badge_qld;
} else if (marker.equals(mAdelaide)) {
- badge = R.drawable.badge_sa;
+ badge = com.example.common_ui.R.drawable.badge_sa;
} else if (marker.equals(mSydney)) {
- badge = R.drawable.badge_nsw;
+ badge = com.example.common_ui.R.drawable.badge_nsw;
} else if (marker.equals(mMelbourne)) {
- badge = R.drawable.badge_victoria;
+ badge = com.example.common_ui.R.drawable.badge_victoria;
} else if (marker.equals(mPerth)) {
- badge = R.drawable.badge_wa;
+ badge = com.example.common_ui.R.drawable.badge_wa;
} else if (marker.equals(mDarwin1)) {
- badge = R.drawable.badge_nt;
+ badge = com.example.common_ui.R.drawable.badge_nt;
} else if (marker.equals(mDarwin2)) {
- badge = R.drawable.badge_nt;
+ badge = com.example.common_ui.R.drawable.badge_nt;
} else if (marker.equals(mDarwin3)) {
- badge = R.drawable.badge_nt;
+ badge = com.example.common_ui.R.drawable.badge_nt;
} else if (marker.equals(mDarwin4)) {
- badge = R.drawable.badge_nt;
+ badge = com.example.common_ui.R.drawable.badge_nt;
} else {
// Passing 0 to setImageResource will clear the image view.
badge = 0;
}
- ((ImageView) view.findViewById(R.id.badge)).setImageResource(badge);
+ ((ImageView) view.findViewById(com.example.common_ui.R.id.badge)).setImageResource(badge);
String title = marker.getTitle();
- TextView titleUi = ((TextView) view.findViewById(R.id.title));
+ TextView titleUi = ((TextView) view.findViewById(com.example.common_ui.R.id.title));
if (title != null) {
// Spannable string allows us to edit the formatting of the text.
SpannableString titleText = new SpannableString(title);
@@ -160,7 +160,7 @@ private void render(Marker marker, View view) {
}
String snippet = marker.getSnippet();
- TextView snippetUi = ((TextView) view.findViewById(R.id.snippet));
+ TextView snippetUi = ((TextView) view.findViewById(com.example.common_ui.R.id.snippet));
if (snippet != null && snippet.length() > 12) {
SpannableString snippetText = new SpannableString(snippet);
snippetText.setSpan(new ForegroundColorSpan(Color.MAGENTA), 0, 10, 0);
@@ -211,17 +211,17 @@ private void render(Marker marker, View view) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.marker_demo);
+ setContentView(com.example.common_ui.R.layout.marker_demo);
- mTopText = (TextView) findViewById(R.id.top_text);
+ mTopText = (TextView) findViewById(com.example.common_ui.R.id.top_text);
- mRotationBar = (SeekBar) findViewById(R.id.rotationSeekBar);
+ mRotationBar = (SeekBar) findViewById(com.example.common_ui.R.id.rotationSeekBar);
mRotationBar.setMax(360);
mRotationBar.setOnSeekBarChangeListener(this);
- mFlatBox = (CheckBox) findViewById(R.id.flat);
+ mFlatBox = (CheckBox) findViewById(com.example.common_ui.R.id.flat);
- mOptions = (RadioGroup) findViewById(R.id.custom_info_window_options);
+ mOptions = (RadioGroup) findViewById(com.example.common_ui.R.id.custom_info_window_options);
mOptions.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
@@ -233,7 +233,7 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
});
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
}
@@ -286,7 +286,7 @@ private void addMarkersToMap() {
.position(SYDNEY)
.title("Sydney")
.snippet("Population: 4,627,300")
- .icon(BitmapDescriptorFactory.fromResource(R.drawable.arrow))
+ .icon(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.arrow))
.infoWindowAnchor(0.5f, 0.5f));
// Creates a draggable marker. Long press to drag.
@@ -332,7 +332,7 @@ private void addMarkersToMap() {
// Vector drawable resource as a marker icon.
mMap.addMarker(new MarkerOptions()
.position(ALICE_SPRINGS)
- .icon(vectorToBitmap(R.drawable.ic_android, Color.parseColor("#A4C639")))
+ .icon(vectorToBitmap(com.example.common_ui.R.drawable.ic_android, Color.parseColor("#A4C639")))
.title("Alice Springs"));
// Creates a marker rainbow demonstrating how to create default marker icons of different
@@ -371,7 +371,7 @@ private BitmapDescriptor vectorToBitmap(@DrawableRes int id, @ColorInt int color
private boolean checkReady() {
if (mMap == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MultiMapDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MultiMapDemoActivity.java
similarity index 93%
rename from ApiDemos/java/app/src/gms/java/com/example/mapdemo/MultiMapDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MultiMapDemoActivity.java
index ea192b8b0..2ca7b1f45 100644
--- a/ApiDemos/java/app/src/gms/java/com/example/mapdemo/MultiMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MultiMapDemoActivity.java
@@ -16,7 +16,6 @@
package com.example.mapdemo;
import android.os.Bundle;
-
import androidx.appcompat.app.AppCompatActivity;
/**
@@ -27,6 +26,6 @@ public class MultiMapDemoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.multimap_demo);
+ setContentView(com.example.common_ui.R.layout.multimap_demo);
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MyLocationDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MyLocationDemoActivity.java
similarity index 97%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/MyLocationDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MyLocationDemoActivity.java
index 545dabe98..fbdacad6b 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/MyLocationDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/MyLocationDemoActivity.java
@@ -62,10 +62,10 @@ public class MyLocationDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.my_location_demo);
+ setContentView(com.example.common_ui.R.layout.my_location_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/OnMapAndViewReadyListener.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/OnMapAndViewReadyListener.java
similarity index 100%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/OnMapAndViewReadyListener.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/OnMapAndViewReadyListener.java
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/OptionsDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/OptionsDemoActivity.java
similarity index 93%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/OptionsDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/OptionsDemoActivity.java
index c068eae6d..ca78523a1 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/OptionsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/OptionsDemoActivity.java
@@ -25,6 +25,6 @@ public final class OptionsDemoActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.options_demo);
+ setContentView(com.example.common_ui.R.layout.options_demo);
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/PermissionUtils.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/PermissionUtils.java
similarity index 91%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/PermissionUtils.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/PermissionUtils.java
index e87f1bd74..ddcf6aa35 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/PermissionUtils.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/PermissionUtils.java
@@ -91,8 +91,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
finishActivity = getArguments().getBoolean(ARGUMENT_FINISH_ACTIVITY);
return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.location_permission_denied)
- .setPositiveButton(android.R.string.ok, null)
+ .setMessage(com.example.common_ui.R.string.location_permission_denied)
+ .setPositiveButton(android.com.example.common_ui.R.string.ok, null)
.create();
}
@@ -100,7 +100,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
if (finishActivity) {
- Toast.makeText(getActivity(), R.string.permission_required_toast,
+ Toast.makeText(getActivity(), com.example.common_ui.R.string.permission_required_toast,
Toast.LENGTH_SHORT).show();
getActivity().finish();
}
@@ -151,8 +151,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
finishActivity = arguments.getBoolean(ARGUMENT_FINISH_ACTIVITY);
return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.permission_rationale_location)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ .setMessage(com.example.common_ui.R.string.permission_rationale_location)
+ .setPositiveButton(android.com.example.common_ui.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// After click on Ok, request the permission.
@@ -163,7 +163,7 @@ public void onClick(DialogInterface dialog, int which) {
finishActivity = false;
}
})
- .setNegativeButton(android.R.string.cancel, null)
+ .setNegativeButton(android.com.example.common_ui.R.string.cancel, null)
.create();
}
@@ -172,7 +172,7 @@ public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
if (finishActivity) {
Toast.makeText(getActivity(),
- R.string.permission_required_toast,
+ com.example.common_ui.R.string.permission_required_toast,
Toast.LENGTH_SHORT)
.show();
getActivity().finish();
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/PolygonDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/PolygonDemoActivity.java
similarity index 83%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/PolygonDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/PolygonDemoActivity.java
index 179d318db..95fe8c333 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/PolygonDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/PolygonDemoActivity.java
@@ -77,57 +77,57 @@ public class PolygonDemoActivity extends AppCompatActivity
// string resource IDs as identifiers.
private static final int[] JOINT_TYPE_NAME_RESOURCE_IDS = {
- R.string.joint_type_default, // Default
- R.string.joint_type_bevel,
- R.string.joint_type_round,
+ com.example.common_ui.R.string.joint_type_default, // Default
+ com.example.common_ui.R.string.joint_type_bevel,
+ com.example.common_ui.R.string.joint_type_round,
};
private static final int[] PATTERN_TYPE_NAME_RESOURCE_IDS = {
- R.string.pattern_solid, // Default
- R.string.pattern_dashed,
- R.string.pattern_dotted,
- R.string.pattern_mixed,
+ com.example.common_ui.R.string.pattern_solid, // Default
+ com.example.common_ui.R.string.pattern_dashed,
+ com.example.common_ui.R.string.pattern_dotted,
+ com.example.common_ui.R.string.pattern_mixed,
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.polygon_demo);
+ setContentView(com.example.common_ui.R.layout.polygon_demo);
- fillHueBar = findViewById(R.id.fillHueSeekBar);
+ fillHueBar = findViewById(com.example.common_ui.R.id.fillHueSeekBar);
fillHueBar.setMax(MAX_HUE_DEGREES);
fillHueBar.setProgress(MAX_HUE_DEGREES / 2);
- fillAlphaBar = findViewById(R.id.fillAlphaSeekBar);
+ fillAlphaBar = findViewById(com.example.common_ui.R.id.fillAlphaSeekBar);
fillAlphaBar.setMax(MAX_ALPHA);
fillAlphaBar.setProgress(MAX_ALPHA / 2);
- strokeWidthBar = findViewById(R.id.strokeWidthSeekBar);
+ strokeWidthBar = findViewById(com.example.common_ui.R.id.strokeWidthSeekBar);
strokeWidthBar.setMax(MAX_WIDTH_PX);
strokeWidthBar.setProgress(MAX_WIDTH_PX / 3);
- strokeHueBar = findViewById(R.id.strokeHueSeekBar);
+ strokeHueBar = findViewById(com.example.common_ui.R.id.strokeHueSeekBar);
strokeHueBar.setMax(MAX_HUE_DEGREES);
strokeHueBar.setProgress(0);
- strokeAlphaBar = findViewById(R.id.strokeAlphaSeekBar);
+ strokeAlphaBar = findViewById(com.example.common_ui.R.id.strokeAlphaSeekBar);
strokeAlphaBar.setMax(MAX_ALPHA);
strokeAlphaBar.setProgress(MAX_ALPHA);
- strokeJointTypeSpinner = findViewById(R.id.strokeJointTypeSpinner);
+ strokeJointTypeSpinner = findViewById(com.example.common_ui.R.id.strokeJointTypeSpinner);
strokeJointTypeSpinner.setAdapter(new ArrayAdapter<>(
- this, android.R.layout.simple_spinner_item,
+ this, android.com.example.common_ui.R.layout.simple_spinner_item,
getResourceStrings(JOINT_TYPE_NAME_RESOURCE_IDS)));
- strokePatternSpinner = findViewById(R.id.strokePatternSpinner);
+ strokePatternSpinner = findViewById(com.example.common_ui.R.id.strokePatternSpinner);
strokePatternSpinner.setAdapter(new ArrayAdapter<>(
- this, android.R.layout.simple_spinner_item,
+ this, android.com.example.common_ui.R.layout.simple_spinner_item,
getResourceStrings(PATTERN_TYPE_NAME_RESOURCE_IDS)));
- clickabilityCheckbox = findViewById(R.id.toggleClickability);
+ clickabilityCheckbox = findViewById(com.example.common_ui.R.id.toggleClickability);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -142,7 +142,7 @@ private String[] getResourceStrings(int[] resourceIds) {
@Override
public void onMapReady(GoogleMap map) {
// Override the default content description on the view, for accessibility mode.
- map.setContentDescription(getString(R.string.polygon_demo_description));
+ map.setContentDescription(getString(com.example.common_ui.R.string.polygon_demo_description));
int fillColorArgb = Color.HSVToColor(
fillAlphaBar.getProgress(), new float[]{fillHueBar.getProgress(), 1, 1});
@@ -198,11 +198,11 @@ private List createRectangle(LatLng center, double halfWidth, double hal
private int getSelectedJointType(int pos) {
switch (JOINT_TYPE_NAME_RESOURCE_IDS[pos]) {
- case R.string.joint_type_bevel:
+ case com.example.common_ui.R.string.joint_type_bevel:
return JointType.BEVEL;
- case R.string.joint_type_round:
+ case com.example.common_ui.R.string.joint_type_round:
return JointType.ROUND;
- case R.string.joint_type_default:
+ case com.example.common_ui.R.string.joint_type_default:
return JointType.DEFAULT;
}
return 0;
@@ -210,13 +210,13 @@ private int getSelectedJointType(int pos) {
private List getSelectedPattern(int pos) {
switch (PATTERN_TYPE_NAME_RESOURCE_IDS[pos]) {
- case R.string.pattern_solid:
+ case com.example.common_ui.R.string.pattern_solid:
return null;
- case R.string.pattern_dotted:
+ case com.example.common_ui.R.string.pattern_dotted:
return PATTERN_DOTTED;
- case R.string.pattern_dashed:
+ case com.example.common_ui.R.string.pattern_dashed:
return PATTERN_DASHED;
- case R.string.pattern_mixed:
+ case com.example.common_ui.R.string.pattern_mixed:
return PATTERN_MIXED;
default:
return null;
@@ -226,10 +226,10 @@ private List getSelectedPattern(int pos) {
@Override
public void onItemSelected(AdapterView> parent, View view, int pos, long id) {
switch (parent.getId()) {
- case R.id.strokeJointTypeSpinner:
+ case com.example.common_ui.R.id.strokeJointTypeSpinner:
mutablePolygon.setStrokeJointType(getSelectedJointType(pos));
break;
- case R.id.strokePatternSpinner:
+ case com.example.common_ui.R.id.strokePatternSpinner:
mutablePolygon.setStrokePattern(getSelectedPattern(pos));
break;
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/ProgrammaticDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/ProgrammaticDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/ProgrammaticDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/ProgrammaticDemoActivity.java
index 4cc43482c..5f62bed42 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/ProgrammaticDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/ProgrammaticDemoActivity.java
@@ -49,7 +49,7 @@ protected void onCreate(Bundle savedInstanceState) {
// Then we add it using a FragmentTransaction.
FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
- fragmentTransaction.add(android.R.id.content, mapFragment, MAP_FRAGMENT_TAG);
+ fragmentTransaction.add(android.com.example.common_ui.R.id.content, mapFragment, MAP_FRAGMENT_TAG);
fragmentTransaction.commit();
}
mapFragment.getMapAsync(this);
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/RawMapViewDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/RawMapViewDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/RawMapViewDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/RawMapViewDemoActivity.java
index 75520e85e..c50c28dd5 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/RawMapViewDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/RawMapViewDemoActivity.java
@@ -37,7 +37,7 @@ public class RawMapViewDemoActivity extends AppCompatActivity implements OnMapRe
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.raw_mapview_demo);
+ setContentView(com.example.common_ui.R.layout.raw_mapview_demo);
// *** IMPORTANT ***
// MapView requires that the Bundle you pass contain _ONLY_ MapView SDK
@@ -46,7 +46,7 @@ protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
- mMapView = (MapView) findViewById(R.id.map);
+ mMapView = (MapView) findViewById(com.example.common_ui.R.id.map);
mMapView.onCreate(mapViewBundle);
mMapView.getMapAsync(this);
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/RetainMapDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/RetainMapDemoActivity.java
similarity index 93%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/RetainMapDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/RetainMapDemoActivity.java
index 65800deac..6a007efd2 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/RetainMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/RetainMapDemoActivity.java
@@ -33,10 +33,10 @@ public class RetainMapDemoActivity extends AppCompatActivity implements OnMapRea
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.basic_demo);
+ setContentView(com.example.common_ui.R.layout.basic_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
if (savedInstanceState == null) {
// First incarnation of this activity.
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/SaveStateDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/SaveStateDemoActivity.java
similarity index 99%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/SaveStateDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/SaveStateDemoActivity.java
index 26b0aa84f..d2b96aeea 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/SaveStateDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/SaveStateDemoActivity.java
@@ -214,6 +214,6 @@ public void onMarkerDragEnd(Marker marker) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.save_state_demo);
+ setContentView(com.example.common_ui.R.layout.save_state_demo);
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/SnapshotDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/SnapshotDemoActivity.java
similarity index 88%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/SnapshotDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/SnapshotDemoActivity.java
index 1d908708f..6d2538819 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/SnapshotDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/SnapshotDemoActivity.java
@@ -43,11 +43,11 @@ public class SnapshotDemoActivity extends AppCompatActivity implements OnMapRead
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.snapshot_demo);
- mWaitForMapLoadCheckBox = (CheckBox) findViewById(R.id.wait_for_map_load);
+ setContentView(com.example.common_ui.R.layout.snapshot_demo);
+ mWaitForMapLoadCheckBox = (CheckBox) findViewById(com.example.common_ui.R.id.wait_for_map_load);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -68,7 +68,7 @@ private void takeSnapshot() {
return;
}
- final ImageView snapshotHolder = (ImageView) findViewById(R.id.snapshot_holder);
+ final ImageView snapshotHolder = (ImageView) findViewById(com.example.common_ui.R.id.snapshot_holder);
final SnapshotReadyCallback callback = new SnapshotReadyCallback() {
@Override
@@ -94,7 +94,7 @@ public void onMapLoaded() {
* Called when the clear button is clicked.
*/
public void onClearScreenshot(View view) {
- ImageView snapshotHolder = (ImageView) findViewById(R.id.snapshot_holder);
+ ImageView snapshotHolder = (ImageView) findViewById(com.example.common_ui.R.id.snapshot_holder);
snapshotHolder.setImageDrawable(null);
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
index 40d92608e..f349b5330 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/SplitStreetViewPanoramaAndMapDemoActivity.java
@@ -50,7 +50,7 @@ public class SplitStreetViewPanoramaAndMapDemoActivity extends AppCompatActivity
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.split_street_view_panorama_and_map_demo);
+ setContentView(com.example.common_ui.R.layout.split_street_view_panorama_and_map_demo);
final LatLng markerPosition;
if (savedInstanceState == null) {
@@ -61,7 +61,7 @@ protected void onCreate(final Bundle savedInstanceState) {
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
new OnStreetViewPanoramaReadyCallback() {
@Override
@@ -78,7 +78,7 @@ public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
});
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap map) {
@@ -86,7 +86,7 @@ public void onMapReady(GoogleMap map) {
// Creates a draggable marker. Long press to drag.
marker = map.addMarker(new MarkerOptions()
.position(markerPosition)
- .icon(BitmapDescriptorFactory.fromResource(R.drawable.pegman))
+ .icon(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.pegman))
.draggable(true));
}
});
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
similarity index 93%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
index 7d6c9bc9d..e68ccea91 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaBasicDemoActivity.java
@@ -34,11 +34,11 @@ public class StreetViewPanoramaBasicDemoActivity extends AppCompatActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.street_view_panorama_basic_demo);
+ setContentView(com.example.common_ui.R.layout.street_view_panorama_basic_demo);
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
new OnStreetViewPanoramaReadyCallback() {
@Override
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
similarity index 91%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
index a905d8830..efd5b54b6 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaEventsDemoActivity.java
@@ -63,16 +63,16 @@ public class StreetViewPanoramaEventsDemoActivity extends AppCompatActivity
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.street_view_panorama_events_demo);
+ setContentView(com.example.common_ui.R.layout.street_view_panorama_events_demo);
- panoChangeTimesTextView = findViewById(R.id.change_pano);
- panoCameraChangeTextView = findViewById(R.id.change_camera);
- panoClickTextView = findViewById(R.id.click_pano);
- panoLongClickTextView = findViewById(R.id.long_click_pano);
+ panoChangeTimesTextView = findViewById(com.example.common_ui.R.id.change_pano);
+ panoCameraChangeTextView = findViewById(com.example.common_ui.R.id.change_camera);
+ panoClickTextView = findViewById(com.example.common_ui.R.id.click_pano);
+ panoLongClickTextView = findViewById(com.example.common_ui.R.id.long_click_pano);
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
panorama -> {
streetViewPanorama = panorama;
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
similarity index 96%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
index f7d578abd..6125d7778 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaNavigationDemoActivity.java
@@ -62,11 +62,11 @@ public class StreetViewPanoramaNavigationDemoActivity extends AppCompatActivity
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.street_view_panorama_navigation_demo);
+ setContentView(com.example.common_ui.R.layout.street_view_panorama_navigation_demo);
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
new OnStreetViewPanoramaReadyCallback() {
@Override
@@ -79,7 +79,7 @@ public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
}
}
});
- mCustomDurationBar = (SeekBar) findViewById(R.id.duration_bar);
+ mCustomDurationBar = (SeekBar) findViewById(com.example.common_ui.R.id.duration_bar);
}
/**
@@ -88,7 +88,7 @@ public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
*/
private boolean checkReady() {
if (mStreetViewPanorama == null) {
- Toast.makeText(this, R.string.panorama_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.panorama_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
similarity index 86%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
index d596fd7fc..787a73117 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaOptionsDemoActivity.java
@@ -51,17 +51,17 @@ public class StreetViewPanoramaOptionsDemoActivity extends AppCompatActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.street_view_panorama_options_demo);
+ setContentView(com.example.common_ui.R.layout.street_view_panorama_options_demo);
- streetNameCheckbox = findViewById(R.id.streetnames);
- navigationCheckbox = findViewById(R.id.navigation);
- zoomCheckbox = findViewById(R.id.zoom);
- panningCheckbox = findViewById(R.id.panning);
- outdoorCheckbox = findViewById(R.id.outdoor);
+ streetNameCheckbox = findViewById(com.example.common_ui.R.id.streetnames);
+ navigationCheckbox = findViewById(com.example.common_ui.R.id.navigation);
+ zoomCheckbox = findViewById(com.example.common_ui.R.id.zoom);
+ panningCheckbox = findViewById(com.example.common_ui.R.id.panning);
+ outdoorCheckbox = findViewById(com.example.common_ui.R.id.outdoor);
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
- getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
+ getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
panorama -> {
streetViewPanorama = panorama;
@@ -88,7 +88,7 @@ private void setPosition() {
private boolean checkReady() {
if (streetViewPanorama == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java
similarity index 100%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StreetViewPanoramaViewDemoActivity.java
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StyledMapDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StyledMapDemoActivity.java
similarity index 82%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/StyledMapDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StyledMapDemoActivity.java
index dd08bf767..23246cef7 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/StyledMapDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/StyledMapDemoActivity.java
@@ -47,16 +47,16 @@ public class StyledMapDemoActivity extends AppCompatActivity implements OnMapRea
// Stores the ID of the currently selected style, so that we can re-apply it when
// the activity restores state, for example when the device changes orientation.
- private int mSelectedStyleId = R.string.style_label_default;
+ private int mSelectedStyleId = com.example.common_ui.R.string.style_label_default;
// These are simply the string resource IDs for each of the style names. We use them
// as identifiers when choosing which style to apply.
private int mStyleIds[] = {
- R.string.style_label_retro,
- R.string.style_label_night,
- R.string.style_label_grayscale,
- R.string.style_label_no_pois_no_transit,
- R.string.style_label_default,
+ com.example.common_ui.R.string.style_label_retro,
+ com.example.common_ui.R.string.style_label_night,
+ com.example.common_ui.R.string.style_label_grayscale,
+ com.example.common_ui.R.string.style_label_no_pois_no_transit,
+ com.example.common_ui.R.string.style_label_default,
};
private static final LatLng SYDNEY = new LatLng(-33.8688, 151.2093);
@@ -67,10 +67,10 @@ protected void onCreate(Bundle savedInstanceState) {
if (savedInstanceState != null) {
mSelectedStyleId = savedInstanceState.getInt(SELECTED_STYLE);
}
- setContentView(R.layout.styled_map_demo);
+ setContentView(com.example.common_ui.R.layout.styled_map_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -96,7 +96,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.menu_style_choose) {
+ if (item.getItemId() == com.example.common_ui.R.id.menu_style_choose) {
showStylesDialog();
}
return true;
@@ -117,13 +117,13 @@ private void showStylesDialog() {
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.style_choose));
+ builder.setTitle(getString(com.example.common_ui.R.string.style_choose));
builder.setItems(styleNames.toArray(new CharSequence[styleNames.size()]),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mSelectedStyleId = mStyleIds[which];
- String msg = getString(R.string.style_set_to, getString(mSelectedStyleId));
+ String msg = getString(com.example.common_ui.R.string.style_set_to, getString(mSelectedStyleId));
Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT).show();
Log.d(TAG, msg);
setSelectedStyle();
@@ -140,19 +140,19 @@ public void onClick(DialogInterface dialog, int which) {
private void setSelectedStyle() {
MapStyleOptions style;
switch (mSelectedStyleId) {
- case R.string.style_label_retro:
+ case com.example.common_ui.R.string.style_label_retro:
// Sets the retro style via raw resource JSON.
- style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_retro);
+ style = MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_retro);
break;
- case R.string.style_label_night:
+ case com.example.common_ui.R.string.style_label_night:
// Sets the night style via raw resource JSON.
- style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_night);
+ style = MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_night);
break;
- case R.string.style_label_grayscale:
+ case com.example.common_ui.R.string.style_label_grayscale:
// Sets the grayscale style via raw resource JSON.
- style = MapStyleOptions.loadRawResourceStyle(this, R.raw.mapstyle_grayscale);
+ style = MapStyleOptions.loadRawResourceStyle(this, com.example.common_ui.R.raw.mapstyle_grayscale);
break;
- case R.string.style_label_no_pois_no_transit:
+ case com.example.common_ui.R.string.style_label_no_pois_no_transit:
// Sets the no POIs or transit style via JSON string.
style = new MapStyleOptions("[" +
" {" +
@@ -175,7 +175,7 @@ private void setSelectedStyle() {
" }" +
"]");
break;
- case R.string.style_label_default:
+ case com.example.common_ui.R.string.style_label_default:
// Removes previously set style, by setting it to null.
style = null;
break;
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/TagsDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/TagsDemoActivity.java
similarity index 95%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/TagsDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/TagsDemoActivity.java
index fd0228294..9d3e7c5c5 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/TagsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/TagsDemoActivity.java
@@ -92,12 +92,12 @@ public String toString() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.tags_demo);
+ setContentView(com.example.common_ui.R.layout.tags_demo);
- mTagText = (TextView) findViewById(R.id.tag_text);
+ mTagText = (TextView) findViewById(com.example.common_ui.R.id.tag_text);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
}
@@ -129,7 +129,7 @@ public void onMapReady(GoogleMap map) {
// Override the default content description on the view, for accessibility mode.
// Ideally this string would be localised.
- map.setContentDescription(getString(R.string.tags_demo_map_description));
+ map.setContentDescription(getString(com.example.common_ui.R.string.tags_demo_map_description));
// Create bounds that include all locations of the map.
LatLngBounds bounds = new LatLngBounds.Builder()
@@ -155,7 +155,7 @@ private void addObjectsToMap() {
// A ground overlay at Sydney.
mSydneyGroundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions()
- .image(BitmapDescriptorFactory.fromResource(R.drawable.harbour_bridge))
+ .image(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.harbour_bridge))
.position(SYDNEY, 700000)
.clickable(true));
mSydneyGroundOverlay.setTag(new CustomTag("Sydney ground overlay"));
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/TileCoordinateDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/TileCoordinateDemoActivity.java
similarity index 77%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/TileCoordinateDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/TileCoordinateDemoActivity.java
index 23ad60062..6de5ed6c2 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/TileCoordinateDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/TileCoordinateDemoActivity.java
@@ -24,6 +24,7 @@
import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
@@ -39,10 +40,10 @@ public class TileCoordinateDemoActivity extends AppCompatActivity implements OnM
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.tile_coordinate_demo);
+ setContentView(com.example.common_ui.R.layout.tile_coordinate_demo);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -58,24 +59,15 @@ private static class CoordTileProvider implements TileProvider {
private final float mScaleFactor;
- private final Bitmap mBorderTile;
-
public CoordTileProvider(Context context) {
/* Scale factor based on density, with a 0.6 multiplier to increase tile generation
* speed */
mScaleFactor = context.getResources().getDisplayMetrics().density * 0.6f;
- Paint borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
- borderPaint.setStyle(Paint.Style.STROKE);
- mBorderTile = Bitmap.createBitmap((int) (TILE_SIZE_DP * mScaleFactor),
- (int) (TILE_SIZE_DP * mScaleFactor), android.graphics.Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(mBorderTile);
- canvas.drawRect(0, 0, TILE_SIZE_DP * mScaleFactor, TILE_SIZE_DP * mScaleFactor,
- borderPaint);
}
@Override
public Tile getTile(int x, int y, int zoom) {
- Bitmap coordTile = drawTileCoords(x, y, zoom);
+ Bitmap coordTile = createTile(x, y, zoom);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
coordTile.compress(Bitmap.CompressFormat.PNG, 0, stream);
byte[] bitmapData = stream.toByteArray();
@@ -83,16 +75,23 @@ public Tile getTile(int x, int y, int zoom) {
(int) (TILE_SIZE_DP * mScaleFactor), bitmapData);
}
- private Bitmap drawTileCoords(int x, int y, int zoom) {
- // Synchronize copying the bitmap to avoid a race condition in some devices.
- Bitmap copy = null;
- synchronized (mBorderTile) {
- copy = mBorderTile.copy(android.graphics.Bitmap.Config.ARGB_8888, true);
- }
- Canvas canvas = new Canvas(copy);
+ private Bitmap createTile(int x, int y, int zoom) {
+ Bitmap tile =
+ Bitmap.createBitmap(
+ (int) (TILE_SIZE_DP * mScaleFactor),
+ (int) (TILE_SIZE_DP * mScaleFactor),
+ Config.ARGB_8888);
+ Canvas canvas = new Canvas(tile);
+
+ // Draw the tile borders.
+ Paint borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ borderPaint.setStyle(Paint.Style.STROKE);
+ canvas.drawRect(0, 0, TILE_SIZE_DP * mScaleFactor,
+ TILE_SIZE_DP * mScaleFactor, borderPaint);
+
+ // Draw the tile position text.
String tileCoords = "(" + x + ", " + y + ")";
String zoomLevel = "zoom = " + zoom;
- /* Paint is not thread safe. */
Paint mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTextPaint.setTextAlign(Paint.Align.CENTER);
mTextPaint.setTextSize(18 * mScaleFactor);
@@ -100,7 +99,8 @@ private Bitmap drawTileCoords(int x, int y, int zoom) {
TILE_SIZE_DP * mScaleFactor / 2, mTextPaint);
canvas.drawText(zoomLevel, TILE_SIZE_DP * mScaleFactor / 2,
TILE_SIZE_DP * mScaleFactor * 2 / 3, mTextPaint);
- return copy;
+
+ return tile;
}
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/TileOverlayDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/TileOverlayDemoActivity.java
similarity index 94%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/TileOverlayDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/TileOverlayDemoActivity.java
index 24319f0ef..70592188d 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/TileOverlayDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/TileOverlayDemoActivity.java
@@ -53,14 +53,14 @@ public class TileOverlayDemoActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.tile_overlay_demo);
+ setContentView(com.example.common_ui.R.layout.tile_overlay_demo);
- mTransparencyBar = (SeekBar) findViewById(R.id.transparencySeekBar);
+ mTransparencyBar = (SeekBar) findViewById(com.example.common_ui.R.id.transparencySeekBar);
mTransparencyBar.setMax(TRANSPARENCY_MAX);
mTransparencyBar.setProgress(0);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/UiSettingsDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/UiSettingsDemoActivity.java
similarity index 87%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/UiSettingsDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/UiSettingsDemoActivity.java
index b7021bd53..c9eaeb1ef 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/UiSettingsDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/UiSettingsDemoActivity.java
@@ -59,13 +59,13 @@ public class UiSettingsDemoActivity extends AppCompatActivity implements OnMapRe
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.ui_settings_demo);
+ setContentView(com.example.common_ui.R.layout.ui_settings_demo);
- mMyLocationButtonCheckbox = (CheckBox) findViewById(R.id.mylocationbutton_toggle);
- mMyLocationLayerCheckbox = (CheckBox) findViewById(R.id.mylocationlayer_toggle);
+ mMyLocationButtonCheckbox = (CheckBox) findViewById(com.example.common_ui.R.id.mylocationbutton_toggle);
+ mMyLocationLayerCheckbox = (CheckBox) findViewById(com.example.common_ui.R.id.mylocationlayer_toggle);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -83,20 +83,20 @@ public void onMapReady(GoogleMap map) {
mUiSettings = mMap.getUiSettings();
// Keep the UI Settings state in sync with the checkboxes.
- mUiSettings.setZoomControlsEnabled(isChecked(R.id.zoom_buttons_toggle));
- mUiSettings.setCompassEnabled(isChecked(R.id.compass_toggle));
- mUiSettings.setMyLocationButtonEnabled(isChecked(R.id.mylocationbutton_toggle));
- mUiSettings.setScrollGesturesEnabled(isChecked(R.id.scroll_toggle));
- mUiSettings.setZoomGesturesEnabled(isChecked(R.id.zoom_gestures_toggle));
- mUiSettings.setTiltGesturesEnabled(isChecked(R.id.tilt_toggle));
- mUiSettings.setRotateGesturesEnabled(isChecked(R.id.rotate_toggle));
+ mUiSettings.setZoomControlsEnabled(isChecked(com.example.common_ui.R.id.zoom_buttons_toggle));
+ mUiSettings.setCompassEnabled(isChecked(com.example.common_ui.R.id.compass_toggle));
+ mUiSettings.setMyLocationButtonEnabled(isChecked(com.example.common_ui.R.id.mylocationbutton_toggle));
+ mUiSettings.setScrollGesturesEnabled(isChecked(com.example.common_ui.R.id.scroll_toggle));
+ mUiSettings.setZoomGesturesEnabled(isChecked(com.example.common_ui.R.id.zoom_gestures_toggle));
+ mUiSettings.setTiltGesturesEnabled(isChecked(com.example.common_ui.R.id.tilt_toggle));
+ mUiSettings.setRotateGesturesEnabled(isChecked(com.example.common_ui.R.id.rotate_toggle));
if (ActivityCompat.checkSelfPermission(this, permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED) {
return;
}
- mMap.setMyLocationEnabled(isChecked(R.id.mylocationlayer_toggle));
+ mMap.setMyLocationEnabled(isChecked(com.example.common_ui.R.id.mylocationlayer_toggle));
}
/**
@@ -105,7 +105,7 @@ public void onMapReady(GoogleMap map) {
*/
private boolean checkReady() {
if (mMap == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/VisibleRegionDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/VisibleRegionDemoActivity.java
similarity index 94%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/VisibleRegionDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/VisibleRegionDemoActivity.java
index 81bc31a18..41ede6037 100755
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/VisibleRegionDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/VisibleRegionDemoActivity.java
@@ -65,11 +65,11 @@ public class VisibleRegionDemoActivity extends AppCompatActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.visible_region_demo);
- mMessageView = (TextView) findViewById(R.id.message_text);
+ setContentView(com.example.common_ui.R.layout.visible_region_demo);
+ mMessageView = (TextView) findViewById(com.example.common_ui.R.id.message_text);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
new OnMapAndViewReadyListener(mapFragment, this);
}
@@ -97,7 +97,7 @@ public void onCameraIdle() {
*/
private boolean checkReady() {
if (mMap == null) {
- Toast.makeText(this, R.string.map_not_ready, Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, com.example.common_ui.R.string.map_not_ready, Toast.LENGTH_SHORT).show();
return false;
}
return true;
@@ -135,7 +135,7 @@ public void setMorePadding(View view) {
if (!checkReady()) {
return;
}
- View mapView = (getSupportFragmentManager().findFragmentById(R.id.map)).getView();
+ View mapView = (getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map)).getView();
int left = 150;
int top = 0;
int right = mapView.getWidth() / 3;
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/anim/AnimationManager.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/anim/AnimationManager.java
similarity index 100%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/anim/AnimationManager.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/anim/AnimationManager.java
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/model/MoveDirection.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/model/MoveDirection.java
similarity index 100%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/model/MoveDirection.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/model/MoveDirection.java
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineCapControlFragment.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineCapControlFragment.java
similarity index 66%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineCapControlFragment.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineCapControlFragment.java
index 3979037b9..cdde9c609 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineCapControlFragment.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineCapControlFragment.java
@@ -54,35 +54,35 @@ public class PolylineCapControlFragment extends PolylineControlFragment implemen
private RadioGroup endCapRadioGroup;
public PolylineCapControlFragment() {
- radioIdToStartCap.put(R.id.start_cap_radio_butt, new ButtCap());
- radioIdToStartCap.put(R.id.start_cap_radio_square, new SquareCap());
- radioIdToStartCap.put(R.id.start_cap_radio_round, new RoundCap());
+ radioIdToStartCap.put(com.example.common_ui.R.id.start_cap_radio_butt, new ButtCap());
+ radioIdToStartCap.put(com.example.common_ui.R.id.start_cap_radio_square, new SquareCap());
+ radioIdToStartCap.put(com.example.common_ui.R.id.start_cap_radio_round, new RoundCap());
radioIdToStartCap.put(
- R.id.start_cap_radio_custom_chevron,
- new CustomCap(BitmapDescriptorFactory.fromResource(R.drawable.chevron),
+ com.example.common_ui.R.id.start_cap_radio_custom_chevron,
+ new CustomCap(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.chevron),
CHEVRON_REF_WIDTH));
radioIdToStartCap.put(
- R.id.start_cap_radio_custom_ook,
- new CustomCap(BitmapDescriptorFactory.fromResource(R.drawable.ook), OOK_REF_WIDTH));
+ com.example.common_ui.R.id.start_cap_radio_custom_ook,
+ new CustomCap(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.ook), OOK_REF_WIDTH));
- radioIdToEndCap.put(R.id.end_cap_radio_butt, new ButtCap());
- radioIdToEndCap.put(R.id.end_cap_radio_square, new SquareCap());
- radioIdToEndCap.put(R.id.end_cap_radio_round, new RoundCap());
+ radioIdToEndCap.put(com.example.common_ui.R.id.end_cap_radio_butt, new ButtCap());
+ radioIdToEndCap.put(com.example.common_ui.R.id.end_cap_radio_square, new SquareCap());
+ radioIdToEndCap.put(com.example.common_ui.R.id.end_cap_radio_round, new RoundCap());
radioIdToEndCap.put(
- R.id.end_cap_radio_custom_chevron,
- new CustomCap(BitmapDescriptorFactory.fromResource(R.drawable.chevron),
+ com.example.common_ui.R.id.end_cap_radio_custom_chevron,
+ new CustomCap(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.chevron),
CHEVRON_REF_WIDTH));
radioIdToEndCap.put(
- R.id.end_cap_radio_custom_ook,
- new CustomCap(BitmapDescriptorFactory.fromResource(R.drawable.ook), OOK_REF_WIDTH));
+ com.example.common_ui.R.id.end_cap_radio_custom_ook,
+ new CustomCap(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.ook), OOK_REF_WIDTH));
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.polyline_cap_control_fragment, container, false);
+ View view = inflater.inflate(com.example.common_ui.R.layout.polyline_cap_control_fragment, container, false);
- startCapRadioGroup = view.findViewById(R.id.start_cap_radio);
- endCapRadioGroup = view.findViewById(R.id.end_cap_radio);
+ startCapRadioGroup = view.findViewById(com.example.common_ui.R.id.start_cap_radio);
+ endCapRadioGroup = view.findViewById(com.example.common_ui.R.id.end_cap_radio);
startCapRadioGroup.setOnCheckedChangeListener(this);
endCapRadioGroup.setOnCheckedChangeListener(this);
@@ -96,12 +96,12 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
}
int groupId = group.getId();
- if (groupId == R.id.start_cap_radio) {
+ if (groupId == com.example.common_ui.R.id.start_cap_radio) {
Cap startCap = radioIdToStartCap.get(checkedId);
if (startCap != null) {
polyline.setStartCap(startCap);
}
- } else if (groupId == R.id.end_cap_radio) {
+ } else if (groupId == com.example.common_ui.R.id.end_cap_radio) {
Cap endCap = radioIdToEndCap.get(checkedId);
if (endCap != null) {
polyline.setEndCap(endCap);
@@ -128,16 +128,16 @@ public void refresh() {
}
Cap startCap = polyline.getStartCap();
if (startCap instanceof ButtCap) {
- startCapRadioGroup.check(R.id.start_cap_radio_butt);
+ startCapRadioGroup.check(com.example.common_ui.R.id.start_cap_radio_butt);
} else if (startCap instanceof SquareCap) {
- startCapRadioGroup.check(R.id.start_cap_radio_square);
+ startCapRadioGroup.check(com.example.common_ui.R.id.start_cap_radio_square);
} else if (startCap instanceof RoundCap) {
- startCapRadioGroup.check(R.id.start_cap_radio_round);
+ startCapRadioGroup.check(com.example.common_ui.R.id.start_cap_radio_round);
} else if (startCap instanceof CustomCap) {
startCapRadioGroup.check(
isOok((CustomCap) startCap)
- ? R.id.start_cap_radio_custom_ook
- : R.id.start_cap_radio_custom_chevron);
+ ? com.example.common_ui.R.id.start_cap_radio_custom_ook
+ : com.example.common_ui.R.id.start_cap_radio_custom_chevron);
} else {
startCapRadioGroup.clearCheck();
}
@@ -147,16 +147,16 @@ public void refresh() {
}
Cap endCap = polyline.getEndCap();
if (endCap instanceof ButtCap) {
- endCapRadioGroup.check(R.id.end_cap_radio_butt);
+ endCapRadioGroup.check(com.example.common_ui.R.id.end_cap_radio_butt);
} else if (endCap instanceof SquareCap) {
- endCapRadioGroup.check(R.id.end_cap_radio_square);
+ endCapRadioGroup.check(com.example.common_ui.R.id.end_cap_radio_square);
} else if (endCap instanceof RoundCap) {
- endCapRadioGroup.check(R.id.end_cap_radio_round);
+ endCapRadioGroup.check(com.example.common_ui.R.id.end_cap_radio_round);
} else if (endCap instanceof CustomCap) {
endCapRadioGroup.check(
isOok((CustomCap) endCap)
- ? R.id.end_cap_radio_custom_ook
- : R.id.end_cap_radio_custom_chevron);
+ ? com.example.common_ui.R.id.end_cap_radio_custom_ook
+ : com.example.common_ui.R.id.end_cap_radio_custom_chevron);
} else {
endCapRadioGroup.clearCheck();
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineColorControlFragment.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineColorControlFragment.java
similarity index 89%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineColorControlFragment.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineColorControlFragment.java
index e3368ee87..6dd3f6d1e 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineColorControlFragment.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineColorControlFragment.java
@@ -37,17 +37,17 @@ public class PolylineColorControlFragment extends PolylineControlFragment implem
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.polyline_color_control_fragment, container, false);
+ View view = inflater.inflate(com.example.common_ui.R.layout.polyline_color_control_fragment, container, false);
- alphaBar = view.findViewById(R.id.alphaSeekBar);
+ alphaBar = view.findViewById(com.example.common_ui.R.id.alphaSeekBar);
alphaBar.setMax(ALPHA_MAX);
alphaBar.setOnSeekBarChangeListener(this);
- hueBar = view.findViewById(R.id.hueSeekBar);
+ hueBar = view.findViewById(com.example.common_ui.R.id.hueSeekBar);
hueBar.setMax(HUE_MAX);
hueBar.setOnSeekBarChangeListener(this);
- argbTextView = (TextView) view.findViewById(R.id.argbTextView);
+ argbTextView = (TextView) view.findViewById(com.example.common_ui.R.id.argbTextView);
return view;
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineControlFragment.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineControlFragment.java
similarity index 100%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineControlFragment.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineControlFragment.java
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineControlFragmentPagerAdapter.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineControlFragmentPagerAdapter.java
similarity index 100%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineControlFragmentPagerAdapter.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineControlFragmentPagerAdapter.java
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineDemoActivity.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineDemoActivity.java
similarity index 92%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineDemoActivity.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineDemoActivity.java
index 8703f043c..327b06ca0 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineDemoActivity.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineDemoActivity.java
@@ -72,22 +72,22 @@ public class PolylineDemoActivity extends AppCompatActivity implements
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.polyline_demo);
+ setContentView(com.example.common_ui.R.layout.polyline_demo);
pagerAdapter =
new PolylineControlFragmentPagerAdapter(
getSupportFragmentManager(), /* isLiteMode= */ false);
- pager = findViewById(R.id.pager);
+ pager = findViewById(com.example.common_ui.R.id.pager);
pager.setAdapter(pagerAdapter);
// onPageSelected(0) isn't invoked once views are ready, so post a Runnable to
// refreshControlPanel() for the first time instead...
pager.post(this::refreshControlPanel);
- polylineRadio = findViewById(R.id.polyline_radio);
+ polylineRadio = findViewById(com.example.common_ui.R.id.polyline_radio);
SupportMapFragment mapFragment =
- (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
+ (SupportMapFragment) getSupportFragmentManager().findFragmentById(com.example.common_ui.R.id.map);
mapFragment.getMapAsync(this);
}
@@ -149,7 +149,7 @@ public void onMapReady(GoogleMap map) {
map.moveCamera(CameraUpdateFactory.newLatLng(SYDNEY));
selectedPolyline = australiaPolyline;
- polylineRadio.check(R.id.polyline_radio_australia);
+ polylineRadio.check(com.example.common_ui.R.id.polyline_radio_australia);
pager.addOnPageChangeListener(this);
polylineRadio.setOnCheckedChangeListener(this);
@@ -168,13 +168,13 @@ public void onPolylineClick(Polyline polyline) {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
- if (checkedId == R.id.polyline_radio_australia) {
+ if (checkedId == com.example.common_ui.R.id.polyline_radio_australia) {
selectedPolyline = australiaPolyline;
- } else if (checkedId == R.id.polyline_radio_sydney) {
+ } else if (checkedId == com.example.common_ui.R.id.polyline_radio_sydney) {
selectedPolyline = sydneyPolyline;
- } else if (checkedId == R.id.polyline_radio_melbourne) {
+ } else if (checkedId == com.example.common_ui.R.id.polyline_radio_melbourne) {
selectedPolyline = melbournePolyline;
- } else if (checkedId == R.id.polyline_radio_world) {
+ } else if (checkedId == com.example.common_ui.R.id.polyline_radio_world) {
selectedPolyline = worldPolyline;
}
refreshControlPanel();
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineJointControlFragment.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineJointControlFragment.java
similarity index 77%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineJointControlFragment.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineJointControlFragment.java
index 014247286..602904281 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineJointControlFragment.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineJointControlFragment.java
@@ -37,15 +37,15 @@ public class PolylineJointControlFragment extends PolylineControlFragment implem
private RadioGroup jointRadioGroup;
public PolylineJointControlFragment() {
- radioIdToJointType.put(R.id.joint_radio_default, JointType.DEFAULT);
- radioIdToJointType.put(R.id.joint_radio_bevel, JointType.BEVEL);
- radioIdToJointType.put(R.id.joint_radio_round, JointType.ROUND);
+ radioIdToJointType.put(com.example.common_ui.R.id.joint_radio_default, JointType.DEFAULT);
+ radioIdToJointType.put(com.example.common_ui.R.id.joint_radio_bevel, JointType.BEVEL);
+ radioIdToJointType.put(com.example.common_ui.R.id.joint_radio_round, JointType.ROUND);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.polyline_joint_control_fragment, container, false);
- jointRadioGroup = view.findViewById(R.id.joint_radio);
+ View view = inflater.inflate(com.example.common_ui.R.layout.polyline_joint_control_fragment, container, false);
+ jointRadioGroup = view.findViewById(com.example.common_ui.R.id.joint_radio);
jointRadioGroup.setOnCheckedChangeListener(this);
return view;
}
@@ -78,13 +78,13 @@ public void refresh() {
switch (polyline.getJointType()) {
case JointType.DEFAULT:
- jointRadioGroup.check(R.id.joint_radio_default);
+ jointRadioGroup.check(com.example.common_ui.R.id.joint_radio_default);
break;
case JointType.BEVEL:
- jointRadioGroup.check(R.id.joint_radio_bevel);
+ jointRadioGroup.check(com.example.common_ui.R.id.joint_radio_bevel);
break;
case JointType.ROUND:
- jointRadioGroup.check(R.id.joint_radio_round);
+ jointRadioGroup.check(com.example.common_ui.R.id.joint_radio_round);
break;
default:
jointRadioGroup.clearCheck();
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineOtherOptionsControlFragment.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineOtherOptionsControlFragment.java
similarity index 84%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineOtherOptionsControlFragment.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineOtherOptionsControlFragment.java
index cd0391455..42982f1ce 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineOtherOptionsControlFragment.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineOtherOptionsControlFragment.java
@@ -34,12 +34,12 @@ public class PolylineOtherOptionsControlFragment extends PolylineControlFragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.polyline_other_options_control_fragment, container, false);
- clickabilityCheckBox = view.findViewById(R.id.clickabilityCheckBox);
+ View view = inflater.inflate(com.example.common_ui.R.layout.polyline_other_options_control_fragment, container, false);
+ clickabilityCheckBox = view.findViewById(com.example.common_ui.R.id.clickabilityCheckBox);
clickabilityCheckBox.setOnClickListener(this);
- geodesicCheckBox = view.findViewById(R.id.geodesicCheckBox);
+ geodesicCheckBox = view.findViewById(com.example.common_ui.R.id.geodesicCheckBox);
geodesicCheckBox.setOnClickListener(this);
- visibilityCheckBox = view.findViewById(R.id.visibilityCheckBox);
+ visibilityCheckBox = view.findViewById(com.example.common_ui.R.id.visibilityCheckBox);
visibilityCheckBox.setOnClickListener(this);
return view;
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylinePatternControlFragment.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylinePatternControlFragment.java
similarity index 83%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylinePatternControlFragment.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylinePatternControlFragment.java
index 497703bba..5657ec315 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylinePatternControlFragment.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylinePatternControlFragment.java
@@ -50,13 +50,13 @@ public class PolylinePatternControlFragment extends PolylineControlFragment impl
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.polyline_pattern_control_fragment, container, false);
- patternTextView = view.findViewById(R.id.patternTextView);
+ View view = inflater.inflate(com.example.common_ui.R.layout.polyline_pattern_control_fragment, container, false);
+ patternTextView = view.findViewById(com.example.common_ui.R.id.patternTextView);
- patternSolidBtn = view.findViewById(R.id.patternSolidBtn);
- patternDottedBtn = view.findViewById(R.id.patternDottedBtn);
- patternDashedBtn = view.findViewById(R.id.patternDashedBtn);
- patternMixedBtn = view.findViewById(R.id.patternMixedBtn);
+ patternSolidBtn = view.findViewById(com.example.common_ui.R.id.patternSolidBtn);
+ patternDottedBtn = view.findViewById(com.example.common_ui.R.id.patternDottedBtn);
+ patternDashedBtn = view.findViewById(com.example.common_ui.R.id.patternDashedBtn);
+ patternMixedBtn = view.findViewById(com.example.common_ui.R.id.patternMixedBtn);
patternSolidBtn.setOnClickListener(this);
patternDottedBtn.setOnClickListener(this);
@@ -73,16 +73,16 @@ public void onClick(View view) {
int id = view.getId();
List pattern;
- if (id == R.id.patternSolidBtn) {
+ if (id == com.example.common_ui.R.id.patternSolidBtn) {
pattern = null;
- } else if (id == R.id.patternDottedBtn) {
+ } else if (id == com.example.common_ui.R.id.patternDottedBtn) {
pattern = Arrays.asList(new Dot(), new Gap(RANDOM.nextFloat() * MAX_GAP_LENGTH));
- } else if (id == R.id.patternDashedBtn) {
+ } else if (id == com.example.common_ui.R.id.patternDashedBtn) {
pattern =
Arrays.asList(
new Dash(RANDOM.nextFloat() * MAX_DASH_LENGTH),
new Gap(RANDOM.nextFloat() * MAX_GAP_LENGTH));
- } else if (id == R.id.patternMixedBtn) {
+ } else if (id == com.example.common_ui.R.id.patternMixedBtn) {
int size = 2 * (1 + RANDOM.nextInt(MAX_PATTERN_SIZE / 2));
pattern = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylinePointsControlFragment.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylinePointsControlFragment.java
similarity index 81%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylinePointsControlFragment.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylinePointsControlFragment.java
index 766b7a133..13a361473 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylinePointsControlFragment.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylinePointsControlFragment.java
@@ -60,19 +60,19 @@ public void run() {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.polyline_points_control_fragment, container, false);
+ View view = inflater.inflate(com.example.common_ui.R.layout.polyline_points_control_fragment, container, false);
- view.findViewById(R.id.move_up).setOnTouchListener(this);
- view.findViewById(R.id.move_down).setOnTouchListener(this);
- view.findViewById(R.id.move_left).setOnTouchListener(this);
- view.findViewById(R.id.move_right).setOnTouchListener(this);
+ view.findViewById(com.example.common_ui.R.id.move_up).setOnTouchListener(this);
+ view.findViewById(com.example.common_ui.R.id.move_down).setOnTouchListener(this);
+ view.findViewById(com.example.common_ui.R.id.move_left).setOnTouchListener(this);
+ view.findViewById(com.example.common_ui.R.id.move_right).setOnTouchListener(this);
- EditText fpsEditText = (EditText) view.findViewById(R.id.fps_edittext);
+ EditText fpsEditText = (EditText) view.findViewById(com.example.common_ui.R.id.fps_edittext);
fpsEditText.setOnEditorActionListener(this);
fpsEditText.setOnFocusChangeListener(this);
setFrameRate(fpsEditText);
- EditText stepEditText = (EditText) view.findViewById(R.id.step_edittext);
+ EditText stepEditText = (EditText) view.findViewById(com.example.common_ui.R.id.step_edittext);
stepEditText.setOnEditorActionListener(this);
stepEditText.setOnFocusChangeListener(this);
setStepSize(stepEditText);
@@ -99,13 +99,13 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
}
private void setMoveDirection(int buttonId) {
- if (buttonId == R.id.move_up) {
+ if (buttonId == com.example.common_ui.R.id.move_up) {
moveDirection = MoveDirection.UP;
- } else if (buttonId == R.id.move_down) {
+ } else if (buttonId == com.example.common_ui.R.id.move_down) {
moveDirection = MoveDirection.DOWN;
- } else if (buttonId == R.id.move_left) {
+ } else if (buttonId == com.example.common_ui.R.id.move_left) {
moveDirection = MoveDirection.LEFT;
- } else if (buttonId == R.id.move_right) {
+ } else if (buttonId == com.example.common_ui.R.id.move_right) {
moveDirection = MoveDirection.RIGHT;
} else {
moveDirection = null;
@@ -120,9 +120,9 @@ public boolean onEditorAction(TextView textView, int actionId, KeyEvent event) {
}
int textViewId = textView.getId();
- if (textViewId == R.id.fps_edittext) {
+ if (textViewId == com.example.common_ui.R.id.fps_edittext) {
setFrameRate(textView);
- } else if (textViewId == R.id.step_edittext) {
+ } else if (textViewId == com.example.common_ui.R.id.step_edittext) {
setStepSize(textView);
}
return false;
@@ -135,9 +135,9 @@ public void onFocusChange(View view, boolean hasFocus) {
}
int viewId = view.getId();
- if (viewId == R.id.fps_edittext) {
+ if (viewId == com.example.common_ui.R.id.fps_edittext) {
setFrameRate((TextView) view);
- } else if (viewId == R.id.step_edittext) {
+ } else if (viewId == com.example.common_ui.R.id.step_edittext) {
setStepSize((TextView) view);
}
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineSpansControlFragment.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineSpansControlFragment.java
similarity index 91%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineSpansControlFragment.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineSpansControlFragment.java
index 4352c90e7..b2d19e7e4 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineSpansControlFragment.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineSpansControlFragment.java
@@ -76,22 +76,22 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.polyline_spans_control_fragment, container, false);
+ View view = inflater.inflate(com.example.common_ui.R.layout.polyline_spans_control_fragment, container, false);
- spanCountBar = view.findViewById(R.id.spansSeekBar);
+ spanCountBar = view.findViewById(com.example.common_ui.R.id.spansSeekBar);
spanCountBar.setMax(SPAN_COUNT_MAX);
spanCountBar.setOnSeekBarChangeListener(this);
- spanCountTextView = view.findViewById(R.id.spansTextView);
+ spanCountTextView = view.findViewById(com.example.common_ui.R.id.spansTextView);
- gradientToggle = view.findViewById(R.id.gradientToggle);
+ gradientToggle = view.findViewById(com.example.common_ui.R.id.gradientToggle);
gradientToggle.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
polylineGradientStates.put(polyline, isChecked);
updateSpans();
});
- polylineStampStyleRadioGroup = view.findViewById(R.id.polyline_stamp_style_radio_group);
+ polylineStampStyleRadioGroup = view.findViewById(com.example.common_ui.R.id.polyline_stamp_style_radio_group);
polylineStampStyleRadioGroup.setVisibility(View.INVISIBLE);
if (isLiteMode) {
@@ -125,9 +125,9 @@ private List generateSpans(int count) {
? StrokeStyle.gradientBuilder(polyline.getColor(), invertedPolylineColor)
: StrokeStyle.colorBuilder(color);
- if (selectedStampStyleId == R.id.polyline_texture_style) {
+ if (selectedStampStyleId == com.example.common_ui.R.id.polyline_texture_style) {
strokeStyleBuilder.stamp(
- TextureStyle.newBuilder(BitmapDescriptorFactory.fromResource(R.drawable.ook))
+ TextureStyle.newBuilder(BitmapDescriptorFactory.fromResource(com.example.common_ui.R.drawable.ook))
.build());
}
diff --git a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineWidthControlFragment.java b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineWidthControlFragment.java
similarity index 88%
rename from ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineWidthControlFragment.java
rename to ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineWidthControlFragment.java
index b69348d43..00e07a340 100644
--- a/ApiDemos/java/app/src/v3/java/com/example/mapdemo/polyline/PolylineWidthControlFragment.java
+++ b/ApiDemos/project/java-app/src/v3/java/com/example/mapdemo/polyline/PolylineWidthControlFragment.java
@@ -36,11 +36,11 @@ public class PolylineWidthControlFragment extends PolylineControlFragment implem
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
- View view = inflater.inflate(R.layout.polyline_width_control_fragment, container, false);
- widthBar = view.findViewById(R.id.widthSeekBar);
+ View view = inflater.inflate(com.example.common_ui.R.layout.polyline_width_control_fragment, container, false);
+ widthBar = view.findViewById(com.example.common_ui.R.id.widthSeekBar);
widthBar.setMax(WIDTH_MAX);
widthBar.setOnSeekBarChangeListener(this);
- widthTextView = view.findViewById(R.id.widthTextView);
+ widthTextView = view.findViewById(com.example.common_ui.R.id.widthTextView);
return view;
}
diff --git a/ApiDemos/project/java-app/src/v3/res/layout/basic_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/basic_demo.xml
new file mode 100644
index 000000000..2a8f42a0e
--- /dev/null
+++ b/ApiDemos/project/java-app/src/v3/res/layout/basic_demo.xml
@@ -0,0 +1,21 @@
+
+
+
diff --git a/ApiDemos/java/app/src/v3/res/layout/camera_clamping_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/camera_clamping_demo.xml
similarity index 83%
rename from ApiDemos/java/app/src/v3/res/layout/camera_clamping_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/camera_clamping_demo.xml
index d5a54872e..7914410a6 100644
--- a/ApiDemos/java/app/src/v3/res/layout/camera_clamping_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/camera_clamping_demo.xml
@@ -1,18 +1,18 @@
+
+
+
+
+
+
+
diff --git a/ApiDemos/java/app/src/v3/res/layout/ground_overlay_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/ground_overlay_demo.xml
similarity index 74%
rename from ApiDemos/java/app/src/v3/res/layout/ground_overlay_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/ground_overlay_demo.xml
index 74354d164..19c5128c8 100644
--- a/ApiDemos/java/app/src/v3/res/layout/ground_overlay_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/ground_overlay_demo.xml
@@ -1,17 +1,18 @@
-
+
+
+
+
+
diff --git a/ApiDemos/java/app/src/v3/res/layout/lite_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/lite_demo.xml
similarity index 78%
rename from ApiDemos/java/app/src/v3/res/layout/lite_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/lite_demo.xml
index 218ae763d..98c4f1426 100755
--- a/ApiDemos/java/app/src/v3/res/layout/lite_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/lite_demo.xml
@@ -1,17 +1,18 @@
-
+
+
+
+
+
+
+
diff --git a/ApiDemos/project/java-app/src/v3/res/layout/map_in_pager_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/map_in_pager_demo.xml
new file mode 100755
index 000000000..931cb73ea
--- /dev/null
+++ b/ApiDemos/project/java-app/src/v3/res/layout/map_in_pager_demo.xml
@@ -0,0 +1,20 @@
+
+
+
diff --git a/ApiDemos/project/java-app/src/v3/res/layout/marker_close_info_window_on_retap_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/marker_close_info_window_on_retap_demo.xml
new file mode 100644
index 000000000..0c35ac07f
--- /dev/null
+++ b/ApiDemos/project/java-app/src/v3/res/layout/marker_close_info_window_on_retap_demo.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
diff --git a/ApiDemos/project/java-app/src/v3/res/layout/marker_collision_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/marker_collision_demo.xml
new file mode 100644
index 000000000..d587601db
--- /dev/null
+++ b/ApiDemos/project/java-app/src/v3/res/layout/marker_collision_demo.xml
@@ -0,0 +1,21 @@
+
+
+
diff --git a/ApiDemos/java/app/src/v3/res/layout/marker_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/marker_demo.xml
similarity index 83%
rename from ApiDemos/java/app/src/v3/res/layout/marker_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/marker_demo.xml
index 609effdb6..c950e752b 100644
--- a/ApiDemos/java/app/src/v3/res/layout/marker_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/marker_demo.xml
@@ -1,17 +1,18 @@
-
+
+
+
+
+
+
diff --git a/ApiDemos/java/app/src/v3/res/layout/options_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/options_demo.xml
similarity index 51%
rename from ApiDemos/java/app/src/v3/res/layout/options_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/options_demo.xml
index e86266e0d..3a5cbe822 100644
--- a/ApiDemos/java/app/src/v3/res/layout/options_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/options_demo.xml
@@ -1,17 +1,18 @@
-
+ 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.
+-->
diff --git a/ApiDemos/kotlin/app/src/v3/res/layout/polyline_cap_control_fragment.xml b/ApiDemos/project/java-app/src/v3/res/layout/polyline_cap_control_fragment.xml
similarity index 86%
rename from ApiDemos/kotlin/app/src/v3/res/layout/polyline_cap_control_fragment.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/polyline_cap_control_fragment.xml
index 6c19db8df..33eef6abd 100644
--- a/ApiDemos/kotlin/app/src/v3/res/layout/polyline_cap_control_fragment.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/polyline_cap_control_fragment.xml
@@ -1,18 +1,19 @@
-
+
+
+
+
+
+
diff --git a/ApiDemos/kotlin/app/src/v3/res/layout/polyline_joint_control_fragment.xml b/ApiDemos/project/java-app/src/v3/res/layout/polyline_joint_control_fragment.xml
similarity index 64%
rename from ApiDemos/kotlin/app/src/v3/res/layout/polyline_joint_control_fragment.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/polyline_joint_control_fragment.xml
index 01521e70e..865d3958d 100644
--- a/ApiDemos/kotlin/app/src/v3/res/layout/polyline_joint_control_fragment.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/polyline_joint_control_fragment.xml
@@ -1,18 +1,19 @@
-
+
+
+
+
+
+
+
+
+ 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.
+-->
+
+
+
+
+
diff --git a/ApiDemos/project/java-app/src/v3/res/layout/raw_mapview_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/raw_mapview_demo.xml
new file mode 100644
index 000000000..be31eb223
--- /dev/null
+++ b/ApiDemos/project/java-app/src/v3/res/layout/raw_mapview_demo.xml
@@ -0,0 +1,20 @@
+
+
+
diff --git a/ApiDemos/project/java-app/src/v3/res/layout/save_state_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/save_state_demo.xml
new file mode 100755
index 000000000..e6aa7cad3
--- /dev/null
+++ b/ApiDemos/project/java-app/src/v3/res/layout/save_state_demo.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
diff --git a/ApiDemos/kotlin/app/src/gms/res/layout-land/snapshot_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/snapshot_demo.xml
similarity index 82%
rename from ApiDemos/kotlin/app/src/gms/res/layout-land/snapshot_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/snapshot_demo.xml
index 20856a210..793d28758 100755
--- a/ApiDemos/kotlin/app/src/gms/res/layout-land/snapshot_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/snapshot_demo.xml
@@ -1,6 +1,6 @@
-
+ android:orientation="vertical">
+ android:layout_height="0dp"
+ class="com.google.android.libraries.maps.SupportMapFragment" />
@@ -54,15 +53,15 @@
android:orientation="horizontal">
diff --git a/ApiDemos/java/app/src/v3/res/layout/split_street_view_panorama_and_map_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/split_street_view_panorama_and_map_demo.xml
similarity index 65%
rename from ApiDemos/java/app/src/v3/res/layout/split_street_view_panorama_and_map_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/split_street_view_panorama_and_map_demo.xml
index 6d2226c28..80369aa27 100755
--- a/ApiDemos/java/app/src/v3/res/layout/split_street_view_panorama_and_map_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/split_street_view_panorama_and_map_demo.xml
@@ -1,17 +1,18 @@
-
+
+
+
+
+
diff --git a/ApiDemos/java/app/src/v3/res/layout/street_view_panorama_events_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/street_view_panorama_events_demo.xml
similarity index 68%
rename from ApiDemos/java/app/src/v3/res/layout/street_view_panorama_events_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/street_view_panorama_events_demo.xml
index ed2825f30..77516c277 100755
--- a/ApiDemos/java/app/src/v3/res/layout/street_view_panorama_events_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/street_view_panorama_events_demo.xml
@@ -1,17 +1,18 @@
-
+
+
diff --git a/ApiDemos/project/java-app/src/v3/res/layout/styled_map_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/styled_map_demo.xml
new file mode 100644
index 000000000..2a8f42a0e
--- /dev/null
+++ b/ApiDemos/project/java-app/src/v3/res/layout/styled_map_demo.xml
@@ -0,0 +1,21 @@
+
+
+
diff --git a/ApiDemos/kotlin/app/src/gms/res/layout/advanced_markers_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/tags_demo.xml
similarity index 50%
rename from ApiDemos/kotlin/app/src/gms/res/layout/advanced_markers_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/tags_demo.xml
index c32d5e3a3..a5c4a46b3 100644
--- a/ApiDemos/kotlin/app/src/gms/res/layout/advanced_markers_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/tags_demo.xml
@@ -1,5 +1,6 @@
+
-
-
-
-
-
\ No newline at end of file
+ android:orientation="vertical">
+
+
+
+
+
\ No newline at end of file
diff --git a/ApiDemos/project/java-app/src/v3/res/layout/text_fragment.xml b/ApiDemos/project/java-app/src/v3/res/layout/text_fragment.xml
new file mode 100755
index 000000000..001c10dad
--- /dev/null
+++ b/ApiDemos/project/java-app/src/v3/res/layout/text_fragment.xml
@@ -0,0 +1,21 @@
+
+
+
diff --git a/ApiDemos/kotlin/app/src/main/res/layout/styled_map_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/tile_coordinate_demo.xml
old mode 100644
new mode 100755
similarity index 83%
rename from ApiDemos/kotlin/app/src/main/res/layout/styled_map_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/tile_coordinate_demo.xml
index 19962c44b..8a93fa305
--- a/ApiDemos/kotlin/app/src/main/res/layout/styled_map_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/tile_coordinate_demo.xml
@@ -1,12 +1,12 @@
-
+
-
-
\ No newline at end of file
+
diff --git a/ApiDemos/kotlin/app/src/v3/res/layout/tile_overlay_demo.xml b/ApiDemos/project/java-app/src/v3/res/layout/tile_overlay_demo.xml
similarity index 68%
rename from ApiDemos/kotlin/app/src/v3/res/layout/tile_overlay_demo.xml
rename to ApiDemos/project/java-app/src/v3/res/layout/tile_overlay_demo.xml
index 43ad79ff3..54587d80d 100755
--- a/ApiDemos/kotlin/app/src/v3/res/layout/tile_overlay_demo.xml
+++ b/ApiDemos/project/java-app/src/v3/res/layout/tile_overlay_demo.xml
@@ -1,17 +1,18 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/AdvancedMarkersDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/AdvancedMarkersDemoActivity.kt
similarity index 95%
rename from ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/AdvancedMarkersDemoActivity.kt
rename to ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/AdvancedMarkersDemoActivity.kt
index 2df551bf4..978187102 100644
--- a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/AdvancedMarkersDemoActivity.kt
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/AdvancedMarkersDemoActivity.kt
@@ -14,7 +14,7 @@
package com.example.kotlindemos
import android.graphics.Color
-import androidx.appcompat.app.AppCompatActivity
+
import com.google.android.gms.maps.OnMapReadyCallback
import android.os.Bundle
import android.util.Log
@@ -37,7 +37,7 @@ private val BANGKOK = LatLng(13.7563, 100.5018)
private val MANILA = LatLng(14.5995, 120.9842)
private val HO_CHI_MINH_CITY = LatLng(10.7769, 106.7009)
-const val ZOOM_LEVEL = 3.5f
+private const val ZOOM_LEVEL = 3.5f
private val TAG = AdvancedMarkersDemoActivity::class.java.name
@@ -47,14 +47,13 @@ private val TAG = AdvancedMarkersDemoActivity::class.java.name
* possibilities.
*/
// [START maps_android_sample_marker_advanced]
-class AdvancedMarkersDemoActivity : AppCompatActivity(), OnMapReadyCallback {
+class AdvancedMarkersDemoActivity : SamplesBaseActivity(), OnMapReadyCallback {
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- setContentView(R.layout.advanced_markers_demo)
- val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
+ setContentView(com.example.common_ui.R.layout.advanced_markers_demo)
+ val mapFragment = supportFragmentManager.findFragmentById(com.example.common_ui.R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync(this)
-
-
}
override fun onMapReady(map: GoogleMap) {
diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/ApiDemoApplication.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/ApiDemoApplication.kt
new file mode 100644
index 000000000..aba7270c1
--- /dev/null
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/ApiDemoApplication.kt
@@ -0,0 +1,100 @@
+/*
+* 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.
+*/
+package com.example.kotlindemos
+
+// <-- Keep this import
+import android.app.Application
+import android.content.pm.PackageManager
+import android.util.Log
+import android.widget.Toast
+import com.example.common_ui.R
+import java.util.Objects
+
+/**
+ * `ApiDemoApplication` is a custom Application class for the API demo.
+ *
+ * This class is responsible for application-wide initialization and setup,
+ * such as checking for the presence and validity of the API key during the
+ * application's startup.
+ *
+ * It extends the [Application] class and overrides the [.onCreate]
+ * method to perform these initialization tasks.
+ */
+class ApiDemoApplication : Application() {
+
+ override fun onCreate() {
+ super.onCreate()
+ checkApiKey()
+ }
+
+ /**
+ * Checks if the API key for Google Maps is properly configured in the application's metadata.
+ *
+ * This method retrieves the API key from the application's metadata, specifically looking for
+ * a string value associated with the key "com.google.android.geo.API_KEY".
+ * The key must be present, not blank, and not set to the placeholder value "DEFAULT_API_KEY".
+ *
+ * If any of these checks fail, a Toast message is displayed indicating that the API key is missing or
+ * incorrectly configured, and a RuntimeException is thrown.
+ */
+ private fun checkApiKey() {
+ try {
+ val appInfo =
+ packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
+ val bundle = Objects.requireNonNull(appInfo.metaData)
+
+ val apiKey =
+ bundle.getString("com.google.android.geo.API_KEY") // Key name is important!
+
+ if (apiKey == null || apiKey.isBlank() || apiKey == "DEFAULT_API_KEY") {
+ Toast.makeText(
+ this,
+ "API Key was not set in secrets.properties",
+ Toast.LENGTH_LONG
+ ).show()
+ throw RuntimeException("API Key was not set in secrets.properties")
+ }
+ } catch (e: PackageManager.NameNotFoundException) {
+ Log.e(TAG, "Package name not found.", e)
+ throw RuntimeException("Error getting package info.", e)
+ } catch (e: NullPointerException) {
+ Log.e(TAG, "Error accessing meta-data.", e) // Handle the case where meta-data is completely missing.
+ throw RuntimeException("Error accessing meta-data in manifest", e)
+ }
+ }
+
+ /**
+ * Retrieves the map ID from the BuildConfig or string resource.
+ *
+ * @return The valid map ID or null if no valid map ID is found.
+ */
+ val mapId: String? by lazy {
+ if (BuildConfig.MAP_ID != "MAP_ID") {
+ BuildConfig.MAP_ID
+ } else if (getString(R.string.map_id) != "DEMO_MAP_ID") {
+ getString(R.string.map_id)
+ } else {
+ Log.w(TAG, "Map ID is not set. See README for instructions.")
+ Toast.makeText(this, "Map ID is not set. Some features may not work. See README for instructions.", Toast.LENGTH_LONG)
+ .show()
+ null
+ }
+ }
+
+ companion object {
+ private const val TAG = "ApiDemoApplication"
+ }
+}
\ No newline at end of file
diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt
similarity index 83%
rename from ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt
rename to ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt
index ba63f97eb..fad3716b4 100644
--- a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationDemoActivity.kt
@@ -13,29 +13,27 @@
// limitations under the License.
package com.example.kotlindemos
-import androidx.appcompat.app.AppCompatActivity
-import com.google.android.gms.maps.OnMapReadyCallback
+
import android.os.Bundle
import android.view.View
-import com.example.kotlindemos.R
-import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.GoogleMap
-import android.widget.CheckBox
-import android.widget.CompoundButton
-import com.google.android.gms.common.internal.Preconditions
-import com.google.android.gms.maps.model.MarkerOptions
+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.material.switchmaterial.SwitchMaterial
+import com.example.common_ui.R
/**
* This shows how to create a simple activity with a custom background color appiled to the map, and
* add a marker on the map.
*/
-class BackgroundColorCustomizationDemoActivity : AppCompatActivity(), OnMapReadyCallback {
+class BackgroundColorCustomizationDemoActivity : SamplesBaseActivity(), OnMapReadyCallback {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.background_color_customization_demo)
val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync(this)
+ applyInsets(findViewById(R.id.map_container))
}
/**
@@ -45,7 +43,7 @@ class BackgroundColorCustomizationDemoActivity : AppCompatActivity(), OnMapReady
override fun onMapReady(map: GoogleMap) {
map.mapType = GoogleMap.MAP_TYPE_NONE
- val mapTypeToggleCheckbox = findViewById(R.id.map_type_toggle)
+ val mapTypeToggleCheckbox = findViewById(R.id.map_type_toggle)
mapTypeToggleCheckbox.setOnCheckedChangeListener { _, isChecked ->
map.mapType = if (isChecked) GoogleMap.MAP_TYPE_NORMAL else GoogleMap.MAP_TYPE_NONE
}
diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt
similarity index 91%
rename from ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt
rename to ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt
index 375a15121..e9d39f1c2 100644
--- a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BackgroundColorCustomizationProgrammaticDemoActivity.kt
@@ -14,25 +14,25 @@
package com.example.kotlindemos
import android.graphics.Color
-import androidx.appcompat.app.AppCompatActivity
+
import com.google.android.gms.maps.OnMapReadyCallback
import android.os.Bundle
import android.view.View
-import com.example.kotlindemos.R
import com.google.android.gms.maps.SupportMapFragment
-import com.example.kotlindemos.BackgroundColorCustomizationProgrammaticDemoActivity
import com.google.android.gms.maps.GoogleMapOptions
import com.google.android.gms.maps.GoogleMap
import android.widget.CheckBox
-import android.widget.CompoundButton
import com.google.android.gms.maps.model.MarkerOptions
import com.google.android.gms.maps.model.LatLng
+import com.example.common_ui.R
+import com.google.android.material.checkbox.MaterialCheckBox
+import com.google.android.material.switchmaterial.SwitchMaterial
/**
* This shows how to to instantiate a SupportMapFragment programmatically with a custom background
* color applied to the map, and add a marker on the map.
*/
-class BackgroundColorCustomizationProgrammaticDemoActivity : AppCompatActivity(),
+class BackgroundColorCustomizationProgrammaticDemoActivity : SamplesBaseActivity(),
OnMapReadyCallback {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -60,6 +60,7 @@ class BackgroundColorCustomizationProgrammaticDemoActivity : AppCompatActivity()
} else {
mapFragment.getMapAsync(this)
}
+ applyInsets(findViewById(R.id.map_container))
}
override fun onMapReady(map: GoogleMap) {
diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/BasicMapDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BasicMapDemoActivity.kt
similarity index 87%
rename from ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/BasicMapDemoActivity.kt
rename to ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BasicMapDemoActivity.kt
index a75d45398..f1a865bd0 100644
--- a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/BasicMapDemoActivity.kt
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/BasicMapDemoActivity.kt
@@ -17,7 +17,7 @@
package com.example.kotlindemos
import android.os.Bundle
-import androidx.appcompat.app.AppCompatActivity
+
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
@@ -29,16 +29,16 @@ import com.google.android.gms.maps.model.MarkerOptions
* This shows how to create a simple activity with a map and a marker on the map.
*/
// [START maps_android_sample_basic_map]
-class BasicMapDemoActivity : AppCompatActivity(), OnMapReadyCallback {
+class BasicMapDemoActivity : SamplesBaseActivity(), OnMapReadyCallback {
val SYDNEY = LatLng(-33.862, 151.21)
val ZOOM_LEVEL = 13f
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_basic_map_demo)
+ setContentView(com.example.common_ui.R.layout.basic_demo)
val mapFragment : SupportMapFragment? =
- supportFragmentManager.findFragmentById(R.id.map) as? SupportMapFragment
+ supportFragmentManager.findFragmentById(com.example.common_ui.R.id.map) as? SupportMapFragment
mapFragment?.getMapAsync(this)
}
diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CameraClampingDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CameraClampingDemoActivity.kt
similarity index 97%
rename from ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CameraClampingDemoActivity.kt
rename to ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CameraClampingDemoActivity.kt
index 773655e5c..76e24a9af 100644
--- a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CameraClampingDemoActivity.kt
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CameraClampingDemoActivity.kt
@@ -19,8 +19,9 @@ import android.view.View
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
-import androidx.appcompat.app.AppCompatActivity
+
import androidx.lifecycle.lifecycleScope
+import com.example.common_ui.R
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.SupportMapFragment
@@ -38,7 +39,7 @@ import kotlinx.coroutines.launch
/**
* This shows how to constrain the camera to specific boundaries and zoom levels.
*/
-class CameraClampingDemoActivity : AppCompatActivity() {
+class CameraClampingDemoActivity : SamplesBaseActivity() {
private lateinit var map: GoogleMap
private lateinit var cameraTextView: TextView
@@ -72,6 +73,7 @@ class CameraClampingDemoActivity : AppCompatActivity() {
}
setButtonClickListeners()
}
+ applyInsets(findViewById(R.id.map_container))
}
private fun setButtonClickListeners() {
diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CameraDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CameraDemoActivity.kt
similarity index 99%
rename from ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CameraDemoActivity.kt
rename to ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CameraDemoActivity.kt
index 1e21c1ed0..e29f38dc8 100644
--- a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CameraDemoActivity.kt
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CameraDemoActivity.kt
@@ -23,7 +23,8 @@ import android.view.View
import android.widget.CompoundButton
import android.widget.SeekBar
import android.widget.Toast
-import androidx.appcompat.app.AppCompatActivity
+import com.example.common_ui.R
+
import com.google.android.gms.maps.CameraUpdate
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
@@ -43,7 +44,7 @@ import com.google.android.gms.maps.model.PolylineOptions
*/
// [START maps_camera_events]
class CameraDemoActivity :
- AppCompatActivity(),
+ SamplesBaseActivity(),
OnCameraMoveStartedListener,
OnCameraMoveListener,
OnCameraMoveCanceledListener,
@@ -94,6 +95,7 @@ class CameraDemoActivity :
val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync(this)
+ applyInsets(findViewById(R.id.map_container))
}
// [START_EXCLUDE silent]
diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CircleDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CircleDemoActivity.kt
similarity index 98%
rename from ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CircleDemoActivity.kt
rename to ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CircleDemoActivity.kt
index 59eb3c42e..e4002eab1 100644
--- a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CircleDemoActivity.kt
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CircleDemoActivity.kt
@@ -26,8 +26,8 @@ import android.widget.ArrayAdapter
import android.widget.CheckBox
import android.widget.SeekBar
import android.widget.Spinner
+import com.example.common_ui.R
-import androidx.appcompat.app.AppCompatActivity
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
@@ -51,7 +51,7 @@ import java.util.Arrays
* This shows how to draw circles on a map.
*/
class CircleDemoActivity :
- AppCompatActivity(),
+ SamplesBaseActivity(),
SeekBar.OnSeekBarChangeListener,
AdapterView.OnItemSelectedListener,
OnMapReadyCallback {
@@ -159,7 +159,7 @@ class CircleDemoActivity :
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_circle_demo)
+ setContentView(R.layout.circle_demo)
// Set all the SeekBars
fillHueBar = findViewById(R.id.fillHueSeekBar).apply {
@@ -196,6 +196,7 @@ class CircleDemoActivity :
val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync(this)
+ applyInsets(findViewById(R.id.map_container))
}
/** Get all the strings of patterns and return them as Array. */
@@ -210,7 +211,7 @@ class CircleDemoActivity :
// we need to initialise map before creating a circle
with(map) {
moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, 4.0f))
- setContentDescription(getString(R.string.circle_demo_details))
+ setContentDescription(getString(R.string.circle_demo_description))
setOnMapLongClickListener { point ->
// We know the center, let's place the outline at a point 3/4 along the view.
val view: View = supportFragmentManager.findFragmentById(R.id.map)?.view
diff --git a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt
similarity index 94%
rename from ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt
rename to ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt
index 7d54b4825..db5b5da5e 100644
--- a/ApiDemos/kotlin/app/src/gms/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/CloudBasedMapStylingDemoActivity.kt
@@ -24,7 +24,8 @@ package com.example.kotlindemos
import android.os.Bundle
import android.view.View
-import androidx.appcompat.app.AppCompatActivity
+import com.example.common_ui.R
+
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
@@ -34,7 +35,7 @@ import com.google.android.gms.maps.SupportMapFragment
* to style a map using this method, see:
* https://developers.google.com/maps/documentation/android-sdk/cloud-based-map-styling
*/
-class CloudBasedMapStylingDemoActivity : AppCompatActivity(), OnMapReadyCallback {
+class CloudBasedMapStylingDemoActivity : SamplesBaseActivity(), OnMapReadyCallback {
private var map: GoogleMap? = null
private var currentMapType = GoogleMap.MAP_TYPE_NORMAL
override fun onCreate(savedInstanceState: Bundle?) {
@@ -49,6 +50,7 @@ class CloudBasedMapStylingDemoActivity : AppCompatActivity(), OnMapReadyCallback
val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment!!.getMapAsync(this)
setUpButtonListeners()
+ applyInsets(findViewById(R.id.map_container))
}
override fun onMapReady(map: GoogleMap) {
diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenBoundariesActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenBoundariesActivity.kt
new file mode 100644
index 000000000..63ffac14c
--- /dev/null
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenBoundariesActivity.kt
@@ -0,0 +1,304 @@
+// 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.
+package com.example.kotlindemos
+
+import android.graphics.Color
+import android.os.Bundle
+import android.util.Log
+import android.view.MenuInflater
+import android.view.MenuItem
+import android.view.View
+import android.widget.Toast
+import androidx.appcompat.widget.PopupMenu
+import androidx.core.graphics.ColorUtils
+
+import com.google.android.gms.maps.CameraUpdateFactory
+import com.google.android.gms.maps.GoogleMap
+import com.google.android.gms.maps.GoogleMapOptions
+import com.google.android.gms.maps.OnMapReadyCallback
+import com.google.android.gms.maps.SupportMapFragment
+import com.google.android.gms.maps.model.FeatureClickEvent
+import com.google.android.gms.maps.model.FeatureLayer
+import com.google.android.gms.maps.model.FeatureLayerOptions
+import com.google.android.gms.maps.model.FeatureStyle
+import com.google.android.gms.maps.model.FeatureType
+import com.google.android.gms.maps.model.LatLng
+import com.google.android.gms.maps.model.MapCapabilities
+import com.google.android.gms.maps.model.PlaceFeature
+import com.google.android.material.button.MaterialButton
+import kotlin.math.roundToInt
+import com.example.common_ui.R
+
+
+private val TAG = DataDrivenBoundariesActivity::class.java.simpleName
+
+/**
+ * This sample showcases how to use the Data-driven styling for boundaries. For more information
+ * on how the Data-driven styling for boundaries work, check out the following link:
+ * https://developers.google.com/maps/documentation/android-sdk/dds-boundaries/overview
+ */
+// Add PopupMenu.OnMenuItemClickListener interface
+class DataDrivenBoundariesActivity : SamplesBaseActivity(), OnMapReadyCallback,
+ FeatureLayer.OnFeatureClickListener, PopupMenu.OnMenuItemClickListener {
+
+ private lateinit var map: GoogleMap
+
+ private var localityLayer: FeatureLayer? = null
+ private var areaLevel1Layer: FeatureLayer? = null
+ private var countryLayer: FeatureLayer? = null
+
+ private val HANA_HAWAII = LatLng(20.7522, -155.9877) // Hana, Hawaii
+ private val CENTER_US = LatLng(39.8283, -98.5795) // Approx center US
+
+ // --- State Variables ---
+ private var localityEnabled = true // Default enabled
+ private var adminAreaEnabled = false
+ private var countryEnabled = false
+ private val selectedPlaceIds = mutableSetOf() // For selected countries
+
+ // --- Style Factories (defined once) ---
+ private val localityStyleFactory: FeatureLayer.StyleFactory = createLocalityStyleFactory()
+ private val areaLevel1StyleFactory: FeatureLayer.StyleFactory = createAreaLevel1StyleFactory()
+ // Country factory references selectedPlaceIds, needs to be instance property or re-created if needed
+ private val countryStyleFactory: FeatureLayer.StyleFactory = createCountryStyleFactory()
+
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ // Assumes layout is in common_ui module
+ setContentView(R.layout.data_driven_boundaries_demo)
+
+ val mapId = (application as ApiDemoApplication).mapId
+
+ // --- Map ID Check ---
+ if (mapId == null) {
+ finish()
+ return // Exit early if no valid Map ID
+ }
+
+ // --- Programmatically create and add the map fragment ---
+ val mapOptions = GoogleMapOptions().apply {
+ mapId(mapId)
+ }
+ val mapFragment = SupportMapFragment.newInstance(mapOptions)
+ supportFragmentManager.beginTransaction()
+ .replace(R.id.map_fragment_container, mapFragment) // Use the container ID
+ .commit()
+ mapFragment.getMapAsync(this)
+
+ // --- Setup Buttons ---
+ findViewById(R.id.button_hawaii).setOnClickListener {
+ centerMapOnLocation(HANA_HAWAII, 11f) // Adjusted zoom from Java
+ }
+ findViewById(R.id.button_us).setOnClickListener {
+ centerMapOnLocation(CENTER_US, 1f) // Adjusted zoom from Java
+ }
+ setupBoundarySelectorButton() // Setup the new selector button
+
+ // --- Insets ---
+ applyInsets(findViewById(R.id.map_container)) // Apply insets if needed
+ }
+
+ private fun setupBoundarySelectorButton() {
+ val stylingTypeButton: MaterialButton = findViewById(R.id.button_feature_type) // Find the button
+ stylingTypeButton.setOnClickListener { view ->
+ val popupMenu = PopupMenu(this, view)
+ val inflater: MenuInflater = popupMenu.menuInflater
+ inflater.inflate(R.menu.boundary_types_menu, popupMenu.menu) // Inflate your menu
+
+ popupMenu.setOnMenuItemClickListener(this) // Set listener to this Activity
+
+ // Set initial check states based on current flags
+ popupMenu.menu.findItem(R.id.boundary_type_locality)?.isChecked = localityEnabled
+ popupMenu.menu.findItem(R.id.boundary_type_administrative_area_level_1)?.isChecked = adminAreaEnabled
+ popupMenu.menu.findItem(R.id.boundary_type_country)?.isChecked = countryEnabled
+
+ popupMenu.show()
+ }
+ }
+
+ private fun centerMapOnLocation(location: LatLng, zoomLevel: Float) {
+ if (::map.isInitialized) { // Check if map is ready
+ map.moveCamera(CameraUpdateFactory.newLatLngZoom(location, zoomLevel))
+ } else {
+ Log.w(TAG, "Map not initialized, cannot center map.")
+ }
+ }
+
+ override fun onMapReady(googleMap: GoogleMap) {
+ map = googleMap
+ val capabilities: MapCapabilities = map.mapCapabilities
+ Log.d(TAG, "Data-driven Styling is available: ${capabilities.isDataDrivenStylingAvailable}")
+
+ if (!capabilities.isDataDrivenStylingAvailable) {
+ Toast.makeText(
+ this,
+ "Data-driven Styling is not available. See README.md for instructions.",
+ Toast.LENGTH_LONG
+ ).show()
+ }
+
+ // Get feature layers
+ localityLayer = googleMap.getFeatureLayer(
+ FeatureLayerOptions.Builder()
+ .featureType(FeatureType.LOCALITY)
+ .build()
+ )
+ areaLevel1Layer = googleMap.getFeatureLayer(
+ FeatureLayerOptions.Builder()
+ .featureType(FeatureType.ADMINISTRATIVE_AREA_LEVEL_1)
+ .build()
+ )
+ countryLayer = googleMap.getFeatureLayer(
+ FeatureLayerOptions.Builder()
+ .featureType(FeatureType.COUNTRY)
+ .build()
+ ).also {
+ it.addOnFeatureClickListener(this)
+ }
+
+ // Apply initial styles based on default flags
+ updateStyles()
+
+ // Center map initially
+ centerMapOnLocation(HANA_HAWAII, 11f)
+ }
+
+ /**
+ * Updates the styles based on the enabled flags.
+ */
+ private fun updateStyles() {
+ Log.d(TAG, "Updating Styles: Locality=$localityEnabled, Admin1=$adminAreaEnabled, Country=$countryEnabled")
+ localityLayer?.featureStyle = if (localityEnabled) localityStyleFactory else null
+ areaLevel1Layer?.featureStyle = if (adminAreaEnabled) areaLevel1StyleFactory else null
+ countryLayer?.featureStyle = if (countryEnabled) countryStyleFactory else null
+ }
+
+ // --- Style Factory Creation Methods ---
+
+ private fun createLocalityStyleFactory(): FeatureLayer.StyleFactory {
+ val purple = 0x810FCB
+ // Define a style with purple fill at 50% opacity and solid purple border.
+ val fillColor = ColorUtils.setAlphaComponent(purple, (0.5f * 255).roundToInt())
+ val strokeColor = ColorUtils.setAlphaComponent(purple, 255) // Fully opaque
+
+ return FeatureLayer.StyleFactory { feature ->
+ if (feature is PlaceFeature && feature.placeId == "ChIJ0zQtYiWsVHkRk8lRoB1RNPo") { // Hana, HI
+ FeatureStyle.Builder()
+ .fillColor(fillColor)
+ .strokeColor(strokeColor)
+ .build()
+ } else {
+ null // No style for other localities
+ }
+ }
+ }
+
+ private fun createAreaLevel1StyleFactory(): FeatureLayer.StyleFactory {
+ val alpha = (255 * 0.25).roundToInt() // 25% opacity
+
+ return FeatureLayer.StyleFactory { feature ->
+ if (feature is PlaceFeature) {
+ // Generate a hue based on placeId hash
+ var hueColor = feature.placeId.hashCode() % 300
+ if (hueColor < 0) hueColor += 300
+ FeatureStyle.Builder()
+ .fillColor(Color.HSVToColor(alpha, floatArrayOf(hueColor.toFloat(), 1f, 1f)))
+ .build()
+ } else {
+ null
+ }
+ }
+ }
+
+ private fun createCountryStyleFactory(): FeatureLayer.StyleFactory {
+ val defaultFillColor = ColorUtils.setAlphaComponent(Color.BLACK, (0.1f * 255).roundToInt()) // 10% Black
+ val selectedFillColor = ColorUtils.setAlphaComponent(Color.RED, (0.33f * 255).roundToInt()) // 33% Red
+
+ return FeatureLayer.StyleFactory { feature ->
+ if (feature is PlaceFeature) {
+ // Check if this country's place ID is in our selected set
+ val fillColor = if (selectedPlaceIds.contains(feature.placeId)) {
+ selectedFillColor
+ } else {
+ defaultFillColor
+ }
+ FeatureStyle.Builder()
+ .fillColor(fillColor)
+ .strokeColor(Color.BLACK) // Solid black border
+ .build()
+ } else {
+ null
+ }
+ }
+ }
+
+ // --- Listener Implementations ---
+
+ /**
+ * Handles clicks on the Country Layer features.
+ */
+ override fun onFeatureClick(event: FeatureClickEvent) {
+ val clickedPlaceIds = event.features
+ .filterIsInstance() // Get only PlaceFeatures
+ .map { it.placeId } // Extract their place IDs
+
+ var changed = false
+ clickedPlaceIds.forEach { placeId ->
+ if (selectedPlaceIds.contains(placeId)) {
+ selectedPlaceIds.remove(placeId)
+ changed = true
+ } else {
+ selectedPlaceIds.add(placeId)
+ changed = true
+ }
+ }
+
+ // If the selection changed and the country layer is enabled, re-apply its style
+ if (changed && countryEnabled) {
+ Log.d(TAG, "Country selection changed. Selected IDs: $selectedPlaceIds")
+ countryLayer?.featureStyle = countryStyleFactory // Re-apply the factory
+ } else if (!countryEnabled) {
+ Log.d(TAG, "Country clicked but layer not enabled.")
+ // Optional: Show a toast? "Enable country layer to select"
+ }
+ }
+
+
+ /**
+ * Handles clicks on the PopupMenu items.
+ */
+ override fun onMenuItemClick(item: MenuItem): Boolean {
+ val id = item.itemId
+ item.isChecked = !item.isChecked // Toggle the checkmark
+
+ when (id) {
+ R.id.boundary_type_locality -> {
+ localityEnabled = item.isChecked
+ }
+ R.id.boundary_type_administrative_area_level_1 -> {
+ adminAreaEnabled = item.isChecked
+ }
+ R.id.boundary_type_country -> {
+ countryEnabled = item.isChecked
+ // If disabling country layer, clear selection visually (optional)
+ // if (!countryEnabled) selectedPlaceIds.clear()
+ }
+ else -> return false // Unknown item
+ }
+
+ updateStyles() // Apply changes to map layers
+ return true
+ }
+}
\ No newline at end of file
diff --git a/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenDatasetStylingActivity.kt b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenDatasetStylingActivity.kt
new file mode 100644
index 000000000..34ad0bbc8
--- /dev/null
+++ b/ApiDemos/project/kotlin-app/src/main/java/com/example/kotlindemos/DataDrivenDatasetStylingActivity.kt
@@ -0,0 +1,385 @@
+// 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.
+package com.example.kotlindemos
+
+import android.graphics.Color
+import android.os.Build
+
+import com.google.android.gms.maps.OnMapReadyCallback
+import android.os.Bundle
+import android.util.Log
+import android.view.View
+import android.view.ViewGroup
+import android.view.WindowInsets
+import android.widget.Button
+import android.widget.LinearLayout
+import android.widget.Toast
+import androidx.activity.enableEdgeToEdge
+import androidx.annotation.ColorInt
+import androidx.core.graphics.ColorUtils
+import com.google.android.gms.maps.SupportMapFragment
+import com.google.android.gms.maps.GoogleMap
+import com.google.android.gms.maps.CameraUpdateFactory
+import com.google.android.gms.maps.model.DatasetFeature
+import com.google.android.gms.maps.model.Feature
+import com.google.android.gms.maps.model.FeatureClickEvent
+import com.google.android.gms.maps.model.FeatureLayer
+import com.google.android.gms.maps.model.FeatureLayerOptions
+import com.google.android.gms.maps.model.FeatureStyle
+import com.google.android.gms.maps.model.FeatureType
+import com.google.android.gms.maps.model.LatLng
+import com.google.android.gms.maps.model.MapCapabilities
+import androidx.core.view.WindowCompat
+import com.google.android.gms.maps.GoogleMapOptions
+
+
+private val TAG = DataDrivenDatasetStylingActivity::class.java.name
+
+/**
+ * This sample showcases how to use the Data-driven styling for datasets. For more information
+ * on how the Data-driven styling for boundaries work, check out the following link:
+ * https://developers.google.com/maps/documentation/android-sdk/dds-datasets/overview
+ */
+class DataDrivenDatasetStylingActivity : SamplesBaseActivity(), OnMapReadyCallback, FeatureLayer.OnFeatureClickListener {
+ private lateinit var mapContainer: ViewGroup
+
+ private lateinit var map: GoogleMap
+ private val zoomLevel = 13.5f
+
+ private var datasetLayer: FeatureLayer? = null
+
+ // The global id of the clicked dataset feature.
+ private var lastGlobalId: String? = null
+
+ private data class DataSet(
+ val datasetId: String,
+ val location: LatLng,
+ val callback: DataDrivenDatasetStylingActivity.() -> Unit
+ )
+
+ private val dataSets = mutableMapOf()
+
+ private lateinit var buttonLayout: LinearLayout
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ enableEdgeToEdge()
+ super.onCreate(savedInstanceState)
+
+ val mapId = (application as ApiDemoApplication).mapId
+
+ // --- Map ID Check ---
+ if (mapId == null) {
+ finish()
+ return // Exit early if no valid Map ID
+ }
+
+ if (dataSets.isEmpty()) {
+ with(dataSets) {
+ put(getString(com.example.common_ui.R.string.boulder), DataSet(BuildConfig.BOULDER_DATASET_ID, LatLng(40.0150, -105.2705)) { styleBoulderDataset() })
+ put(getString(com.example.common_ui.R.string.new_york), DataSet(BuildConfig.NEW_YORK_DATASET_ID, LatLng(40.786244, -73.962684)) { styleNYCDataset() })
+ put(getString(com.example.common_ui.R.string.kyoto), DataSet(BuildConfig.KYOTO_DATASET_ID, LatLng(35.005081, 135.764385)) { styleKyotoDataset() })
+ }
+ }
+
+ setContentView(com.example.common_ui.R.layout.data_driven_styling_demo)
+
+ mapContainer = findViewById(com.example.common_ui.R.id.map_container)
+
+ // --- Programmatically create and add the map fragment ---
+ // 1. Create GoogleMapOptions
+ val mapOptions = GoogleMapOptions().apply {
+ // 2. Set the mapId using your BuildConfig field
+ mapId(mapId)
+ }
+
+ // 3. Create SupportMapFragment instance with options
+ val mapFragment = SupportMapFragment.newInstance(mapOptions)
+
+ // 4. Add the fragment to your FrameLayout container
+ supportFragmentManager.beginTransaction()
+ .replace(com.example.common_ui.R.id.map_fragment_container, mapFragment) // Use the container ID from XML
+ .commit()
+ // --- End of programmatic creation ---
+
+ mapFragment.getMapAsync(this)
+
+ // Set the click listener for each of the buttons
+ listOf(com.example.common_ui.R.id.button_kyoto, com.example.common_ui.R.id.button_ny, com.example.common_ui.R.id.button_boulder).forEach { viewId ->
+ findViewById