diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractActivityChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractActivityChartFragment.java index ad0f9a6e4..306ed2c25 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractActivityChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractActivityChartFragment.java @@ -141,6 +141,11 @@ public abstract class AbstractActivityChartFragment extend akNotWorn = new ActivityConfig(ActivityKind.NOT_WORN, getString(R.string.abstract_chart_fragment_kind_not_worn), AK_NOT_WORN_COLOR); } + @Override + protected boolean isSingleDay() { + return false; + } + protected Integer getColorFor(ActivityKind activityKind) { switch (activityKind) { case DEEP_SLEEP: diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java index 3b30e7d27..1d589c0aa 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/AbstractChartFragment.java @@ -154,6 +154,7 @@ public abstract class AbstractChartFragment extends Abstra protected void onMadeVisibleInActivity() { super.onMadeVisibleInActivity(); showDateBar(true); + updateDateInfo(getStartDate(), getEndDate()); if (mChartDirty) { refresh(); } @@ -187,6 +188,14 @@ public abstract class AbstractChartFragment extends Abstra return toTimestamp(getStartDate()); } + /** + * Whether this chart shows data only for a single day. The day is expected to match + * the end timestamp. + */ + protected boolean isSingleDay() { + return true; + } + protected int toTimestamp(Date date) { return (int) ((date.getTime() / 1000)); } @@ -236,6 +245,8 @@ public abstract class AbstractChartFragment extends Abstra if (!shiftDates(startDate, endDate, offset)) { return; } + + updateDateInfo(getStartDate(), getEndDate()); } refreshIfVisible(); } @@ -316,7 +327,6 @@ public abstract class AbstractChartFragment extends Abstra if (chartsHost != null) { if (chartsHost.getDevice() != null) { mChartDirty = false; - updateDateInfo(getStartDate(), getEndDate()); if (refreshTask != null && refreshTask.getStatus() != AsyncTask.Status.FINISHED) { refreshTask.cancel(true); } @@ -383,8 +393,8 @@ public abstract class AbstractChartFragment extends Abstra private void updateDateInfo(final Date from, final Date to) { int dateFlags = DateUtils.FORMAT_SHOW_WEEKDAY; - if (from.equals(to)) { - getChartsHost().setDateInfo(DateTimeUtils.formatDate(from, dateFlags)); + if (isSingleDay() || from.equals(to)) { + getChartsHost().setDateInfo(DateTimeUtils.formatDate(to, dateFlags)); } else { getChartsHost().setDateInfo(DateTimeUtils.formatDateRange(from, to, dateFlags)); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/DaySleepChartFragment.java similarity index 99% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/DaySleepChartFragment.java index 8fa821ed8..6482647ef 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/SleepChartFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/charts/DaySleepChartFragment.java @@ -60,7 +60,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; -public class SleepChartFragment extends AbstractActivityChartFragment { +public class DaySleepChartFragment extends AbstractActivityChartFragment { protected static final Logger LOG = LoggerFactory.getLogger(ActivitySleepChartFragment.class); private LineChart mActivityChart; @@ -93,6 +93,10 @@ public class SleepChartFragment extends AbstractActivityChartFragment 0 && SHOW_CHARTS_AVERAGE) { final LimitLine averageLine = new LimitLine(spo2Data.getAverage()); @@ -142,6 +140,11 @@ public class Spo2ChartFragment extends AbstractChartFragment + android:text="@string/stats_empty_value" /> @@ -58,7 +58,8 @@ android:layout_height="wrap_content" android:padding="0dp" android:layout_marginHorizontal="2dp" - android:text="<<<" /> + android:text="<<<" + tools:ignore="HardcodedText"/>