Skip to content

Commit 1815a21

Browse files
Seth BourgetSeth Bourget
authored andcommitted
Added feature to mask the primary route line in order to give the appearance the active leg is above the inactive legs for multi-leg routes.
1 parent 09b5248 commit 1815a21

File tree

26 files changed

+2762
-370
lines changed

26 files changed

+2762
-370
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Modified the route line implementation so that for multi-leg routes the active leg appears above inactive route legs.

instrumentation-tests/src/androidTest/java/com/mapbox/navigation/instrumentation_tests/ui/routeline/RouteLineLayersTest.kt

Lines changed: 121 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -100,82 +100,105 @@ class RouteLineLayersTest : BaseTest<BasicNavigationViewActivity>(
100100
)
101101

102102
assertEquals(
103-
"mapbox-layerGroup-1-restricted",
103+
"mapbox-masking-layer-restricted",
104104
style.styleLayers[topLevelRouteLayerIndex - 1].id
105105
)
106106
assertEquals(
107-
"mapbox-layerGroup-1-traffic",
107+
"mapbox-masking-layer-traffic",
108108
style.styleLayers[topLevelRouteLayerIndex - 2].id
109109
)
110110
assertEquals(
111-
"mapbox-layerGroup-1-main",
111+
"mapbox-masking-layer-main",
112112
style.styleLayers[topLevelRouteLayerIndex - 3].id
113113
)
114114
assertEquals(
115-
"mapbox-layerGroup-1-casing",
115+
"mapbox-masking-layer-casing",
116116
style.styleLayers[topLevelRouteLayerIndex - 4].id
117117
)
118118
assertEquals(
119-
"mapbox-layerGroup-1-trail",
119+
"mapbox-masking-layer-trail",
120120
style.styleLayers[topLevelRouteLayerIndex - 5].id
121121
)
122122
assertEquals(
123-
"mapbox-layerGroup-1-trailCasing",
123+
"mapbox-masking-layer-trailCasing",
124124
style.styleLayers[topLevelRouteLayerIndex - 6].id
125125
)
126-
127126
assertEquals(
128-
"mapbox-layerGroup-2-restricted",
127+
"mapbox-layerGroup-1-restricted",
129128
style.styleLayers[topLevelRouteLayerIndex - 7].id
130129
)
131130
assertEquals(
132-
"mapbox-layerGroup-2-traffic",
131+
"mapbox-layerGroup-1-traffic",
133132
style.styleLayers[topLevelRouteLayerIndex - 8].id
134133
)
135134
assertEquals(
136-
"mapbox-layerGroup-2-main",
135+
"mapbox-layerGroup-1-main",
137136
style.styleLayers[topLevelRouteLayerIndex - 9].id
138137
)
139138
assertEquals(
140-
"mapbox-layerGroup-2-casing",
139+
"mapbox-layerGroup-1-casing",
141140
style.styleLayers[topLevelRouteLayerIndex - 10].id
142141
)
143142
assertEquals(
144-
"mapbox-layerGroup-2-trail",
143+
"mapbox-layerGroup-1-trail",
145144
style.styleLayers[topLevelRouteLayerIndex - 11].id
146145
)
147146
assertEquals(
148-
"mapbox-layerGroup-2-trailCasing",
147+
"mapbox-layerGroup-1-trailCasing",
149148
style.styleLayers[topLevelRouteLayerIndex - 12].id
150149
)
150+
assertEquals(
151+
"mapbox-layerGroup-2-restricted",
152+
style.styleLayers[topLevelRouteLayerIndex - 13].id
153+
)
154+
assertEquals(
155+
"mapbox-layerGroup-2-traffic",
156+
style.styleLayers[topLevelRouteLayerIndex - 14].id
157+
)
158+
assertEquals(
159+
"mapbox-layerGroup-2-main",
160+
style.styleLayers[topLevelRouteLayerIndex - 15].id
161+
)
162+
assertEquals(
163+
"mapbox-layerGroup-2-casing",
164+
style.styleLayers[topLevelRouteLayerIndex - 16].id
165+
)
166+
assertEquals(
167+
"mapbox-layerGroup-2-trail",
168+
style.styleLayers[topLevelRouteLayerIndex - 17].id
169+
)
170+
assertEquals(
171+
"mapbox-layerGroup-2-trailCasing",
172+
style.styleLayers[topLevelRouteLayerIndex - 18].id
173+
)
151174

