From a00922efe13c9c67a85e03d004a26e7ff70c8cef Mon Sep 17 00:00:00 2001 From: Grzegorz Orczykowski Date: Wed, 9 Aug 2023 15:50:39 +0200 Subject: [PATCH] Improved strings --- .../android/readytosend/ReadyToSendBanner.kt | 14 +++++++---- strings/src/main/res/values/strings.xml | 25 +++++++++++++++---- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/collect_app/src/main/java/org/odk/collect/android/readytosend/ReadyToSendBanner.kt b/collect_app/src/main/java/org/odk/collect/android/readytosend/ReadyToSendBanner.kt index 7f00cf0ad67..7de6c44c24f 100644 --- a/collect_app/src/main/java/org/odk/collect/android/readytosend/ReadyToSendBanner.kt +++ b/collect_app/src/main/java/org/odk/collect/android/readytosend/ReadyToSendBanner.kt @@ -31,16 +31,20 @@ class ReadyToSendBanner(context: Context, attrs: AttributeSet?) : ConstraintLayo val lastSentInstance = sentInstances.maxBy { instance -> instance.lastStatusChangeDate } val millisecondsAgo = clock.get() - lastSentInstance.lastStatusChangeDate if (millisecondsAgo >= ONE_DAY) { - binding.title.text = context.getString(R.string.last_form_sent_days_ago, millisecondsAgo / ONE_DAY) + val days: Int = (millisecondsAgo / ONE_DAY).toInt() + binding.title.text = context.resources.getQuantityString(R.plurals.last_form_sent_days_ago, days, days) } else if (millisecondsAgo >= ONE_HOUR) { - binding.title.text = context.getString(R.string.last_form_sent_hours_ago, millisecondsAgo / ONE_HOUR) + val hours: Int = (millisecondsAgo / ONE_HOUR).toInt() + binding.title.text = context.resources.getQuantityString(R.plurals.last_form_sent_hours_ago, hours, hours) } else if (millisecondsAgo >= ONE_MINUTE) { - binding.title.text = context.getString(R.string.last_form_sent_minutes_ago, millisecondsAgo / ONE_MINUTE) + val minutes: Int = (millisecondsAgo / ONE_MINUTE).toInt() + binding.title.text = context.resources.getQuantityString(R.plurals.last_form_sent_minutes_ago, minutes, minutes) } else { - binding.title.text = context.getString(R.string.last_form_sent_seconds_ago, millisecondsAgo / ONE_SECOND) + val seconds: Int = (millisecondsAgo / ONE_SECOND).toInt() + binding.title.text = context.resources.getQuantityString(R.plurals.last_form_sent_seconds_ago, seconds, seconds) } - binding.subtext.text = context.getString(R.string.forms_ready_to_send, numberOfInstancesReadyToSend) + binding.subtext.text = context.resources.getQuantityString(R.plurals.forms_ready_to_send, numberOfInstancesReadyToSend, numberOfInstancesReadyToSend) binding.banner.visibility = VISIBLE } } diff --git a/strings/src/main/res/values/strings.xml b/strings/src/main/res/values/strings.xml index 2a9ae269abe..935d3d66746 100644 --- a/strings/src/main/res/values/strings.xml +++ b/strings/src/main/res/values/strings.xml @@ -1220,9 +1220,24 @@ # Forms ready to send banner ############################################## --> - Last form sent: %d second(s) ago - Last form sent: %d minute(s) ago - Last form sent: %d hour(s) ago - Last form sent: %d day(s) ago - %d form(s) ready to send + + Last form sent: %d second ago + Last form sent: %d seconds ago + + + Last form sent: %d minute ago + Last form sent: %d minutes ago + + + Last form sent: %d hour ago + Last form sent: %d hours ago + + + Last form sent: %d day ago + Last form sent: %d days ago + + + %d form ready to send + %d forms ready to send +