diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DashboardFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DashboardFragment.java index 328087cff..a5252cf40 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DashboardFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DashboardFragment.java @@ -93,10 +93,12 @@ public class DashboardFragment extends Fragment { String action = intent.getAction(); if (action == null) return; switch (action) { - case GBDevice.ACTION_DEVICE_CHANGED: - GBDevice dev = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE); + case GBApplication.ACTION_NEW_DATA: + final GBDevice dev = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE); if (dev != null && !dev.isBusy()) { - refresh(); + if (dashboardData.showAllDevices || dashboardData.showDeviceList.contains(dev.getAddress())) { + refresh(); + } } break; case ACTION_CONFIG_CHANGE: @@ -140,6 +142,7 @@ public class DashboardFragment extends Fragment { IntentFilter filterLocal = new IntentFilter(); filterLocal.addAction(GBDevice.ACTION_DEVICE_CHANGED); + filterLocal.addAction(GBApplication.ACTION_NEW_DATA); filterLocal.addAction(ACTION_CONFIG_CHANGE); LocalBroadcastManager.getInstance(requireContext()).registerReceiver(mReceiver, filterLocal); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DevicesFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DevicesFragment.java index 45e07e823..72cb87c48 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DevicesFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DevicesFragment.java @@ -75,9 +75,17 @@ public class DevicesFragment extends Fragment { switch (Objects.requireNonNull(action)) { case DeviceManager.ACTION_DEVICES_CHANGED: case GBApplication.ACTION_NEW_DATA: - createRefreshTask("get activity data", requireContext()).execute(); - mGBDeviceAdapter.rebuildFolders(); - refreshPairedDevices(); + final GBDevice device = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE); + if (action.equals(GBApplication.ACTION_NEW_DATA)) { + createRefreshTask("get activity data", requireContext(), device).execute(); + } + if (device != null) { + // Refresh only this device + refreshSingleDevice(device); + } else { + refreshPairedDevices(); + } + break; case DeviceService.ACTION_REALTIME_SAMPLES: handleRealtimeSample(intent.getSerializableExtra(DeviceService.EXTRA_REALTIME_SAMPLE)); @@ -117,7 +125,7 @@ public class DevicesFragment extends Fragment { @Override public void run() { if (getContext() != null) { - createRefreshTask("get activity data", getContext()).execute(); + createRefreshTask("get activity data", getContext(), null).execute(); } } }); @@ -216,36 +224,56 @@ public class DevicesFragment extends Fragment { public void refreshPairedDevices() { if (mGBDeviceAdapter != null) { - mGBDeviceAdapter.notifyDataSetChanged(); mGBDeviceAdapter.rebuildFolders(); + mGBDeviceAdapter.notifyDataSetChanged(); } } - public RefreshTask createRefreshTask(String task, Context context) { - return new RefreshTask(task, context); + public void refreshSingleDevice(final GBDevice device) { + if (mGBDeviceAdapter != null) { + mGBDeviceAdapter.refreshSingleDevice(device); + } + } + + public RefreshTask createRefreshTask(String task, Context context, GBDevice device) { + return new RefreshTask(task, context, device); } public class RefreshTask extends DBAccess { - public RefreshTask(String task, Context context) { + private final GBDevice device; + + public RefreshTask(final String task, final Context context, final GBDevice device) { super(task, context); + this.device = device; } @Override - protected void doInBackground(DBHandler db) { - for (GBDevice gbDevice : deviceList) { - final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator(); - boolean showActivityCard = GBApplication.getDevicePrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREFS_ACTIVITY_IN_DEVICE_CARD, true); - if (coordinator.supportsActivityTracking() && showActivityCard) { - long[] stepsAndSleepData = getSteps(gbDevice, db); - deviceActivityHashMap.put(gbDevice.getAddress(), stepsAndSleepData); + protected void doInBackground(final DBHandler db) { + if (device != null) { + updateDevice(db, device); + } else { + for (GBDevice gbDevice : deviceList) { + updateDevice(db, gbDevice); } } } - @Override - protected void onPostExecute(Object o) { - refreshPairedDevices(); + private void updateDevice(final DBHandler db, final GBDevice gbDevice) { + final DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator(); + final boolean showActivityCard = GBApplication.getDevicePrefs(gbDevice.getAddress()).getBoolean(DeviceSettingsPreferenceConst.PREFS_ACTIVITY_IN_DEVICE_CARD, true); + if (coordinator.supportsActivityTracking() && showActivityCard) { + final long[] stepsAndSleepData = getSteps(gbDevice, db); + deviceActivityHashMap.put(gbDevice.getAddress(), stepsAndSleepData); + } } + @Override + protected void onPostExecute(final Object o) { + if (device != null) { + refreshSingleDevice(device); + } else { + refreshPairedDevices(); + } + } } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java index d734988b7..ac1ba0ff4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/adapter/GBDeviceAdapterv2.java @@ -21,6 +21,7 @@ package nodomain.freeyourgadget.gadgetbridge.adapter; import static nodomain.freeyourgadget.gadgetbridge.model.DeviceService.ACTION_CONNECT; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.content.DialogInterface; @@ -143,7 +144,7 @@ public class GBDeviceAdapterv2 extends ListAdapter deviceActivityMap = new HashMap(); - private StableIdGenerator idGenerator = new StableIdGenerator(); + private final StableIdGenerator idGenerator = new StableIdGenerator(); public GBDeviceAdapterv2(Context context, List deviceList, HashMap deviceMap) { super(new GBDeviceDiffUtil()); @@ -153,10 +154,22 @@ public class GBDeviceAdapterv2 extends ListAdapter 0) { + notifyItemChanged(i); + } else { + // Somehow the device was not on the list - rebuild everything + rebuildFolders(); + notifyDataSetChanged(); + } + } + private List enrichDeviceListWithFolder(List deviceList) { final Map> devicesPerFolder = new LinkedHashMap<>(); final List enrichedList = new ArrayList<>(); @@ -221,10 +234,10 @@ public class GBDeviceAdapterv2 extends ListAdapter { - LOG.debug("new device connection state: " + newState); + LOG.debug("new device connection state: {}", newState); mGbDevice.setState(newState); mGbDevice.sendDeviceUpdateIntent(mContext, GBDevice.DeviceUpdateSubject.CONNECTION_STATE); }); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSActivityTrack.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSActivityTrack.java index 1900a5959..4acc39332 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSActivityTrack.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/banglejs/BangleJSActivityTrack.java @@ -668,6 +668,7 @@ class BangleJSActivityTrack { resetPacketCount(); device.unsetBusyTask(); device.sendDeviceUpdateIntent(context); + GB.signalActivityDataFinish(device); GB.updateTransferNotification(null, "", false, 100, context); GB.toast(context.getString(R.string.activity_detail_end_label) + " : " + context.getString(R.string.busy_task_fetch_sports_details), Toast.LENGTH_SHORT, GB.INFO); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/cmfwatchpro/CmfActivitySync.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/cmfwatchpro/CmfActivitySync.java index 9f8665d2f..8ee2c8ec7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/cmfwatchpro/CmfActivitySync.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/cmfwatchpro/CmfActivitySync.java @@ -495,8 +495,8 @@ public class CmfActivitySync { activitiesWithGps.clear(); - GB.signalActivityDataFinish(); getDevice().unsetBusyTask(); + GB.signalActivityDataFinish(getDevice()); GB.updateTransferNotification(null, "", false, 100, getContext()); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/colmi/ColmiR0xDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/colmi/ColmiR0xDeviceSupport.java index 2ad033bc6..043807d30 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/colmi/ColmiR0xDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/colmi/ColmiR0xDeviceSupport.java @@ -572,10 +572,10 @@ public class ColmiR0xDeviceSupport extends AbstractBTLEDeviceSupport { private void fetchRecordedDataFinished() { GB.updateTransferNotification(null, "", false, 100, getContext()); - GB.signalActivityDataFinish(); LOG.info("Sync finished!"); getDevice().unsetBusyTask(); getDevice().sendDeviceUpdateIntent(getContext()); + GB.signalActivityDataFinish(getDevice()); } private void fetchHistoryActivity() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/fitpro/FitProDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/fitpro/FitProDeviceSupport.java index 61460d2da..1c45b5848 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/fitpro/FitProDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/fitpro/FitProDeviceSupport.java @@ -365,7 +365,7 @@ public class FitProDeviceSupport extends AbstractBTLEDeviceSupport { public void indicateFinishedFetchingOperation() { //LOG.debug("download finish announced"); GB.updateTransferNotification(null, "", false, 100, getContext()); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); unsetBusy(); } @@ -1354,7 +1354,7 @@ public class FitProDeviceSupport extends AbstractBTLEDeviceSupport { addGBActivitySample(sample); broadcastSample(sample); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } public void handleDayTotalsData(int steps, int distance, int calories) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java index aac49b5f7..8516d5ddd 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java @@ -541,8 +541,8 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni LOG.debug("No pending files to process"); // No downloaded fit files to process if (gbDevice.isBusy() && isBusyFetching) { - GB.signalActivityDataFinish(); getDevice().unsetBusyTask(); + GB.signalActivityDataFinish(getDevice()); GB.updateTransferNotification(null, "", false, 100, getContext()); getDevice().sendDeviceUpdateIntent(getContext()); } @@ -570,8 +570,8 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni @Override public void onFinish() { - GB.signalActivityDataFinish(); getDevice().unsetBusyTask(); + GB.signalActivityDataFinish(getDevice()); GB.updateTransferNotification(null, "", false, 100, getContext()); getDevice().sendDeviceUpdateIntent(getContext()); isBusyFetching = false; @@ -903,7 +903,7 @@ public class GarminSupport extends AbstractBTLEDeviceSupport implements ICommuni public void onFinish() { parsingFitFilesFromStorage = false; GB.updateTransferNotification("", "", false, 100, getContext()); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } }); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/fetch/AbstractFetchOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/fetch/AbstractFetchOperation.java index 5b180b1a6..9a68eedab 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/fetch/AbstractFetchOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/fetch/AbstractFetchOperation.java @@ -155,7 +155,7 @@ public abstract class AbstractFetchOperation extends AbstractHuamiOperation { LOG.debug("All operations finished"); GB.updateTransferNotification(null, "", false, 100, getContext()); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); operationFinished(); unsetBusy(); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java index 8de2af2a4..e7c27698b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java @@ -810,7 +810,7 @@ public class HuaweiSupportProvider { // Properly update the device card gbDevice.sendDeviceUpdateIntent(GBApplication.getContext()); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } public void setProtocolVersion(byte protocolVersion) { @@ -1289,7 +1289,7 @@ public class HuaweiSupportProvider { gbDevice.unsetBusyTask(); gbDevice.sendDeviceUpdateIntent(context); } - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } public void onReset(int flags) { @@ -2118,7 +2118,7 @@ public class HuaweiSupportProvider { for (HuaweiTruSleepParser.TruSleepStatus status : results) addSleepActivity(status.startTime, status.endTime, (byte) 0x06, (byte) 0x0a); // This should only be called once per sync - also if we start downloading more sleep data - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); // Unsetting busy is done at the end of all downloads } // "sleep_data.bin" later as well } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java index 14c8b8091..9ecce3f54 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/operations/FetchActivityOperation.java @@ -200,7 +200,7 @@ public class FetchActivityOperation extends AbstractMiBand1Operation { activityStruct = null; operationFinished(); unsetBusy(); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } /** diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/no1f1/No1F1Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/no1f1/No1F1Support.java index ac0bccf4b..624b563d1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/no1f1/No1F1Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/no1f1/No1F1Support.java @@ -514,7 +514,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport { GB.updateTransferNotification(null,"", false, 100, getContext()); if (getDevice().isBusy()) { getDevice().unsetBusyTask(); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } } } catch (Exception ex) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMisfit.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMisfit.java index b82a3e600..2eedbb102 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMisfit.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMisfit.java @@ -70,7 +70,7 @@ class AppMessageHandlerMisfit extends AppMessageHandler { LOG.info("incoming data start"); break; case KEY_INCOMING_DATA_END: - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); LOG.info("incoming data end"); break; case KEY_INCOMING_DATA: diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java index ef48d300f..409a9aff8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java @@ -109,7 +109,7 @@ class AppMessageHandlerMorpheuz extends AppMessageHandler { for (Pair pair : pairs) { if (Objects.equals(pair.first, keyTransmit)) { ctrl_message |= CTRL_TRANSMIT_DONE; - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } else if (pair.first.equals(keyGoneoff)) { alarm_gone_off = (int) pair.second; LOG.info("got gone off: " + alarm_gone_off / 60 + ":" + alarm_gone_off % 60); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index 503143dcb..7de164f0f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -2320,7 +2320,7 @@ public class PebbleProtocol extends GBDeviceProtocol { devEvtsDataLogging = new GBDeviceEvent[]{dataLogging, null}; } if (datalogSession.uuid.equals(UUID_ZERO) && (datalogSession.tag == 81 || datalogSession.tag == 83 || datalogSession.tag == 84)) { - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } mDatalogSessions.remove(id); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java index 355526da1..0d119fccf 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pinetime/PineTimeJFSupport.java @@ -1240,7 +1240,7 @@ public class PineTimeJFSupport extends AbstractBTLEDeviceSupport implements DfuL provider.addGBActivitySample(sample); } - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } catch (Exception ex) { GB.toast(getContext(), "Error saving samples: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java index f49d8762c..4bc4ad267 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil/FossilWatchAdapter.java @@ -565,7 +565,7 @@ public class FossilWatchAdapter extends WatchAdapter { queueWrite(new FileDeleteRequest(getHandle())); GB.updateTransferNotification(null, "", false, 100, getContext()); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDeviceSupport().getDevice()); LOG.debug("Synchronized activity data"); } catch (Exception ex) { GB.toast(getContext(), "Error saving steps data: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java index 95d5250b0..5a043de98 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java @@ -1251,7 +1251,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { } queueWrite(new FileDeleteRequest(fileHandle)); GB.updateTransferNotification(null, "", false, 100, getContext()); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDeviceSupport().getDevice()); LOG.debug("Synchronized activity data"); } catch (Exception ex) { GB.toast(getContext(), "Error saving steps data: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/misfit/MisfitWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/misfit/MisfitWatchAdapter.java index 8f8bde0b0..2c5fa8136 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/misfit/MisfitWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/misfit/MisfitWatchAdapter.java @@ -468,7 +468,7 @@ public class MisfitWatchAdapter extends WatchAdapter { getDeviceSupport().getDevice().unsetBusyTask(); GB.updateTransferNotification(null, "", false, 100, getContext()); getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext()); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDeviceSupport().getDevice()); } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/tlw64/TLW64Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/tlw64/TLW64Support.java index e76c49272..8d0d99ff3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/tlw64/TLW64Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/tlw64/TLW64Support.java @@ -543,7 +543,7 @@ public class TLW64Support extends AbstractBTLEDeviceSupport { if (getDevice().isBusy()) { getDevice().unsetBusyTask(); getDevice().sendDeviceUpdateIntent(getContext()); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } } } catch (Exception ex) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/XiaomiActivityFileFetcher.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/XiaomiActivityFileFetcher.java index 440bac64f..fdfa7ca46 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/XiaomiActivityFileFetcher.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/activity/XiaomiActivityFileFetcher.java @@ -146,8 +146,8 @@ public class XiaomiActivityFileFetcher { if (fileId == null) { LOG.debug("Nothing more to fetch"); isFetching = false; - GB.signalActivityDataFinish(); mHealthService.getSupport().getDevice().unsetBusyTask(); + GB.signalActivityDataFinish(mHealthService.getSupport().getDevice()); GB.updateTransferNotification(null, "", false, 100, mHealthService.getSupport().getContext()); mHealthService.getSupport().getDevice().sendDeviceUpdateIntent(mHealthService.getSupport().getContext()); return; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java index 8f298c244..8c0189a3b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java @@ -1033,6 +1033,8 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { getHeartRateData(); } else if (availableSleepData > 0) { getSleepData(); + } else { + GB.signalActivityDataFinish(getDevice()); } } @@ -1179,6 +1181,8 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { getHeartRateData(); } else if (availableSleepData > 0) { getSleepData(); + } else { + GB.signalActivityDataFinish(getDevice()); } } } @@ -1217,7 +1221,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { GB.updateTransferNotification(null, "", false, 100, getContext()); if (getDevice().isBusy()) { getDevice().unsetBusyTask(); - GB.signalActivityDataFinish(); + GB.signalActivityDataFinish(getDevice()); } if (!prefs.getBoolean(ZeTimeConstants.PREF_ZETIME_DONT_DEL_ACTDATA, false)) { deleteSleepData(); @@ -1283,6 +1287,8 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { } if (availableSleepData > 0) { getSleepData(); + } else { + GB.signalActivityDataFinish(getDevice()); } } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java index a20e84a76..231bf51f4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GB.java @@ -677,8 +677,10 @@ public class GB { } } - public static void signalActivityDataFinish() { + public static void signalActivityDataFinish(final GBDevice device) { final Intent intent = new Intent(GBApplication.ACTION_NEW_DATA); + intent.putExtra(GBDevice.EXTRA_DEVICE, device); + LocalBroadcastManager.getInstance(GBApplication.getContext()).sendBroadcast(intent); if (!GBApplication.getPrefs().getBoolean("intent_api_broadcast_activity_sync", false)) {