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() {
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("---")) {
//ensure the glucose dial is the correct units
if (!sUnits.equals("-")) {
@ -65,8 +83,10 @@ public class Steampunk extends BaseWatchFace {
if (sUnits.equals("mmol")) {
rotationAngle = Float.valueOf(sSgv) * 18f; //convert to mg/dL, which is equivalent to degrees
} else {
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 != 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);
}
@ -157,22 +177,41 @@ public class Steampunk extends BaseWatchFace {
protected void setTextSizes() {
float fontSmall = 10f;
float fontMedium = 11f;
float fontLarge = 12f;
if (bIsRound) {
mCOB2.setTextSize(13);
mBasalRate.setTextSize(13);
mIOB2.setTextSize(12);
mTimestamp.setTextSize(12);
mLoop.setTextSize(12);
mUploaderBattery.setTextSize(11);
mRigBattery.setTextSize(11);
fontSmall = 11f;
fontMedium = 12f;
fontLarge = 13f;
}
//top row. large font unless text too big (i.e. detailedIOB)
mCOB2.setTextSize(fontLarge);
mBasalRate.setTextSize(fontLarge);
if (sIOB2.length() < 7) {
mIOB2.setTextSize(fontLarge);
} else {
mCOB2.setTextSize(11);
mBasalRate.setTextSize(11);
mIOB2.setTextSize(10);
mTimestamp.setTextSize(9);
mLoop.setTextSize(9);
mUploaderBattery.setTextSize(9);
mRigBattery.setTextSize(9);
mIOB2.setTextSize(fontSmall);
}
//bottom row. font medium unless text too long (i.e. longer than 9' timestamp)
if (mTimestamp.getText().length() < 3 || mLoop.getText().length() < 3) { //always resize these fields together, for symmetry.
mTimestamp.setTextSize(fontMedium);
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
android:id="@+id/tertiary_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@ -63,7 +62,7 @@
android:layout_gravity="center"
android:layout_weight="0.05"
android:gravity="center"
android:orientation="horizontal"/>
android:orientation="horizontal" />
<LinearLayout
android:layout_width="match_parent"
@ -86,7 +85,7 @@
<LinearLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.14"
android:layout_weight="0.16"
android:orientation="horizontal">
@ -101,7 +100,7 @@
android:text="--g"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="12sp"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
@ -109,7 +108,7 @@
<LinearLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.26"
android:layout_weight="0.24"
android:orientation="horizontal">
<TextView
@ -118,12 +117,12 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:paddingBottom="14dp"
android:rotation="-2"
android:paddingBottom="12dp"
android:rotation="-1"
android:text="-.--U/h"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="13sp"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
@ -145,7 +144,7 @@
android:text="0.00U"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="12sp"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
@ -174,19 +173,19 @@
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:orientation="horizontal"/>
android:orientation="horizontal" />
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.5"/>
android:layout_weight="0.5" />
<LinearLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:orientation="horizontal"/>
android:orientation="horizontal" />
</LinearLayout>
@ -194,23 +193,24 @@
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.03"
android:orientation="vertical"/>
android:orientation="vertical" />
</LinearLayout>
<LinearLayout
android:id="@+id/tertiary_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.15"
android:orientation="horizontal"/>
android:orientation="horizontal" />
<LinearLayout
android:layout_width="match_parent"
@ -224,13 +224,13 @@
<LinearLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.34"
android:orientation="horizontal"/>
android:layout_weight="0.32"
android:orientation="horizontal" />
<LinearLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:layout_weight="0.12"
android:orientation="horizontal">
<TextView
@ -245,7 +245,7 @@
android:text="-'"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textSize="10sp"
android:textStyle="bold" />
</LinearLayout>
@ -267,7 +267,7 @@
android:text="--%"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textSize="10sp"
android:textStyle="bold"
android:visibility="gone" />
@ -280,7 +280,7 @@
android:text="--%"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textSize="10sp"
android:textStyle="bold" />
</LinearLayout>
@ -288,7 +288,7 @@
<LinearLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:layout_weight="0.12"
android:orientation="horizontal">
<TextView
@ -303,7 +303,7 @@
android:text="-'"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textSize="10sp"
android:textStyle="bold" />
</LinearLayout>
@ -311,8 +311,8 @@
<LinearLayout
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.34"
android:orientation="horizontal"/>
android:layout_weight="0.32"
android:orientation="horizontal" />
</LinearLayout>
@ -320,8 +320,7 @@
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.64"
android:orientation="horizontal">
</LinearLayout>
android:orientation="horizontal"></LinearLayout>
</LinearLayout>

View file

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