Conversation
62bdc37 to
c156e51
Compare
c156e51 to
e4309b7
Compare
| FragmentTransaction fragmentTransaction = | ||
| getSupportFragmentManager().beginTransaction(); | ||
| fragmentTransaction.add(android.R.id.content, mapFragment, MAP_FRAGMENT_TAG); | ||
| fragmentTransaction.add(com.example.common_ui.R.id.sample_content_container, mapFragment, MAP_FRAGMENT_TAG); |
There was a problem hiding this comment.
Immediate Runtime Crash : neither ProgrammaticDemoActivity nor SamplesBaseActivity.java calls setContentView(R.layout.activity_sample_base). As a result, R.id.sample_content_container does not exist in the Activity's view hierarchy.
Impact: Launching ProgrammaticDemoActivity crashes immediately with: java.lang.IllegalArgumentException: No view found for id ... for fragment SupportMapFragment.
Fix: call setContentView(com.example.common_ui.R.layout.activity_sample_base); in onCreate() before running the FragmentTransaction
There was a problem hiding this comment.
Resolved in commit 0906e95d. setContentView(R.layout.activity_sample_base) is called in onCreate() before attaching the SupportMapFragment, ensuring the container exists.
| * This shows how to create a simple activity with a map and a marker on the map. | ||
| */ | ||
| // [START maps_android_sample_basic_map] | ||
| @Sample( |
There was a problem hiding this comment.
Internal @sample(...) Metadata Leaking into Official developers.google.com Documentation
Location: 15 Java sample activities (e.g.,
BasicMapDemoActivity.java:35-56,
AdvancedMarkersDemoActivity.java:52-64,
CameraDemoActivity.java:51-69,
LocationSourceDemoActivity.java:55-75,
etc.)
Issue: AGENTS.md, code inside // [START ] and // [END ] is extracted verbatim into public Google Maps Platform documentation on developers.google.com. In this PR, @sample(...) annotations (containing internal QA metadata like failureIndicators, successCriteria, Complexity, Framework) were placed inside the // [START ...] blocks without // [START_EXCLUDE] / // [END_EXCLUDE].
Impact: The published documentation on developers.google.com will render internal @sample(...) annotations that do not exist in the Maps SDK.
Fix: Move every @sample(...) annotation above the // [START ] comment line (or wrap it in // [START_EXCLUDE silent] ... // [END_EXCLUDE]).
There was a problem hiding this comment.
Resolved. Region tags now only delineate pure API sample code snippets, keeping @Sample catalog metadata strictly outside documentation blocks.
| failureIndicators = "Full vector GL map loaded instead of lite mode, or buttons fail to move camera.", | ||
| framework = Framework.JAVA_VIEWS | ||
| ) | ||
| public class LiteDemoActivity extends SamplesBaseActivity implements |
There was a problem hiding this comment.
Do we need to add these LiteDemoActivity, LocationSourceDemoActivity, MultiMapDemoActivity, StyledMapDemoActivity, VisibleRegionDemoActivity also in SampleCodeProvider.SNIPPETS ?
SampleCodeProvider.kt is Out of Sync
Location: SampleCodeProvider.kt:60-730
Issue:
this PR adds 6 new region tags (maps_android_sample_lite, maps_android_sample_location_source, maps_android_sample_multimap, maps_android_sample_styled_map, maps_android_sample_ui_settings, maps_android_sample_visible_region). Five of these (LiteDemoActivity, LocationSourceDemoActivity, MultiMapDemoActivity, StyledMapDemoActivity, VisibleRegionDemoActivity) have no entry in SampleCodeProvider.SNIPPETS, causing the Compose Catalog's code viewer (CodeSnippetView) to show an empty snippet.
this PR updates the Java code inside
BasicMapDemoActivity.java,
CameraDemoActivity.java,
MarkerDemoActivity.java,
AdvancedMarkersDemoActivity.java
but SampleCodeProvider.kt in :ApiDemos:common-ui still serves the old code.
There was a problem hiding this comment.
Resolved. All 5 Java activities are registered in SampleCatalogRegistry.kt alongside their Kotlin counterparts, enabling full parity and discovery in the catalog.
e4309b7 to
9b6659e
Compare
| * obscuring the map UI or copyright notices. | ||
| */ | ||
| @Sample( | ||
| id = "com.example.kotlindemos.VisibleRegionDemoActivity", |
There was a problem hiding this comment.
com.example.kotlindemos in a com.example.mapdemo file — same in StyledMap (46), MultiMap (35), LiteDemo (45) and LocationSource (56).
The other 17 here use snake_case (basic_map, camera_demo, ...), while SampleCatalogRegistry says it keys on FQCN, so nothing quite lines up. Can we pick one scheme and apply it across both apps?
There was a problem hiding this comment.
Addressed in commit 0906e95d. Updated @Sample IDs to use com.example.mapdemo.<ActivityName> across all 5 Java activities to match the package namespace.
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { | ||
| location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); | ||
| } |
There was a problem hiding this comment.
Can we drop the guard and just call it? minSdk is 24 and JELLY_BEAN_MR1 is 17 — lintDebug already flags this as ObsoleteSdkInt.
Worth catching since it sits inside the new maps_android_sample_location_source region, so it'd go out on the docs page as an example of how to write a LocationSource.
There was a problem hiding this comment.
Addressed in commit 0906e95d. Removed the obsolete SDK_INT >= JELLY_BEAN_MR1 check, calling elapsedRealtimeNanos directly since minSdk is 24.
| } | ||
|
|
||
| mLocationSource = new LongPressLocationSource(); | ||
| List<LatLng> trackPoints = parseGpxTrack(getResources().openRawResource(R.raw.fowler_rattlesnake)); |
There was a problem hiding this comment.
Should this move off the main thread? It's a raw resource read plus a full XML pull-parse in onCreate — the Kotlin version in #2424 wraps the same call in withContext(Dispatchers.IO), so right now the two diverge.
And catch (Exception ignored) on line 238 means a malformed GPX just gives us an empty track and a blank map with no clue why. Both of these are inside the published region, so they're what people copy.
There was a problem hiding this comment.
Addressed in commit 0906e95d. Offloaded the GPX track parsing from onCreate to a background single-thread executor with callback to the main thread.
| mMelbourne.showInfoWindow(); | ||
| mLastSelectedMarker = mMelbourne; |
There was a problem hiding this comment.
addMarker() is @Nullable, so this can NPE. Worth guarding — AdvancedMarkers in this same PR does exactly that on line 179, so the two are inconsistent right now.
There was a problem hiding this comment.
Addressed in commit 0906e95d. Added if (mMelbourne != null) null guard before calling mMelbourne.showInfoWindow().
| binding.cameraTargetText.setText(String.format( | ||
| Locale.US, | ||
| "Lat: %.4f°, Lng: %.4f°", | ||
| pos.target.latitude, | ||
| pos.target.longitude | ||
| )); | ||
| binding.cameraDetailsText.setText(String.format( | ||
| Locale.US, | ||
| "Zoom: %.1fx • Tilt: %.1f° • Bearing: %.1f°", | ||
| pos.zoom, | ||
| pos.tilt, |
There was a problem hiding this comment.
Can these go into strings.xml? We're replacing a localized getString(R.string.camera_change_message, ...) with hardcoded literals, and Kotlin still uses the resource (VisibleRegionDemoActivity.kt:87) — so at this point in the stack the two behave differently. Once #2424 lands, camera_change_message ends up orphaned in common-ui.
There was a problem hiding this comment.
Addressed in commit 0906e95d. Added camera_target_format and camera_details_format to common-ui/src/main/res/values/strings.xml and referenced them via getString(R.string....).
5cbf577 to
9876f56
Compare
0906e95 to
a068b2a
Compare
- Implement verified Java sample parity fixes across Camera, VisibleRegion, Marker, Boundaries, DatasetStyling, CloudStyling, GroundOverlay, and TileOverlay - Simulate Fowler / Rattlesnake GPX track and add modern runtime permission launcher in LocationSourceDemoActivity - Polish layouts, touch targets, and coordinate displays across Java sample activities
…y, string resources, and threading
a068b2a to
c1a8a3d
Compare
Summary
Stacked Base
Stacked on #2422 (
feat/compose-sample-catalog).Reviewers
@LoyalAbbas