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.
*