From 41134cc4555cefffc299169f3b5932ba8147aa80 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 13 Nov 2026 15:36:43 +0100 Subject: [PATCH] fix(native): read the flight widget's direction from the locale Android lint refuses a composition reading the Configuration through LocalContext. The arc's mirroring now follows the locale's layout direction, which is what the widget's language decides anyway. --- .../main/java/com/liketrek/trek/widget/TrekWidgets.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/android/app/src/main/java/com/liketrek/trek/widget/TrekWidgets.kt b/client/android/app/src/main/java/com/liketrek/trek/widget/TrekWidgets.kt index 71919eea7..1af7aa1e8 100644 --- a/client/android/app/src/main/java/com/liketrek/trek/widget/TrekWidgets.kt +++ b/client/android/app/src/main/java/com/liketrek/trek/widget/TrekWidgets.kt @@ -537,10 +537,13 @@ class FlightWidget : TrekWidget() { } } -/** The origin stands on the right in a right-to-left layout, so the drawn arc is mirrored with it. */ -@Composable +/** + * The origin stands on the right in a right-to-left layout, so the drawn arc is + * mirrored with it. Read from the locale the widget speaks, not from the + * Configuration, which a composition may not read directly. + */ private fun isRtl(): Boolean = - LocalContext.current.resources.configuration.layoutDirection == android.view.View.LAYOUT_DIRECTION_RTL + android.text.TextUtils.getLayoutDirectionFromLocale(java.util.Locale.getDefault()) == android.view.View.LAYOUT_DIRECTION_RTL @Composable private fun ColumnScope.FlightBody(f: WidgetSnapshot.Flight, labels: WidgetSnapshot.Labels, wide: Boolean, tall: Boolean) {