From 70ae5a2a3a3efc9d7d1f0dc3e7f088938f11a303 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 18 Feb 2016 20:41:22 +0100 Subject: [PATCH] Pebble: Allow to select the preferred activity tracker via settings activity (Health, Misfit, Morpheuz) --- CHANGELOG.md | 2 ++ .../activities/SettingsActivity.java | 1 + .../devices/pebble/PebbleCoordinator.java | 18 ++++++++++++------ app/src/main/res/values/arrays.xml | 12 ++++++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/preferences.xml | 6 ++++++ 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8725069d1..465db271b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ####Version (next) * Pebble: Support Pebble Health: steps/activity data are stored correctly. Sleep time is considered as light sleep. Deep sleep is discarded. The pebble will send data where it deems appropriate, there is no action to perform on the watch for this to happen. +* Pebble: Fix support for newer version of morpheuz (>=3.3?) +* Pebble: Allow to select the preferred activity tracker via settings activity (Health, Misfit, Morpheuz) * Mi Band: improvements to pairing ####Version 0.7.4 diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java index 2c37c9141..acf843044 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java @@ -112,6 +112,7 @@ public class SettingsActivity extends AbstractSettingsActivity { "notification_mode_calls", "notification_mode_sms", "notification_mode_k9mail", + "pebble_activitytracker", "pebble_emu_addr", "pebble_emu_port", "pebble_reconnect_attempts", diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleCoordinator.java index 917e19e5c..a76534d13 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleCoordinator.java @@ -45,13 +45,19 @@ public class PebbleCoordinator extends AbstractDeviceCoordinator { @Override public SampleProvider getSampleProvider() { - // FIXME: make this configurable somewhere else. SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(GBApplication.getContext()); - if (sharedPrefs.getBoolean("pebble_force_untested", false)) { - //return new PebbleGadgetBridgeSampleProvider(); - return new HealthSampleProvider(); - } else { - return new MorpheuzSampleProvider(); + int activityTracker = Integer.parseInt(sharedPrefs.getString("pebble_activitytracker", Integer.toString(SampleProvider.PROVIDER_PEBBLE_HEALTH))); + switch (activityTracker) { + case SampleProvider.PROVIDER_PEBBLE_HEALTH: + return new HealthSampleProvider(); + case SampleProvider.PROVIDER_PEBBLE_MISFIT: + return new MisfitSampleProvider(); + case SampleProvider.PROVIDER_PEBBLE_MORPHEUZ: + return new MorpheuzSampleProvider(); + case SampleProvider.PROVIDER_PEBBLE_GADGETBRIDGE: + return new PebbleGadgetBridgeSampleProvider(); + default: + return new HealthSampleProvider(); } } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index cc31c187c..1f5cfa293 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -59,4 +59,16 @@ @string/p_alarm_clock + + Pebble Health + Misfit + Morpheuz + + + + 4 + 3 + 1 + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cb75de4d8..149516920 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -62,6 +62,7 @@ Mi Band address Pebble Settings + Preferred Activitytracker Allow 3rd Party Android App Access Enable experimental support for Android Apps using PebbleKit Force Notification Protocol diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index aea487610..f547b01e8 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -180,6 +180,12 @@ android:key="pebble_reconnect_attempts" android:maxLength="4" android:title="@string/pref_title_pebble_reconnect_attempts" /> +