1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 01:09:47 +01:00

Light colors for the graphs.

Closes #99
This commit is contained in:
Daniele Gobbetti 2015-08-28 14:35:22 +02:00
parent 086bb8aa4a
commit fb5ebeacb6
4 changed files with 49 additions and 5 deletions

View File

@ -81,7 +81,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
protected static final class ActivityConfig {
public final int type;
public final String label;
public final Integer color;
public Integer color;
public ActivityConfig(int kind, String label, Integer color) {
this.type = kind;
@ -94,10 +94,13 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
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 static final int BACKGROUND_COLOR = Color.rgb(24, 22, 24);
protected static final int DESCRIPTION_COLOR = Color.WHITE;
protected static final int CHART_TEXT_COLOR = Color.WHITE;
protected static final int LEGEND_TEXT_COLOR = Color.WHITE;
protected int BACKGROUND_COLOR;
protected int DESCRIPTION_COLOR;
protected int CHART_TEXT_COLOR;
protected int LEGEND_TEXT_COLOR;
protected int AK_ACTIVITY_COLOR;
protected int AK_DEEP_SLEEP_COLOR;
protected int AK_LIGHT_SLEEP_COLOR;
protected AbstractChartFragment(String... intentFilterActions) {
mIntentFilterActions = new HashSet<>();
@ -113,6 +116,8 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initColors();
IntentFilter filter = new IntentFilter();
for (String action : mIntentFilterActions) {
filter.addAction(action);
@ -120,6 +125,20 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mReceiver, filter);
}
protected void initColors() {
BACKGROUND_COLOR = getResources().getColor(R.color.background_material_light);
DESCRIPTION_COLOR = getResources().getColor(R.color.primarytext);
CHART_TEXT_COLOR = getResources().getColor(R.color.secondarytext);
LEGEND_TEXT_COLOR = getResources().getColor(R.color.primarytext);
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);
akActivity.color = AK_ACTIVITY_COLOR;
akLightSleep.color = AK_LIGHT_SLEEP_COLOR;
akDeepSleep.color = AK_DEEP_SLEEP_COLOR;
}
private void setStartDate(Date date) {
getHost().setStartDate(date);
}

View File

@ -9,6 +9,7 @@ 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_SLEEP = TYPE_LIGHT_SLEEP | TYPE_DEEP_SLEEP;
public static final int TYPE_ALL = TYPE_ACTIVITY | TYPE_SLEEP;

View File

@ -5,11 +5,25 @@
<item name="android:colorPrimaryDark">@color/primarydark_light</item>
<item name="android:colorAccent">@color/accent</item>
<item name="android:textColor">@color/primary_text_default_material_light</item>
<!-- unfortunately it doesn't work this way :( -->
<!--
<item name="chart_deep_sleep">@color/chart_deep_sleep_light</item>
<item name="chart_light_sleep">@color/chart_light_sleep_light</item>
<item name="chart_activity">@color/chart_activity_light</item>
-->
</style>
<style name="GadgetbridgeThemeDark" parent="@android:style/Theme.Material">
<item name="android:colorPrimary">@color/primary_dark</item>
<item name="android:colorPrimaryDark">@color/primarydark_dark</item>
<item name="android:colorAccent">@color/accent</item>
<item name="android:textColor">@color/primary_text_default_material_dark</item>
<!-- unfortunately it doesn't work this way :( -->
<!--
<item name="chart_deep_sleep">@color/chart_deep_sleep_dark</item>
<item name="chart_light_sleep">@color/chart_light_sleep_dark</item>
<item name="chart_activity">@color/chart_activity_dark</item>
-->
</style>
</resources>

View File

@ -10,4 +10,14 @@
<color name="primarytext" type="color">#ff000000</color>
<color name="secondarytext" type="color">#ff808080</color>
<color name="divider">#1f000000</color>
<color name="chart_deep_sleep_light" type="color">#0071b7</color>
<color name="chart_deep_sleep_dark" type="color">#4c5aff</color>
<color name="chart_light_sleep_light" type="color">#46acea</color>
<color name="chart_light_sleep_dark" type="color">#b6bfff</color>
<color name="chart_activity_light" type="color">#60bd6d</color>
<color name="chart_activity_dark" type="color">#59b22c</color>
</resources>