diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/AbstractFetchOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/AbstractFetchOperation.java index 3b59b70fd..6c026576a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/AbstractFetchOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/AbstractFetchOperation.java @@ -89,7 +89,7 @@ public abstract class AbstractFetchOperation extends AbstractHuamiOperation { TransactionBuilder builder = performInitialized(getName()); if (fetchCount == 0) { - builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.busy_task_fetch_activity_data), getContext())); + builder.add(new SetDeviceBusyAction(getDevice(), taskDescription(), getContext())); } fetchCount++; @@ -104,6 +104,11 @@ public abstract class AbstractFetchOperation extends AbstractHuamiOperation { builder.queue(getQueue()); } + /** + * A task description, to display in notifications and device card. + */ + protected abstract String taskDescription(); + protected abstract void startFetching(TransactionBuilder builder); protected abstract String getLastSyncTimeKey(); @@ -277,7 +282,7 @@ public abstract class AbstractFetchOperation extends AbstractHuamiOperation { setStartTimestamp(startTimestamp); LOG.info("Will transfer {} packets since {}", expectedDataLength, startTimestamp.getTime()); - GB.updateTransferNotification(getContext().getString(R.string.busy_task_fetch_activity_data), + GB.updateTransferNotification(taskDescription(), getContext().getString(R.string.FetchActivityOperation_about_to_transfer_since, DateFormat.getDateTimeInstance().format(startTimestamp.getTime())), true, 0, getContext()); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchActivityOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchActivityOperation.java index 60ed87b43..ef01c1a34 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchActivityOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchActivityOperation.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Locale; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; @@ -60,6 +61,11 @@ public class FetchActivityOperation extends AbstractRepeatingFetchOperation { this.sampleSize = support.getActivitySampleSize(); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_activity_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { if (bytes.length % sampleSize != 0) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateManualOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateManualOperation.java index e8ab2ef52..504a485b3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateManualOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateManualOperation.java @@ -28,6 +28,7 @@ import java.util.GregorianCalendar; import java.util.List; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; @@ -53,6 +54,11 @@ public class FetchHeartRateManualOperation extends AbstractRepeatingFetchOperati super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_MANUAL_HEART_RATE, "manual hr data"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_hr_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { if (bytes.length % 6 != 0) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateMaxOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateMaxOperation.java index 6869f4b7b..1cfdc3be0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateMaxOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateMaxOperation.java @@ -28,6 +28,7 @@ import java.util.GregorianCalendar; import java.util.List; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; @@ -52,6 +53,11 @@ public class FetchHeartRateMaxOperation extends AbstractRepeatingFetchOperation super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_MAX_HEART_RATE, "max hr data"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_hr_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { if (bytes.length % 6 != 0) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateRestingOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateRestingOperation.java index 155514fe3..d51e37e9d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateRestingOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchHeartRateRestingOperation.java @@ -28,6 +28,7 @@ import java.util.GregorianCalendar; import java.util.List; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; @@ -52,6 +53,11 @@ public class FetchHeartRateRestingOperation extends AbstractRepeatingFetchOperat super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_RESTING_HEART_RATE, "resting hr data"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_hr_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { if (bytes.length % 6 != 0) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchPaiOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchPaiOperation.java index 863212acc..65d64ffff 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchPaiOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchPaiOperation.java @@ -28,6 +28,7 @@ import java.util.GregorianCalendar; import java.util.List; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; @@ -51,6 +52,11 @@ public class FetchPaiOperation extends AbstractRepeatingFetchOperation { super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_PAI, "pai data"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_pai_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { final List samples = new ArrayList<>(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSleepRespiratoryRateOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSleepRespiratoryRateOperation.java index d71c21508..805d3fbaf 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSleepRespiratoryRateOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSleepRespiratoryRateOperation.java @@ -28,6 +28,7 @@ import java.util.GregorianCalendar; import java.util.List; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; @@ -51,6 +52,11 @@ public class FetchSleepRespiratoryRateOperation extends AbstractRepeatingFetchOp super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_SLEEP_RESPIRATORY_RATE, "sleep respiratory rate data"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_sleep_respiratory_rate_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { if (bytes.length % 8 != 0) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSpo2NormalOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSpo2NormalOperation.java index 0599dbc2f..d0a63e39c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSpo2NormalOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSpo2NormalOperation.java @@ -28,6 +28,7 @@ import java.util.GregorianCalendar; import java.util.List; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; @@ -52,6 +53,11 @@ public class FetchSpo2NormalOperation extends AbstractRepeatingFetchOperation { super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_SPO2_NORMAL, "spo2 normal data"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_spo2_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { if ((bytes.length - 1) % 65 != 0) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSpo2SleepOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSpo2SleepOperation.java index d2d91f93f..68902c193 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSpo2SleepOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSpo2SleepOperation.java @@ -23,6 +23,7 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.GregorianCalendar; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport; import nodomain.freeyourgadget.gadgetbridge.util.GB; @@ -37,6 +38,11 @@ public class FetchSpo2SleepOperation extends AbstractRepeatingFetchOperation { super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_SPO2_SLEEP, "spo2 sleep data"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_spo2_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { if ((bytes.length - 1) % 30 != 0) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java index ec0b6e439..484347ab3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsDetailsOperation.java @@ -76,6 +76,11 @@ public class FetchSportsDetailsOperation extends AbstractFetchOperation { this.fetchCount = fetchCount; } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_sports_details); + } + @Override protected void startFetching(TransactionBuilder builder) { LOG.info("start " + getName()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsSummaryOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsSummaryOperation.java index 04fab1c53..1feb2ecd8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsSummaryOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchSportsSummaryOperation.java @@ -30,6 +30,7 @@ import java.util.GregorianCalendar; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.Logging; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; @@ -63,6 +64,11 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation { this.fetchCount = fetchCount; } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_sports_summaries); + } + @Override protected void startFetching(TransactionBuilder builder) { LOG.info("start" + getName()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchStressAutoOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchStressAutoOperation.java index 1cdd8ab21..ab6cc672e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchStressAutoOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchStressAutoOperation.java @@ -27,6 +27,7 @@ import java.util.GregorianCalendar; import java.util.List; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; @@ -51,6 +52,11 @@ public class FetchStressAutoOperation extends AbstractRepeatingFetchOperation { super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_STRESS_AUTOMATIC, "auto stress data"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_stress_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { final List samples = new ArrayList<>(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchStressManualOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchStressManualOperation.java index 90ef0e0f7..6544ecc08 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchStressManualOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/FetchStressManualOperation.java @@ -28,6 +28,7 @@ import java.util.GregorianCalendar; import java.util.List; import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; @@ -53,6 +54,11 @@ public class FetchStressManualOperation extends AbstractRepeatingFetchOperation super(support, HuamiService.COMMAND_ACTIVITY_DATA_TYPE_STRESS_MANUAL, "manual stress data"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_stress_data); + } + @Override protected boolean handleActivityData(final GregorianCalendar timestamp, final byte[] bytes) { if (bytes.length % 5 != 0) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/HuamiFetchDebugLogsOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/HuamiFetchDebugLogsOperation.java index ba6797eba..53974b73d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/HuamiFetchDebugLogsOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/HuamiFetchDebugLogsOperation.java @@ -32,6 +32,8 @@ import java.util.GregorianCalendar; import java.util.Locale; import androidx.annotation.NonNull; + +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipService; import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; @@ -49,6 +51,11 @@ public class HuamiFetchDebugLogsOperation extends AbstractFetchOperation { setName("fetch debug logs"); } + @Override + protected String taskDescription() { + return getContext().getString(R.string.busy_task_fetch_debug_logs); + } + @Override protected void startFetching(TransactionBuilder builder) { File dir; @@ -121,7 +128,7 @@ public class HuamiFetchDebugLogsOperation extends AbstractFetchOperation { protected void bufferActivityData(@NonNull byte[] value) { try { logOutputStream.write(value, 1, value.length - 1); - } catch (IOException e) { + } catch (final IOException e) { LOG.warn("could not write to output stream", e); handleActivityFetchFinish(false); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7f78d6982..1f6ab2a66 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -610,6 +610,14 @@ File logging initialization failed, writing log files is currently not available. Restart the application to attempt to initialize the log files again. Initializing Fetching activity data + Fetching sports summaries + Fetching sports details + Fetching debug logs + Fetching stress data + Fetching PAI data + Fetching SpO2 data + Fetching heart rate data + Fetching sleep respiratory rate data From %1$s to %2$s Wearing left or right? Wearing direction