forked from upstream-mirrors/OpenTracks
Proper handling of timezone data on UI. Fixes #301.
Details: - Date and time handled by OffsetDateTime Java class. - Track default name with offset (for date local and ISO 8601 options). - TrackListActivity: shows relative today's date (like Today, Yesterday, 22 Dec, 22 Dec 2021, etc). - StatisticsRecordedFragment: always shows the original date and time. For example, if you record an activity at 20h then it always will show 20h regardless the zone are where you are. - Added new tests.
This commit is contained in:
committed by
Román Martínez
parent
1631836327
commit
5cd6992c90
@@ -82,10 +82,10 @@ public class FilterDialogFragment extends DialogFragment {
|
||||
TextInputEditText dateTo = layout.findViewById(R.id.filter_date_edit_text_to);
|
||||
|
||||
LocalDateTime firstDayThisWeek = LocalDate.now().with(WeekFields.of(Locale.getDefault()).getFirstDayOfWeek()).atStartOfDay();
|
||||
dateFrom.setText(StringUtils.formatDate(getActivity(), firstDayThisWeek));
|
||||
dateFrom.setText(StringUtils.formatLocalDateTime(firstDayThisWeek));
|
||||
datePickerFrom.init(firstDayThisWeek.getYear(), firstDayThisWeek.getMonthValue() - 1, firstDayThisWeek.getDayOfMonth(), (view, year, monthOfYear, dayOfMonth) -> {
|
||||
LocalDateTime localDateTime = LocalDateTime.of(year, monthOfYear + 1, dayOfMonth, 0, 0, 0);
|
||||
dateFrom.setText(StringUtils.formatDate(getActivity(), localDateTime));
|
||||
dateFrom.setText(StringUtils.formatLocalDateTime(localDateTime));
|
||||
datePickerFrom.setVisibility(View.GONE);
|
||||
datePickerTo.setMinDate(localDateTime.toInstant(ZoneOffset.ofTotalSeconds(0)).toEpochMilli());
|
||||
if (localDateTime.isAfter(LocalDateTime.of(datePickerTo.getYear(), datePickerTo.getMonth() + 1, datePickerTo.getDayOfMonth(), 23, 59, 59))) {
|
||||
@@ -94,10 +94,10 @@ public class FilterDialogFragment extends DialogFragment {
|
||||
});
|
||||
|
||||
LocalDateTime lastDayThisWeek = firstDayThisWeek.plusDays(6).withHour(23).withMinute(59).withSecond(59);
|
||||
dateTo.setText(StringUtils.formatDate(getActivity(), lastDayThisWeek));
|
||||
dateTo.setText(StringUtils.formatLocalDateTime(lastDayThisWeek));
|
||||
datePickerTo.init(lastDayThisWeek.getYear(), lastDayThisWeek.getMonthValue() - 1, lastDayThisWeek.getDayOfMonth(), (view, year, monthOfYear, dayOfMonth) -> {
|
||||
LocalDateTime localDateTime = LocalDateTime.of(year, monthOfYear + 1, dayOfMonth, 23, 59, 59);
|
||||
dateTo.setText(StringUtils.formatDate(getActivity(), localDateTime));
|
||||
dateTo.setText(StringUtils.formatLocalDateTime(localDateTime));
|
||||
datePickerTo.setVisibility(View.GONE);
|
||||
});
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ public class StatisticsRecordedFragment extends Fragment {
|
||||
private void loadTrackDescription(@NonNull Track track) {
|
||||
viewBinding.statsNameValue.setText(track.getName());
|
||||
viewBinding.statsDescriptionValue.setText(track.getDescription());
|
||||
viewBinding.statsStartDatetimeValue.setText(StringUtils.formatDateTime(getContext(), track.getTrackStatistics().getStartTime()));
|
||||
viewBinding.statsStartDatetimeValue.setText(StringUtils.formatDateTime(track.getStartTime()));
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
|
||||
Reference in New Issue
Block a user