feat(demo): edge-to-edge insets, editable fields, mock location, and UX polish - #118
feat(demo): edge-to-edge insets, editable fields, mock location, and UX polish#118dkhawk wants to merge 1 commit into
Conversation
Code Coverage
|
ad70ac8 to
85c6c96
Compare
| NextLocationButton( | ||
| isSelected = commonViewState.buttonStates.mockLocation == ButtonState.SELECTED | ||
| ) { | ||
| onEvent(CommonEvent.OnNextMockLocation) |
There was a problem hiding this comment.
onEvent(CommonEvent.OnNextMockLocation) updates the state asynchronously in CommonViewModel, but commonViewState.locationLabel is read synchronously in the same click frame before Compose recomposes. As a result, the Snackbar displays the previous location's name (or "Mock Location" on first tap) instead of the newly selected location.
There was a problem hiding this comment.
Updated! Resolved by decoupling the Snackbar display from synchronous Compose state reads:
MergedLocationRepository.nextMockLocation()now returns the selected mock location label directly.CommonViewModelemits the message viasnackbarMessage: SharedFlow<String>.CommonScreencollects this flow in aLaunchedEffect(Unit)to show the Snackbar, eliminating the race condition with recomposition and always displaying the newly selected location label immediately.
85c6c96 to
fcc3170
Compare
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:aapt="http://schemas.android.com/aapt" | ||
| android:width="108dp" | ||
| android:height="108dp" | ||
| android:viewportWidth="108" | ||
| android:viewportHeight="108"> | ||
| <path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z"> | ||
| <aapt:attr name="android:fillColor"> | ||
| <gradient | ||
| android:endX="85.84757" | ||
| android:endY="92.4963" | ||
| android:startX="42.9492" | ||
| android:startY="49.59793" | ||
| android:type="linear"> | ||
| <item | ||
| android:color="#44000000" | ||
| android:offset="0.0" /> | ||
| <item | ||
| android:color="#00000000" | ||
| android:offset="1.0" /> | ||
| </gradient> | ||
| </aapt:attr> | ||
| </path> | ||
| <path | ||
| android:fillColor="#FFFFFF" | ||
| android:fillType="nonZero" | ||
| android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" | ||
| android:strokeWidth="1" | ||
| android:strokeColor="#00000000" /> | ||
| </vector> No newline at end of file |
| ) | ||
| queue.add(stringRequest) | ||
| return try { | ||
| suspendCancellableCoroutine { cont -> |
There was a problem hiding this comment.
Coroutine Cancellation & RequestQueue Leak in GeocoderRepository.reverseGeocode()
Issues:
Thread/Memory Leak: Volley.newRequestQueue(context) creates a new thread pool (CacheDispatcher + 4 NetworkDispatcher threads) on every single geocoding request and never stops them. RequestQueue should be initialized once as an instance property on GeocoderRepository (e.g. private val requestQueue by lazy { Volley.newRequestQueue(context.applicationContext) }).
Missing Cancellation Hook: Add cont.invokeOnCancellation { stringRequest.cancel() } inside suspendCancellableCoroutine so cancelled coroutines cancel the underlying HTTP request.
There was a problem hiding this comment.
Updated! Both issues resolved:
- Initialized
RequestQueueonce onGeocoderRepositoryviaprivate val requestQueue by lazy { Volley.newRequestQueue(context.applicationContext) }, avoiding creating thread pools on each geocode request. - Added
cont.invokeOnCancellation { stringRequest.cancel() }insidesuspendCancellableCoroutineso cancelled coroutines properly cancel the underlying Volley request.
fcc3170 to
50fde82
Compare
Description
This PR refactors and polishes the demo application (
:places-compose-demo):Highlights:
MainActivity,PlacesAutocompleteMinimalActivity,LandmarkSelectionActivity, andCommonScreenfor full edge-to-edge rendering withScaffoldpadding and Material 3TopAppBarstyling.PluralsCandidate, removed redundant activity labels, and moved legacy drawable assets.📚 Stacked PR Chain
ci/workflow-security-hardening(Workflow permissions & action pinning)maintest/library-coverage-baseline(Test suite reaching 93.8% coverage)build/dependency-modernization(AGP 9.3.2, Gradle 9.5.1, Places 5.3.0)feat/places-usage-attribution(Usage attribution & remove:library)demo/ux-edge-to-edge-polish(Demo UX, edge-to-edge, mock location)Umbrella PR: #109