diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java
index b83597b175..06be3da737 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java
@@ -21,6 +21,7 @@ import android.view.Display;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -50,6 +51,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
public final static IntentFilter INTENT_FILTER;
public static final long[] vibratePattern = {0,400,300,400,300,400};
public TextView mTime, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mMonth, isAAPSv2, mHighLight, mLowLight;
+ public ImageView mGlucoseDial, mDeltaGauge;
public long datetime;
public RelativeLayout mRelativeLayout;
public LinearLayout mLinearLayout, mLinearLayout2, mDate;
@@ -160,10 +162,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
mLinearLayout = (LinearLayout) stub.findViewById(R.id.secondary_layout);
mLinearLayout2 = (LinearLayout) stub.findViewById(R.id.tertiary_layout);
+ mGlucoseDial = (ImageView) stub.findViewById(R.id.glucose_dial);
+ mDeltaGauge = (ImageView) stub.findViewById(R.id.delta_gauge);
chart = (LineChartView) stub.findViewById(R.id.chart);
layoutSet = true;
setDataFields();
+ setColor();
}
}
);
@@ -225,6 +230,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
wakeLock.acquire(50);
setDataFields();
+ setColor();
missedReadingAlert();
mRelativeLayout.measure(specW, specH);
@@ -273,6 +279,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
}
setDataFields();
+ setColor();
bundle = intent.getBundleExtra("basals");
if (layoutSet && bundle != null) {
@@ -285,7 +292,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
invalidate();
- setColor();
}
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java
index a1b176cc30..353a475fbd 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java
@@ -2,20 +2,18 @@ package info.nightscout.androidaps.watchfaces;
import android.content.Intent;
import android.support.v4.content.ContextCompat;
-import android.support.wearable.view.WatchViewStub;
import android.support.wearable.watchface.WatchFaceStyle;
import android.view.LayoutInflater;
-import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
+import static android.view.View.GONE;
+import static android.view.View.VISIBLE;
+
/**
* Created by andrew-warrington on 01/12/2017.
*/
@@ -23,7 +21,6 @@ import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
public class Steampunk extends BaseWatchFace {
private long sgvTapTime = 0;
- public ImageView mGlucoseDial;
private float lastEndDegrees = 0f;
@Override
@@ -32,7 +29,6 @@ public class Steampunk extends BaseWatchFace {
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
layoutView = inflater.inflate(R.layout.activity_steampunk, null);
performViewSetup();
- mGlucoseDial = (ImageView) layoutView.findViewById(R.id.glucose_dial);
}
@Override
@@ -64,10 +60,8 @@ public class Steampunk extends BaseWatchFace {
protected void setColorDark() {
//rotate glucose dial.
- float rotationAngle = 0;
- if (sSgv != "---") {
- rotationAngle = Float.valueOf(sSgv);
- }
+ float rotationAngle = 0f;
+ if (!sSgv.equals("---")) rotationAngle = Float.valueOf(sSgv);
if (rotationAngle > 330) rotationAngle = 330;
if (rotationAngle != 0 && rotationAngle < 30) rotationAngle = 30;
@@ -81,6 +75,24 @@ public class Steampunk extends BaseWatchFace {
mGlucoseDial.startAnimation(rotate);
lastEndDegrees = rotationAngle;
+ //rotate delta gauge.
+ rotationAngle = 0f;
+ //for each 10 in avgDelta we need to move 15 degrees, hence multiply avgDelta by 1.5.
+ if (!sAvgDelta.equals("--")) rotationAngle = (Float.valueOf(sAvgDelta.substring(1)) * 1.5f);
+ if (rotationAngle > 35 || rotationAngle < -35) { //if the needle will go off the chart in either direction...
+ mDeltaGauge.setVisibility(GONE);
+ } else {
+ mDeltaGauge.setVisibility(VISIBLE);
+ rotate = new RotateAnimation(
+ 0f, rotationAngle * -1,
+ Animation.RELATIVE_TO_SELF, 0.5f,
+ Animation.RELATIVE_TO_SELF, 0.5f);
+ rotate.setFillAfter(true);
+ rotate.setInterpolator(new LinearInterpolator());
+ rotate.setDuration(2000);
+ mDeltaGauge.startAnimation(rotate);
+ }
+
setTextSizes();
if (mLoop != null) {
@@ -103,7 +115,7 @@ public class Steampunk extends BaseWatchFace {
}
protected void setColorLowRes() {
- return;
+ setColorDark();
}
protected void setColorBright() {
diff --git a/wear/src/main/res/layout/rect_steampunk.xml b/wear/src/main/res/layout/rect_steampunk.xml
index de6cd3c757..4b27207fc1 100644
--- a/wear/src/main/res/layout/rect_steampunk.xml
+++ b/wear/src/main/res/layout/rect_steampunk.xml
@@ -29,188 +29,195 @@
android:background="@drawable/steampunk_gauge"
android:orientation="vertical">
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_gravity="center"
+ android:layout_weight="0.11"
+ android:gravity="center"
+ android:orientation="horizontal">
-
-
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:layout_weight="0.2"
+ android:gravity="center" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+ android:layout_width="0px"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.25"
+ android:orientation="horizontal">
+
+
+
-
-
+ android:orientation="vertical"/>
-
-
+ android:orientation="vertical"/>
\ No newline at end of file
diff --git a/wear/src/main/res/layout/round_steampunk.xml b/wear/src/main/res/layout/round_steampunk.xml
index eb7a112f60..d62a58e634 100644
--- a/wear/src/main/res/layout/round_steampunk.xml
+++ b/wear/src/main/res/layout/round_steampunk.xml
@@ -29,188 +29,195 @@
android:background="@drawable/steampunk_gauge"
android:orientation="vertical">
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_gravity="center"
+ android:layout_weight="0.11"
+ android:gravity="center"
+ android:orientation="horizontal">
-
-
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:layout_weight="0.2"
+ android:gravity="center" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+ android:layout_width="0px"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.25"
+ android:orientation="horizontal">
+
+
+
-
-
+ android:orientation="vertical"/>
-
-
+ android:orientation="vertical"/>
\ No newline at end of file