diff --git a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java index 8d619cf5e7..637908600e 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java +++ b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java @@ -31,7 +31,6 @@ import android.widget.RelativeLayout; import android.widget.TextView; import com.google.android.gms.wearable.DataMap; -import com.ustwo.clockwise.common.util.Logr; import com.ustwo.clockwise.wearable.WatchFace; import com.ustwo.clockwise.common.WatchFaceTime; import com.ustwo.clockwise.common.WatchMode; @@ -59,7 +58,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre public int basalBackgroundColor = Color.BLUE; public int basalCenterColor = Color.BLUE; public int pointSize = 2; - public boolean singleLine = false; + public boolean lowResMode = false; public boolean layoutSet = false; public BgGraphBuilder bgGraphBuilder; public LineChartView chart; @@ -163,13 +162,18 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre } protected void onWatchModeChanged(WatchMode watchMode) { - if (! sharedPrefs.getBoolean("dark", true)){ + + if(lowResMode ^ isLowRes(watchMode)){ //if there was a change in lowResMode + lowResMode = isLowRes(watchMode); + setColor(); + } else if (! sharedPrefs.getBoolean("dark", true)){ //in bright mode: different colours if active: setColor(); - } else { - //TODO: Handle low bit ambient } + } + private boolean isLowRes(WatchMode watchMode) { + return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN) || (watchMode == WatchMode.LOW_BIT_BURN_IN); } @@ -306,7 +310,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre //start animation? // dataMap.getDataMapArrayList("entries") == null -> not on "resend data". - if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5"))) { + if (!lowResMode && (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5")))) { startAnimation(); } } @@ -393,7 +397,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre } public void setColor() { - if (sharedPrefs.getBoolean("dark", true)) { + if(lowResMode){ + setColorLowRes(); + } else if (sharedPrefs.getBoolean("dark", true)) { setColorDark(); } else { setColorBright(); @@ -465,8 +471,26 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre animator.start(); } - //without theme + protected void setColorLowRes() { + mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime)); + statusView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView)); + mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); + mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp)); + if (chart != null) { + highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); + lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); + midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); + gridColour = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor); + basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark_lowres); + basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light_lowres); + pointSize = 2; + setupCharts(); + } + } protected void setColorDark() { mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime)); @@ -487,9 +511,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre } if (ageLevel == 1) { - mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp)); } else { - mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld)); } if (chart != null) { @@ -499,7 +523,6 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre 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(); } @@ -540,7 +563,6 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre 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(); } @@ -560,18 +582,12 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre ArrayList entries = dataMap.getDataMapArrayList("entries"); if (entries != null) { + bgDataList = new ArrayList(); for (DataMap entry : entries) { double sgv = entry.getDouble("sgvDouble"); double high = entry.getDouble("high"); double low = entry.getDouble("low"); double timestamp = entry.getDouble("timestamp"); - - final int size = bgDataList.size(); - if (size > 0) { - if (bgDataList.get(size - 1).timestamp == timestamp) - continue; // Ignore duplicates. - } - bgDataList.add(new BgWatchData(sgv, high, low, timestamp)); } } else { @@ -600,7 +616,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre public void setupCharts() { 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) { + if (lowResMode) { 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, basalBackgroundColor, basalCenterColor, timeframe); diff --git a/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java index 542665dba4..ce594f1d2f 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java @@ -26,6 +26,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import com.google.android.gms.wearable.DataMap; +import com.ustwo.clockwise.common.WatchMode; import com.ustwo.clockwise.wearable.WatchFace; import com.ustwo.clockwise.common.WatchFaceTime; import com.ustwo.clockwise.common.WatchShape; @@ -53,8 +54,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen public int gridColor = Color.WHITE; public int basalBackgroundColor = Color.BLUE; public int basalCenterColor = Color.BLUE; + public boolean lowResMode = false; public int pointSize = 2; - public boolean singleLine = false; public boolean layoutSet = false; public int missed_readings_alert_id = 818; public BgGraphBuilder bgGraphBuilder; @@ -312,15 +313,29 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen } public void setColor() { - if (sharedPrefs.getBoolean("dark", true)) { + if(lowResMode){ + setColorLowRes(); + } else if (sharedPrefs.getBoolean("dark", true)) { setColorDark(); } else { setColorBright(); } - } - + protected void onWatchModeChanged(WatchMode watchMode) { + + if(lowResMode ^ isLowRes(watchMode)){ //if there was a change in lowResMode + lowResMode = isLowRes(watchMode); + setColor(); + } else if (! sharedPrefs.getBoolean("dark", true)){ + //in bright mode: different colours if active: + setColor(); + } + } + + private boolean isLowRes(WatchMode watchMode) { + return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN) || (watchMode == WatchMode.LOW_BIT_BURN_IN); + } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){ @@ -335,6 +350,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen } protected abstract void setColorDark(); protected abstract void setColorBright(); + protected abstract void setColorLowRes(); public void missedReadingAlert() { @@ -348,18 +364,12 @@ protected abstract void setColorDark(); ArrayList entries = dataMap.getDataMapArrayList("entries"); if (entries != null) { + bgDataList = new ArrayList(); for (DataMap entry : entries) { double sgv = entry.getDouble("sgvDouble"); double high = entry.getDouble("high"); double low = entry.getDouble("low"); double timestamp = entry.getDouble("timestamp"); - - final int size = bgDataList.size(); - if (size > 0) { - if (bgDataList.get(size - 1).timestamp == timestamp) - continue; // Ignore duplicates. - } - bgDataList.add(new BgWatchData(sgv, high, low, timestamp)); } } else { @@ -388,7 +398,7 @@ protected abstract void setColorDark(); public void setupCharts() { 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) { + if (lowResMode) { 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, basalBackgroundColor, basalCenterColor, timeframe); diff --git a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java b/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java index d3c8a9442b..bcb41311fc 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java +++ b/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java @@ -52,6 +52,7 @@ public class BgGraphBuilder { public Viewport viewport; + //used for low resolution screen. 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 @@ -72,7 +73,6 @@ public class BgGraphBuilder { this.basalBackgroundColor = basalBackgroundColor; } - // 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 diff --git a/wear/src/main/java/info/nightscout/androidaps/Home.java b/wear/src/main/java/info/nightscout/androidaps/Home.java index 1a96de6142..e84098a341 100644 --- a/wear/src/main/java/info/nightscout/androidaps/Home.java +++ b/wear/src/main/java/info/nightscout/androidaps/Home.java @@ -40,16 +40,6 @@ public class Home extends BaseWatchFace { sharedPrefs.edit().putString("chart_timeframe", "" + timeframe).commit(); } - protected void onWatchModeChanged(WatchMode watchMode) { - if (! sharedPrefs.getBoolean("dark", true)){ - //in bright mode: different colours if active: - setColor(); - } else { - //TODO: Handle low bit ambient - } - - } - @Override protected WatchFaceStyle getWatchFaceStyle(){ return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build(); @@ -77,7 +67,7 @@ public class Home extends BaseWatchFace { if (ageLevel == 1) { mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1_home)); } else { - mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld)); } if (batteryLevel == 1) { @@ -95,12 +85,30 @@ public class Home extends BaseWatchFace { 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(); } } + protected void setColorLowRes() { + mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime)); + mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); + mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp)); + if (chart != null) { + highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); + lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); + midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); + gridColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor); + basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark_lowres); + basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light_lowres); + pointSize = 2; + setupCharts(); + } + + } + protected void setColorBright() { @@ -142,7 +150,6 @@ public class Home extends BaseWatchFace { 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/java/info/nightscout/androidaps/LargeHome.java b/wear/src/main/java/info/nightscout/androidaps/LargeHome.java index 8f4f0e88af..9f412702d4 100644 --- a/wear/src/main/java/info/nightscout/androidaps/LargeHome.java +++ b/wear/src/main/java/info/nightscout/androidaps/LargeHome.java @@ -16,7 +16,6 @@ public class LargeHome extends BaseWatchFace { performViewSetup(); } - @Override protected void setColorDark(){ mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mLinearLayout)); @@ -39,7 +38,7 @@ public class LargeHome extends BaseWatchFace { if (ageLevel == 1) { mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1_home)); } else { - mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld)); } if (batteryLevel == 1) { @@ -106,4 +105,17 @@ public class LargeHome extends BaseWatchFace { mTime.setTextColor(Color.WHITE); } } + + @Override + protected void setColorLowRes() { + mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mLinearLayout)); + mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime)); + mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); + mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1_home)); + mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBattery)); + mStatus.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mStatus_home)); + } } diff --git a/wear/src/main/res/values/colors.xml b/wear/src/main/res/values/colors.xml index c3e3b9daf2..e96c77ede8 100644 --- a/wear/src/main/res/values/colors.xml +++ b/wear/src/main/res/values/colors.xml @@ -31,9 +31,9 @@ @color/grey_50 @color/black @color/grey_50 - @color/grey_50 + @color/grey_50 @color/black - @color/red_600 + @color/red_600 @color/black @color/red_600 @color/black @@ -46,6 +46,8 @@ @color/blue_300 @color/BLUE + @color/grey_300 + @color/grey_500