mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +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());
|
else this.name.setText(deviceInfo.getName());
|
||||||
|
|
||||||
this.created.setText(getContext().getString(R.string.DeviceListItem_linked_s,
|
this.created.setText(getContext().getString(R.string.DeviceListItem_linked_s,
|
||||||
DateUtils.getExtendedRelativeTimeSpanString(getContext(),
|
DateUtils.getDayPrecisionTimeSpanString(getContext(),
|
||||||
Locale.getDefault(),
|
Locale.getDefault(),
|
||||||
deviceInfo.getCreated())));
|
deviceInfo.getCreated())));
|
||||||
|
|
||||||
this.lastActive.setText(getContext().getString(R.string.DeviceListItem_last_active_s,
|
this.lastActive.setText(getContext().getString(R.string.DeviceListItem_last_active_s,
|
||||||
DateUtils.getExtendedRelativeTimeSpanString(getContext(),
|
DateUtils.getDayPrecisionTimeSpanString(getContext(),
|
||||||
Locale.getDefault(),
|
Locale.getDefault(),
|
||||||
deviceInfo.getLastSeen())));
|
deviceInfo.getLastSeen())));
|
||||||
|
|
||||||
this.deviceId = deviceInfo.getId();
|
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) {
|
public static SimpleDateFormat getDetailedDateFormatter(Context context, Locale locale) {
|
||||||
String dateFormatPattern;
|
String dateFormatPattern;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user