mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 08:47:46 +00:00
Limit 'last active' device timestamp to day level precision
Closes #4614 // FREEBIE
This commit is contained in:
parent
67415a8dcb
commit
785f737244
@ -39,14 +39,14 @@ public class DeviceListItem extends LinearLayout {
|
||||
else this.name.setText(deviceInfo.getName());
|
||||
|
||||
this.created.setText(getContext().getString(R.string.DeviceListItem_linked_s,
|
||||
DateUtils.getExtendedRelativeTimeSpanString(getContext(),
|
||||
Locale.getDefault(),
|
||||
deviceInfo.getCreated())));
|
||||
DateUtils.getDayPrecisionTimeSpanString(getContext(),
|
||||
Locale.getDefault(),
|
||||
deviceInfo.getCreated())));
|
||||
|
||||
this.lastActive.setText(getContext().getString(R.string.DeviceListItem_last_active_s,
|
||||
DateUtils.getExtendedRelativeTimeSpanString(getContext(),
|
||||
Locale.getDefault(),
|
||||
deviceInfo.getLastSeen())));
|
||||
DateUtils.getDayPrecisionTimeSpanString(getContext(),
|
||||
Locale.getDefault(),
|
||||
deviceInfo.getLastSeen())));
|
||||
|
||||
this.deviceId = deviceInfo.getId();
|
||||
}
|
||||
|
@ -83,6 +83,22 @@ public class DateUtils extends android.text.format.DateUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDayPrecisionTimeSpanString(Context context, Locale locale, long timestamp) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
|
||||
if (simpleDateFormat.format(System.currentTimeMillis()).equals(simpleDateFormat.format(timestamp))) {
|
||||
return "Today";
|
||||
} else {
|
||||
String format;
|
||||
|
||||
if (isWithin(timestamp, 6, TimeUnit.DAYS)) format = "EEE ";
|
||||
else if (isWithin(timestamp, 365, TimeUnit.DAYS)) format = "MMM d";
|
||||
else format = "MMM d, yyy";
|
||||
|
||||
return getFormattedDateTime(timestamp, format, locale);
|
||||
}
|
||||
}
|
||||
|
||||
public static SimpleDateFormat getDetailedDateFormatter(Context context, Locale locale) {
|
||||
String dateFormatPattern;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user