1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 13:26:50 +01:00

Huami: Display fetch operation description

This commit is contained in:
José Rebelo 2023-07-22 20:27:20 +01:00
parent 07ec8a095b
commit db4349bfc9
15 changed files with 94 additions and 3 deletions

View File

@ -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());
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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<HuamiPaiSample> samples = new ArrayList<>();

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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());

View File

@ -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());

View File

@ -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<HuamiStressSample> samples = new ArrayList<>();

View File

@ -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) {

View File

@ -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);
}

View File

@ -610,6 +610,14 @@
<string name="pref_write_logfiles_not_available">File logging initialization failed, writing log files is currently not available. Restart the application to attempt to initialize the log files again.</string>
<string name="initializing">Initializing</string>
<string name="busy_task_fetch_activity_data">Fetching activity data</string>
<string name="busy_task_fetch_sports_summaries">Fetching sports summaries</string>
<string name="busy_task_fetch_sports_details">Fetching sports details</string>
<string name="busy_task_fetch_debug_logs">Fetching debug logs</string>
<string name="busy_task_fetch_stress_data">Fetching stress data</string>
<string name="busy_task_fetch_pai_data">Fetching PAI data</string>
<string name="busy_task_fetch_spo2_data">Fetching SpO2 data</string>
<string name="busy_task_fetch_hr_data">Fetching heart rate data</string>
<string name="busy_task_fetch_sleep_respiratory_rate_data">Fetching sleep respiratory rate data</string>
<string name="sleep_activity_date_range">From %1$s to %2$s</string>
<string name="prefs_wearside">Wearing left or right?</string>
<string name="prefs_weardirection">Wearing direction</string>