1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-05 09:47:01 +01:00

Intent API: Add broadcast on activity sync finish

This commit is contained in:
José Rebelo 2024-06-02 22:01:57 +01:00
parent 15ba9e6c85
commit 4459b30ee6
5 changed files with 22 additions and 1 deletions

View File

@ -489,6 +489,7 @@ public class CmfActivitySync {
activitiesWithGps.clear();
GB.signalActivityDataFinish();
getDevice().unsetBusyTask();
GB.updateTransferNotification(null, "", false, 100, getContext());
}

View File

@ -153,6 +153,7 @@ public class XiaomiActivityFileFetcher {
if (fileId == null) {
LOG.debug("Nothing more to fetch");
isFetching = false;
GB.signalActivityDataFinish();
mHealthService.getSupport().getDevice().unsetBusyTask();
GB.updateTransferNotification(null, "", false, 100, mHealthService.getSupport().getContext());
mHealthService.getSupport().getDevice().sendDeviceUpdateIntent(mHealthService.getSupport().getContext());

View File

@ -64,6 +64,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceCommunicationService;
public class GB {
public static final String ACTION_ACTIVITY_SYNC = "nodomain.freeyourgadget.gadgetbridge.action.ACTIVITY_SYNC_FINISH";
public static final String NOTIFICATION_CHANNEL_ID = "gadgetbridge";
public static final String NOTIFICATION_CHANNEL_ID_CONNECTION_STATUS = "gadgetbridge connection status";
@ -598,8 +599,17 @@ public class GB {
}
public static void signalActivityDataFinish() {
Intent intent = new Intent(GBApplication.ACTION_NEW_DATA);
final Intent intent = new Intent(GBApplication.ACTION_NEW_DATA);
LocalBroadcastManager.getInstance(GBApplication.getContext()).sendBroadcast(intent);
if (!GBApplication.getPrefs().getBoolean("intent_api_broadcast_activity_sync", false)) {
return;
}
LOG.info("Broadcasting activity sync finish");
final Intent activitySyncFinishIntent = new Intent(ACTION_ACTIVITY_SYNC);
GBApplication.getContext().sendBroadcast(activitySyncFinishIntent);
}
public static boolean checkPermission(final Context context, final String permission) {

View File

@ -2511,6 +2511,8 @@
<string name="intent_api_allow_trigger_export_summary">Allow triggering database export via Intent API</string>
<string name="intent_api_broadcast_export_title">Broadcast on database export</string>
<string name="intent_api_broadcast_export_summary">Broadcast an intent when database export finishes</string>
<string name="intent_api_broadcast_activity_sync_title">Broadcast on activity sync finish</string>
<string name="intent_api_broadcast_activity_sync_summary">Broadcast an intent when activity sync finishes for any device</string>
<string name="intent_api_allow_debug_commands_title">Allow Debug Commands</string>
<string name="intent_api_allow_debug_commands_summary">Allow triggering debug menu commands via Intent API</string>
<string name="devicetype_super_cars">Shell Racing</string>

View File

@ -393,6 +393,13 @@
android:title="@string/intent_api_allow_activity_sync_title"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:key="intent_api_broadcast_activity_sync"
android:layout="@layout/preference_checkbox"
android:summary="@string/intent_api_broadcast_activity_sync_summary"
android:title="@string/intent_api_broadcast_activity_sync_title"
app:iconSpaceReserved="false" />
<SwitchPreferenceCompat
android:key="intent_api_allow_trigger_export"
android:layout="@layout/preference_checkbox"