show direction next to BG

This commit is contained in:
Milos Kozak 2016-12-27 20:41:28 +01:00
parent 13f2fce31e
commit fdb252b62d
6 changed files with 96 additions and 38 deletions

View file

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" /> <ConfirmationsSetting value="0" id="Remove" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View file

@ -149,7 +149,7 @@ public class DataService extends IntentService {
BgReading bgReading = new BgReading(); BgReading bgReading = new BgReading();
bgReading.value = bundle.getDouble(Intents.EXTRA_BG_ESTIMATE); bgReading.value = bundle.getDouble(Intents.EXTRA_BG_ESTIMATE);
bgReading.slope = bundle.getDouble(Intents.EXTRA_BG_SLOPE); bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME);
bgReading.battery_level = bundle.getInt(Intents.EXTRA_SENSOR_BATTERY); bgReading.battery_level = bundle.getInt(Intents.EXTRA_SENSOR_BATTERY);
bgReading.timeIndex = bundle.getLong(Intents.EXTRA_TIMESTAMP); bgReading.timeIndex = bundle.getLong(Intents.EXTRA_TIMESTAMP);
bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW); bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW);

View file

@ -32,7 +32,7 @@ public class BgReading implements DataPointInterface {
public double value; public double value;
@DatabaseField @DatabaseField
public double slope; public String direction;
@DatabaseField @DatabaseField
public double raw; public double raw;
@ -48,6 +48,7 @@ public class BgReading implements DataPointInterface {
timeIndex = sgv.getMills(); timeIndex = sgv.getMills();
value = sgv.getMgdl(); value = sgv.getMgdl();
raw = sgv.getFiltered(); raw = sgv.getFiltered();
direction = sgv.getDirection();
} }
public Double valueToUnits(String units) { public Double valueToUnits(String units) {
@ -62,13 +63,48 @@ public class BgReading implements DataPointInterface {
else return DecimalFormatter.to1Decimal(value * Constants.MGDL_TO_MMOLL); else return DecimalFormatter.to1Decimal(value * Constants.MGDL_TO_MMOLL);
} }
public String directionToSymbol() {
String symbol = "";
if (direction.compareTo("DoubleDown") == 0) {
symbol = "\u21ca";
} else if (direction.compareTo("SingleDown") == 0) {
symbol = "\u2193";
} else if (direction.compareTo("FortyFiveDown") == 0) {
symbol = "\u2198";
} else if (direction.compareTo("Flat") == 0) {
symbol = "\u2192";
} else if (direction.compareTo("FortyFiveUp") == 0) {
symbol = "\u2197";
} else if (direction.compareTo("SingleUp") == 0) {
symbol = "\u2191";
} else if (direction.compareTo("DoubleUp") == 0) {
symbol = "\u21c8";
} else if (isSlopeNameInvalid(direction)) {
symbol = "??";
}
return symbol;
}
public static boolean isSlopeNameInvalid(String direction) {
if (direction.compareTo("NOT_COMPUTABLE") == 0 ||
direction.compareTo("NOT COMPUTABLE") == 0 ||
direction.compareTo("OUT_OF_RANGE") == 0 ||
direction.compareTo("OUT OF RANGE") == 0 ||
direction.compareTo("NONE") == 0) {
return true;
} else {
return false;
}
}
@Override @Override
public String toString() { public String toString() {
return "BgReading{" + return "BgReading{" +
"timeIndex=" + timeIndex + "timeIndex=" + timeIndex +
", date=" + new Date(timeIndex) + ", date=" + new Date(timeIndex) +
", value=" + value + ", value=" + value +
", slope=" + slope + ", direction=" + direction +
", raw=" + raw + ", raw=" + raw +
", battery_level=" + battery_level + ", battery_level=" + battery_level +
'}'; '}';

View file

@ -40,7 +40,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public static final String DATABASE_TREATMENTS = "Treatments"; public static final String DATABASE_TREATMENTS = "Treatments";
public static final String DATABASE_DANARHISTORY = "DanaRHistory"; public static final String DATABASE_DANARHISTORY = "DanaRHistory";
private static final int DATABASE_VERSION = 4; private static final int DATABASE_VERSION = 5;
public DatabaseHelper(Context context) { public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION); super(context, DATABASE_NAME, null, DATABASE_VERSION);

View file

@ -96,6 +96,7 @@ public class OverviewFragment extends Fragment {
} }
TextView bgView; TextView bgView;
TextView arrowView;
TextView timeAgoView; TextView timeAgoView;
TextView deltaView; TextView deltaView;
TextView runningTempView; TextView runningTempView;
@ -139,6 +140,7 @@ public class OverviewFragment extends Fragment {
View view = inflater.inflate(R.layout.overview_fragment, container, false); View view = inflater.inflate(R.layout.overview_fragment, container, false);
bgView = (TextView) view.findViewById(R.id.overview_bg); bgView = (TextView) view.findViewById(R.id.overview_bg);
arrowView = (TextView) view.findViewById(R.id.overview_arrow);
timeAgoView = (TextView) view.findViewById(R.id.overview_timeago); timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
deltaView = (TextView) view.findViewById(R.id.overview_delta); deltaView = (TextView) view.findViewById(R.id.overview_delta);
runningTempView = (TextView) view.findViewById(R.id.overview_runningtemp); runningTempView = (TextView) view.findViewById(R.id.overview_runningtemp);
@ -566,6 +568,7 @@ public class OverviewFragment extends Fragment {
// **** BG value **** // **** BG value ****
if (lastBG != null && bgView != null) { if (lastBG != null && bgView != null) {
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits())); bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
arrowView.setText(lastBG.directionToSymbol());
DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData(); DatabaseHelper.GlucoseStatus glucoseStatus = MainApp.getDbHelper().getGlucoseStatusData();
if (glucoseStatus != null) if (glucoseStatus != null)
deltaView.setText("Δ " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units); deltaView.setText("Δ " + NSProfile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units);

View file

@ -35,12 +35,24 @@
android:textSize="80dp" android:textSize="80dp"
android:textStyle="bold" /> android:textStyle="bold" />
<TextView
android:id="@+id/overview_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:gravity="center_vertical"
android:paddingLeft="-5dp"
android:paddingRight="-5dp"
android:text="→"
android:textSize="80dp"
android:textStyle="bold" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="top" android:layout_gravity="top"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:gravity="center_vertical" android:gravity="top"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
@ -79,47 +91,54 @@
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView <TextView
android:id="@+id/overview_runningtemp" android:id="@+id/overview_activeprofile"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" android:layout_gravity="right"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:layout_marginRight="10dp"
android:layout_weight="0.5"
<LinearLayout android:background="@drawable/pillborder"
android:layout_width="match_parent" android:gravity="center_vertical|center_horizontal"
android:layout_height="wrap_content" android:paddingLeft="10dp"
android:orientation="horizontal"> android:paddingRight="10dp"
<TextView android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/overview_basebasal" android:textColor="@color/colorProfileSwitchButton" />
android:layout_weight="0.5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/overview_activeprofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_marginRight="10dp"
android:textColor="@color/colorProfileSwitchButton"
android:gravity="center_vertical|center_horizontal"
android:background="@drawable/pillborder"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="@+id/overview_runningtemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="normal|bold" />
<TextView
android:layout_width="20dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/overview_basebasal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<TextView <TextView
android:id="@+id/overview_iob" android:id="@+id/overview_iob"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
<com.jjoe64.graphview.GraphView <com.jjoe64.graphview.GraphView
@ -216,9 +235,9 @@
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:layout_marginTop="3dp" android:layout_marginTop="3dp"
android:layout_weight="0.5" android:layout_weight="0.5"
android:drawableLeft="@drawable/bread"
android:text="Quick wizard" android:text="Quick wizard"
android:textColor="@color/colorCancelTempButton" android:textColor="@color/colorCancelTempButton" />
android:drawableLeft="@drawable/bread" />
</LinearLayout> </LinearLayout>