ControlCenterv2: Improve toast when no connected device supports sync

This commit is contained in:
José Rebelo
2026-01-18 18:39:51 +00:00
parent 489bff52e2
commit fd8fc8a3a5
2 changed files with 16 additions and 8 deletions
@@ -258,17 +258,24 @@ public class ControlCenterv2 extends AppCompatActivity
swipeLayout.setEnabled(prefs.refreshOnSwipe());
swipeLayout.setOnRefreshListener(() -> {
if (prefs.refreshOnSwipe()) {
List<GBDevice> devices1 = GBApplication.app().getDeviceManager().getDevices();
final boolean anyConnected = devices1.stream().anyMatch(GBDevice::isInitialized);
if (!anyConnected) {
// No devices are connected at all
GB.toast(getString(R.string.info_no_devices_connected), Toast.LENGTH_LONG, GB.WARN);
swipeLayout.setRefreshing(false);
return;
}
// Fetch activity for all connected devices
GBApplication.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_SYNC);
// Hide 'refreshing' animation immediately if no health devices are connected
List<GBDevice> devices1 = GBApplication.app().getDeviceManager().getDevices();
for (GBDevice dev : devices1) {
if (dev.getDeviceCoordinator().supportsDataFetching(dev) && dev.isInitialized()) {
return;
}
// Hide 'refreshing' animation immediately if no devices are connected that support sync
final boolean anySupported = devices1.stream().filter(GBDevice::isInitialized)
.anyMatch(dev -> dev.getDeviceCoordinator().supportsDataFetching(dev));
if (!anySupported) {
swipeLayout.setRefreshing(false);
GB.toast(getString(R.string.info_no_devices_to_sync), Toast.LENGTH_LONG, GB.WARN);
}
swipeLayout.setRefreshing(false);
GB.toast(getString(R.string.info_no_devices_connected), Toast.LENGTH_LONG, GB.WARN);
} else {
swipeLayout.setRefreshing(false);
}
+1
View File
@@ -3527,6 +3527,7 @@
<string name="huawei_reparse_workout_data_description">This will only do something after certain updates</string>
<string name="info_no_devices_connected">No devices connected</string>
<string name="info_no_devices_to_sync">Connected devices do not support data sync</string>
<string name="info_connected_count">%d devices connected</string>
<string name="controlcenter_test_new_function">Test new function</string>
<string name="controlcenter_set_parent_folder">Set parent folder</string>