1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-09-27 16:56:57 +02:00

Display REM sleep separately from other types of sleep on the today widget

Thanks @joserebelo for the patch!
This commit is contained in:
Arjan Schrijver 2024-03-27 22:18:42 +01:00
parent ac47994422
commit 5320b095fa
2 changed files with 9 additions and 2 deletions

View File

@ -44,6 +44,7 @@ public abstract class AbstractDashboardWidget extends Fragment {
protected @ColorInt int color_exercise = Color.rgb(255, 128, 0);
protected @ColorInt int color_deep_sleep = Color.BLUE;
protected @ColorInt int color_light_sleep = Color.rgb(150, 150, 255);
protected @ColorInt int color_rem_sleep = Color.rgb(182, 191, 255);
protected @ColorInt int color_distance = Color.BLUE;
protected @ColorInt int color_active_time = Color.rgb(170, 0, 255);

View File

@ -116,8 +116,10 @@ public class DashboardTodayWidget extends AbstractDashboardWidget {
l_deep_sleep.setSpan(new ForegroundColorSpan(color_deep_sleep), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
SpannableString l_light_sleep = new SpannableString("" + getString(R.string.activity_type_light_sleep));
l_light_sleep.setSpan(new ForegroundColorSpan(color_light_sleep), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
SpannableString l_rem_sleep = new SpannableString("" + getString(R.string.abstract_chart_fragment_kind_rem_sleep));
l_rem_sleep.setSpan(new ForegroundColorSpan(color_rem_sleep), 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
SpannableStringBuilder legendBuilder = new SpannableStringBuilder();
legend.setText(legendBuilder.append(l_not_worn).append(" ").append(l_worn).append("\n").append(l_activity).append(" ").append(l_exercise).append("\n").append(l_light_sleep).append(" ").append(l_deep_sleep));
legend.setText(legendBuilder.append(l_not_worn).append(" ").append(l_worn).append("\n").append(l_activity).append(" ").append(l_exercise).append("\n").append(l_light_sleep).append(" ").append(l_deep_sleep).append(" ").append(l_rem_sleep));
legend.setVisibility(prefs.getBoolean("dashboard_widget_today_legend", true) ? View.VISIBLE : View.GONE);
@ -384,10 +386,14 @@ public class DashboardTodayWidget extends AbstractDashboardWidget {
paint.setStrokeWidth(barWidth / 3f);
paint.setColor(color_not_worn);
canvas.drawArc(margin, margin, width - margin, height - margin, start_angle, sweep_angle, false, paint);
} else if (activity.activityKind == ActivityKind.TYPE_REM_SLEEP || activity.activityKind == ActivityKind.TYPE_LIGHT_SLEEP || activity.activityKind == ActivityKind.TYPE_SLEEP) {
} else if (activity.activityKind == ActivityKind.TYPE_LIGHT_SLEEP || activity.activityKind == ActivityKind.TYPE_SLEEP) {
paint.setStrokeWidth(barWidth);
paint.setColor(color_light_sleep);
canvas.drawArc(margin, margin, width - margin, height - margin, start_angle, sweep_angle, false, paint);
} else if (activity.activityKind == ActivityKind.TYPE_REM_SLEEP) {
paint.setStrokeWidth(barWidth);
paint.setColor(color_rem_sleep);
canvas.drawArc(margin, margin, width - margin, height - margin, start_angle, sweep_angle, false, paint);
} else if (activity.activityKind == ActivityKind.TYPE_DEEP_SLEEP) {
paint.setStrokeWidth(barWidth);
paint.setColor(color_deep_sleep);