Steampunk watchface: Updated graphics for more accuracy / brighter background, enabled double-tap, corrected issue when changing from mg/dL to mmol/L (glucose would show as "low").

This commit is contained in:
Andrew Warrington 2018-01-02 15:11:59 +01:00
parent 5609fbf738
commit 7b0cc80369
13 changed files with 29 additions and 37 deletions

View file

@ -33,14 +33,7 @@ public class Steampunk extends BaseWatchFace {
@Override @Override
protected void onTapCommand(int tapType, int x, int y, long eventTime) { protected void onTapCommand(int tapType, int x, int y, long eventTime) {
if (mSgv != null) { if (tapType == TAP_TYPE_TAP) {
int extra = (mSgv.getRight() - mSgv.getLeft()) / 2;
if (tapType == TAP_TYPE_TAP &&
x + extra >= mSgv.getLeft() &&
x - extra <= mSgv.getRight() &&
y >= mSgv.getTop() &&
y <= mSgv.getBottom()) {
if (eventTime - sgvTapTime < 800) { if (eventTime - sgvTapTime < 800) {
Intent intent = new Intent(this, MainMenuActivity.class); Intent intent = new Intent(this, MainMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -49,7 +42,6 @@ public class Steampunk extends BaseWatchFace {
sgvTapTime = eventTime; sgvTapTime = eventTime;
} }
} }
}
@Override @Override
protected WatchFaceStyle getWatchFaceStyle() { protected WatchFaceStyle getWatchFaceStyle() {
@ -58,7 +50,8 @@ public class Steampunk extends BaseWatchFace {
protected void setColorDark() { protected void setColorDark() {
//ensure the glucose dial is the right units if (!sSgv.equals("---")) {
//ensure the glucose dial is the correct units
if (!sUnits.equals("-")) { if (!sUnits.equals("-")) {
if (sUnits.equals("mmol")) { if (sUnits.equals("mmol")) {
mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mmol); mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mmol);
@ -67,15 +60,13 @@ public class Steampunk extends BaseWatchFace {
} }
} }
//rotate glucose dial. //rotate glucose dial
float rotationAngle = 0f; //by default, show ? on the dial (? is at 0 degrees on the dial) float rotationAngle = 0f; //by default, show ? on the dial (? is at 0 degrees on the dial)
if (!sSgv.equals("---")) {
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. 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)
@ -85,9 +76,10 @@ public class Steampunk extends BaseWatchFace {
Animation.RELATIVE_TO_SELF, 0.5f); Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setFillAfter(true); rotate.setFillAfter(true);
rotate.setInterpolator(new LinearInterpolator()); rotate.setInterpolator(new LinearInterpolator());
rotate.setDuration(2000); rotate.setDuration(1);
mGlucoseDial.startAnimation(rotate); mGlucoseDial.startAnimation(rotate);
lastEndDegrees = rotationAngle; //store the final angle as a starting point for the next rotation. lastEndDegrees = rotationAngle; //store the final angle as a starting point for the next rotation.
}
//set the delta gauge and rotate the delta pointer //set the delta gauge and rotate the delta pointer
float deltaIsNegative = 1f; //by default go clockwise float deltaIsNegative = 1f; //by default go clockwise

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 KiB

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 645 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 317 KiB

After

Width:  |  Height:  |  Size: 24 KiB