Steampunk watch face (not yet functional)

This commit is contained in:
Andrew Warrington 2017-12-10 03:29:14 +01:00
parent 2d3333deda
commit c3aef7b6f2
4 changed files with 359 additions and 331 deletions

View file

@ -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();
}
}

View file

@ -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() {

View file

@ -29,188 +29,195 @@
android:background="@drawable/steampunk_gauge"
android:orientation="vertical">
<LinearLayout
android:id="@+id/tertiary_layout"
<ImageView
android:id="@+id/delta_gauge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/steampunk_pointer"
android:src="@drawable/steampunk_pointer"
android:layout_gravity="center"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:id="@+id/tertiary_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.7"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.7"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center" />
<TextView
android:id="@+id/cobView"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tmpBasal"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:id="@+id/iobView"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_gravity="center"
android:layout_weight="0.21"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.34"
android:gravity="center" />
<TextView
android:id="@+id/loop"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.1"
android:gravity="center" />
<TextView
android:id="@+id/timestamp"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.34"
android:gravity="center" />
</LinearLayout>
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.27"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
<TextView
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal">
</LinearLayout>
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center" />
<lecho.lib.hellocharts.view.LineChartView
<TextView
android:id="@+id/cobView"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tmpBasal"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:id="@+id/iobView"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_gravity="center"
android:layout_weight="0.21"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.34"
android:gravity="center" />
<TextView
android:id="@+id/loop"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.1"
android:gravity="center" />
<TextView
android:id="@+id/timestamp"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.34"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.27"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal">
</LinearLayout>
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.5"/>
<LinearLayout
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.03"
android:orientation="vertical">
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.03"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<LinearLayout
@ -221,20 +228,18 @@
android:orientation="vertical">
</LinearLayout>
<LinearLayout
<ImageView
android:id="@+id/hour_hand"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/steampunk_hour_hand"
android:orientation="vertical">
</LinearLayout>
android:orientation="vertical"/>
<LinearLayout
<ImageView
android:id="@+id/minute_hand"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/steampunk_minute_hand"
android:orientation="vertical">
</LinearLayout>
android:orientation="vertical"/>
</RelativeLayout>

View file

@ -29,188 +29,195 @@
android:background="@drawable/steampunk_gauge"
android:orientation="vertical">
<LinearLayout
android:id="@+id/tertiary_layout"
<ImageView
android:id="@+id/delta_gauge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/steampunk_pointer"
android:src="@drawable/steampunk_pointer"
android:layout_gravity="center"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:id="@+id/tertiary_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.7"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.7"
android:orientation="vertical"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center" />
<TextView
android:id="@+id/cobView"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tmpBasal"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:id="@+id/iobView"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_gravity="center"
android:layout_weight="0.21"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.34"
android:gravity="center" />
<TextView
android:id="@+id/loop"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.1"
android:gravity="center" />
<TextView
android:id="@+id/timestamp"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.34"
android:gravity="center" />
</LinearLayout>
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.27"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
<TextView
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal">
</LinearLayout>
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center" />
<lecho.lib.hellocharts.view.LineChartView
<TextView
android:id="@+id/cobView"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tmpBasal"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:id="@+id/iobView"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.2"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_gravity="center"
android:layout_weight="0.21"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.34"
android:gravity="center" />
<TextView
android:id="@+id/loop"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.1"
android:gravity="center" />
<TextView
android:id="@+id/timestamp"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.11"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/black_86p"
android:textSize="11sp"
android:textStyle="bold" />
<TextView
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.34"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.27"
android:orientation="horizontal"
android:weightSum="1">
<LinearLayout
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal">
</LinearLayout>
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="0.5"/>
<LinearLayout
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.03"
android:orientation="vertical">
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="0.03"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
<LinearLayout
@ -221,20 +228,18 @@
android:orientation="vertical">
</LinearLayout>
<LinearLayout
<ImageView
android:id="@+id/hour_hand"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/steampunk_hour_hand"
android:orientation="vertical">
</LinearLayout>
android:orientation="vertical"/>
<LinearLayout
<ImageView
android:id="@+id/minute_hand"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/steampunk_minute_hand"
android:orientation="vertical">
</LinearLayout>
android:orientation="vertical"/>
</RelativeLayout>