Skip to content

Commit

Permalink
Improved strings
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Aug 9, 2023
1 parent e7fdc1d commit a00922e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
25 changes: 20 additions & 5 deletions strings/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1220,9 +1220,24 @@
# Forms ready to send banner
##############################################
-->
<string name="last_form_sent_seconds_ago">Last form sent: %d second(s) ago</string>
<string name="last_form_sent_minutes_ago">Last form sent: %d minute(s) ago</string>
<string name="last_form_sent_hours_ago">Last form sent: %d hour(s) ago</string>
<string name="last_form_sent_days_ago">Last form sent: %d day(s) ago</string>
<string name="forms_ready_to_send">%d form(s) ready to send</string>
<plurals name="last_form_sent_seconds_ago">
<item quantity="one">Last form sent: %d second ago</item>
<item quantity="other">Last form sent: %d seconds ago</item>
</plurals>
<plurals name="last_form_sent_minutes_ago">
<item quantity="one">Last form sent: %d minute ago</item>
<item quantity="other">Last form sent: %d minutes ago</item>
</plurals>
<plurals name="last_form_sent_hours_ago">
<item quantity="one">Last form sent: %d hour ago</item>
<item quantity="other">Last form sent: %d hours ago</item>
</plurals>
<plurals name="last_form_sent_days_ago">
<item quantity="one">Last form sent: %d day ago</item>
<item quantity="other">Last form sent: %d days ago</item>
</plurals>
<plurals name="forms_ready_to_send">
<item quantity="one">%d form ready to send</item>
<item quantity="other">%d forms ready to send</item>
</plurals>
</resources>

0 comments on commit a00922e

Please sign in to comment.