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
|
||||
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
|
||||
|
||||
if (mSgv != null) {
|
||||
|
||||
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) {
|
||||
Intent intent = new Intent(this, MainMenuActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
sgvTapTime = eventTime;
|
||||
if (tapType == TAP_TYPE_TAP) {
|
||||
if (eventTime - sgvTapTime < 800) {
|
||||
Intent intent = new Intent(this, MainMenuActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
sgvTapTime = eventTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,36 +50,36 @@ public class Steampunk extends BaseWatchFace {
|
|||
|
||||
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("---")) {
|
||||
//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")) {
|
||||
rotationAngle = Float.valueOf(sSgv) * 18f; //convert to mg/dL, which is equivalent to degrees
|
||||
} else {
|
||||
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)
|
||||
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)
|
||||
|
||||
RotateAnimation rotate = new RotateAnimation(
|
||||
lastEndDegrees, rotationAngle - lastEndDegrees,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
rotate.setFillAfter(true);
|
||||
rotate.setInterpolator(new LinearInterpolator());
|
||||
rotate.setDuration(2000);
|
||||
mGlucoseDial.startAnimation(rotate);
|
||||
lastEndDegrees = rotationAngle; //store the final angle as a starting point for the next rotation.
|
||||
RotateAnimation rotate = new RotateAnimation(
|
||||
lastEndDegrees, rotationAngle - lastEndDegrees,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
rotate.setFillAfter(true);
|
||||
rotate.setInterpolator(new LinearInterpolator());
|
||||
rotate.setDuration(1);
|
||||
mGlucoseDial.startAnimation(rotate);
|
||||
lastEndDegrees = rotationAngle; //store the final angle as a starting point for the next rotation.
|
||||
}
|
||||
|
||||
//set the delta gauge and rotate the delta pointer
|
||||
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 |