Steampunk watchface (mmol support)
Includes delta granularity in the watch preferences.
This commit is contained in:
parent
a0983a99b9
commit
bc8b93045b
6 changed files with 58 additions and 6 deletions
|
@ -553,6 +553,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
|
||||
if(layoutSet){
|
||||
setDataFields();
|
||||
setColor();
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package info.nightscout.androidaps.watchfaces;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.wearable.watchface.WatchFaceStyle;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -70,7 +72,7 @@ public class Steampunk extends BaseWatchFace {
|
|||
float rotationAngle = 0f; //by default, show ? on the dial (? is at 0 degrees on the dial)
|
||||
if (!sSgv.equals("---")) {
|
||||
if (sUnits.equals("mmol")) {
|
||||
rotationAngle = Float.valueOf(sSgv) * 18f;
|
||||
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.
|
||||
}
|
||||
|
@ -88,13 +90,42 @@ public class Steampunk extends BaseWatchFace {
|
|||
mGlucoseDial.startAnimation(rotate);
|
||||
lastEndDegrees = rotationAngle; //store the final angle as a starting point for the next rotation.
|
||||
|
||||
//rotate delta pointer.
|
||||
//set the delta gauge and rotate the delta pointer
|
||||
float deltaIsNegative = 1f; //by default go clockwise
|
||||
if (!sAvgDelta.equals("--")) { //if a legitimate delta value is received, then...
|
||||
if (sAvgDelta.substring(0,1).equals("-")) deltaIsNegative = -1f; //if the delta is negative, go counter-clockwise
|
||||
deltaRotationAngle = (Float.valueOf(sAvgDelta.substring(1)) * 1.5f); //get rid of the sign so it can be converted to float. then, for each 10 in avgDelta we need to move 15 degrees, hence multiply avgDelta by 1.5.
|
||||
|
||||
//ensure the delta gauge is the right units and granularity
|
||||
if (!sUnits.equals("-")) {
|
||||
if (sUnits.equals("mmol")) {
|
||||
if (sharedPrefs.getString("delta_granularity", "2").equals("1")) { //low
|
||||
mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mmol_10);
|
||||
deltaRotationAngle = (Float.valueOf(sAvgDelta.substring(1)) * 30f); //get rid of the sign so it can be converted to float.
|
||||
}
|
||||
if (sharedPrefs.getString("delta_granularity", "2").equals("2")) { //medium
|
||||
mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mmol_05);
|
||||
deltaRotationAngle = (Float.valueOf(sAvgDelta.substring(1)) * 60f); //get rid of the sign so it can be converted to float.
|
||||
}
|
||||
if (sharedPrefs.getString("delta_granularity", "2").equals("3")) { //high
|
||||
mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mmol_03);
|
||||
deltaRotationAngle = (Float.valueOf(sAvgDelta.substring(1)) * 100f); //get rid of the sign so it can be converted to float.
|
||||
}
|
||||
} else {
|
||||
if (sharedPrefs.getString("delta_granularity", "2").equals("1")) { //low
|
||||
mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_20);
|
||||
deltaRotationAngle = (Float.valueOf(sAvgDelta.substring(1)) * 1.5f); //get rid of the sign so it can be converted to float.
|
||||
}
|
||||
if (sharedPrefs.getString("delta_granularity", "2").equals("2")) { //medium
|
||||
mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_10);
|
||||
deltaRotationAngle = (Float.valueOf(sAvgDelta.substring(1)) * 3f); //get rid of the sign so it can be converted to float.
|
||||
}
|
||||
if (sharedPrefs.getString("delta_granularity", "2").equals("3")) { //high
|
||||
mLinearLayout.setBackgroundResource(R.drawable.steampunk_gauge_mgdl_5);
|
||||
deltaRotationAngle = (Float.valueOf(sAvgDelta.substring(1)) * 6f); //get rid of the sign so it can be converted to float.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (deltaRotationAngle > 35) deltaRotationAngle = 35f;
|
||||
if (deltaRotationAngle < -35) deltaRotationAngle = -35f; //if the needle will go off the chart in either direction, make it stop at the end of the gauge.
|
||||
mDeltaGauge.setRotation(deltaRotationAngle * deltaIsNegative);
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 645 KiB |
|
@ -245,7 +245,7 @@
|
|||
android:text="-'"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/black_86p"
|
||||
android:textSize="12sp"
|
||||
android:textSize="11sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -303,7 +303,7 @@
|
|||
android:text="-'"
|
||||
android:textAlignment="center"
|
||||
android:textColor="@color/black_86p"
|
||||
android:textSize="12sp"
|
||||
android:textSize="11sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -20,6 +20,18 @@
|
|||
<item>5</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="delta_granularity">
|
||||
<item>Low</item>
|
||||
<item>Medium</item>
|
||||
<item>High</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="delta_granularity_values">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="input_design">
|
||||
<item>Default</item>
|
||||
<item>Quick righty</item>
|
||||
|
|
|
@ -141,6 +141,14 @@
|
|||
android:summary="Input Design"
|
||||
android:title="Input Design" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="2"
|
||||
android:entries="@array/delta_granularity"
|
||||
android:entryValues="@array/delta_granularity_values"
|
||||
android:key="delta_granularity"
|
||||
android:summary="Delta Granularity (Steampunk)"
|
||||
android:title="Delta Granularity (Steampunk)" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="showBigNumbers"
|
||||
|
|
Loading…
Reference in a new issue