Steampunk watch face - unit testing complete.

This commit is contained in:
Andrew Warrington 2018-01-03 01:18:13 +01:00
parent 7b0cc80369
commit 37f262efdc
5 changed files with 106 additions and 69 deletions

View file

@ -50,6 +50,24 @@ public class Steampunk extends BaseWatchFace {
protected void setColorDark() { protected void setColorDark() {
if (mLinearLayout2 != null) {
if (ageLevel() <= 0) {
mLinearLayout2.setBackgroundResource(R.drawable.redline);
mTimestamp.setTextColor(getResources().getColor(R.color.red_600));
} else {
mLinearLayout2.setBackgroundResource(0);
mTimestamp.setTextColor(getResources().getColor(R.color.black_86p));
}
}
if (mLoop != null) {
if (loopLevel == 0) {
mLoop.setTextColor(getResources().getColor(R.color.red_600));
} else {
mLoop.setTextColor(getResources().getColor(R.color.black_86p));
}
}
if (!sSgv.equals("---")) { if (!sSgv.equals("---")) {
//ensure the glucose dial is the correct units //ensure the glucose dial is the correct units
if (!sUnits.equals("-")) { if (!sUnits.equals("-")) {
@ -65,7 +83,9 @@ public class Steampunk extends BaseWatchFace {
if (sUnits.equals("mmol")) { if (sUnits.equals("mmol")) {
rotationAngle = Float.valueOf(sSgv) * 18f; //convert to mg/dL, which is equivalent to degrees rotationAngle = Float.valueOf(sSgv) * 18f; //convert to mg/dL, which is equivalent to degrees
} else { } else {
rotationAngle = Float.valueOf(sSgv); //if glucose a value is received, use it to determine the amount of rotation of the dial. if (!sUnits.equals("-")) {
rotationAngle = Float.valueOf(sSgv); //if glucose a value is received, use it to determine the amount of rotation of the dial.
}
} }
if (rotationAngle > 330) rotationAngle = 330; //if the glucose value is higher than 330 then show "HIGH" on the dial. ("HIGH" is at 330 degrees on the dial) if (rotationAngle > 330) rotationAngle = 330; //if the glucose value is higher than 330 then show "HIGH" on the dial. ("HIGH" is at 330 degrees on the dial)
if (rotationAngle != 0 && rotationAngle < 30) rotationAngle = 30; //if the glucose value is lower than 30 show "LOW" on the dial. ("LOW" is at 30 degrees on the dial) if (rotationAngle != 0 && rotationAngle < 30) rotationAngle = 30; //if the glucose value is lower than 30 show "LOW" on the dial. ("LOW" is at 30 degrees on the dial)
@ -116,7 +136,7 @@ public class Steampunk extends BaseWatchFace {
} }
} }
} }
if (deltaRotationAngle > 35) deltaRotationAngle = 35f; if (deltaRotationAngle > 40) deltaRotationAngle = 40f;
mDeltaGauge.setRotation(deltaRotationAngle * deltaIsNegative); mDeltaGauge.setRotation(deltaRotationAngle * deltaIsNegative);
} }
@ -157,22 +177,41 @@ public class Steampunk extends BaseWatchFace {
protected void setTextSizes() { protected void setTextSizes() {
float fontSmall = 10f;
float fontMedium = 11f;
float fontLarge = 12f;
if (bIsRound) { if (bIsRound) {
mCOB2.setTextSize(13); fontSmall = 11f;
mBasalRate.setTextSize(13); fontMedium = 12f;
mIOB2.setTextSize(12); fontLarge = 13f;
mTimestamp.setTextSize(12); }
mLoop.setTextSize(12);
mUploaderBattery.setTextSize(11); //top row. large font unless text too big (i.e. detailedIOB)
mRigBattery.setTextSize(11); mCOB2.setTextSize(fontLarge);
mBasalRate.setTextSize(fontLarge);
if (sIOB2.length() < 7) {
mIOB2.setTextSize(fontLarge);
} else { } else {
mCOB2.setTextSize(11); mIOB2.setTextSize(fontSmall);
mBasalRate.setTextSize(11); }
mIOB2.setTextSize(10);
mTimestamp.setTextSize(9); //bottom row. font medium unless text too long (i.e. longer than 9' timestamp)
mLoop.setTextSize(9); if (mTimestamp.getText().length() < 3 || mLoop.getText().length() < 3) { //always resize these fields together, for symmetry.
mUploaderBattery.setTextSize(9); mTimestamp.setTextSize(fontMedium);
mRigBattery.setTextSize(9); mLoop.setTextSize(fontMedium);
} else {
mTimestamp.setTextSize(fontSmall);
mLoop.setTextSize(fontSmall);
}
//if both batteries are shown, make them smaller.
if (sharedPrefs.getBoolean("show_uploader_battery", true) && sharedPrefs.getBoolean("show_rig_battery", false)) {
mUploaderBattery.setTextSize(fontSmall);
mRigBattery.setTextSize(fontSmall);
} else {
mUploaderBattery.setTextSize(fontMedium);
mRigBattery.setTextSize(fontMedium);
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 143 KiB

View file

@ -44,7 +44,6 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/tertiary_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
@ -63,7 +62,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_weight="0.05" android:layout_weight="0.05"
android:gravity="center" android:gravity="center"
android:orientation="horizontal"/> android:orientation="horizontal" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -86,7 +85,7 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.14" android:layout_weight="0.16"
android:orientation="horizontal"> android:orientation="horizontal">
@ -101,7 +100,7 @@
android:text="--g" android:text="--g"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="12sp" android:textSize="11sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -109,7 +108,7 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.26" android:layout_weight="0.24"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -118,12 +117,12 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:paddingBottom="14dp" android:paddingBottom="12dp"
android:rotation="-2" android:rotation="-1"
android:text="-.--U/h" android:text="-.--U/h"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="13sp" android:textSize="11sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -145,7 +144,7 @@
android:text="0.00U" android:text="0.00U"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="12sp" android:textSize="11sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -174,19 +173,19 @@
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.25" android:layout_weight="0.25"
android:orientation="horizontal"/> android:orientation="horizontal" />
<lecho.lib.hellocharts.view.LineChartView <lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart" android:id="@+id/chart"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.5"/> android:layout_weight="0.5" />
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.25" android:layout_weight="0.25"
android:orientation="horizontal"/> android:orientation="horizontal" />
</LinearLayout> </LinearLayout>
@ -194,23 +193,24 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0px" android:layout_height="0px"
android:layout_weight="0.03" android:layout_weight="0.03"
android:orientation="vertical"/> android:orientation="vertical" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/tertiary_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:orientation="vertical"
android:weightSum="1"> android:weightSum="1">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0px" android:layout_height="0px"
android:layout_weight="0.15" android:layout_weight="0.15"
android:orientation="horizontal"/> android:orientation="horizontal" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -224,13 +224,13 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.34" android:layout_weight="0.32"
android:orientation="horizontal"/> android:orientation="horizontal" />
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.1" android:layout_weight="0.12"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -245,7 +245,7 @@
android:text="-'" android:text="-'"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="11sp" android:textSize="10sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -267,7 +267,7 @@
android:text="--%" android:text="--%"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="11sp" android:textSize="10sp"
android:textStyle="bold" android:textStyle="bold"
android:visibility="gone" /> android:visibility="gone" />
@ -280,7 +280,7 @@
android:text="--%" android:text="--%"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="11sp" android:textSize="10sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -288,7 +288,7 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.1" android:layout_weight="0.12"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -303,7 +303,7 @@
android:text="-'" android:text="-'"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="11sp" android:textSize="10sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -311,8 +311,8 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.34" android:layout_weight="0.32"
android:orientation="horizontal"/> android:orientation="horizontal" />
</LinearLayout> </LinearLayout>
@ -320,8 +320,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0px" android:layout_height="0px"
android:layout_weight="0.64" android:layout_weight="0.64"
android:orientation="horizontal"> android:orientation="horizontal"></LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -44,7 +44,6 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/tertiary_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
@ -63,7 +62,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_weight="0.05" android:layout_weight="0.05"
android:gravity="center" android:gravity="center"
android:orientation="horizontal"/> android:orientation="horizontal" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -86,7 +85,7 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.14" android:layout_weight="0.165"
android:orientation="horizontal"> android:orientation="horizontal">
@ -101,7 +100,7 @@
android:text="--g" android:text="--g"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="12sp" android:textSize="13sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -109,7 +108,7 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.26" android:layout_weight="0.27"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -119,7 +118,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:paddingBottom="14dp" android:paddingBottom="14dp"
android:rotation="-2" android:rotation="0"
android:text="-.--U/h" android:text="-.--U/h"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
@ -131,7 +130,7 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.2" android:layout_weight="0.165"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -145,7 +144,7 @@
android:text="0.00U" android:text="0.00U"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="12sp" android:textSize="13sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -174,19 +173,19 @@
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.25" android:layout_weight="0.25"
android:orientation="horizontal"/> android:orientation="horizontal" />
<lecho.lib.hellocharts.view.LineChartView <lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart" android:id="@+id/chart"
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.5"/> android:layout_weight="0.5" />
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.25" android:layout_weight="0.25"
android:orientation="horizontal"/> android:orientation="horizontal" />
</LinearLayout> </LinearLayout>
@ -194,23 +193,24 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0px" android:layout_height="0px"
android:layout_weight="0.03" android:layout_weight="0.03"
android:orientation="vertical"/> android:orientation="vertical" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/tertiary_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:orientation="vertical"
android:weightSum="1"> android:weightSum="1">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0px" android:layout_height="0px"
android:layout_weight="0.15" android:layout_weight="0.15"
android:orientation="horizontal"/> android:orientation="horizontal" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -224,13 +224,13 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.34" android:layout_weight="0.32"
android:orientation="horizontal"/> android:orientation="horizontal" />
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.1" android:layout_weight="0.12"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -245,7 +245,7 @@
android:text="-'" android:text="-'"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="11sp" android:textSize="12sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -267,7 +267,7 @@
android:text="--%" android:text="--%"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="11sp" android:textSize="12sp"
android:textStyle="bold" android:textStyle="bold"
android:visibility="gone" /> android:visibility="gone" />
@ -280,7 +280,7 @@
android:text="--%" android:text="--%"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="11sp" android:textSize="12sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -288,7 +288,7 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.1" android:layout_weight="0.12"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
@ -303,7 +303,7 @@
android:text="-'" android:text="-'"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/black_86p" android:textColor="@color/black_86p"
android:textSize="11sp" android:textSize="12sp"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
@ -311,8 +311,8 @@
<LinearLayout <LinearLayout
android:layout_width="0px" android:layout_width="0px"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.34" android:layout_weight="0.32"
android:orientation="horizontal"/> android:orientation="horizontal" />
</LinearLayout> </LinearLayout>
@ -320,8 +320,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0px" android:layout_height="0px"
android:layout_weight="0.64" android:layout_weight="0.64"
android:orientation="horizontal"> android:orientation="horizontal"></LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>