Add date to unlinked dialog.

This commit is contained in:
Michelle Tang 2025-01-16 15:45:16 -05:00 committed by Greyson Parrelli
parent 5a4c8a6f9a
commit 71c21eeba6
3 changed files with 16 additions and 3 deletions

View file

@ -325,7 +325,7 @@ fun DeviceListScreen(
)
}
is DialogState.DeviceUnlinked -> {
val createdAt = DateUtils.getOnlyTimeString(LocalContext.current, state.dialogState.deviceCreatedAt)
val createdAt = DateUtils.getDateTimeString(LocalContext.current, Locale.getDefault(), state.dialogState.deviceCreatedAt)
Dialogs.SimpleMessageDialog(
title = stringResource(id = R.string.LinkDeviceFragment__device_unlinked),
message = stringResource(id = R.string.LinkDeviceFragment__the_device_that_was, createdAt),

View file

@ -181,6 +181,17 @@ object DateUtils : android.text.format.DateUtils() {
return timestamp.toDateString(format.toString(), locale)
}
/**
* Formats the timestamp as a date, without the year, followed by the time
* eg. Jan 15 at 9:00pm
*/
@JvmStatic
fun getDateTimeString(context: Context, locale: Locale, timestamp: Long): String {
val date = timestamp.toDateString("MMM d", locale)
val time = timestamp.toLocalTime().formatHours(context)
return context.getString(R.string.DateUtils_date_at, date, time)
}
/**
* Formats the passed timestamp based on the current time at a day precision.
*

View file

@ -920,6 +920,8 @@
<string name="DateUtils_tomorrow">Tomorrow</string>
<!-- Used in the context: Tonight at 9:00pm for example. Specifically this is after 7pm -->
<string name="DateUtils_tonight">Tonight</string>
<!-- Used when showing the time a device was linked. %1$s is replaced with the date while %2$s is replaced with the time. e.g. Jan 15 at 9:00pm -->
<string name="DateUtils_date_at">%1$s at %2$s</string>
<!-- Scheduled Messages -->
<!-- Title for dialog that shows all the users scheduled messages for a chat -->
@ -1027,8 +1029,8 @@
<string name="LinkDeviceFragment__do_not_close">Do not close app</string>
<!-- Dialog title shown when a device is unlinked -->
<string name="LinkDeviceFragment__device_unlinked">Device unlinked</string>
<!-- Dialog body shown when a device is unlinked where %1$s is when the device was originally linked -->
<string name="LinkDeviceFragment__the_device_that_was">The device that was recently linked at %1$s is no longer linked.</string>
<!-- Dialog body shown when a device is unlinked where %1$s is the date and time the device was originally linked (eg Jan 15 at 9:00pm) -->
<string name="LinkDeviceFragment__the_device_that_was">The device that was linked on %1$s is no longer linked.</string>
<!-- Button to dismiss dialog -->
<string name="LinkDeviceFragment__ok">OK</string>