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").
|
@ -33,21 +33,13 @@ 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) {
|
||||||
|
if (eventTime - sgvTapTime < 800) {
|
||||||
int extra = (mSgv.getRight() - mSgv.getLeft()) / 2;
|
Intent intent = new Intent(this, MainMenuActivity.class);
|
||||||
if (tapType == TAP_TYPE_TAP &&
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
x + extra >= mSgv.getLeft() &&
|
startActivity(intent);
|
||||||
x - extra <= mSgv.getRight() &&
|
|
||||||
y >= mSgv.getTop() &&
|
|
||||||
y <= mSgv.getBottom()) {
|
|
||||||
if (eventTime - sgvTapTime < 800) {
|
|
||||||
Intent intent = new Intent(this, MainMenuActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
sgvTapTime = eventTime;
|
|
||||||
}
|
}
|
||||||
|
sgvTapTime = eventTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,36 +50,36 @@ public class Steampunk extends BaseWatchFace {
|
||||||
|
|
||||||
protected void setColorDark() {
|
protected void setColorDark() {
|
||||||
|
|
||||||
//ensure the glucose dial is the right units
|
|
||||||
if (!sUnits.equals("-")) {
|
|
||||||
if (sUnits.equals("mmol")) {
|
|
||||||
mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mmol);
|
|
||||||
} else {
|
|
||||||
mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mgdl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//rotate glucose dial.
|
|
||||||
float rotationAngle = 0f; //by default, show ? on the dial (? is at 0 degrees on the dial)
|
|
||||||
if (!sSgv.equals("---")) {
|
if (!sSgv.equals("---")) {
|
||||||
|
//ensure the glucose dial is the correct units
|
||||||
|
if (!sUnits.equals("-")) {
|
||||||
|
if (sUnits.equals("mmol")) {
|
||||||
|
mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mmol);
|
||||||
|
} else {
|
||||||
|
mGlucoseDial.setImageResource(R.drawable.steampunk_dial_mgdl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//rotate glucose dial
|
||||||
|
float rotationAngle = 0f; //by default, show ? on the dial (? is at 0 degrees on the dial)
|
||||||
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)
|
|
||||||
|
|
||||||
RotateAnimation rotate = new RotateAnimation(
|
RotateAnimation rotate = new RotateAnimation(
|
||||||
lastEndDegrees, rotationAngle - lastEndDegrees,
|
lastEndDegrees, rotationAngle - lastEndDegrees,
|
||||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||||
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
|
||||||
|
|
Before Width: | Height: | Size: 645 KiB After Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 645 KiB After Width: | Height: | Size: 140 KiB |
Before Width: | Height: | Size: 645 KiB After Width: | Height: | Size: 107 KiB |
Before Width: | Height: | Size: 645 KiB After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 645 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 645 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 645 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 645 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 645 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 317 KiB After Width: | Height: | Size: 24 KiB |