mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
parent
0945a0b9e8
commit
36aae1e81c
@ -64,6 +64,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.NotificationCollectorMonitorService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.receivers.GBAutoFetchReceiver;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.AndroidUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
@ -197,6 +198,10 @@ public class GBApplication extends Application {
|
||||
}
|
||||
startService(new Intent(this, NotificationCollectorMonitorService.class));
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("auto_fetch_enabled", false)) {
|
||||
registerReceiver(new GBAutoFetchReceiver(), new IntentFilter("android.intent.action.USER_PRESENT"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,32 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.receivers;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.RecordedDataTypes;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
|
||||
|
||||
|
||||
public class GBAutoFetchReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
GBApplication application = (GBApplication) context;
|
||||
List<GBDevice> devices = application.getDeviceManager().getDevices();
|
||||
for (int i = 0; i < devices.size(); i++) {
|
||||
GBDevice device = devices.get(i);
|
||||
// Will show that the device is not connected even when the device is connected
|
||||
if (device.isConnected() && device.isInitialized()) {
|
||||
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
|
||||
if (coordinator.supportsActivityDataFetching() && !device.isBusy()) {
|
||||
application.deviceService().onFetchRecordedData(RecordedDataTypes.TYPE_ACTIVITY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,6 +199,9 @@
|
||||
<string name="pref_title_auto_export_interval">Export interval</string>
|
||||
<string name="pref_summary_auto_export_interval">Export every %d hour</string>
|
||||
|
||||
<!-- Auto fetch activity preferences -->
|
||||
<string name="pref_auto_fetch">Auto fetch activity data</string>
|
||||
|
||||
<string name="not_connected">Not connected</string>
|
||||
<string name="connecting">Connecting</string>
|
||||
<string name="connected">Connected</string>
|
||||
|
@ -28,12 +28,12 @@
|
||||
android:defaultValue="@string/pref_theme_value_light"
|
||||
android:summary="%s" />
|
||||
<ListPreference
|
||||
android:key="language"
|
||||
android:title="@string/pref_title_language"
|
||||
android:defaultValue="default"
|
||||
android:entries="@array/pref_language_options"
|
||||
android:entryValues="@array/pref_language_values"
|
||||
android:defaultValue="default"
|
||||
android:summary="%s" />
|
||||
android:key="language"
|
||||
android:summary="%s"
|
||||
android:title="@string/pref_title_language" />
|
||||
<ListPreference
|
||||
android:defaultValue="metric"
|
||||
android:entries="@array/pref_entries_unit_system"
|
||||
@ -527,6 +527,15 @@
|
||||
android:title="@string/pref_title_auto_export_interval"
|
||||
android:summary="@string/pref_summary_auto_export_interval"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="Auto fetch">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="auto_fetch_enabled"
|
||||
android:title="@string/pref_auto_fetch" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="pref_key_development"
|
||||
android:title="@string/pref_header_development">
|
||||
|
Loading…
Reference in New Issue
Block a user