Skip to content

Commit 5dedf7e

Browse files
tomaszrybakiewiczrunner
andauthored
SpeedInfo - fixed MUTCD 3-digit speed limit rendering (#6919)
* SpeedInfo - fixed MUTCD 3 digit speed limit rendering - Added more customization testing options to qa-test-app “Customized NavigationView” activity * Rename changelog files * SpeedInfo - Using “dp” instead of “sp” sizing for MapboxSpeedInfoView speed text. * Qa-Test-App - Moved new Speed Info customization options to its own menu section --------- Co-authored-by: runner <runner@fv-az212-263>
1 parent bf3b935 commit 5dedf7e

7 files changed

Lines changed: 88 additions & 15 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixed rendering of 3 digit speed limit values in `MapboxSpeedInfoView`.

libnavui-speedlimit/src/main/res/layout/mapbox_speed_info_view.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
android:layout_height="wrap_content"
1212
android:padding="2dp"
1313
android:visibility="gone"
14+
tools:visibility="visible"
1415
tools:background="@drawable/background_mutcd_outer_layout"
1516
>
1617
<androidx.constraintlayout.widget.ConstraintLayout
1718
android:id="@+id/postedSpeedLayoutMutcd"
1819
android:layout_width="64dp"
1920
android:layout_height="wrap_content"
20-
android:padding="10dp"
21+
android:paddingTop="10dp"
22+
android:paddingBottom="10dp"
2123
app:layout_constraintEnd_toEndOf="parent"
2224
app:layout_constraintTop_toTopOf="parent"
2325
app:layout_constraintStart_toStartOf="parent"
@@ -44,12 +46,13 @@
4446
android:layout_width="0dp"
4547
android:layout_height="wrap_content"
4648
android:gravity="center"
49+
android:maxLines="1"
4750
android:includeFontPadding="false"
4851
app:layout_constraintEnd_toEndOf="parent"
4952
app:layout_constraintStart_toStartOf="parent"
5053
app:layout_constraintTop_toBottomOf="@id/postedSpeedLegend"
5154
tools:textAppearance="@style/MapboxSpeedInfoPostedSpeedMutcdStyle"
52-
tools:text="60"
55+
tools:text="110"
5356
/>
5457

5558
<androidx.appcompat.widget.AppCompatTextView
@@ -70,6 +73,7 @@
7073
android:id="@+id/currentSpeedMutcd"
7174
android:layout_width="wrap_content"
7275
android:layout_height="wrap_content"
76+
android:maxLines="1"
7377
android:padding="4dp"
7478
android:gravity="center"
7579
android:visibility="gone"
@@ -105,6 +109,7 @@
105109
android:layout_width="0dp"
106110
android:layout_height="wrap_content"
107111
android:gravity="center"
112+
android:maxLines="1"
108113
android:includeFontPadding="false"
109114
app:layout_constraintTop_toTopOf="parent"
110115
app:layout_constraintEnd_toEndOf="parent"
@@ -120,6 +125,7 @@
120125
android:layout_height="wrap_content"
121126
android:padding="6dp"
122127
android:gravity="center"
128+
android:maxLines="1"
123129
android:includeFontPadding="false"
124130
app:layout_constraintEnd_toEndOf="parent"
125131
app:layout_constraintStart_toStartOf="parent"

libnavui-speedlimit/src/main/res/values/styles.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
</style>
2222

2323
<style name="MapboxSpeedInfoPostedSpeedMutcdStyle">
24-
<item name="android:textSize">32sp</item>
24+
<item name="android:textSize">32dp</item>
2525
<item name="android:textColor">@android:color/black</item>
2626
</style>
2727

2828
<style name="MapboxSpeedInfoCurrentSpeedMutcdStyle">
29-
<item name="android:textSize">32sp</item>
29+
<item name="android:textSize">32dp</item>
3030
<item name="android:textColor">@color/mapbox_current_speed_color</item>
3131
</style>
3232

3333
<style name="MapboxSpeedInfoPostedSpeedViennaStyle">
34-
<item name="android:textSize">32sp</item>
34+
<item name="android:textSize">32dp</item>
3535
<item name="android:textColor">@android:color/black</item>
3636
</style>
3737

3838
<style name="MapboxSpeedInfoCurrentSpeedViennaStyle">
39-
<item name="android:textSize">32sp</item>
39+
<item name="android:textSize">32dp</item>
4040
<item name="android:textColor">@color/mapbox_current_speed_color</item>
4141
</style>
4242
</resources>

qa-test-app/src/main/java/com/mapbox/navigation/qa_test_app/view/customnavview/CustomizedViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class CustomizedViewModel : ViewModel() {
1616
// General
1717
val showManeuver = MutableLiveData(true)
1818
val showSpeedLimit = MutableLiveData(true)
19+
val showSpeedInfoLegend = MutableLiveData(false)
20+
val speedInfoSign = MutableLiveData("--")
1921
val showRoadName = MutableLiveData(true)
2022
val showActionButtons = MutableLiveData(true)
2123
val useCustomStyles = MutableLiveData(false)

qa-test-app/src/main/java/com/mapbox/navigation/qa_test_app/view/customnavview/MapboxNavigationViewCustomizedActivity.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.mapbox.navigation.base.route.NavigationRoute
4040
import com.mapbox.navigation.base.route.NavigationRouterCallback
4141
import com.mapbox.navigation.base.route.RouterFailure
4242
import com.mapbox.navigation.base.route.RouterOrigin
43+
import com.mapbox.navigation.base.speed.model.SpeedLimitSign
4344
import com.mapbox.navigation.core.MapboxNavigation
4445
import com.mapbox.navigation.core.internal.dump.MapboxDumpRegistry
4546
import com.mapbox.navigation.core.internal.extensions.attachCreated
@@ -237,6 +238,32 @@ class MapboxNavigationViewCustomizedActivity : DrawerActivity() {
237238
viewModel.useLegacy,
238239
::toggleLegacySpeedLimit
239240
)
241+
242+
bindSwitch(
243+
menuBinding.toggleShowSpeedInfoLegend,
244+
viewModel.showSpeedInfoLegend
245+
) { updateSpeedInfoOptions() }
246+
247+
bindSpinner(
248+
menuBinding.spinnerSpeedInfoSign,
249+
viewModel.speedInfoSign
250+
) { updateSpeedInfoOptions() }
251+
}
252+
253+
private fun updateSpeedInfoOptions() {
254+
val speedLimitSign = when (viewModel.speedInfoSign.value) {
255+
"MUTCD" -> SpeedLimitSign.MUTCD
256+
"VIENNA" -> SpeedLimitSign.VIENNA
257+
else -> null
258+
}
259+
val showLegend = viewModel.showSpeedInfoLegend.value ?: false
260+
261+
binding.navigationView.customizeViewStyles {
262+
speedInfoOptions = MapboxSpeedInfoOptions.Builder()
263+
.renderWithSpeedSign(speedLimitSign)
264+
.showLegend(showLegend)
265+
.build()
266+
}
240267
}
241268

242269
//endregion

qa-test-app/src/main/res/layout/layout_drawer_menu_nav_view_custom.xml

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,6 @@
130130
android:text="Show Maneuver"
131131
android:textAllCaps="true" />
132132

133-
<androidx.appcompat.widget.SwitchCompat
134-
android:id="@+id/toggleShowSpeedLimit"
135-
android:layout_width="match_parent"
136-
android:layout_height="wrap_content"
137-
android:layout_weight="1"
138-
android:paddingVertical="10dp"
139-
android:text="Show Speed Limit"
140-
android:textAllCaps="true" />
141-
142133
<androidx.appcompat.widget.SwitchCompat
143134
android:id="@+id/toggleShowRoadName"
144135
android:layout_width="match_parent"
@@ -321,6 +312,47 @@
321312
android:text="Use Legacy Speed Limit"
322313
android:textAllCaps="true" />
323314

315+
<androidx.appcompat.widget.SwitchCompat
316+
android:id="@+id/toggleShowSpeedLimit"
317+
android:layout_width="match_parent"
318+
android:layout_height="wrap_content"
319+
android:layout_weight="1"
320+
android:paddingVertical="10dp"
321+
android:text="Show Speed Info"
322+
android:textAllCaps="true" />
323+
324+
<androidx.appcompat.widget.SwitchCompat
325+
android:id="@+id/toggleShowSpeedInfoLegend"
326+
android:layout_width="match_parent"
327+
android:layout_height="wrap_content"
328+
android:layout_weight="1"
329+
android:paddingVertical="10dp"
330+
android:text="Show Speed Info Legend"
331+
android:textAllCaps="true" />
332+
333+
<LinearLayout
334+
android:layout_width="match_parent"
335+
android:layout_height="40dp"
336+
android:gravity="center_vertical"
337+
android:paddingVertical="10dp">
338+
339+
<TextView
340+
android:layout_width="wrap_content"
341+
android:layout_height="wrap_content"
342+
android:textAllCaps="true"
343+
android:textColor="@color/colorOnSurface"
344+
android:text="Speed Info Sign" />
345+
346+
<androidx.appcompat.widget.AppCompatSpinner
347+
android:id="@+id/spinnerSpeedInfoSign"
348+
android:layout_width="wrap_content"
349+
android:layout_height="wrap_content"
350+
android:layout_gravity="center_vertical"
351+
android:layout_marginStart="5dp"
352+
android:entries="@array/drop_in_speed_info_sign"
353+
android:spinnerMode="dropdown" />
354+
355+
</LinearLayout>
324356
</androidx.appcompat.widget.LinearLayoutCompat>
325357

326358
<!-- Actions Customization -->

qa-test-app/src/main/res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
<item>--</item>
7373
<item>LARGE</item>
7474
</string-array>
75+
<string-array name="drop_in_speed_info_sign" translatable="false">
76+
<item>--</item>
77+
<item>MUTCD</item>
78+
<item>VIENNA</item>
79+
</string-array>
7580
<string-array name="drop_in_routing_profile" translatable="false">
7681
<item>--</item>
7782
<item>DRIVING-TRAFFIC</item>

0 commit comments

Comments
 (0)