Skip to content

Commit 641dfad

Browse files
adsamcikCopilot
andcommitted
fix(map): chip-sized labels for long layer names + shorten search placeholder (R7 QC)
Two cosmetic findings from emulator QC of HEAD f915b35: (1) Active-layer chip on the map control bar truncated long titles. 'Location polyline' rendered as 'Location polyli...' at typical 360dp widths; 'Wi-Fi count heatmap' and 'Vehicle speed compliance' have the same problem. Add optional LayerDescriptor.chipLabelRes so we can ship a short label for the chip while keeping the full title in the layer menu / legend. Cover the four longest titles: Polyline, Locations, Wi-Fi count, Speeding. MapChromeHost.activeLayerLabel prefers chipLabelRes when set, falls back to titleRes. (2) Map search placeholder 'Search lat, lng (e.g. 50.075, 14.437)' truncated to 'Search lat, lng (e.g. 50.075, 14.4...' losing the example coordinate. Shorten to 'Lat, Lng e.g. 50.075, 14.437' (28 chars) which fits the field at 754dp with 200dp to spare. The full coordinate-format reference still lives in map_search_invalid_format. Verified on emulator: chip text 'Polyline' (was 'Location polyli...'); placeholder 'Lat, Lng e.g. 50.075, 14.437' (was '...e.g. 50.075, 14.4...'). All :map unit tests green; LayerDescriptorTest updated to use named params for the new optional field. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f915b35 commit 641dfad

5 files changed

Lines changed: 29 additions & 4 deletions

File tree

map/src/main/java/com/adsamcik/tracker/map/layers/registry/DefaultLayerRegistry.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class DefaultLayerRegistry(
102102
LayerDescriptor(
103103
id = "location_heatmap",
104104
titleRes = R.string.map_layer_location_heatmap_title,
105+
chipLabelRes = R.string.map_layer_location_heatmap_chip,
105106
iconRes = null,
106107
capabilities = LayerCapabilities(isHeatmap = true),
107108
recipe = LayerRecipe(factory = LayerFactory {
@@ -192,6 +193,7 @@ class DefaultLayerRegistry(
192193
LayerDescriptor(
193194
id = "wifi_count_heatmap",
194195
titleRes = R.string.map_layer_wifi_count_heatmap_title,
196+
chipLabelRes = R.string.map_layer_wifi_count_heatmap_chip,
195197
iconRes = null,
196198
capabilities = LayerCapabilities(isHeatmap = true),
197199
recipe = LayerRecipe(factory = LayerFactory {
@@ -261,6 +263,7 @@ class DefaultLayerRegistry(
261263
LayerDescriptor(
262264
id = "vehicle_compliance",
263265
titleRes = R.string.map_layer_vehicle_compliance_title,
266+
chipLabelRes = R.string.map_layer_vehicle_compliance_chip,
264267
iconRes = null,
265268
capabilities = LayerCapabilities(isPolyline = true),
266269
recipe = LayerRecipe(factory = LayerFactory {
@@ -382,6 +385,7 @@ class DefaultLayerRegistry(
382385
LayerDescriptor(
383386
id = "location_polyline",
384387
titleRes = R.string.map_layer_location_polyline_title,
388+
chipLabelRes = R.string.map_layer_location_polyline_chip,
385389
iconRes = null,
386390
capabilities = LayerCapabilities(isPolyline = true),
387391
recipe = LayerRecipe(factory = LayerFactory {

map/src/main/java/com/adsamcik/tracker/map/shared/layers/LayerDescriptor.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ import androidx.annotation.StringRes
77
data class LayerDescriptor(
88
val id: String,
99
@StringRes val titleRes: Int,
10+
/**
11+
* Optional short label used in compact UI (e.g. the active-layer chip
12+
* on the map control bar) where the full [titleRes] would truncate.
13+
* Falls back to [titleRes] when null.
14+
*/
15+
@StringRes val chipLabelRes: Int? = null,
1016
@DrawableRes val iconRes: Int?,
1117
val capabilities: LayerCapabilities,
1218
val recipe: LayerRecipe

map/src/main/java/com/adsamcik/tracker/map/ui/controls/MapChromeHost.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,12 @@ fun MapChromeHost(
153153
context.getString(R.string.map_layer_none_title)
154154
} else {
155155
val descriptor = layers.firstOrNull { it.id == active }
156-
descriptor?.titleRes?.let {
156+
// Prefer the short chip label when set; long titles like
157+
// "Location polyline" / "Wi-Fi count heatmap" / "Vehicle speed
158+
// compliance" truncate to "Location polyli..." in the active-layer
159+
// chip on the map control bar (~360dp width).
160+
val labelRes = descriptor?.chipLabelRes ?: descriptor?.titleRes
161+
labelRes?.let {
157162
try {
158163
context.getString(it)
159164
} catch (e: Exception) {

map/src/main/res/values/strings.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@
5454
<string name="map_layer_location_polyline">Location polyline</string>
5555
<string name="map_layer_location_polyline_description">Line connecting your recorded locations over time.</string>
5656
<string name="map_layer_location_polyline_title">Location polyline</string>
57+
<!-- Compact chip labels: long titles truncate to "Location polyli..." in the
58+
layer chip on the map control bar (~360dp). Each chip label fits in
59+
~12 characters at typical font sizes. Fall back to titleRes for layers
60+
whose titleRes already fits. -->
61+
<string name="map_layer_location_polyline_chip">Polyline</string>
62+
<string name="map_layer_location_heatmap_chip">Locations</string>
63+
<string name="map_layer_wifi_count_heatmap_chip">Wi-Fi count</string>
64+
<string name="map_layer_vehicle_compliance_chip">Speeding</string>
5765
<string name="map_layer_no_data">Current layer has no available data</string>
5866
<string name="map_layer_none">No overlay</string>
5967
<string name="map_layer_none_title">No overlay</string>
@@ -112,7 +120,9 @@
112120
<string name="tips_map_sheet_title">More options</string>
113121

114122
<!-- Map Sheet Controls -->
115-
<string name="map_search_placeholder">Search lat, lng (e.g. 50.075, 14.437)</string>
123+
<!-- Keep short so it fits the search field at typical 360dp widths;
124+
the full coordinate-format reference lives in map_search_invalid_format. -->
125+
<string name="map_search_placeholder">Lat, Lng e.g. 50.075, 14.437</string>
116126
<string name="map_search_hint">Lat, Lng • e.g. 48.8566, 2.3522</string>
117127
<string name="map_search_invalid_format">Try 48.8566, 2.3522 • 48.8566 2.3522 • N48.8566 E2.3522 • 48°51\'24\"N 2°21\'08\"E</string>
118128
<string name="map_search_clear">Clear search</string>

map/src/test/java/com/adsamcik/tracker/map/shared/layers/LayerDescriptorTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ class LayerDescriptorTest {
232232
val capabilities = LayerCapabilities()
233233
val recipe = LayerRecipe(factory = LayerFactory { Unit })
234234

235-
val desc1 = LayerDescriptor("id1", 1, null, capabilities, recipe)
236-
val desc2 = LayerDescriptor("id2", 1, null, capabilities, recipe)
235+
val desc1 = LayerDescriptor("id1", 1, iconRes = null, capabilities = capabilities, recipe = recipe)
236+
val desc2 = LayerDescriptor("id2", 1, iconRes = null, capabilities = capabilities, recipe = recipe)
237237

238238
desc1 shouldNotBe desc2
239239
}

0 commit comments

Comments
 (0)