mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-14 05:59:26 +01:00
Merge branch 'master' of github.com:Freeyourgadget/Gadgetbridge into fossil-q-hybrid
This commit is contained in:
commit
b6c744c8c6
@ -712,6 +712,29 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
|||||||
return samples;
|
return samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<? extends ActivitySample> getSamplesofSleep(DBHandler db, GBDevice device) {
|
||||||
|
int SLEEP_HOUR_LIMIT = 13;
|
||||||
|
|
||||||
|
int tsStart = getTSStart();
|
||||||
|
Calendar day = GregorianCalendar.getInstance();
|
||||||
|
day.setTimeInMillis(tsStart * 1000L);
|
||||||
|
day.set(Calendar.HOUR_OF_DAY, SLEEP_HOUR_LIMIT);
|
||||||
|
day.set(Calendar.MINUTE, 0);
|
||||||
|
day.set(Calendar.SECOND, 0);
|
||||||
|
tsStart = toTimestamp(day.getTime());
|
||||||
|
|
||||||
|
int tsEnd = getTSEnd();
|
||||||
|
day.setTimeInMillis(tsEnd* 1000L);
|
||||||
|
day.set(Calendar.HOUR_OF_DAY, SLEEP_HOUR_LIMIT);
|
||||||
|
day.set(Calendar.MINUTE, 0);
|
||||||
|
day.set(Calendar.SECOND, 0);
|
||||||
|
tsEnd = toTimestamp(day.getTime());
|
||||||
|
|
||||||
|
List<ActivitySample> samples = (List<ActivitySample>) getSamples(db, device, tsStart, tsEnd);
|
||||||
|
ensureStartAndEndSamples(samples, tsStart, tsEnd);
|
||||||
|
return samples;
|
||||||
|
}
|
||||||
|
|
||||||
protected void ensureStartAndEndSamples(List<ActivitySample> samples, int tsStart, int tsEnd) {
|
protected void ensureStartAndEndSamples(List<ActivitySample> samples, int tsStart, int tsEnd) {
|
||||||
if (samples == null || samples.isEmpty()) {
|
if (samples == null || samples.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -52,7 +53,6 @@ import nodomain.freeyourgadget.gadgetbridge.activities.HeartRateUtils;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.activities.charts.SleepAnalysis.SleepSession;
|
import nodomain.freeyourgadget.gadgetbridge.activities.charts.SleepAnalysis.SleepSession;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityAmount;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||||
@ -72,9 +72,20 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ChartsData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
protected ChartsData refreshInBackground(ChartsHost chartsHost, DBHandler db, GBDevice device) {
|
||||||
List<? extends ActivitySample> samples = getSamples(db, device);
|
List<? extends ActivitySample> samples = getSamplesofSleep(db, device);
|
||||||
|
|
||||||
MySleepChartsData mySleepChartsData = refreshSleepAmounts(device, samples);
|
MySleepChartsData mySleepChartsData = refreshSleepAmounts(device, samples);
|
||||||
|
if (mySleepChartsData.sleepSessions.size()>0) {
|
||||||
|
long tstart = mySleepChartsData.sleepSessions.get(0).getSleepStart().getTime() / 1000;
|
||||||
|
long tend = mySleepChartsData.sleepSessions.get(mySleepChartsData.sleepSessions.size() - 1).getSleepEnd().getTime() / 1000;
|
||||||
|
|
||||||
|
for (Iterator<ActivitySample> iterator = (Iterator<ActivitySample>) samples.iterator(); iterator.hasNext(); ) {
|
||||||
|
ActivitySample sample = iterator.next();
|
||||||
|
if (sample.getTimestamp() < tstart || sample.getTimestamp() > tend) {
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
DefaultChartsData chartsData = refresh(device, samples);
|
DefaultChartsData chartsData = refresh(device, samples);
|
||||||
|
|
||||||
return new MyChartsData(mySleepChartsData, chartsData);
|
return new MyChartsData(mySleepChartsData, chartsData);
|
||||||
|
@ -216,7 +216,7 @@ public final class MakibesHR3Constants {
|
|||||||
public static final byte ARG_SEND_NOTIFICATION_SOURCE_WEIBO = (byte) 0x13;
|
public static final byte ARG_SEND_NOTIFICATION_SOURCE_WEIBO = (byte) 0x13;
|
||||||
public static final byte ARG_SEND_NOTIFICATION_SOURCE_KAKOTALK = (byte) 0x14;
|
public static final byte ARG_SEND_NOTIFICATION_SOURCE_KAKOTALK = (byte) 0x14;
|
||||||
// ARG_SET_NOTIFICATION_SOURCE_*
|
// ARG_SET_NOTIFICATION_SOURCE_*
|
||||||
// 02 (This is 00 and 01 during connection. I don't know what it does. Maybe clears notifications?)
|
// 02 (This is 00 and 01 during connection. Doesn't seem to do anything.)
|
||||||
// ASCII
|
// ASCII
|
||||||
public static final byte CMD_SEND_NOTIFICATION = (byte) 0x72;
|
public static final byte CMD_SEND_NOTIFICATION = (byte) 0x72;
|
||||||
|
|
||||||
|
@ -18,7 +18,9 @@ package nodomain.freeyourgadget.gadgetbridge.devices.makibeshr3;
|
|||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -145,9 +147,15 @@ public class MakibesHR3Coordinator extends AbstractDeviceCoordinator {
|
|||||||
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
||||||
String name = candidate.getDevice().getName();
|
String name = candidate.getDevice().getName();
|
||||||
|
|
||||||
// TODO: Device discovery
|
List<String> deviceNames = new ArrayList<String>(){{
|
||||||
if ((name != null) && name.equals("Y808")) {
|
add("Y808"); // Chinese version
|
||||||
return DeviceType.MAKIBESHR3;
|
add("MAKIBES HR3"); // English version
|
||||||
|
}};
|
||||||
|
|
||||||
|
if (name != null) {
|
||||||
|
if (deviceNames.contains(name)) {
|
||||||
|
return DeviceType.MAKIBESHR3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeviceType.UNKNOWN;
|
return DeviceType.UNKNOWN;
|
||||||
@ -162,7 +170,7 @@ public class MakibesHR3Coordinator extends AbstractDeviceCoordinator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBondingStyle() {
|
public int getBondingStyle() {
|
||||||
return BONDING_STYLE_NONE;
|
return BONDING_STYLE_BOND;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
// TODO: GB sometimes fails to connect until a connection with WearFit was made. This must be caused
|
|
||||||
// TODO: by GB, not by Makibes hr3 support. Charging the watch, attempting to pair, delete and
|
|
||||||
// TODO: re-add, scan for devices and go back, might also help. This needs further research.
|
|
||||||
|
|
||||||
// TODO: All the commands that aren't supported by GB should be added to device specific settings.
|
// TODO: All the commands that aren't supported by GB should be added to device specific settings.
|
||||||
|
|
||||||
// TODO: It'd be cool if we could change the language. There's no official way to do so, but the
|
// TODO: It'd be cool if we could change the language. There's no official way to do so, but the
|
||||||
|
Loading…
Reference in New Issue
Block a user