From 299e235f4ba2f50661ab932d9dc4b041e239e67b Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 27 Nov 2016 04:14:46 +0100 Subject: [PATCH] wear adopt basal to light theme --- .../info/nightscout/androidaps/BIGChart.java | 10 ++++++++-- .../nightscout/androidaps/BaseWatchFace.java | 6 ++++-- .../nightscout/androidaps/BgGraphBuilder.java | 17 ++++++++++++----- .../java/info/nightscout/androidaps/Home.java | 5 ++++- wear/src/main/res/values/colors.xml | 5 ++--- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java index 432e58b96f..8d619cf5e7 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java +++ b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java @@ -56,6 +56,8 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre public int lowColor = Color.RED; public int midColor = Color.WHITE; public int gridColour = Color.WHITE; + public int basalBackgroundColor = Color.BLUE; + public int basalCenterColor = Color.BLUE; public int pointSize = 2; public boolean singleLine = false; public boolean layoutSet = false; @@ -495,6 +497,8 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor); midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); gridColour = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor); + basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark); + basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light); singleLine = false; pointSize = 2; setupCharts(); @@ -534,6 +538,8 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre lowColor = ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor); midColor = ContextCompat.getColor(getApplicationContext(), R.color.light_midColor); gridColour = ContextCompat.getColor(getApplicationContext(), R.color.light_gridColor); + basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light); + basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark); singleLine = false; pointSize = 2; setupCharts(); @@ -595,9 +601,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); if (singleLine) { - bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColour, timeframe); + bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe); } else { - bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, timeframe); + bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe); } chart.setLineChartData(bgGraphBuilder.lineData()); diff --git a/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java index 5c23a94ef1..542665dba4 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java @@ -51,6 +51,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen public int lowColor = Color.RED; public int midColor = Color.WHITE; public int gridColor = Color.WHITE; + public int basalBackgroundColor = Color.BLUE; + public int basalCenterColor = Color.BLUE; public int pointSize = 2; public boolean singleLine = false; public boolean layoutSet = false; @@ -387,9 +389,9 @@ protected abstract void setColorDark(); if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); if (singleLine) { - bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColor, timeframe); + bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe); } else { - bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColor, timeframe); + bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe); } chart.setLineChartData(bgGraphBuilder.lineData()); diff --git a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java b/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java index 6a35dff018..d3c8a9442b 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java +++ b/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java @@ -41,6 +41,8 @@ public class BgGraphBuilder { public int lowColor; public int midColor; public int gridColour; + public int basalCenterColor; + public int basalBackgroundColor; public boolean singleLine = false; private double endHour; @@ -50,7 +52,7 @@ public class BgGraphBuilder { public Viewport viewport; - public BgGraphBuilder(Context context, List aBgList, List tempWatchDataList, ArrayList basalWatchDataList, int aPointSize, int aMidColor, int gridColour, int timespan) { + public BgGraphBuilder(Context context, List aBgList, List tempWatchDataList, ArrayList basalWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) { end_time = new Date().getTime() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) start_time = new Date().getTime() - (1000 * 60 * 60 * timespan); //timespan hours ago this.bgDataList = aBgList; @@ -66,9 +68,12 @@ public class BgGraphBuilder { this.tempWatchDataList = tempWatchDataList; this.basalWatchDataList = basalWatchDataList; this.gridColour = gridColour; + this.basalCenterColor = basalCenterColor; + this.basalBackgroundColor = basalBackgroundColor; } - public BgGraphBuilder(Context context, List aBgList, List tempWatchDataList, ArrayList basalWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int timespan) { + // TODO: use for ambient mode! + public BgGraphBuilder(Context context, List aBgList, List tempWatchDataList, ArrayList basalWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) { end_time = new Date().getTime() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.) start_time = new Date().getTime() - (1000 * 60 * 60 * timespan); //timespan hours ago this.bgDataList = aBgList; @@ -83,6 +88,8 @@ public class BgGraphBuilder { this.tempWatchDataList = tempWatchDataList; this.basalWatchDataList = basalWatchDataList; this.gridColour = gridColour; + this.basalCenterColor = basalCenterColor; + this.basalBackgroundColor = basalBackgroundColor; } public LineChartData lineData() { @@ -163,7 +170,7 @@ public class BgGraphBuilder { Line basalLine = new Line(pointValues); basalLine.setHasPoints(false); - basalLine.setColor(ContextCompat.getColor(context, R.color.basalLine_primary)); + basalLine.setColor(basalCenterColor); basalLine.setPathEffect(new DashPathEffect(new float[]{4f, 3f}, 4f)); basalLine.setStrokeWidth(highlight?2:1); return basalLine; @@ -215,10 +222,10 @@ public class BgGraphBuilder { Line valueLine = new Line(lineValues); valueLine.setHasPoints(false); if (isHighlightLine){ - valueLine.setColor(ContextCompat.getColor(context, R.color.tempbasal_highlight)); + valueLine.setColor(basalCenterColor); valueLine.setStrokeWidth(1); }else { - valueLine.setColor(ContextCompat.getColor(context, R.color.tempbasal_primary)); + valueLine.setColor(basalBackgroundColor); valueLine.setStrokeWidth(strokeWidth); } return valueLine; diff --git a/wear/src/main/java/info/nightscout/androidaps/Home.java b/wear/src/main/java/info/nightscout/androidaps/Home.java index 9c6a9df861..1a96de6142 100644 --- a/wear/src/main/java/info/nightscout/androidaps/Home.java +++ b/wear/src/main/java/info/nightscout/androidaps/Home.java @@ -93,7 +93,8 @@ public class Home extends BaseWatchFace { lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor); midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); gridColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor); - + basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark); + basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light); singleLine = false; pointSize = 2; setupCharts(); @@ -139,6 +140,8 @@ public class Home extends BaseWatchFace { lowColor = ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor); midColor = ContextCompat.getColor(getApplicationContext(), R.color.light_midColor); gridColor = ContextCompat.getColor(getApplicationContext(), R.color.light_gridColor); + basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light); + basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark); singleLine = false; pointSize = 2; setupCharts(); diff --git a/wear/src/main/res/values/colors.xml b/wear/src/main/res/values/colors.xml index a8867a5bc9..c3e3b9daf2 100644 --- a/wear/src/main/res/values/colors.xml +++ b/wear/src/main/res/values/colors.xml @@ -44,9 +44,8 @@ @color/grey_50 - @color/blue_300 - @color/blue_300 - @color/BLUE + @color/blue_300 + @color/BLUE