Author: Adam Evyčędo <git@apiote.xyz>
finish adding basic transitous
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/ui/map/MapViewModel.kt b/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/ui/map/MapViewModel.kt index 29ab95545f1d7ad0c79246c6a85e095b5f023af5..6aa86b0cb2362798e410558411e5229ae8ba873e 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/ui/map/MapViewModel.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/dashboard/ui/map/MapViewModel.kt @@ -74,6 +74,7 @@ ) } content.findViewById<TextView>(R.id.time).visibility = View.GONE + content.findViewById<TextView>(R.id.local_time).visibility = View.GONE content.findViewById<MapView>(R.id.map).visibility = View.GONE content.findViewById<LinearLayout>(R.id.boarding).visibility = View.GONE diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/departures/Departures.kt b/app/src/main/java/xyz/apiote/bimba/czwek/departures/Departures.kt index 5f50f5add8aba3a517babe6d39eb0166eef25257..17c08de21676990de2632a77c932c099454c4626 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/departures/Departures.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/departures/Departures.kt @@ -34,6 +34,7 @@ import org.osmdroid.views.MapView import org.osmdroid.views.overlay.Marker import org.osmdroid.views.overlay.TilesOverlay import org.osmdroid.views.overlay.gestures.RotationGestureOverlay +import org.w3c.dom.Text import xyz.apiote.bimba.czwek.R import xyz.apiote.bimba.czwek.dpToPixelI import xyz.apiote.bimba.czwek.repo.Alert @@ -179,7 +180,7 @@ PreferenceManager.getDefaultSharedPreferences( it ).getString(TERMINUS_ARRIVAL_SHOWING_KEY, TERMINUS_ARRIVAL_GREY_OUT) } - ?: TERMINUS_ARRIVAL_GREY_OUT + ?: TERMINUS_ARRIVAL_GREY_OUT var lastUpdate: ZonedDateTime = ZonedDateTime.of(0, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()) @@ -204,15 +205,15 @@ val oldDeparture = oldDepartures[oldItemPosition] val newDeparture = newDepartures[newItemPosition] return if (oldDeparture.departure != null && newDeparture.departure != null) { !oldDeparture.departure.terminusArrival && - oldDeparture.departure.terminusArrival == newDeparture.departure.terminusArrival && - oldDeparture.departure.exact == newDeparture.departure.exact && - oldDeparture.departure.vehicle.Line == newDeparture.departure.vehicle.Line && - oldDeparture.departure.vehicle.Headsign == newDeparture.departure.vehicle.Headsign && - oldDeparture.departure.statusText( - context, - false, - lastUpdate - ) == newDeparture.departure.statusText(context, false) && !showAsTimeChanged + oldDeparture.departure.terminusArrival == newDeparture.departure.terminusArrival && + oldDeparture.departure.exact == newDeparture.departure.exact && + oldDeparture.departure.vehicle.Line == newDeparture.departure.vehicle.Line && + oldDeparture.departure.vehicle.Headsign == newDeparture.departure.vehicle.Headsign && + oldDeparture.departure.statusText( + context, + false, + lastUpdate + ) == newDeparture.departure.statusText(context, false) && !showAsTimeChanged } else if (oldDeparture.alert.isNotEmpty() && newDeparture.alert.isEmpty()) { oldDeparture.alert == newDeparture.alert } else { @@ -339,6 +340,12 @@ private fun setContent(view: View, ctx: Context, updating: Boolean = false) { view.apply { findViewById<TextView>(R.id.time).text = departure.timeString(ctx) + findViewById<TextView>(R.id.local_time).visibility = + if (departure.time.Zone == ZoneId.systemDefault().id) { + View.GONE + } else { + View.VISIBLE + } findViewById<ImageView>(R.id.rt_icon).apply { visibility = if (departure.isRealtime) { @@ -372,7 +379,15 @@ departure.vehicle.Headsign ) } - findViewById<TextView>(R.id.boarding_text).text = departure.boardingText(ctx) + + departure.boardingText(ctx).let { + findViewById<TextView>(R.id.boarding_text).text = it + findViewById<ImageView>(R.id.boarding_icon).visibility = if (it == "") { + View.GONE + } else { + View.VISIBLE + } + } UnitSystem.getSelected(requireContext()).let { us -> findViewById<TextView>(R.id.speed_text).apply { text = @@ -522,7 +537,7 @@ content.apply { findViewById<MapView>(R.id.map).let { map -> map.setTileSource(TileSourceFactory.MAPNIK) if (((context?.resources?.configuration?.uiMode ?: UI_MODE_NIGHT_UNDEFINED) - and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES + and UI_MODE_NIGHT_MASK) == UI_MODE_NIGHT_YES ) { map.overlayManager.tilesOverlay.setColorFilter(TilesOverlay.INVERT_COLORS) } diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/repo/Departure.kt b/app/src/main/java/xyz/apiote/bimba/czwek/repo/Departure.kt index 66ac62094ec48793ce330634aa369da2d1b18c68..38a48a946c2048ad2fa19b5eb4fa169769287adc 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/repo/Departure.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/repo/Departure.kt @@ -232,6 +232,7 @@ fun boardingText(context: Context): String { // todo [3.x] probably should take into account (on|off)-boarding only, on demand return when { boarding == (0b0000_0000).toUByte() -> context.getString(R.string.no_boarding) + boarding == (0b1111_1111).toUByte() -> "" // unknown boarding.and(0b0011_0011u) == (0b0000_0001).toUByte() -> context.getString(R.string.on_boarding) boarding.and(0b0011_0011u) == (0b0001_0000).toUByte() -> context.getString(R.string.off_boarding) boarding.and(0b0011_0011u) == (0b0001_0001).toUByte() -> context.getString(R.string.boarding) diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/repo/OnlineRepository.kt b/app/src/main/java/xyz/apiote/bimba/czwek/repo/OnlineRepository.kt index 64f5498c6cdb53cc8340ee59a386083a6233db8b..b7d2e006eaff96892534f2e72bf447aa6cb96d54 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/repo/OnlineRepository.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/repo/OnlineRepository.kt @@ -265,8 +265,8 @@ } return if (transitousQueryables == null && bimbaQueryables == null) { null } else { - (transitousQueryables ?: listOf()) + (bimbaQueryables ?: listOf()) - } // TODO sort + (bimbaQueryables ?: listOf()) + (transitousQueryables ?: listOf()) + } } override suspend fun locateQueryables( diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/search/Results.kt b/app/src/main/java/xyz/apiote/bimba/czwek/search/Results.kt index 57d79cf7d143b6290b74b68ef7848fc69bb782b4..6edad804085f30265578b89d4abe728cf3c147c8 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/search/Results.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/search/Results.kt @@ -142,6 +142,8 @@ holder?.title?.text = stop.name if ((feedsSettings?.activeFeedsCount() ?: 0) > 1 || (stop.feedID ?: "") == "transitous") { holder?.feedName?.visibility = View.VISIBLE holder?.feedName?.text = feeds?.get(stop.feedID)?.name ?: "" + } else { + holder?.feedName?.visibility = View.GONE } context?.let { stop.changeOptions(it, Stop.LineDecoration.fromPreferences(context)).let { changeOptions -> diff --git a/app/src/main/res/layout/departure_bottom_sheet.xml b/app/src/main/res/layout/departure_bottom_sheet.xml index 5d5c7b3acb6ae7a0b5a21c7c50f67771ed7fc176..3b6e92fa314f2d9967ae05c9200666b9989f8bbb 100644 --- a/app/src/main/res/layout/departure_bottom_sheet.xml +++ b/app/src/main/res/layout/departure_bottom_sheet.xml @@ -31,6 +31,16 @@ app:layout_constraintTop_toBottomOf="@+id/drag_handle" tool:text="at 12:10:30" /> <com.google.android.material.textview.MaterialTextView + android:id="@+id/local_time" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + app:layout_constraintTop_toBottomOf="@+id/time" + app:layout_constraintEnd_toEndOf="@+id/time" + android:text="@string/local_time" + android:visibility="gone" + app:layout_constraintStart_toStartOf="@+id/time" /> + + <com.google.android.material.textview.MaterialTextView android:id="@+id/offset" android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -73,7 +83,7 @@ android:textAlignment="center" android:textAppearance="@style/TextAppearance.Material3.HeadlineSmall" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/time" /> + app:layout_constraintTop_toBottomOf="@id/local_time" /> <androidx.constraintlayout.helper.widget.Flow android:id="@+id/info" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e7276841464dd7fc779cddd62a31bc9b3402309d..e8c8b70d098ddbdba4dd709f21c267dd8a8458e0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -287,4 +287,5 @@link to Matrix channel <string name="email_button_description">link to email</string> <string name="transitous_description">A community-run provider-neutral international public transport routing service. Coverage is available at https://transitous.org/sources/</string> <string name="transitous_attribution">Transitous (https://transitous.org) API provided by Spline (https://routing.spline.de). Localities (https://github.com/public-transport/transitous/tree/main/feeds) maintained by the community.</string> + <string name="local_time">local time</string> </resources>