152175
assertEquals(
153176
"mapbox-layerGroup-3-restricted",
154-
style.styleLayers[topLevelRouteLayerIndex - 13].id
177+
style.styleLayers[topLevelRouteLayerIndex - 19].id
155178
)
156179
assertEquals(
157180
"mapbox-layerGroup-3-traffic",
158-
style.styleLayers[topLevelRouteLayerIndex - 14].id
181+
style.styleLayers[topLevelRouteLayerIndex - 20].id
159182
)
160183
assertEquals(
161184
"mapbox-layerGroup-3-main",
162-
style.styleLayers[topLevelRouteLayerIndex - 15].id
185+
style.styleLayers[topLevelRouteLayerIndex - 21].id
163186
)
164187
assertEquals(
165188
"mapbox-layerGroup-3-casing",
166-
style.styleLayers[topLevelRouteLayerIndex - 16].id
189+
style.styleLayers[topLevelRouteLayerIndex - 22].id
167190
)
168191
assertEquals(
169192
"mapbox-layerGroup-3-trail",
170-
style.styleLayers[topLevelRouteLayerIndex - 17].id
193+
style.styleLayers[topLevelRouteLayerIndex - 23].id
171194
)
172195
assertEquals(
173196
"mapbox-layerGroup-3-trailCasing",
174-
style.styleLayers[topLevelRouteLayerIndex - 18].id
197+
style.styleLayers[topLevelRouteLayerIndex - 24].id
175198
)
176199
assertEquals(
177200
"mapbox-bottom-level-route-layer",
178-
style.styleLayers[topLevelRouteLayerIndex - 19].id
201+
style.styleLayers[topLevelRouteLayerIndex - 25].id
179202
)
180203
}
181204
}
@@ -212,29 +235,53 @@ class RouteLineLayersTest : BaseTest<BasicNavigationViewActivity>(
212235
)
213236
)
214237
assertEquals(
215-
"mapbox-layerGroup-1-restricted",
238+
"mapbox-masking-layer-restricted",
216239
style.styleLayers[topLevelRouteLayerIndex - 1].id
217240
)
218241
assertEquals(
219-
"mapbox-layerGroup-1-traffic",
242+
"mapbox-masking-layer-traffic",
220243
style.styleLayers[topLevelRouteLayerIndex - 2].id
221244
)
222245
assertEquals(
223-
"mapbox-layerGroup-1-main",
246+
"mapbox-masking-layer-main",
224247
style.styleLayers[topLevelRouteLayerIndex - 3].id
225248
)
226249
assertEquals(
227-
"mapbox-layerGroup-1-casing",
250+
"mapbox-masking-layer-casing",
228251
style.styleLayers[topLevelRouteLayerIndex - 4].id
229252
)
230253
assertEquals(
231-
"mapbox-layerGroup-1-trail",
254+
"mapbox-masking-layer-trail",
232255
style.styleLayers[topLevelRouteLayerIndex - 5].id
233256
)
234257
assertEquals(
235-
"mapbox-layerGroup-1-trailCasing",
258+
"mapbox-masking-layer-trailCasing",
236259
style.styleLayers[topLevelRouteLayerIndex - 6].id
237260
)
261+
assertEquals(
262+
"mapbox-layerGroup-1-restricted",
263+
style.styleLayers[topLevelRouteLayerIndex - 7].id
264+
)
265+
assertEquals(
266+
"mapbox-layerGroup-1-traffic",
267+
style.styleLayers[topLevelRouteLayerIndex - 8].id
268+
)
269+
assertEquals(
270+
"mapbox-layerGroup-1-main",
271+
style.styleLayers[topLevelRouteLayerIndex - 9].id
272+
)
273+
assertEquals(
274+
"mapbox-layerGroup-1-casing",
275+
style.styleLayers[topLevelRouteLayerIndex - 10].id
276+
)
277+
assertEquals(
278+
"mapbox-layerGroup-1-trail",
279+
style.styleLayers[topLevelRouteLayerIndex - 11].id
280+
)
281+
assertEquals(
282+
"mapbox-layerGroup-1-trailCasing",
283+
style.styleLayers[topLevelRouteLayerIndex - 12].id
284+
)
238285
// This mimics selecting an alternative route by making the first
239286
// alternative the primary route and the original primary route one
240287
// of the alternatives.
@@ -253,29 +300,53 @@ class RouteLineLayersTest : BaseTest<BasicNavigationViewActivity>(
253300
object : CountDownTimer(1000, 1000) {
254301
override fun onFinish() {
255302
assertEquals(
256-
"mapbox-layerGroup-2-restricted",
303+
"mapbox-masking-layer-restricted",
257304
style.styleLayers[topLevelRouteLayerIndex - 1].id
258305
)
259306
assertEquals(
260-
"mapbox-layerGroup-2-traffic",
307+
"mapbox-masking-layer-traffic",
261308
style.styleLayers[topLevelRouteLayerIndex - 2].id
262309
)
263310
assertEquals(
264-
"mapbox-layerGroup-2-main",
311+
"mapbox-masking-layer-main",
265312
style.styleLayers[topLevelRouteLayerIndex - 3].id
266313
)
267314
assertEquals(
268-
"mapbox-layerGroup-2-casing",
315+
"mapbox-masking-layer-casing",
269316
style.styleLayers[topLevelRouteLayerIndex - 4].id
270317
)
271318
assertEquals(
272-
"mapbox-layerGroup-2-trail",
319+
"mapbox-masking-layer-trail",
273320
style.styleLayers[topLevelRouteLayerIndex - 5].id
274321
)
275322
assertEquals(
276-
"mapbox-layerGroup-2-trailCasing",
323+
"mapbox-masking-layer-trailCasing",
277324
style.styleLayers[topLevelRouteLayerIndex - 6].id
278325
)
326+
assertEquals(
327+
"mapbox-layerGroup-2-restricted",
328+
style.styleLayers[topLevelRouteLayerIndex - 7].id
329+
)
330+
assertEquals(
331+
"mapbox-layerGroup-2-traffic",
332+
style.styleLayers[topLevelRouteLayerIndex - 8].id
333+
)
334+
assertEquals(
335+
"mapbox-layerGroup-2-main",
336+
style.styleLayers[topLevelRouteLayerIndex - 9].id
337+
)
338+
assertEquals(
339+
"mapbox-layerGroup-2-casing",
340+
style.styleLayers[topLevelRouteLayerIndex - 10].id
341+
)
342+
assertEquals(
343+
"mapbox-layerGroup-2-trail",
344+
style.styleLayers[topLevelRouteLayerIndex - 11].id
345+
)
346+
assertEquals(
347+
"mapbox-layerGroup-2-trailCasing",
348+
style.styleLayers[topLevelRouteLayerIndex - 12].id
349+
)
279350
countDownLatch.countDown()
280351
}
281352

@@ -332,9 +403,13 @@ class RouteLineLayersTest : BaseTest<BasicNavigationViewActivity>(
332403
)?.visibility
333404
)
334405
assertEquals(
335-
"mapbox-layerGroup-1-traffic",
406+
"mapbox-masking-layer-traffic",
336407
style.styleLayers[topLevelRouteLayerIndex - 1].id
337408
)
409+
assertEquals(
410+
"mapbox-layerGroup-1-traffic",
411+
style.styleLayers[topLevelRouteLayerIndex - 6].id
412+
)
338413
// This mimics selecting an alternative route by making the first
339414
// alternative the primary route and the original primary route one
340415
// of the alternatives.
@@ -354,24 +429,34 @@ class RouteLineLayersTest : BaseTest<BasicNavigationViewActivity>(
354429
override fun onFinish() {
355430
// Primary route group is now 2 and not visible
356431
assertEquals(
357-
"mapbox-layerGroup-2-traffic",
432+
"mapbox-masking-layer-traffic",
358433
style.styleLayers[topLevelRouteLayerIndex - 1].id
359434
)
435+
assertEquals(
436+
"mapbox-layerGroup-2-traffic",
437+
style.styleLayers[topLevelRouteLayerIndex - 6].id
438+
)
360439
assertEquals(
361440
Visibility.NONE,
362441
style.getLayer(
363442
style.styleLayers[topLevelRouteLayerIndex - 1].id
364443
)?.visibility
365444
)
445+
assertEquals(
446+
Visibility.NONE,
447+
style.getLayer(
448+
style.styleLayers[topLevelRouteLayerIndex - 6].id
449+
)?.visibility
450+
)
366451
// Previously primary route group is 1 and is now visible
367452
assertEquals(
368453
"mapbox-layerGroup-1-traffic",
369-
style.styleLayers[topLevelRouteLayerIndex - 6].id
454+
style.styleLayers[topLevelRouteLayerIndex - 11].id
370455
)
371456
assertEquals(
372457
Visibility.VISIBLE,
373458
style.getLayer(
374-
style.styleLayers[topLevelRouteLayerIndex - 6].id
459+
style.styleLayers[topLevelRouteLayerIndex - 11].id
375460
)?.visibility
376461
)
377462
countDownLatch.countDown()

0 commit comments

Comments
 (0)