From 484e65530a960c5ee2fdfc878bec49ac649c90bd Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 12 Dec 2019 11:10:41 +0100 Subject: [PATCH] Steampunk watchface, add "Auto Granularity" option --- .../androidaps/watchfaces/Steampunk.java | 29 +++++++++++++++---- wear/src/main/res/values/arrays.xml | 2 ++ wear/src/main/res/values/strings.xml | 1 + 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java index 8842d4b531..48f7a4e792 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java @@ -125,31 +125,48 @@ public class Steampunk extends BaseWatchFace { if (!rawData.sAvgDelta.equals("--")) { //if a legitimate delta value is received, then... if (rawData.sAvgDelta.substring(0,1).equals("-")) deltaIsNegative = -1f; //if the delta is negative, go counter-clockwise Float AbssAvgDelta = SafeParse.stringToFloat(rawData.sAvgDelta.substring(1)) ; //get rid of the sign so it can be converted to float. + String autogranularity = "0" ; //autogranularity off //ensure the delta gauge is the right units and granularity if (!rawData.sUnits.equals("-")) { if (rawData.sUnits.equals("mmol")) { - if (sharedPrefs.getString("delta_granularity", "2").equals("1")) { //low + if (sharedPrefs.getString("delta_granularity", "2").equals("4")) { //Auto granularity + autogranularity = "1"; // low (init) + if (AbssAvgDelta < 0.3 ) { + autogranularity = "3" ; // high if below 0.3 mmol/l + } else if (AbssAvgDelta < 0.5) { + autogranularity = "2" ; // medium if below 0.5 mmol/l + } + } + if (sharedPrefs.getString("delta_granularity", "2").equals("1") || autogranularity.equals("1")) { //low mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mmol_10); deltaRotationAngle = (AbssAvgDelta * 30f); } - if (sharedPrefs.getString("delta_granularity", "2").equals("2")) { //medium + if (sharedPrefs.getString("delta_granularity", "2").equals("2") || autogranularity.equals("2")) { //medium mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mmol_05); deltaRotationAngle = (AbssAvgDelta * 60f); } - if (sharedPrefs.getString("delta_granularity", "2").equals("3")) { //high + if (sharedPrefs.getString("delta_granularity", "2").equals("3") || autogranularity.equals("3")) { //high mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mmol_03); deltaRotationAngle = (AbssAvgDelta * 100f); } } else { - if (sharedPrefs.getString("delta_granularity", "2").equals("1")) { //low + if (sharedPrefs.getString("delta_granularity", "2").equals("4")) { //Auto granularity + autogranularity = "1"; // low (init) + if (AbssAvgDelta < 5 ) { + autogranularity = "3" ; // high if below 5 mg/dl + } else if (AbssAvgDelta < 10) { + autogranularity = "2" ; // medium if below 10 mg/dl + } + } + if (sharedPrefs.getString("delta_granularity", "2").equals("1") || autogranularity.equals("1")) { //low mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_20); deltaRotationAngle = (AbssAvgDelta * 1.5f); } - if (sharedPrefs.getString("delta_granularity", "2").equals("2")) { //medium + if (sharedPrefs.getString("delta_granularity", "2").equals("2") || autogranularity.equals("2")) { //medium mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_10); deltaRotationAngle = (AbssAvgDelta * 3f); } - if (sharedPrefs.getString("delta_granularity", "2").equals("3")) { //high + if (sharedPrefs.getString("delta_granularity", "2").equals("3") || autogranularity.equals("3")) { //high mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_5); deltaRotationAngle = (AbssAvgDelta * 6f); } diff --git a/wear/src/main/res/values/arrays.xml b/wear/src/main/res/values/arrays.xml index 281da2427c..b3f80eb126 100644 --- a/wear/src/main/res/values/arrays.xml +++ b/wear/src/main/res/values/arrays.xml @@ -21,12 +21,14 @@ @string/pref_low @string/pref_medium @string/pref_high + @string/pref_auto 1 2 3 + 4 diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index 29b8bea72e..d003d24a18 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -55,6 +55,7 @@ Low Medium High + Auto Big Numbers Ring History Light Ring History