mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
ControlCenterv2: Improve toast when no connected device supports sync
This commit is contained in:
+15
-8
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user