1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 10:35:50 +01:00

Pebble: allow to enable or disable sync for each activity tracker in settings

This is useful if you have multiple phones and do not want to have your data synced to one of them
This commit is contained in:
Andreas Shimokawa 2016-06-07 22:51:14 +02:00
parent 2b6ee41970
commit 32429df7bc
5 changed files with 28 additions and 13 deletions

View File

@ -17,7 +17,6 @@ import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.MisfitSampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.pebble.MisfitSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.impl.GBActivitySample; import nodomain.freeyourgadget.gadgetbridge.impl.GBActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
@ -46,8 +45,7 @@ public class AppMessageHandlerMisfit extends AppMessageHandler {
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = GBApplication.getPrefs();
int activityTracker = prefs.getInt("pebble_activitytracker", SampleProvider.PROVIDER_PEBBLE_HEALTH); return prefs.getBoolean("pebble_sync_misfit", true);
return (activityTracker == SampleProvider.PROVIDER_PEBBLE_MISFIT);
} }
@Override @Override

View File

@ -60,8 +60,7 @@ public class AppMessageHandlerMorpheuz extends AppMessageHandler {
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = GBApplication.getPrefs();
int activityTracker = prefs.getInt("pebble_activitytracker", SampleProvider.PROVIDER_PEBBLE_HEALTH); return prefs.getBoolean("pebble_sync_morpheuz", true);
return (activityTracker == SampleProvider.PROVIDER_PEBBLE_MORPHEUZ);
} }
@Override @Override

View File

@ -3,7 +3,6 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble;
import java.util.UUID; import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
abstract class DatalogSessionPebbleHealth extends DatalogSession { abstract class DatalogSessionPebbleHealth extends DatalogSession {
@ -14,7 +13,6 @@ abstract class DatalogSessionPebbleHealth extends DatalogSession {
protected boolean isPebbleHealthEnabled() { protected boolean isPebbleHealthEnabled() {
Prefs prefs = GBApplication.getPrefs(); Prefs prefs = GBApplication.getPrefs();
int activityTracker = prefs.getInt("pebble_activitytracker", SampleProvider.PROVIDER_PEBBLE_HEALTH); return prefs.getBoolean("pebble_sync_health", true);
return (activityTracker == SampleProvider.PROVIDER_PEBBLE_HEALTH);
} }
} }

View File

@ -74,7 +74,13 @@
<string name="pref_title_development_miaddr">Mi Band address</string> <string name="pref_title_development_miaddr">Mi Band address</string>
<string name="pref_title_pebble_settings">Pebble Settings</string> <string name="pref_title_pebble_settings">Pebble Settings</string>
<string name="pref_header_activitytrackers">Activity Trackers</string>
<string name="pref_title_pebble_activitytracker">Preferred Activitytracker</string> <string name="pref_title_pebble_activitytracker">Preferred Activitytracker</string>
<string name="pref_title_pebble_sync_health">Sync Pebble Health</string>
<string name="pref_title_pebble_sync_misfit">Sync Misfit</string>
<string name="pref_title_pebble_sync_morpheuz">Sync Morpheuz</string>
<string name="pref_title_enable_pebblekit">Allow 3rd Party Android App Access</string> <string name="pref_title_enable_pebblekit">Allow 3rd Party Android App Access</string>
<string name="pref_summary_enable_pebblekit">Enable experimental support for Android Apps using PebbleKit</string> <string name="pref_summary_enable_pebblekit">Enable experimental support for Android Apps using PebbleKit</string>

View File

@ -215,17 +215,31 @@
android:key="pebble_reconnect_attempts" android:key="pebble_reconnect_attempts"
android:maxLength="4" android:maxLength="4"
android:title="@string/pref_title_pebble_reconnect_attempts" /> android:title="@string/pref_title_pebble_reconnect_attempts" />
<CheckBoxPreference
android:title="@string/pref_title_sunrise_sunset"
android:summary="@string/pref_summary_sunrise_sunset"
android:key="send_sunrise_sunset" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_header_activitytrackers">
<ListPreference <ListPreference
android:defaultValue="4" android:defaultValue="4"
android:entries="@array/pebble_activitytracker" android:entries="@array/pebble_activitytracker"
android:entryValues="@array/pebble_activitytracker_values" android:entryValues="@array/pebble_activitytracker_values"
android:key="pebble_activitytracker" android:key="pebble_activitytracker"
android:title="@string/pref_title_pebble_activitytracker" android:summary="%s"
android:summary="%s" /> android:title="@string/pref_title_pebble_activitytracker" />
<CheckBoxPreference <CheckBoxPreference
android:title="@string/pref_title_sunrise_sunset" android:defaultValue="true"
android:summary="@string/pref_summary_sunrise_sunset" android:key="pebble_sync_health"
android:key="send_sunrise_sunset" /> android:title="@string/pref_title_pebble_sync_health" />
<CheckBoxPreference
android:defaultValue="true"
android:key="pebble_sync_misfit"
android:title="@string/pref_title_pebble_sync_misfit" />>
<CheckBoxPreference
android:defaultValue="true"
android:key="pebble_sync_morpheuz"
android:title="@string/pref_title_pebble_sync_morpheuz" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
android:title="@string/pref_header_location"> android:title="@string/pref_header_location">