1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-10-02 11:17:00 +02:00

Fossil/Skagen Hybrids: While syncing, mark device busy and show transfer notification

This commit is contained in:
Arjan Schrijver 2024-02-23 20:56:31 +01:00
parent 28e0914330
commit 0383169767
4 changed files with 18 additions and 3 deletions

View File

@ -549,6 +549,9 @@ public class QHybridSupport extends QHybridBaseSupport {
@Override
public void onFetchRecordedData(int dataTypes) {
if ((dataTypes & RecordedDataTypes.TYPE_ACTIVITY) != 0) {
GB.updateTransferNotification(getContext().getString(R.string.busy_task_fetch_activity_data), "", true, 0, getContext());
getDevice().setBusyTask(getContext().getString(R.string.busy_task_fetch_activity_data));
getDevice().sendDeviceUpdateIntent(getContext());
this.watchAdapter.onFetchActivityData();
}
}

View File

@ -554,20 +554,25 @@ public class FossilWatchAdapter extends WatchAdapter {
provider.addGBActivitySamples(samples);
queueWrite(new FileDeleteRequest(getHandle()));
GB.updateTransferNotification(null, "", false, 100, getContext());
if (BuildConfig.DEBUG)
GB.toast("synced activity data", Toast.LENGTH_SHORT, GB.INFO);
GB.toast(getContext().getString(R.string.fossil_hr_synced_activity_data), Toast.LENGTH_SHORT, GB.INFO);
} catch (Exception ex) {
GB.toast(getContext(), "Error saving steps data: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
GB.updateTransferNotification(null, "Data transfer failed", false, 0, getContext());
}
getDeviceSupport().getDevice().unsetBusyTask();
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
}
@Override
public void handleFileLookupError(FILE_LOOKUP_ERROR error) {
if(error == FILE_LOOKUP_ERROR.FILE_EMPTY && BuildConfig.DEBUG){
GB.toast("activity file empty", Toast.LENGTH_SHORT, GB.INFO);
GB.toast("No activity data to sync", Toast.LENGTH_SHORT, GB.INFO);
}
getDeviceSupport().getDevice().unsetBusyTask();
GB.updateTransferNotification(null, "", false, 100, getContext());
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
}
});
}

View File

@ -1250,12 +1250,14 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
writeFile(String.valueOf(System.currentTimeMillis()), fileData);
}
queueWrite(new FileDeleteRequest(fileHandle));
GB.updateTransferNotification(null, "", false, 100, getContext());
if (BuildConfig.DEBUG)
GB.toast(getContext().getString(R.string.fossil_hr_synced_activity_data), Toast.LENGTH_SHORT, GB.INFO);
} catch (Exception ex) {
GB.toast(getContext(), "Error saving steps data: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
GB.updateTransferNotification(null, "Data transfer failed", false, 0, getContext());
}
getDeviceSupport().getDevice().unsetBusyTask();
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
}
});
@ -1265,10 +1267,12 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
public void handleFileLookupError(FILE_LOOKUP_ERROR error) {
if (error == FILE_LOOKUP_ERROR.FILE_EMPTY) {
if (BuildConfig.DEBUG)
GB.toast("activity file empty yet", Toast.LENGTH_LONG, GB.ERROR);
GB.toast("No activity data to sync", Toast.LENGTH_SHORT, GB.INFO);
} else {
throw new RuntimeException("strange lookup stuff");
}
getDeviceSupport().getDevice().unsetBusyTask();
GB.updateTransferNotification(null, "", false, 100, getContext());
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
}
});

View File

@ -467,6 +467,9 @@ public class MisfitWatchAdapter extends WatchAdapter {
requestQueue.add(new GetCurrentStepCountRequest());
// requestQueue.add(new ListFilesRequest());
queueWrite(new ActivityPointGetRequest());
getDeviceSupport().getDevice().unsetBusyTask();
GB.updateTransferNotification(null, "", false, 100, getContext());
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
}
@Override