Author: Adam Evyčędo <git@apiote.xyz>
specify arrival and departure fields visibility
app/src/main/java/xyz/apiote/bimba/czwek/departures/Departures.kt | 25 app/src/main/java/xyz/apiote/bimba/czwek/repo/Event.kt | 2 app/src/main/res/values-en-rGB/strings.xml | 1 app/src/main/res/values-en-rUS/strings.xml | 1 app/src/main/res/values/strings.xml | 1
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 1149a1f49dab7759417338931a1bfcb36165e2a7..6e375b9056ef7f69e650ef9f137ce9debc822557 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 @@ -117,13 +117,23 @@ } val statusTexts = event.statusText(context, showAsTime) if (event.arrivalTime == event.departureTime) { + if (!event.exact) { + holder?.arrivalStatus?.apply{ + visibility = View.VISIBLE + text = context?.getString(R.string.approximately) + } + } else { + holder?.arrivalStatus?.visibility = View.GONE + } holder?.arrivalStatus?.visibility = View.GONE holder?.arrivalTime?.text = statusTexts.first holder?.departureStatus?.visibility = View.GONE holder?.departureTime?.visibility = View.GONE } else { if (statusTexts.first != null) { + holder?.arrivalTime?.visibility = View.VISIBLE holder?.arrivalTime?.text = statusTexts.first + holder?.arrivalStatus?.visibility = View.VISIBLE holder?.arrivalStatus?.text = if (!event.exact) { context?.getString(R.string.arrival_approximate) } else { @@ -134,7 +144,9 @@ holder?.arrivalTime?.visibility = View.GONE holder?.arrivalStatus?.visibility = View.GONE } if (statusTexts.second != null) { + holder?.departureTime?.visibility = View.VISIBLE holder?.departureTime?.text = statusTexts.second + holder?.departureStatus?.visibility = View.VISIBLE holder?.departureStatus?.text = if (!event.exact) { context?.getString(R.string.departure_approximate) } else { @@ -368,13 +380,22 @@ private fun setContent(view: View, ctx: Context, updating: Boolean = false) { view.apply { if (event.arrivalTime == event.departureTime) { - findViewById<TextView>(R.id.arrival_status).visibility = View.GONE + if (!event.exact) { + findViewById<TextView>(R.id.arrival_status).apply { + visibility = View.VISIBLE + text = context.getString(R.string.approximately) + } + } else { + findViewById<TextView>(R.id.arrival_status).visibility = View.GONE + } findViewById<TextView>(R.id.arrival_time).text = event.arrivalTimeString(ctx) findViewById<TextView>(R.id.departure_status).visibility = View.GONE findViewById<TextView>(R.id.departure_time).visibility = View.GONE } else { if (event.arrivalTime != null) { + findViewById<TextView>(R.id.arrival_time).visibility = View.VISIBLE findViewById<TextView>(R.id.arrival_time).text = event.arrivalTimeString(ctx) + findViewById<TextView>(R.id.arrival_status).visibility = View.VISIBLE findViewById<TextView>(R.id.arrival_status).text = if (!event.exact) { context?.getString(R.string.arrival_approximate) } else { @@ -382,7 +403,9 @@ context?.getString(R.string.arrival) } } if (event.departureTime != null) { + findViewById<TextView>(R.id.departure_time).visibility = View.VISIBLE findViewById<TextView>(R.id.departure_time).text = event.departureTimeString(ctx) + findViewById<TextView>(R.id.departure_status).visibility = View.VISIBLE findViewById<TextView>(R.id.departure_status).text = if (!event.exact) { context?.getString(R.string.departure_approximate) } else { diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/repo/Event.kt b/app/src/main/java/xyz/apiote/bimba/czwek/repo/Event.kt index 6fad703e8548c4544c9b53d3406a61cd173691d2..7124878123c6fdac915f2f3f76e6b89a9d8f2819 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/repo/Event.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/repo/Event.kt @@ -119,7 +119,7 @@ val vehicle: Vehicle, val boarding: UByte, val alerts: List<Alert>, val exact: Boolean, - val terminusArrival: Boolean + val terminusArrival: Boolean // TODO origin, middle, terminus; if origin -> only departure, if terminus -> only arrival ) { constructor(d: DepartureV1) : this( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6ddbc228a9ae386902163571a89eea12cb8ad0e0..d7eabb6448290335cfad6b1b52b8943562ede311 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -291,4 +291,5 @@approx. arr. <string name="arrival">arrival</string> <string name="departure_approximate">approx. dep.</string> <string name="departure">departure</string> + <string name="approximately">approximately</string> </resources> diff --git a/app/src/main/res/values-en-rGB/strings.xml b/app/src/main/res/values-en-rGB/strings.xml index f20916cb26b056ffd7ed22c61aed616a0e33d316..ec997e571a28a41d46c974304df3b6e0d861996c 100644 --- a/app/src/main/res/values-en-rGB/strings.xml +++ b/app/src/main/res/values-en-rGB/strings.xml @@ -288,4 +288,5 @@arrived <string name="arrival_approximate">approx. arr.</string> <string name="departure_approximate">approx. dep.</string> <string name="departure">departure</string> + <string name="approximately">approximately</string> </resources> diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml index 5bec455c4cb9b41af902e598c8062810869a6359..6ad527fb5a1a97aa900aacfce8b26a8ce55a2821 100644 --- a/app/src/main/res/values-en-rUS/strings.xml +++ b/app/src/main/res/values-en-rUS/strings.xml @@ -286,4 +286,5 @@arrived <string name="arrival_approximate">approx. arr.</string> <string name="departure_approximate">approx. dep.</string> <string name="departure">departure</string> + <string name="approximately">approximately</string> </resources> \ No newline at end of file