mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-25 16:50:44 +02:00
Add showing when the device wasn't worn by the user
This commit is contained in:
parent
fb5ebeacb6
commit
26792717d4
@ -93,6 +93,8 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
||||
protected ActivityConfig akActivity = new ActivityConfig(ActivityKind.TYPE_ACTIVITY, "Activity", Color.rgb(89, 178, 44));
|
||||
protected ActivityConfig akLightSleep = new ActivityConfig(ActivityKind.TYPE_LIGHT_SLEEP, "Light Sleep", Color.rgb(182, 191, 255));
|
||||
protected ActivityConfig akDeepSleep = new ActivityConfig(ActivityKind.TYPE_DEEP_SLEEP, "Deep Sleep", Color.rgb(76, 90, 255));
|
||||
protected ActivityConfig akNotWorn = new ActivityConfig(ActivityKind.TYPE_NOT_WORN, "Not Worn", Color.rgb(84, 82, 84));
|
||||
|
||||
|
||||
protected int BACKGROUND_COLOR;
|
||||
protected int DESCRIPTION_COLOR;
|
||||
@ -101,6 +103,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
||||
protected int AK_ACTIVITY_COLOR;
|
||||
protected int AK_DEEP_SLEEP_COLOR;
|
||||
protected int AK_LIGHT_SLEEP_COLOR;
|
||||
protected int AK_NOT_WORN_COLOR;
|
||||
|
||||
protected AbstractChartFragment(String... intentFilterActions) {
|
||||
mIntentFilterActions = new HashSet<>();
|
||||
@ -133,10 +136,12 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
||||
AK_ACTIVITY_COLOR = getResources().getColor(R.color.chart_activity_light);
|
||||
AK_DEEP_SLEEP_COLOR = getResources().getColor(R.color.chart_light_sleep_light);
|
||||
AK_LIGHT_SLEEP_COLOR = getResources().getColor(R.color.chart_deep_sleep_light);
|
||||
AK_NOT_WORN_COLOR = getResources().getColor(R.color.chart_not_worn_light);
|
||||
|
||||
akActivity.color = AK_ACTIVITY_COLOR;
|
||||
akLightSleep.color = AK_LIGHT_SLEEP_COLOR;
|
||||
akDeepSleep.color = AK_DEEP_SLEEP_COLOR;
|
||||
akNotWorn.color = AK_NOT_WORN_COLOR;
|
||||
}
|
||||
|
||||
private void setStartDate(Date date) {
|
||||
@ -396,25 +401,28 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
|
||||
float movement = sample.getIntensity();
|
||||
|
||||
float value = movement;
|
||||
if (type == ActivityKind.TYPE_DEEP_SLEEP) {
|
||||
value += SleepUtils.Y_VALUE_DEEP_SLEEP;
|
||||
activityEntries.add(createBarEntry(value, i));
|
||||
colors.add(akDeepSleep.color);
|
||||
} else {
|
||||
if (type == ActivityKind.TYPE_LIGHT_SLEEP) {
|
||||
activityEntries.add(createBarEntry(value, i));
|
||||
switch (type) {
|
||||
case ActivityKind.TYPE_DEEP_SLEEP:
|
||||
value += SleepUtils.Y_VALUE_DEEP_SLEEP;
|
||||
colors.add(akDeepSleep.color);
|
||||
break;
|
||||
case ActivityKind.TYPE_LIGHT_SLEEP:
|
||||
colors.add(akLightSleep.color);
|
||||
} else {
|
||||
break;
|
||||
case ActivityKind.TYPE_NOT_WORN:
|
||||
value = SleepUtils.Y_VALUE_DEEP_SLEEP; //a small value, just to show something on the graphs
|
||||
colors.add(akNotWorn.color);
|
||||
break;
|
||||
default:
|
||||
// short steps = sample.getSteps();
|
||||
// if (use_steps_as_movement && steps != 0) {
|
||||
// // I'm not sure using steps for this is actually a good idea
|
||||
// movement = steps;
|
||||
// }
|
||||
// value = ((float) movement) / movement_divisor;
|
||||
activityEntries.add(createBarEntry(value, i));
|
||||
colors.add(akActivity.color);
|
||||
}
|
||||
}
|
||||
activityEntries.add(createBarEntry(value, i));
|
||||
|
||||
String xLabel = "";
|
||||
if (annotate) {
|
||||
|
@ -11,6 +11,7 @@ public class ActivityAnalysis {
|
||||
public ActivityAmounts calculateActivityAmounts(List<ActivitySample> samples) {
|
||||
ActivityAmount deepSleep = new ActivityAmount(ActivityKind.TYPE_DEEP_SLEEP);
|
||||
ActivityAmount lightSleep = new ActivityAmount(ActivityKind.TYPE_LIGHT_SLEEP);
|
||||
ActivityAmount notWorn = new ActivityAmount(ActivityKind.TYPE_NOT_WORN);
|
||||
ActivityAmount activity = new ActivityAmount(ActivityKind.TYPE_ACTIVITY);
|
||||
|
||||
ActivityAmount previousAmount = null;
|
||||
@ -24,6 +25,9 @@ public class ActivityAnalysis {
|
||||
case ActivityKind.TYPE_LIGHT_SLEEP:
|
||||
amount = lightSleep;
|
||||
break;
|
||||
case ActivityKind.TYPE_NOT_WORN:
|
||||
amount = notWorn;
|
||||
break;
|
||||
case ActivityKind.TYPE_ACTIVITY:
|
||||
default:
|
||||
amount = activity;
|
||||
|
@ -115,14 +115,16 @@ public class ActivitySleepChartFragment extends AbstractChartFragment {
|
||||
}
|
||||
|
||||
protected void setupLegend(Chart chart) {
|
||||
List<Integer> legendColors = new ArrayList<>(3);
|
||||
List<String> legendLabels = new ArrayList<>(3);
|
||||
List<Integer> legendColors = new ArrayList<>(4);
|
||||
List<String> legendLabels = new ArrayList<>(4);
|
||||
legendColors.add(akActivity.color);
|
||||
legendLabels.add(akActivity.label);
|
||||
legendColors.add(akLightSleep.color);
|
||||
legendLabels.add(akLightSleep.label);
|
||||
legendColors.add(akDeepSleep.color);
|
||||
legendLabels.add(akDeepSleep.label);
|
||||
legendColors.add(akNotWorn.color);
|
||||
legendLabels.add(akNotWorn.label);
|
||||
chart.getLegend().setColors(legendColors);
|
||||
chart.getLegend().setLabels(legendLabels);
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ public class MiBandSampleProvider implements SampleProvider {
|
||||
public static final byte TYPE_LIGHT_SLEEP = 4;
|
||||
public static final byte TYPE_ACTIVITY = -1;
|
||||
public static final byte TYPE_UNKNOWN = -1;
|
||||
public static final byte TYPE_NONWEAR = 3;
|
||||
public static final byte TYPE_CHARGING = 6;
|
||||
|
||||
// public static final byte TYPE_CHARGING = 6;
|
||||
// public static final byte TYPE_NONWEAR = 3;
|
||||
// public static final byte TYPE_NREM = 5; // DEEP SLEEP
|
||||
// public static final byte TYPE_ONBED = 7;
|
||||
// public static final byte TYPE_REM = 4; // LIGHT SLEEP
|
||||
@ -31,6 +31,10 @@ public class MiBandSampleProvider implements SampleProvider {
|
||||
return ActivityKind.TYPE_LIGHT_SLEEP;
|
||||
case TYPE_ACTIVITY:
|
||||
return ActivityKind.TYPE_ACTIVITY;
|
||||
case TYPE_NONWEAR:
|
||||
return ActivityKind.TYPE_NOT_WORN;
|
||||
case TYPE_CHARGING:
|
||||
return ActivityKind.TYPE_NOT_WORN; //I believe it's a safe assumption
|
||||
default:
|
||||
// case TYPE_UNKNOWN: // fall through
|
||||
return ActivityKind.TYPE_UNKNOWN;
|
||||
@ -46,6 +50,8 @@ public class MiBandSampleProvider implements SampleProvider {
|
||||
return TYPE_DEEP_SLEEP;
|
||||
case ActivityKind.TYPE_LIGHT_SLEEP:
|
||||
return TYPE_LIGHT_SLEEP;
|
||||
case ActivityKind.TYPE_NOT_WORN:
|
||||
return TYPE_NONWEAR;
|
||||
case ActivityKind.TYPE_UNKNOWN: // fall through
|
||||
default:
|
||||
return TYPE_UNKNOWN;
|
||||
|
@ -9,9 +9,10 @@ public class ActivityKind {
|
||||
public static final int TYPE_ACTIVITY = 1;
|
||||
public static final int TYPE_LIGHT_SLEEP = 2;
|
||||
public static final int TYPE_DEEP_SLEEP = 4;
|
||||
public static final int TYPE_NOT_WORN = 8;
|
||||
|
||||
public static final int TYPE_SLEEP = TYPE_LIGHT_SLEEP | TYPE_DEEP_SLEEP;
|
||||
public static final int TYPE_ALL = TYPE_ACTIVITY | TYPE_SLEEP;
|
||||
public static final int TYPE_ALL = TYPE_ACTIVITY | TYPE_SLEEP | TYPE_NOT_WORN;
|
||||
|
||||
public static byte[] mapToDBActivityTypes(int types, SampleProvider provider) {
|
||||
byte[] result = new byte[3];
|
||||
@ -25,6 +26,9 @@ public class ActivityKind {
|
||||
if ((types & ActivityKind.TYPE_LIGHT_SLEEP) != 0) {
|
||||
result[i++] = provider.toRawActivityKind(TYPE_LIGHT_SLEEP);
|
||||
}
|
||||
if ((types & ActivityKind.TYPE_NOT_WORN) != 0) {
|
||||
result[i++] = provider.toRawActivityKind(TYPE_NOT_WORN);
|
||||
}
|
||||
return Arrays.copyOf(result, i);
|
||||
}
|
||||
|
||||
|
@ -20,4 +20,7 @@
|
||||
<color name="chart_activity_light" type="color">#60bd6d</color>
|
||||
<color name="chart_activity_dark" type="color">#59b22c</color>
|
||||
|
||||
<color name="chart_not_worn_light" type="color">#545254</color>
|
||||
<color name="chart_not_worn_dark" type="color">#d8d9d8</color>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user