From eabe625c47ac7e39697de684c2a99bebce3e32f2 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 30 Jul 2016 23:22:27 +0200 Subject: [PATCH] rename some classes, remove obsolete ones --- .../gadgetbridge/daogen/GBDaoGenerator.java | 6 +- .../gadgetbridge/database/DBHelper.java | 2 +- .../gadgetbridge/devices/SampleProvider.java | 2 +- .../pebble/AbstractPebbleSampleProvider.java | 21 +++-- .../devices/pebble/PebbleCoordinator.java | 10 +-- .../PebbleGadgetBridgeSampleProvider.java | 17 ---- ...r.java => PebbleHealthSampleProvider.java} | 5 +- ...r.java => PebbleMisfitSampleProvider.java} | 4 +- ...java => PebbleMorpheuzSampleProvider.java} | 4 +- .../devices/pebble/AppMessageHandler.java | 8 +- .../pebble/AppMessageHandlerGBPebble.java | 87 ------------------- .../pebble/AppMessageHandlerMisfit.java | 4 +- .../pebble/AppMessageHandlerMorpheuz.java | 15 ++-- .../DatalogSessionHealthOverlayData.java | 4 +- .../pebble/DatalogSessionHealthSleep.java | 4 +- .../pebble/DatalogSessionHealthSteps.java | 10 +-- .../devices/pebble/PebbleProtocol.java | 1 - 17 files changed, 46 insertions(+), 158 deletions(-) delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleGadgetBridgeSampleProvider.java rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/{HealthSampleProvider.java => PebbleHealthSampleProvider.java} (88%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/{MisfitSampleProvider.java => PebbleMisfitSampleProvider.java} (96%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/{MorpheuzSampleProvider.java => PebbleMorpheuzSampleProvider.java} (91%) delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerGBPebble.java diff --git a/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java b/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java index 1c5d7fc87..3858e5d5f 100644 --- a/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java +++ b/GBDaoGenerator/src/nodomain/freeyourgadget/gadgetbridge/daogen/GBDaoGenerator.java @@ -45,7 +45,7 @@ public class GBDaoGenerator { Entity device = addDevice(schema, deviceAttributes); addMiBandActivitySample(schema, user, device); - addPebbleActivitySample(schema, user, device); + addPebbleHealthActivitySample(schema, user, device); addPebbleMisfitActivitySample(schema, user, device); new DaoGenerator().generateAll(schema, "app/src/main/java"); @@ -142,9 +142,9 @@ public class GBDaoGenerator { activitySample.addIntProperty("heartRate").notNull(); } - private static Entity addPebbleActivitySample(Schema schema, Entity user, Entity device) { + private static Entity addPebbleHealthActivitySample(Schema schema, Entity user, Entity device) { // public GBActivitySample(SampleProvider provider, int timestamp, int intensity, int steps, int type, int customValue) { - Entity activitySample = addEntity(schema, "PebbleActivitySample"); + Entity activitySample = addEntity(schema, "PebbleHealthActivitySample"); addCommonActivitySampleProperties("AbstractActivitySample", activitySample, user, device); addDefaultActivitySampleAttributes(activitySample); addCommonActivitySampleProperties2(activitySample, user, device); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/database/DBHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/database/DBHelper.java index 8369bcfb7..a89f0fa59 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/database/DBHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/database/DBHelper.java @@ -345,7 +345,7 @@ public class DBHelper { private boolean isEmpty(DaoSession session) { long totalSamplesCount = session.getMiBandActivitySampleDao().count(); - totalSamplesCount += session.getPebbleActivitySampleDao().count(); + totalSamplesCount += session.getPebbleHealthActivitySampleDao().count(); return totalSamplesCount == 0; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/SampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/SampleProvider.java index c81745d0b..553ace1d1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/SampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/SampleProvider.java @@ -8,7 +8,7 @@ public interface SampleProvider { // TODO: these constants can all be removed int PROVIDER_MIBAND = 0; int PROVIDER_PEBBLE_MORPHEUZ = 1; - int PROVIDER_PEBBLE_GADGETBRIDGE = 2; + int PROVIDER_PEBBLE_GADGETBRIDGE = 2; // removed int PROVIDER_PEBBLE_MISFIT = 3; int PROVIDER_PEBBLE_HEALTH = 4; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/AbstractPebbleSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/AbstractPebbleSampleProvider.java index ce9f969d0..b69b251d4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/AbstractPebbleSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/AbstractPebbleSampleProvider.java @@ -4,38 +4,37 @@ import de.greenrobot.dao.AbstractDao; import de.greenrobot.dao.Property; import nodomain.freeyourgadget.gadgetbridge.devices.AbstractSampleProvider; import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; -import nodomain.freeyourgadget.gadgetbridge.entities.MiBandActivitySampleDao; -import nodomain.freeyourgadget.gadgetbridge.entities.PebbleActivitySample; -import nodomain.freeyourgadget.gadgetbridge.entities.PebbleActivitySampleDao; +import nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivitySample; +import nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivitySampleDao; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -public abstract class AbstractPebbleSampleProvider extends AbstractSampleProvider { +public abstract class AbstractPebbleSampleProvider extends AbstractSampleProvider { protected AbstractPebbleSampleProvider(GBDevice device, DaoSession session) { super(device, session); } @Override - public AbstractDao getSampleDao() { - return getSession().getPebbleActivitySampleDao(); + public AbstractDao getSampleDao() { + return getSession().getPebbleHealthActivitySampleDao(); } @Override protected Property getTimestampSampleProperty() { - return PebbleActivitySampleDao.Properties.Timestamp; + return PebbleHealthActivitySampleDao.Properties.Timestamp; } @Override protected Property getRawKindSampleProperty() { - return PebbleActivitySampleDao.Properties.RawKind; + return PebbleHealthActivitySampleDao.Properties.RawKind; } @Override protected Property getDeviceIdentifierSampleProperty() { - return PebbleActivitySampleDao.Properties.DeviceId; + return PebbleHealthActivitySampleDao.Properties.DeviceId; } @Override - public PebbleActivitySample createActivitySample() { - return new PebbleActivitySample(); + public PebbleHealthActivitySample createActivitySample() { + return new PebbleHealthActivitySample(); } } 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 a1425951e..9b9c6eb22 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 @@ -52,15 +52,13 @@ public class PebbleCoordinator extends AbstractDeviceCoordinator { int activityTracker = prefs.getInt("pebble_activitytracker", SampleProvider.PROVIDER_PEBBLE_HEALTH); switch (activityTracker) { case SampleProvider.PROVIDER_PEBBLE_HEALTH: - return new HealthSampleProvider(device, session); + return new PebbleHealthSampleProvider(device, session); case SampleProvider.PROVIDER_PEBBLE_MISFIT: - return new MisfitSampleProvider(device, session); + return new PebbleMisfitSampleProvider(device, session); case SampleProvider.PROVIDER_PEBBLE_MORPHEUZ: - return new MorpheuzSampleProvider(device, session); - case SampleProvider.PROVIDER_PEBBLE_GADGETBRIDGE: - return new PebbleGadgetBridgeSampleProvider(device, session); + return new PebbleMorpheuzSampleProvider(device, session); default: - return new HealthSampleProvider(device, session); + return new PebbleHealthSampleProvider(device, session); } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleGadgetBridgeSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleGadgetBridgeSampleProvider.java deleted file mode 100644 index f04c70b49..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleGadgetBridgeSampleProvider.java +++ /dev/null @@ -1,17 +0,0 @@ -package nodomain.freeyourgadget.gadgetbridge.devices.pebble; - -import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; -import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; - -public class PebbleGadgetBridgeSampleProvider extends MorpheuzSampleProvider { - public PebbleGadgetBridgeSampleProvider(GBDevice device, DaoSession session) { - super(device, session); - movementDivisor = 63.0f; - } - - @Override - public int getID() { - return SampleProvider.PROVIDER_PEBBLE_GADGETBRIDGE; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/HealthSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleHealthSampleProvider.java similarity index 88% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/HealthSampleProvider.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleHealthSampleProvider.java index b55099032..df82de8d7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/HealthSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleHealthSampleProvider.java @@ -2,18 +2,17 @@ package nodomain.freeyourgadget.gadgetbridge.devices.pebble; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; -import nodomain.freeyourgadget.gadgetbridge.entities.PebbleActivitySample; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; -public class HealthSampleProvider extends AbstractPebbleSampleProvider { +public class PebbleHealthSampleProvider extends AbstractPebbleSampleProvider { public static final int TYPE_DEEP_SLEEP = 5; public static final int TYPE_LIGHT_SLEEP = 4; public static final int TYPE_ACTIVITY = -1; protected final float movementDivisor = 8000f; - public HealthSampleProvider(GBDevice device, DaoSession session) { + public PebbleHealthSampleProvider(GBDevice device, DaoSession session) { super(device, session); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MisfitSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleMisfitSampleProvider.java similarity index 96% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MisfitSampleProvider.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleMisfitSampleProvider.java index bce945c83..f543a4578 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MisfitSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleMisfitSampleProvider.java @@ -16,13 +16,13 @@ import nodomain.freeyourgadget.gadgetbridge.entities.PebbleMisfitSampleDao; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; -public class MisfitSampleProvider implements SampleProvider { +public class PebbleMisfitSampleProvider implements SampleProvider { private final DaoSession mSession; private final GBDevice mDevice; protected final float movementDivisor = 300f; - public MisfitSampleProvider(GBDevice device, DaoSession session) { + public PebbleMisfitSampleProvider(GBDevice device, DaoSession session) { mSession = session; mDevice = device; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MorpheuzSampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleMorpheuzSampleProvider.java similarity index 91% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MorpheuzSampleProvider.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleMorpheuzSampleProvider.java index 0e82e6087..cee3c3a03 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/MorpheuzSampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleMorpheuzSampleProvider.java @@ -5,7 +5,7 @@ import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; -public class MorpheuzSampleProvider extends AbstractPebbleSampleProvider { +public class PebbleMorpheuzSampleProvider extends AbstractPebbleSampleProvider { // raw types public static final int TYPE_DEEP_SLEEP = 5; public static final int TYPE_LIGHT_SLEEP = 4; @@ -14,7 +14,7 @@ public class MorpheuzSampleProvider extends AbstractPebbleSampleProvider { protected float movementDivisor = 5000f; - public MorpheuzSampleProvider(GBDevice device, DaoSession session) { + public PebbleMorpheuzSampleProvider(GBDevice device, DaoSession session) { super(device, session); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandler.java index 6f57458e5..956b703ae 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandler.java @@ -6,11 +6,9 @@ import android.util.Pair; import java.util.ArrayList; import java.util.UUID; -import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; -import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.entities.Device; -import nodomain.freeyourgadget.gadgetbridge.entities.PebbleActivitySample; +import nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivitySample; import nodomain.freeyourgadget.gadgetbridge.entities.User; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; @@ -39,8 +37,8 @@ public class AppMessageHandler { return null; } - protected PebbleActivitySample createSample(int timestamp, int intensity, int steps, int type, User user, Device device) { - return new PebbleActivitySample(null, timestamp, intensity, steps, type, user.getId(), device.getId()); + protected PebbleHealthActivitySample createSample(int timestamp, int intensity, int steps, int type, User user, Device device) { + return new PebbleHealthActivitySample(null, timestamp, intensity, steps, type, user.getId(), device.getId()); } protected GBDevice getDevice() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerGBPebble.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerGBPebble.java deleted file mode 100644 index 02713c433..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerGBPebble.java +++ /dev/null @@ -1,87 +0,0 @@ -package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble; - -import android.util.Pair; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.SimpleTimeZone; -import java.util.TimeZone; -import java.util.UUID; - -import nodomain.freeyourgadget.gadgetbridge.GBApplication; -import nodomain.freeyourgadget.gadgetbridge.GBException; -import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; -import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; -import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; -import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes; -import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; -import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleGadgetBridgeSampleProvider; -import nodomain.freeyourgadget.gadgetbridge.entities.AbstractActivitySample; -import nodomain.freeyourgadget.gadgetbridge.entities.Device; -import nodomain.freeyourgadget.gadgetbridge.entities.PebbleActivitySample; -import nodomain.freeyourgadget.gadgetbridge.entities.User; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; - -public class AppMessageHandlerGBPebble extends AppMessageHandler { - - public static final int KEY_TIMESTAMP = 1; - public static final int KEY_SAMPLES = 2; - - private static final Logger LOG = LoggerFactory.getLogger(AppMessageHandlerGBPebble.class); - - AppMessageHandlerGBPebble(UUID uuid, PebbleProtocol pebbleProtocol) { - super(uuid, pebbleProtocol); - } - - @Override - public GBDeviceEvent[] handleMessage(ArrayList> pairs) { - int timestamp = 0; - for (Pair pair : pairs) { - switch (pair.first) { - case KEY_TIMESTAMP: - TimeZone tz = SimpleTimeZone.getDefault(); - timestamp = (int) pair.second - (tz.getOffset(System.currentTimeMillis())) / 1000; - LOG.info("got timestamp " + timestamp); - break; - case KEY_SAMPLES: - byte[] samples = (byte[]) pair.second; - ByteBuffer samplesBuffer = ByteBuffer.wrap(samples); - samplesBuffer.order(ByteOrder.LITTLE_ENDIAN); - int samples_remaining = samples.length / 2; - LOG.info("got " + samples_remaining + " samples"); - int offset_seconds = 0; - try (DBHandler db = GBApplication.acquireDB()) { - User user = DBHelper.getUser(db.getDaoSession()); - Device device = DBHelper.getDevice(getDevice(), db.getDaoSession()); - PebbleGadgetBridgeSampleProvider sampleProvider = new PebbleGadgetBridgeSampleProvider(getDevice(), db.getDaoSession()); - PebbleActivitySample[] activitySamples = new PebbleActivitySample[samples_remaining]; - int i = 0; - while (samples_remaining-- > 0) { - short sample = samplesBuffer.getShort(); - int type = ((sample & 0xe000) >>> 13); - int intensity = ((sample & 0x1f80) >>> 7); - int steps = (sample & 0x007f); - activitySamples[i++] = createSample(timestamp + offset_seconds, intensity, steps, type, user, device); - activitySamples[i].setProvider(sampleProvider); - offset_seconds += 60; - } - sampleProvider.addGBActivitySamples(activitySamples); - } catch (Exception e) { - LOG.error("Error acquiring database", e); - } - break; - default: - LOG.info("unhandled key: " + pair.first); - break; - } - } - GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes(); - sendBytes.encodedBytes = mPebbleProtocol.encodeApplicationMessageAck(mUUID, mPebbleProtocol.last_id); - return new GBDeviceEvent[]{sendBytes}; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMisfit.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMisfit.java index ad74f3a06..11134de18 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMisfit.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMisfit.java @@ -17,7 +17,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes; -import nodomain.freeyourgadget.gadgetbridge.devices.pebble.MisfitSampleProvider; +import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleMisfitSampleProvider; import nodomain.freeyourgadget.gadgetbridge.entities.PebbleMisfitSample; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; @@ -78,7 +78,7 @@ public class AppMessageHandlerMisfit extends AppMessageHandler { int totalSteps = 0; PebbleMisfitSample[] misfitSamples = new PebbleMisfitSample[samples]; try (DBHandler db = GBApplication.acquireDB()) { - MisfitSampleProvider sampleProvider = new MisfitSampleProvider(device, db.getDaoSession()); + PebbleMisfitSampleProvider sampleProvider = new PebbleMisfitSampleProvider(device, db.getDaoSession()); Long userId = DBHelper.getUser(db.getDaoSession()).getId(); Long deviceId = DBHelper.getDevice(getDevice(), db.getDaoSession()).getId(); for (int i = 0; i < samples; i++) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java index 116153e94..fbd9d857a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/AppMessageHandlerMorpheuz.java @@ -16,10 +16,9 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSleepMonitorResult; -import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; -import nodomain.freeyourgadget.gadgetbridge.devices.pebble.MorpheuzSampleProvider; +import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleMorpheuzSampleProvider; import nodomain.freeyourgadget.gadgetbridge.entities.Device; -import nodomain.freeyourgadget.gadgetbridge.entities.PebbleActivitySample; +import nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivitySample; import nodomain.freeyourgadget.gadgetbridge.entities.User; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; @@ -93,18 +92,18 @@ public class AppMessageHandlerMorpheuz extends AppMessageHandler { int index = ((int) pair.second >> 16); int intensity = ((int) pair.second & 0xffff); LOG.info("got point:" + index + " " + intensity); - int type = MorpheuzSampleProvider.TYPE_UNKNOWN; + int type = PebbleMorpheuzSampleProvider.TYPE_UNKNOWN; if (intensity <= 120) { - type = MorpheuzSampleProvider.TYPE_DEEP_SLEEP; + type = PebbleMorpheuzSampleProvider.TYPE_DEEP_SLEEP; } else if (intensity <= 1000) { - type = MorpheuzSampleProvider.TYPE_LIGHT_SLEEP; + type = PebbleMorpheuzSampleProvider.TYPE_LIGHT_SLEEP; } if (index >= 0) { try (DBHandler db = GBApplication.acquireDB()) { User user = DBHelper.getUser(db.getDaoSession()); Device device = DBHelper.getDevice(getDevice(), db.getDaoSession()); - MorpheuzSampleProvider sampleProvider = new MorpheuzSampleProvider(getDevice(), db.getDaoSession()); - PebbleActivitySample sample = createSample(recording_base_timestamp + index * 600, intensity, 0, type, user, device); + PebbleMorpheuzSampleProvider sampleProvider = new PebbleMorpheuzSampleProvider(getDevice(), db.getDaoSession()); + PebbleHealthActivitySample sample = createSample(recording_base_timestamp + index * 600, intensity, 0, type, user, device); sample.setProvider(sampleProvider); sampleProvider.addGBActivitySample(sample); } catch (Exception e) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthOverlayData.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthOverlayData.java index 5555835f8..d9c1002ce 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthOverlayData.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthOverlayData.java @@ -9,7 +9,7 @@ import java.util.UUID; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; -import nodomain.freeyourgadget.gadgetbridge.devices.pebble.HealthSampleProvider; +import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleHealthSampleProvider; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.util.GB; @@ -60,7 +60,7 @@ class DatalogSessionHealthOverlayData extends DatalogSessionPebbleHealth { private boolean store(OverlayRecord[] overlayRecords) { try (DBHandler dbHandler = GBApplication.acquireDB()) { - SampleProvider sampleProvider = new HealthSampleProvider(getDevice(), dbHandler.getDaoSession()); + SampleProvider sampleProvider = new PebbleHealthSampleProvider(getDevice(), dbHandler.getDaoSession()); int latestTimestamp = sampleProvider.fetchLatestTimestamp(); for (OverlayRecord overlayRecord : overlayRecords) { if (latestTimestamp < (overlayRecord.timestampStart + overlayRecord.durationSeconds)) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSleep.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSleep.java index 3b6561c57..377c4fa09 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSleep.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSleep.java @@ -9,7 +9,7 @@ import java.util.UUID; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; -import nodomain.freeyourgadget.gadgetbridge.devices.pebble.HealthSampleProvider; +import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleHealthSampleProvider; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.util.GB; @@ -59,7 +59,7 @@ class DatalogSessionHealthSleep extends DatalogSessionPebbleHealth { private boolean store(SleepRecord[] sleepRecords) { try (DBHandler dbHandler = GBApplication.acquireDB()) { - SampleProvider sampleProvider = new HealthSampleProvider(getDevice(), dbHandler.getDaoSession()); + SampleProvider sampleProvider = new PebbleHealthSampleProvider(getDevice(), dbHandler.getDaoSession()); int latestTimestamp = sampleProvider.fetchLatestTimestamp(); for (SleepRecord sleepRecord : sleepRecords) { if (latestTimestamp < sleepRecord.bedTimeEnd) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSteps.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSteps.java index c03c3ab7a..f2167505c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSteps.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/DatalogSessionHealthSteps.java @@ -10,8 +10,8 @@ import java.util.UUID; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.pebble.HealthSampleProvider; -import nodomain.freeyourgadget.gadgetbridge.entities.PebbleActivitySample; +import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleHealthSampleProvider; +import nodomain.freeyourgadget.gadgetbridge.entities.PebbleHealthActivitySample; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.util.GB; @@ -75,14 +75,14 @@ public class DatalogSessionHealthSteps extends DatalogSessionPebbleHealth { private void store(StepsRecord[] stepsRecords) { try (DBHandler dbHandler = GBApplication.acquireDB()) { - HealthSampleProvider sampleProvider = new HealthSampleProvider(getDevice(), dbHandler.getDaoSession()); - PebbleActivitySample[] samples = new PebbleActivitySample[stepsRecords.length]; + PebbleHealthSampleProvider sampleProvider = new PebbleHealthSampleProvider(getDevice(), dbHandler.getDaoSession()); + PebbleHealthActivitySample[] samples = new PebbleHealthActivitySample[stepsRecords.length]; // TODO: user and device Long userId = DBHelper.getUser(dbHandler.getDaoSession()).getId(); Long deviceId = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession()).getId(); for (int j = 0; j < stepsRecords.length; j++) { StepsRecord stepsRecord = stepsRecords[j]; - samples[j] = new PebbleActivitySample( + samples[j] = new PebbleHealthActivitySample( null, stepsRecord.timestamp, stepsRecord.intensity, diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index fcaabe2fa..61a974d40 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -378,7 +378,6 @@ public class PebbleProtocol extends GBDeviceProtocol { public PebbleProtocol(GBDevice device) { super(device); - mAppMessageHandlers.put(UUID_GBPEBBLE, new AppMessageHandlerGBPebble(UUID_GBPEBBLE, PebbleProtocol.this)); mAppMessageHandlers.put(UUID_MORPHEUZ, new AppMessageHandlerMorpheuz(UUID_MORPHEUZ, PebbleProtocol.this)); mAppMessageHandlers.put(UUID_WHETHERNEAT, new AppMessageHandlerWeatherNeat(UUID_WHETHERNEAT, PebbleProtocol.this)); mAppMessageHandlers.put(UUID_MISFIT, new AppMessageHandlerMisfit(UUID_MISFIT, PebbleProtocol.this));